babylon.module.d.ts 6.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Check if the document object exists
  290. * @returns true if the document object exists
  291. */
  292. static IsDocumentAvailable(): boolean;
  293. /**
  294. * Extracts text content from a DOM element hierarchy
  295. * @param element defines the root element
  296. * @returns a string
  297. */
  298. static GetDOMTextContent(element: HTMLElement): string;
  299. }
  300. }
  301. declare module "babylonjs/Misc/logger" {
  302. /**
  303. * Logger used througouht the application to allow configuration of
  304. * the log level required for the messages.
  305. */
  306. export class Logger {
  307. /**
  308. * No log
  309. */
  310. static readonly NoneLogLevel: number;
  311. /**
  312. * Only message logs
  313. */
  314. static readonly MessageLogLevel: number;
  315. /**
  316. * Only warning logs
  317. */
  318. static readonly WarningLogLevel: number;
  319. /**
  320. * Only error logs
  321. */
  322. static readonly ErrorLogLevel: number;
  323. /**
  324. * All logs
  325. */
  326. static readonly AllLogLevel: number;
  327. private static _LogCache;
  328. /**
  329. * Gets a value indicating the number of loading errors
  330. * @ignorenaming
  331. */
  332. static errorsCount: number;
  333. /**
  334. * Callback called when a new log is added
  335. */
  336. static OnNewCacheEntry: (entry: string) => void;
  337. private static _AddLogEntry;
  338. private static _FormatMessage;
  339. private static _LogDisabled;
  340. private static _LogEnabled;
  341. private static _WarnDisabled;
  342. private static _WarnEnabled;
  343. private static _ErrorDisabled;
  344. private static _ErrorEnabled;
  345. /**
  346. * Log a message to the console
  347. */
  348. static Log: (message: string) => void;
  349. /**
  350. * Write a warning message to the console
  351. */
  352. static Warn: (message: string) => void;
  353. /**
  354. * Write an error message to the console
  355. */
  356. static Error: (message: string) => void;
  357. /**
  358. * Gets current log cache (list of logs)
  359. */
  360. static get LogCache(): string;
  361. /**
  362. * Clears the log cache
  363. */
  364. static ClearLogCache(): void;
  365. /**
  366. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  367. */
  368. static set LogLevels(level: number);
  369. }
  370. }
  371. declare module "babylonjs/Misc/typeStore" {
  372. /** @hidden */
  373. export class _TypeStore {
  374. /** @hidden */
  375. static RegisteredTypes: {
  376. [key: string]: Object;
  377. };
  378. /** @hidden */
  379. static GetClass(fqdn: string): any;
  380. }
  381. }
  382. declare module "babylonjs/Misc/stringTools" {
  383. /**
  384. * Helper to manipulate strings
  385. */
  386. export class StringTools {
  387. /**
  388. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  389. * @param str Source string
  390. * @param suffix Suffix to search for in the source string
  391. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  392. */
  393. static EndsWith(str: string, suffix: string): boolean;
  394. /**
  395. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  396. * @param str Source string
  397. * @param suffix Suffix to search for in the source string
  398. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  399. */
  400. static StartsWith(str: string, suffix: string): boolean;
  401. /**
  402. * Decodes a buffer into a string
  403. * @param buffer The buffer to decode
  404. * @returns The decoded string
  405. */
  406. static Decode(buffer: Uint8Array | Uint16Array): string;
  407. /**
  408. * Encode a buffer to a base64 string
  409. * @param buffer defines the buffer to encode
  410. * @returns the encoded string
  411. */
  412. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  413. /**
  414. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  415. * @param num the number to convert and pad
  416. * @param length the expected length of the string
  417. * @returns the padded string
  418. */
  419. static PadNumber(num: number, length: number): string;
  420. }
  421. }
  422. declare module "babylonjs/Misc/deepCopier" {
  423. /**
  424. * Class containing a set of static utilities functions for deep copy.
  425. */
  426. export class DeepCopier {
  427. /**
  428. * Tries to copy an object by duplicating every property
  429. * @param source defines the source object
  430. * @param destination defines the target object
  431. * @param doNotCopyList defines a list of properties to avoid
  432. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  433. */
  434. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  435. }
  436. }
  437. declare module "babylonjs/Misc/precisionDate" {
  438. /**
  439. * Class containing a set of static utilities functions for precision date
  440. */
  441. export class PrecisionDate {
  442. /**
  443. * Gets either window.performance.now() if supported or Date.now() else
  444. */
  445. static get Now(): number;
  446. }
  447. }
  448. declare module "babylonjs/Misc/devTools" {
  449. /** @hidden */
  450. export class _DevTools {
  451. static WarnImport(name: string): string;
  452. }
  453. }
  454. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  455. /**
  456. * Interface used to define the mechanism to get data from the network
  457. */
  458. export interface IWebRequest {
  459. /**
  460. * Returns client's response url
  461. */
  462. responseURL: string;
  463. /**
  464. * Returns client's status
  465. */
  466. status: number;
  467. /**
  468. * Returns client's status as a text
  469. */
  470. statusText: string;
  471. }
  472. }
  473. declare module "babylonjs/Misc/webRequest" {
  474. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  475. import { Nullable } from "babylonjs/types";
  476. /**
  477. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  478. */
  479. export class WebRequest implements IWebRequest {
  480. private _xhr;
  481. /**
  482. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  483. * i.e. when loading files, where the server/service expects an Authorization header
  484. */
  485. static CustomRequestHeaders: {
  486. [key: string]: string;
  487. };
  488. /**
  489. * Add callback functions in this array to update all the requests before they get sent to the network
  490. */
  491. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  492. private _injectCustomRequestHeaders;
  493. /**
  494. * Gets or sets a function to be called when loading progress changes
  495. */
  496. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  497. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  498. /**
  499. * Returns client's state
  500. */
  501. get readyState(): number;
  502. /**
  503. * Returns client's status
  504. */
  505. get status(): number;
  506. /**
  507. * Returns client's status as a text
  508. */
  509. get statusText(): string;
  510. /**
  511. * Returns client's response
  512. */
  513. get response(): any;
  514. /**
  515. * Returns client's response url
  516. */
  517. get responseURL(): string;
  518. /**
  519. * Returns client's response as text
  520. */
  521. get responseText(): string;
  522. /**
  523. * Gets or sets the expected response type
  524. */
  525. get responseType(): XMLHttpRequestResponseType;
  526. set responseType(value: XMLHttpRequestResponseType);
  527. /** @hidden */
  528. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  529. /** @hidden */
  530. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  531. /**
  532. * Cancels any network activity
  533. */
  534. abort(): void;
  535. /**
  536. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  537. * @param body defines an optional request body
  538. */
  539. send(body?: Document | BodyInit | null): void;
  540. /**
  541. * Sets the request method, request URL
  542. * @param method defines the method to use (GET, POST, etc..)
  543. * @param url defines the url to connect with
  544. */
  545. open(method: string, url: string): void;
  546. /**
  547. * Sets the value of a request header.
  548. * @param name The name of the header whose value is to be set
  549. * @param value The value to set as the body of the header
  550. */
  551. setRequestHeader(name: string, value: string): void;
  552. /**
  553. * Get the string containing the text of a particular header's value.
  554. * @param name The name of the header
  555. * @returns The string containing the text of the given header name
  556. */
  557. getResponseHeader(name: string): Nullable<string>;
  558. }
  559. }
  560. declare module "babylonjs/Misc/fileRequest" {
  561. import { Observable } from "babylonjs/Misc/observable";
  562. /**
  563. * File request interface
  564. */
  565. export interface IFileRequest {
  566. /**
  567. * Raised when the request is complete (success or error).
  568. */
  569. onCompleteObservable: Observable<IFileRequest>;
  570. /**
  571. * Aborts the request for a file.
  572. */
  573. abort: () => void;
  574. }
  575. }
  576. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  577. /**
  578. * Define options used to create a render target texture
  579. */
  580. export class RenderTargetCreationOptions {
  581. /**
  582. * Specifies is mipmaps must be generated
  583. */
  584. generateMipMaps?: boolean;
  585. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  586. generateDepthBuffer?: boolean;
  587. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  588. generateStencilBuffer?: boolean;
  589. /** Defines texture type (int by default) */
  590. type?: number;
  591. /** Defines sampling mode (trilinear by default) */
  592. samplingMode?: number;
  593. /** Defines format (RGBA by default) */
  594. format?: number;
  595. }
  596. }
  597. declare module "babylonjs/Engines/constants" {
  598. /** Defines the cross module used constants to avoid circular dependncies */
  599. export class Constants {
  600. /** Defines that alpha blending is disabled */
  601. static readonly ALPHA_DISABLE: number;
  602. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  603. static readonly ALPHA_ADD: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  605. static readonly ALPHA_COMBINE: number;
  606. /** Defines that alpha blending is DEST - SRC * DEST */
  607. static readonly ALPHA_SUBTRACT: number;
  608. /** Defines that alpha blending is SRC * DEST */
  609. static readonly ALPHA_MULTIPLY: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  611. static readonly ALPHA_MAXIMIZED: number;
  612. /** Defines that alpha blending is SRC + DEST */
  613. static readonly ALPHA_ONEONE: number;
  614. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  615. static readonly ALPHA_PREMULTIPLIED: number;
  616. /**
  617. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  618. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  619. */
  620. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  621. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  622. static readonly ALPHA_INTERPOLATE: number;
  623. /**
  624. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  625. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  626. */
  627. static readonly ALPHA_SCREENMODE: number;
  628. /**
  629. * Defines that alpha blending is SRC + DST
  630. * Alpha will be set to SRC ALPHA + DST ALPHA
  631. */
  632. static readonly ALPHA_ONEONE_ONEONE: number;
  633. /**
  634. * Defines that alpha blending is SRC * DST ALPHA + DST
  635. * Alpha will be set to 0
  636. */
  637. static readonly ALPHA_ALPHATOCOLOR: number;
  638. /**
  639. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  640. */
  641. static readonly ALPHA_REVERSEONEMINUS: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  644. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  645. */
  646. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  647. /**
  648. * Defines that alpha blending is SRC + DST
  649. * Alpha will be set to SRC ALPHA
  650. */
  651. static readonly ALPHA_ONEONE_ONEZERO: number;
  652. /**
  653. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  654. * Alpha will be set to DST ALPHA
  655. */
  656. static readonly ALPHA_EXCLUSION: number;
  657. /** Defines that alpha blending equation a SUM */
  658. static readonly ALPHA_EQUATION_ADD: number;
  659. /** Defines that alpha blending equation a SUBSTRACTION */
  660. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  661. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  663. /** Defines that alpha blending equation a MAX operation */
  664. static readonly ALPHA_EQUATION_MAX: number;
  665. /** Defines that alpha blending equation a MIN operation */
  666. static readonly ALPHA_EQUATION_MIN: number;
  667. /**
  668. * Defines that alpha blending equation a DARKEN operation:
  669. * It takes the min of the src and sums the alpha channels.
  670. */
  671. static readonly ALPHA_EQUATION_DARKEN: number;
  672. /** Defines that the ressource is not delayed*/
  673. static readonly DELAYLOADSTATE_NONE: number;
  674. /** Defines that the ressource was successfully delay loaded */
  675. static readonly DELAYLOADSTATE_LOADED: number;
  676. /** Defines that the ressource is currently delay loading */
  677. static readonly DELAYLOADSTATE_LOADING: number;
  678. /** Defines that the ressource is delayed and has not started loading */
  679. static readonly DELAYLOADSTATE_NOTLOADED: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  681. static readonly NEVER: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  683. static readonly ALWAYS: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  685. static readonly LESS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  687. static readonly EQUAL: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  689. static readonly LEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  691. static readonly GREATER: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  693. static readonly GEQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  695. static readonly NOTEQUAL: number;
  696. /** Passed to stencilOperation to specify that stencil value must be kept */
  697. static readonly KEEP: number;
  698. /** Passed to stencilOperation to specify that stencil value must be replaced */
  699. static readonly REPLACE: number;
  700. /** Passed to stencilOperation to specify that stencil value must be incremented */
  701. static readonly INCR: number;
  702. /** Passed to stencilOperation to specify that stencil value must be decremented */
  703. static readonly DECR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be inverted */
  705. static readonly INVERT: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  707. static readonly INCR_WRAP: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  709. static readonly DECR_WRAP: number;
  710. /** Texture is not repeating outside of 0..1 UVs */
  711. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  712. /** Texture is repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  714. /** Texture is repeating and mirrored */
  715. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  716. /** ALPHA */
  717. static readonly TEXTUREFORMAT_ALPHA: number;
  718. /** LUMINANCE */
  719. static readonly TEXTUREFORMAT_LUMINANCE: number;
  720. /** LUMINANCE_ALPHA */
  721. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  722. /** RGB */
  723. static readonly TEXTUREFORMAT_RGB: number;
  724. /** RGBA */
  725. static readonly TEXTUREFORMAT_RGBA: number;
  726. /** RED */
  727. static readonly TEXTUREFORMAT_RED: number;
  728. /** RED (2nd reference) */
  729. static readonly TEXTUREFORMAT_R: number;
  730. /** RG */
  731. static readonly TEXTUREFORMAT_RG: number;
  732. /** RED_INTEGER */
  733. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  734. /** RED_INTEGER (2nd reference) */
  735. static readonly TEXTUREFORMAT_R_INTEGER: number;
  736. /** RG_INTEGER */
  737. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  738. /** RGB_INTEGER */
  739. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  740. /** RGBA_INTEGER */
  741. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  742. /** UNSIGNED_BYTE */
  743. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  744. /** UNSIGNED_BYTE (2nd reference) */
  745. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  746. /** FLOAT */
  747. static readonly TEXTURETYPE_FLOAT: number;
  748. /** HALF_FLOAT */
  749. static readonly TEXTURETYPE_HALF_FLOAT: number;
  750. /** BYTE */
  751. static readonly TEXTURETYPE_BYTE: number;
  752. /** SHORT */
  753. static readonly TEXTURETYPE_SHORT: number;
  754. /** UNSIGNED_SHORT */
  755. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  756. /** INT */
  757. static readonly TEXTURETYPE_INT: number;
  758. /** UNSIGNED_INT */
  759. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  760. /** UNSIGNED_SHORT_4_4_4_4 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  762. /** UNSIGNED_SHORT_5_5_5_1 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  764. /** UNSIGNED_SHORT_5_6_5 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  766. /** UNSIGNED_INT_2_10_10_10_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  768. /** UNSIGNED_INT_24_8 */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  770. /** UNSIGNED_INT_10F_11F_11F_REV */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  772. /** UNSIGNED_INT_5_9_9_9_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  774. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  775. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  776. /** nearest is mag = nearest and min = nearest and no mip */
  777. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  778. /** mag = nearest and min = nearest and mip = none */
  779. static readonly TEXTURE_NEAREST_NEAREST: number;
  780. /** Bilinear is mag = linear and min = linear and no mip */
  781. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  782. /** mag = linear and min = linear and mip = none */
  783. static readonly TEXTURE_LINEAR_LINEAR: number;
  784. /** Trilinear is mag = linear and min = linear and mip = linear */
  785. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  788. /** mag = nearest and min = nearest and mip = nearest */
  789. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  790. /** mag = nearest and min = linear and mip = nearest */
  791. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = linear */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = linear and mip = none */
  795. static readonly TEXTURE_NEAREST_LINEAR: number;
  796. /** nearest is mag = nearest and min = nearest and mip = linear */
  797. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  798. /** mag = linear and min = nearest and mip = nearest */
  799. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = linear */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  803. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  804. /** mag = linear and min = nearest and mip = none */
  805. static readonly TEXTURE_LINEAR_NEAREST: number;
  806. /** Explicit coordinates mode */
  807. static readonly TEXTURE_EXPLICIT_MODE: number;
  808. /** Spherical coordinates mode */
  809. static readonly TEXTURE_SPHERICAL_MODE: number;
  810. /** Planar coordinates mode */
  811. static readonly TEXTURE_PLANAR_MODE: number;
  812. /** Cubic coordinates mode */
  813. static readonly TEXTURE_CUBIC_MODE: number;
  814. /** Projection coordinates mode */
  815. static readonly TEXTURE_PROJECTION_MODE: number;
  816. /** Skybox coordinates mode */
  817. static readonly TEXTURE_SKYBOX_MODE: number;
  818. /** Inverse Cubic coordinates mode */
  819. static readonly TEXTURE_INVCUBIC_MODE: number;
  820. /** Equirectangular coordinates mode */
  821. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  822. /** Equirectangular Fixed coordinates mode */
  823. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed Mirrored coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  826. /** Offline (baking) quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  828. /** High quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  830. /** Medium quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  832. /** Low quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  834. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  835. static readonly SCALEMODE_FLOOR: number;
  836. /** Defines that texture rescaling will look for the nearest power of 2 size */
  837. static readonly SCALEMODE_NEAREST: number;
  838. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  839. static readonly SCALEMODE_CEILING: number;
  840. /**
  841. * The dirty texture flag value
  842. */
  843. static readonly MATERIAL_TextureDirtyFlag: number;
  844. /**
  845. * The dirty light flag value
  846. */
  847. static readonly MATERIAL_LightDirtyFlag: number;
  848. /**
  849. * The dirty fresnel flag value
  850. */
  851. static readonly MATERIAL_FresnelDirtyFlag: number;
  852. /**
  853. * The dirty attribute flag value
  854. */
  855. static readonly MATERIAL_AttributesDirtyFlag: number;
  856. /**
  857. * The dirty misc flag value
  858. */
  859. static readonly MATERIAL_MiscDirtyFlag: number;
  860. /**
  861. * The all dirty flag value
  862. */
  863. static readonly MATERIAL_AllDirtyFlag: number;
  864. /**
  865. * Returns the triangle fill mode
  866. */
  867. static readonly MATERIAL_TriangleFillMode: number;
  868. /**
  869. * Returns the wireframe mode
  870. */
  871. static readonly MATERIAL_WireFrameFillMode: number;
  872. /**
  873. * Returns the point fill mode
  874. */
  875. static readonly MATERIAL_PointFillMode: number;
  876. /**
  877. * Returns the point list draw mode
  878. */
  879. static readonly MATERIAL_PointListDrawMode: number;
  880. /**
  881. * Returns the line list draw mode
  882. */
  883. static readonly MATERIAL_LineListDrawMode: number;
  884. /**
  885. * Returns the line loop draw mode
  886. */
  887. static readonly MATERIAL_LineLoopDrawMode: number;
  888. /**
  889. * Returns the line strip draw mode
  890. */
  891. static readonly MATERIAL_LineStripDrawMode: number;
  892. /**
  893. * Returns the triangle strip draw mode
  894. */
  895. static readonly MATERIAL_TriangleStripDrawMode: number;
  896. /**
  897. * Returns the triangle fan draw mode
  898. */
  899. static readonly MATERIAL_TriangleFanDrawMode: number;
  900. /**
  901. * Stores the clock-wise side orientation
  902. */
  903. static readonly MATERIAL_ClockWiseSideOrientation: number;
  904. /**
  905. * Stores the counter clock-wise side orientation
  906. */
  907. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  908. /**
  909. * Nothing
  910. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_NothingTrigger: number;
  913. /**
  914. * On pick
  915. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickTrigger: number;
  918. /**
  919. * On left pick
  920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnLeftPickTrigger: number;
  923. /**
  924. * On right pick
  925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnRightPickTrigger: number;
  928. /**
  929. * On center pick
  930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnCenterPickTrigger: number;
  933. /**
  934. * On pick down
  935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnPickDownTrigger: number;
  938. /**
  939. * On double pick
  940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnDoublePickTrigger: number;
  943. /**
  944. * On pick up
  945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickUpTrigger: number;
  948. /**
  949. * On pick out.
  950. * This trigger will only be raised if you also declared a OnPickDown
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickOutTrigger: number;
  954. /**
  955. * On long press
  956. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnLongPressTrigger: number;
  959. /**
  960. * On pointer over
  961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPointerOverTrigger: number;
  964. /**
  965. * On pointer out
  966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnPointerOutTrigger: number;
  969. /**
  970. * On every frame
  971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnEveryFrameTrigger: number;
  974. /**
  975. * On intersection enter
  976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnIntersectionEnterTrigger: number;
  979. /**
  980. * On intersection exit
  981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnIntersectionExitTrigger: number;
  984. /**
  985. * On key down
  986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnKeyDownTrigger: number;
  989. /**
  990. * On key up
  991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnKeyUpTrigger: number;
  994. /**
  995. * Billboard mode will only apply to Y axis
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  998. /**
  999. * Billboard mode will apply to all axes
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1002. /**
  1003. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1004. */
  1005. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1006. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1007. * Test order :
  1008. * Is the bounding sphere outside the frustum ?
  1009. * If not, are the bounding box vertices outside the frustum ?
  1010. * It not, then the cullable object is in the frustum.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1013. /** Culling strategy : Bounding Sphere Only.
  1014. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1015. * It's also less accurate than the standard because some not visible objects can still be selected.
  1016. * Test : is the bounding sphere outside the frustum ?
  1017. * If not, then the cullable object is in the frustum.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1020. /** Culling strategy : Optimistic Inclusion.
  1021. * This in an inclusion test first, then the standard exclusion test.
  1022. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1023. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1024. * Anyway, it's as accurate as the standard strategy.
  1025. * Test :
  1026. * Is the cullable object bounding sphere center in the frustum ?
  1027. * If not, apply the default culling strategy.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1030. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1031. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1032. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1033. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1034. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1040. /**
  1041. * No logging while loading
  1042. */
  1043. static readonly SCENELOADER_NO_LOGGING: number;
  1044. /**
  1045. * Minimal logging while loading
  1046. */
  1047. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1048. /**
  1049. * Summary logging while loading
  1050. */
  1051. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1052. /**
  1053. * Detailled logging while loading
  1054. */
  1055. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1056. /**
  1057. * Prepass texture index for color
  1058. */
  1059. static readonly PREPASS_COLOR_INDEX: number;
  1060. /**
  1061. * Prepass texture index for irradiance
  1062. */
  1063. static readonly PREPASS_IRRADIANCE_INDEX: number;
  1064. /**
  1065. * Prepass texture index for depth + normal
  1066. */
  1067. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  1068. /**
  1069. * Prepass texture index for albedo
  1070. */
  1071. static readonly PREPASS_ALBEDO_INDEX: number;
  1072. }
  1073. }
  1074. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1075. import { Nullable } from "babylonjs/types";
  1076. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1077. /**
  1078. * This represents the required contract to create a new type of texture loader.
  1079. */
  1080. export interface IInternalTextureLoader {
  1081. /**
  1082. * Defines wether the loader supports cascade loading the different faces.
  1083. */
  1084. supportCascades: boolean;
  1085. /**
  1086. * This returns if the loader support the current file information.
  1087. * @param extension defines the file extension of the file being loaded
  1088. * @param mimeType defines the optional mime type of the file being loaded
  1089. * @returns true if the loader can load the specified file
  1090. */
  1091. canLoad(extension: string, mimeType?: string): boolean;
  1092. /**
  1093. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1094. * @param data contains the texture data
  1095. * @param texture defines the BabylonJS internal texture
  1096. * @param createPolynomials will be true if polynomials have been requested
  1097. * @param onLoad defines the callback to trigger once the texture is ready
  1098. * @param onError defines the callback to trigger in case of error
  1099. */
  1100. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1101. /**
  1102. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1103. * @param data contains the texture data
  1104. * @param texture defines the BabylonJS internal texture
  1105. * @param callback defines the method to call once ready to upload
  1106. */
  1107. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1108. }
  1109. }
  1110. declare module "babylonjs/Engines/IPipelineContext" {
  1111. /**
  1112. * Class used to store and describe the pipeline context associated with an effect
  1113. */
  1114. export interface IPipelineContext {
  1115. /**
  1116. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1117. */
  1118. isAsync: boolean;
  1119. /**
  1120. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1121. */
  1122. isReady: boolean;
  1123. /** @hidden */
  1124. _getVertexShaderCode(): string | null;
  1125. /** @hidden */
  1126. _getFragmentShaderCode(): string | null;
  1127. /** @hidden */
  1128. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1129. }
  1130. }
  1131. declare module "babylonjs/Meshes/dataBuffer" {
  1132. /**
  1133. * Class used to store gfx data (like WebGLBuffer)
  1134. */
  1135. export class DataBuffer {
  1136. /**
  1137. * Gets or sets the number of objects referencing this buffer
  1138. */
  1139. references: number;
  1140. /** Gets or sets the size of the underlying buffer */
  1141. capacity: number;
  1142. /**
  1143. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1144. */
  1145. is32Bits: boolean;
  1146. /**
  1147. * Gets the underlying buffer
  1148. */
  1149. get underlyingResource(): any;
  1150. }
  1151. }
  1152. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1153. /** @hidden */
  1154. export interface IShaderProcessor {
  1155. attributeProcessor?: (attribute: string) => string;
  1156. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1157. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1158. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1159. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1160. lineProcessor?: (line: string, isFragment: boolean) => string;
  1161. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1162. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1163. }
  1164. }
  1165. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1166. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1167. /** @hidden */
  1168. export interface ProcessingOptions {
  1169. defines: string[];
  1170. indexParameters: any;
  1171. isFragment: boolean;
  1172. shouldUseHighPrecisionShader: boolean;
  1173. supportsUniformBuffers: boolean;
  1174. shadersRepository: string;
  1175. includesShadersStore: {
  1176. [key: string]: string;
  1177. };
  1178. processor?: IShaderProcessor;
  1179. version: string;
  1180. platformName: string;
  1181. lookForClosingBracketForUniformBuffer?: boolean;
  1182. }
  1183. }
  1184. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1185. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1186. /** @hidden */
  1187. export class ShaderCodeNode {
  1188. line: string;
  1189. children: ShaderCodeNode[];
  1190. additionalDefineKey?: string;
  1191. additionalDefineValue?: string;
  1192. isValid(preprocessors: {
  1193. [key: string]: string;
  1194. }): boolean;
  1195. process(preprocessors: {
  1196. [key: string]: string;
  1197. }, options: ProcessingOptions): string;
  1198. }
  1199. }
  1200. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1201. /** @hidden */
  1202. export class ShaderCodeCursor {
  1203. private _lines;
  1204. lineIndex: number;
  1205. get currentLine(): string;
  1206. get canRead(): boolean;
  1207. set lines(value: string[]);
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1211. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1212. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1213. /** @hidden */
  1214. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1215. process(preprocessors: {
  1216. [key: string]: string;
  1217. }, options: ProcessingOptions): string;
  1218. }
  1219. }
  1220. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1221. /** @hidden */
  1222. export class ShaderDefineExpression {
  1223. isTrue(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. private static _OperatorPriority;
  1227. private static _Stack;
  1228. static postfixToInfix(postfix: string[]): string;
  1229. static infixToPostfix(infix: string): string[];
  1230. }
  1231. }
  1232. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1233. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1234. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1235. /** @hidden */
  1236. export class ShaderCodeTestNode extends ShaderCodeNode {
  1237. testExpression: ShaderDefineExpression;
  1238. isValid(preprocessors: {
  1239. [key: string]: string;
  1240. }): boolean;
  1241. }
  1242. }
  1243. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1244. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1245. /** @hidden */
  1246. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1247. define: string;
  1248. not: boolean;
  1249. constructor(define: string, not?: boolean);
  1250. isTrue(preprocessors: {
  1251. [key: string]: string;
  1252. }): boolean;
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1256. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1257. /** @hidden */
  1258. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1259. leftOperand: ShaderDefineExpression;
  1260. rightOperand: ShaderDefineExpression;
  1261. isTrue(preprocessors: {
  1262. [key: string]: string;
  1263. }): boolean;
  1264. }
  1265. }
  1266. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1267. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1268. /** @hidden */
  1269. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1270. leftOperand: ShaderDefineExpression;
  1271. rightOperand: ShaderDefineExpression;
  1272. isTrue(preprocessors: {
  1273. [key: string]: string;
  1274. }): boolean;
  1275. }
  1276. }
  1277. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1278. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1279. /** @hidden */
  1280. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1281. define: string;
  1282. operand: string;
  1283. testValue: string;
  1284. constructor(define: string, operand: string, testValue: string);
  1285. isTrue(preprocessors: {
  1286. [key: string]: string;
  1287. }): boolean;
  1288. }
  1289. }
  1290. declare module "babylonjs/Offline/IOfflineProvider" {
  1291. /**
  1292. * Class used to enable access to offline support
  1293. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1294. */
  1295. export interface IOfflineProvider {
  1296. /**
  1297. * Gets a boolean indicating if scene must be saved in the database
  1298. */
  1299. enableSceneOffline: boolean;
  1300. /**
  1301. * Gets a boolean indicating if textures must be saved in the database
  1302. */
  1303. enableTexturesOffline: boolean;
  1304. /**
  1305. * Open the offline support and make it available
  1306. * @param successCallback defines the callback to call on success
  1307. * @param errorCallback defines the callback to call on error
  1308. */
  1309. open(successCallback: () => void, errorCallback: () => void): void;
  1310. /**
  1311. * Loads an image from the offline support
  1312. * @param url defines the url to load from
  1313. * @param image defines the target DOM image
  1314. */
  1315. loadImage(url: string, image: HTMLImageElement): void;
  1316. /**
  1317. * Loads a file from offline support
  1318. * @param url defines the URL to load from
  1319. * @param sceneLoaded defines a callback to call on success
  1320. * @param progressCallBack defines a callback to call when progress changed
  1321. * @param errorCallback defines a callback to call on error
  1322. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1323. */
  1324. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1325. }
  1326. }
  1327. declare module "babylonjs/Misc/filesInputStore" {
  1328. /**
  1329. * Class used to help managing file picking and drag'n'drop
  1330. * File Storage
  1331. */
  1332. export class FilesInputStore {
  1333. /**
  1334. * List of files ready to be loaded
  1335. */
  1336. static FilesToLoad: {
  1337. [key: string]: File;
  1338. };
  1339. }
  1340. }
  1341. declare module "babylonjs/Misc/retryStrategy" {
  1342. import { WebRequest } from "babylonjs/Misc/webRequest";
  1343. /**
  1344. * Class used to define a retry strategy when error happens while loading assets
  1345. */
  1346. export class RetryStrategy {
  1347. /**
  1348. * Function used to defines an exponential back off strategy
  1349. * @param maxRetries defines the maximum number of retries (3 by default)
  1350. * @param baseInterval defines the interval between retries
  1351. * @returns the strategy function to use
  1352. */
  1353. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1354. }
  1355. }
  1356. declare module "babylonjs/Misc/baseError" {
  1357. /**
  1358. * @ignore
  1359. * Application error to support additional information when loading a file
  1360. */
  1361. export abstract class BaseError extends Error {
  1362. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1363. }
  1364. }
  1365. declare module "babylonjs/Misc/fileTools" {
  1366. import { WebRequest } from "babylonjs/Misc/webRequest";
  1367. import { Nullable } from "babylonjs/types";
  1368. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1369. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1370. import { BaseError } from "babylonjs/Misc/baseError";
  1371. /** @ignore */
  1372. export class LoadFileError extends BaseError {
  1373. request?: WebRequest;
  1374. file?: File;
  1375. /**
  1376. * Creates a new LoadFileError
  1377. * @param message defines the message of the error
  1378. * @param request defines the optional web request
  1379. * @param file defines the optional file
  1380. */
  1381. constructor(message: string, object?: WebRequest | File);
  1382. }
  1383. /** @ignore */
  1384. export class RequestFileError extends BaseError {
  1385. request: WebRequest;
  1386. /**
  1387. * Creates a new LoadFileError
  1388. * @param message defines the message of the error
  1389. * @param request defines the optional web request
  1390. */
  1391. constructor(message: string, request: WebRequest);
  1392. }
  1393. /** @ignore */
  1394. export class ReadFileError extends BaseError {
  1395. file: File;
  1396. /**
  1397. * Creates a new ReadFileError
  1398. * @param message defines the message of the error
  1399. * @param file defines the optional file
  1400. */
  1401. constructor(message: string, file: File);
  1402. }
  1403. /**
  1404. * @hidden
  1405. */
  1406. export class FileTools {
  1407. /**
  1408. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1409. */
  1410. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1411. /**
  1412. * Gets or sets the base URL to use to load assets
  1413. */
  1414. static BaseUrl: string;
  1415. /**
  1416. * Default behaviour for cors in the application.
  1417. * It can be a string if the expected behavior is identical in the entire app.
  1418. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1419. */
  1420. static CorsBehavior: string | ((url: string | string[]) => string);
  1421. /**
  1422. * Gets or sets a function used to pre-process url before using them to load assets
  1423. */
  1424. static PreprocessUrl: (url: string) => string;
  1425. /**
  1426. * Removes unwanted characters from an url
  1427. * @param url defines the url to clean
  1428. * @returns the cleaned url
  1429. */
  1430. private static _CleanUrl;
  1431. /**
  1432. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1433. * @param url define the url we are trying
  1434. * @param element define the dom element where to configure the cors policy
  1435. */
  1436. static SetCorsBehavior(url: string | string[], element: {
  1437. crossOrigin: string | null;
  1438. }): void;
  1439. /**
  1440. * Loads an image as an HTMLImageElement.
  1441. * @param input url string, ArrayBuffer, or Blob to load
  1442. * @param onLoad callback called when the image successfully loads
  1443. * @param onError callback called when the image fails to load
  1444. * @param offlineProvider offline provider for caching
  1445. * @param mimeType optional mime type
  1446. * @returns the HTMLImageElement of the loaded image
  1447. */
  1448. 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>;
  1449. /**
  1450. * Reads a file from a File object
  1451. * @param file defines the file to load
  1452. * @param onSuccess defines the callback to call when data is loaded
  1453. * @param onProgress defines the callback to call during loading process
  1454. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1455. * @param onError defines the callback to call when an error occurs
  1456. * @returns a file request object
  1457. */
  1458. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1459. /**
  1460. * Loads a file from a url
  1461. * @param url url to load
  1462. * @param onSuccess callback called when the file successfully loads
  1463. * @param onProgress callback called while file is loading (if the server supports this mode)
  1464. * @param offlineProvider defines the offline provider for caching
  1465. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1466. * @param onError callback called when the file fails to load
  1467. * @returns a file request object
  1468. */
  1469. 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;
  1470. /**
  1471. * Loads a file
  1472. * @param url url to load
  1473. * @param onSuccess callback called when the file successfully loads
  1474. * @param onProgress callback called while file is loading (if the server supports this mode)
  1475. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1476. * @param onError callback called when the file fails to load
  1477. * @param onOpened callback called when the web request is opened
  1478. * @returns a file request object
  1479. */
  1480. 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;
  1481. /**
  1482. * Checks if the loaded document was accessed via `file:`-Protocol.
  1483. * @returns boolean
  1484. */
  1485. static IsFileURL(): boolean;
  1486. }
  1487. }
  1488. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1489. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1490. import { WebRequest } from "babylonjs/Misc/webRequest";
  1491. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1492. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1493. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1494. /** @hidden */
  1495. export class ShaderProcessor {
  1496. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1497. private static _ProcessPrecision;
  1498. private static _ExtractOperation;
  1499. private static _BuildSubExpression;
  1500. private static _BuildExpression;
  1501. private static _MoveCursorWithinIf;
  1502. private static _MoveCursor;
  1503. private static _EvaluatePreProcessors;
  1504. private static _PreparePreProcessors;
  1505. private static _ProcessShaderConversion;
  1506. private static _ProcessIncludes;
  1507. /**
  1508. * Loads a file from a url
  1509. * @param url url to load
  1510. * @param onSuccess callback called when the file successfully loads
  1511. * @param onProgress callback called while file is loading (if the server supports this mode)
  1512. * @param offlineProvider defines the offline provider for caching
  1513. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1514. * @param onError callback called when the file fails to load
  1515. * @returns a file request object
  1516. * @hidden
  1517. */
  1518. 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;
  1519. }
  1520. }
  1521. declare module "babylonjs/Maths/math.like" {
  1522. import { float, int, DeepImmutable } from "babylonjs/types";
  1523. /**
  1524. * @hidden
  1525. */
  1526. export interface IColor4Like {
  1527. r: float;
  1528. g: float;
  1529. b: float;
  1530. a: float;
  1531. }
  1532. /**
  1533. * @hidden
  1534. */
  1535. export interface IColor3Like {
  1536. r: float;
  1537. g: float;
  1538. b: float;
  1539. }
  1540. /**
  1541. * @hidden
  1542. */
  1543. export interface IVector4Like {
  1544. x: float;
  1545. y: float;
  1546. z: float;
  1547. w: float;
  1548. }
  1549. /**
  1550. * @hidden
  1551. */
  1552. export interface IVector3Like {
  1553. x: float;
  1554. y: float;
  1555. z: float;
  1556. }
  1557. /**
  1558. * @hidden
  1559. */
  1560. export interface IVector2Like {
  1561. x: float;
  1562. y: float;
  1563. }
  1564. /**
  1565. * @hidden
  1566. */
  1567. export interface IMatrixLike {
  1568. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1569. updateFlag: int;
  1570. }
  1571. /**
  1572. * @hidden
  1573. */
  1574. export interface IViewportLike {
  1575. x: float;
  1576. y: float;
  1577. width: float;
  1578. height: float;
  1579. }
  1580. /**
  1581. * @hidden
  1582. */
  1583. export interface IPlaneLike {
  1584. normal: IVector3Like;
  1585. d: float;
  1586. normalize(): void;
  1587. }
  1588. }
  1589. declare module "babylonjs/Materials/iEffectFallbacks" {
  1590. import { Effect } from "babylonjs/Materials/effect";
  1591. /**
  1592. * Interface used to define common properties for effect fallbacks
  1593. */
  1594. export interface IEffectFallbacks {
  1595. /**
  1596. * Removes the defines that should be removed when falling back.
  1597. * @param currentDefines defines the current define statements for the shader.
  1598. * @param effect defines the current effect we try to compile
  1599. * @returns The resulting defines with defines of the current rank removed.
  1600. */
  1601. reduce(currentDefines: string, effect: Effect): string;
  1602. /**
  1603. * Removes the fallback from the bound mesh.
  1604. */
  1605. unBindMesh(): void;
  1606. /**
  1607. * Checks to see if more fallbacks are still availible.
  1608. */
  1609. hasMoreFallbacks: boolean;
  1610. }
  1611. }
  1612. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1613. /**
  1614. * Class used to evalaute queries containing `and` and `or` operators
  1615. */
  1616. export class AndOrNotEvaluator {
  1617. /**
  1618. * Evaluate a query
  1619. * @param query defines the query to evaluate
  1620. * @param evaluateCallback defines the callback used to filter result
  1621. * @returns true if the query matches
  1622. */
  1623. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1624. private static _HandleParenthesisContent;
  1625. private static _SimplifyNegation;
  1626. }
  1627. }
  1628. declare module "babylonjs/Misc/tags" {
  1629. /**
  1630. * Class used to store custom tags
  1631. */
  1632. export class Tags {
  1633. /**
  1634. * Adds support for tags on the given object
  1635. * @param obj defines the object to use
  1636. */
  1637. static EnableFor(obj: any): void;
  1638. /**
  1639. * Removes tags support
  1640. * @param obj defines the object to use
  1641. */
  1642. static DisableFor(obj: any): void;
  1643. /**
  1644. * Gets a boolean indicating if the given object has tags
  1645. * @param obj defines the object to use
  1646. * @returns a boolean
  1647. */
  1648. static HasTags(obj: any): boolean;
  1649. /**
  1650. * Gets the tags available on a given object
  1651. * @param obj defines the object to use
  1652. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1653. * @returns the tags
  1654. */
  1655. static GetTags(obj: any, asString?: boolean): any;
  1656. /**
  1657. * Adds tags to an object
  1658. * @param obj defines the object to use
  1659. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1660. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1661. */
  1662. static AddTagsTo(obj: any, tagsString: string): void;
  1663. /**
  1664. * @hidden
  1665. */
  1666. static _AddTagTo(obj: any, tag: string): void;
  1667. /**
  1668. * Removes specific tags from a specific object
  1669. * @param obj defines the object to use
  1670. * @param tagsString defines the tags to remove
  1671. */
  1672. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1673. /**
  1674. * @hidden
  1675. */
  1676. static _RemoveTagFrom(obj: any, tag: string): void;
  1677. /**
  1678. * Defines if tags hosted on an object match a given query
  1679. * @param obj defines the object to use
  1680. * @param tagsQuery defines the tag query
  1681. * @returns a boolean
  1682. */
  1683. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1684. }
  1685. }
  1686. declare module "babylonjs/Maths/math.scalar" {
  1687. /**
  1688. * Scalar computation library
  1689. */
  1690. export class Scalar {
  1691. /**
  1692. * Two pi constants convenient for computation.
  1693. */
  1694. static TwoPi: number;
  1695. /**
  1696. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1697. * @param a number
  1698. * @param b number
  1699. * @param epsilon (default = 1.401298E-45)
  1700. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1701. */
  1702. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1703. /**
  1704. * Returns a string : the upper case translation of the number i to hexadecimal.
  1705. * @param i number
  1706. * @returns the upper case translation of the number i to hexadecimal.
  1707. */
  1708. static ToHex(i: number): string;
  1709. /**
  1710. * Returns -1 if value is negative and +1 is value is positive.
  1711. * @param value the value
  1712. * @returns the value itself if it's equal to zero.
  1713. */
  1714. static Sign(value: number): number;
  1715. /**
  1716. * Returns the value itself if it's between min and max.
  1717. * Returns min if the value is lower than min.
  1718. * Returns max if the value is greater than max.
  1719. * @param value the value to clmap
  1720. * @param min the min value to clamp to (default: 0)
  1721. * @param max the max value to clamp to (default: 1)
  1722. * @returns the clamped value
  1723. */
  1724. static Clamp(value: number, min?: number, max?: number): number;
  1725. /**
  1726. * the log2 of value.
  1727. * @param value the value to compute log2 of
  1728. * @returns the log2 of value.
  1729. */
  1730. static Log2(value: number): number;
  1731. /**
  1732. * Loops the value, so that it is never larger than length and never smaller than 0.
  1733. *
  1734. * This is similar to the modulo operator but it works with floating point numbers.
  1735. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1736. * With t = 5 and length = 2.5, the result would be 0.0.
  1737. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1738. * @param value the value
  1739. * @param length the length
  1740. * @returns the looped value
  1741. */
  1742. static Repeat(value: number, length: number): number;
  1743. /**
  1744. * Normalize the value between 0.0 and 1.0 using min and max values
  1745. * @param value value to normalize
  1746. * @param min max to normalize between
  1747. * @param max min to normalize between
  1748. * @returns the normalized value
  1749. */
  1750. static Normalize(value: number, min: number, max: number): number;
  1751. /**
  1752. * Denormalize the value from 0.0 and 1.0 using min and max values
  1753. * @param normalized value to denormalize
  1754. * @param min max to denormalize between
  1755. * @param max min to denormalize between
  1756. * @returns the denormalized value
  1757. */
  1758. static Denormalize(normalized: number, min: number, max: number): number;
  1759. /**
  1760. * Calculates the shortest difference between two given angles given in degrees.
  1761. * @param current current angle in degrees
  1762. * @param target target angle in degrees
  1763. * @returns the delta
  1764. */
  1765. static DeltaAngle(current: number, target: number): number;
  1766. /**
  1767. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1768. * @param tx value
  1769. * @param length length
  1770. * @returns The returned value will move back and forth between 0 and length
  1771. */
  1772. static PingPong(tx: number, length: number): number;
  1773. /**
  1774. * Interpolates between min and max with smoothing at the limits.
  1775. *
  1776. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1777. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1778. * @param from from
  1779. * @param to to
  1780. * @param tx value
  1781. * @returns the smooth stepped value
  1782. */
  1783. static SmoothStep(from: number, to: number, tx: number): number;
  1784. /**
  1785. * Moves a value current towards target.
  1786. *
  1787. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1788. * Negative values of maxDelta pushes the value away from target.
  1789. * @param current current value
  1790. * @param target target value
  1791. * @param maxDelta max distance to move
  1792. * @returns resulting value
  1793. */
  1794. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1795. /**
  1796. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1797. *
  1798. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1799. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1800. * @param current current value
  1801. * @param target target value
  1802. * @param maxDelta max distance to move
  1803. * @returns resulting angle
  1804. */
  1805. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1806. /**
  1807. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1808. * @param start start value
  1809. * @param end target value
  1810. * @param amount amount to lerp between
  1811. * @returns the lerped value
  1812. */
  1813. static Lerp(start: number, end: number, amount: number): number;
  1814. /**
  1815. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1816. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1817. * @param start start value
  1818. * @param end target value
  1819. * @param amount amount to lerp between
  1820. * @returns the lerped value
  1821. */
  1822. static LerpAngle(start: number, end: number, amount: number): number;
  1823. /**
  1824. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1825. * @param a start value
  1826. * @param b target value
  1827. * @param value value between a and b
  1828. * @returns the inverseLerp value
  1829. */
  1830. static InverseLerp(a: number, b: number, value: number): number;
  1831. /**
  1832. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1833. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1834. * @param value1 spline value
  1835. * @param tangent1 spline value
  1836. * @param value2 spline value
  1837. * @param tangent2 spline value
  1838. * @param amount input value
  1839. * @returns hermite result
  1840. */
  1841. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1842. /**
  1843. * Returns a random float number between and min and max values
  1844. * @param min min value of random
  1845. * @param max max value of random
  1846. * @returns random value
  1847. */
  1848. static RandomRange(min: number, max: number): number;
  1849. /**
  1850. * This function returns percentage of a number in a given range.
  1851. *
  1852. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1853. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1854. * @param number to convert to percentage
  1855. * @param min min range
  1856. * @param max max range
  1857. * @returns the percentage
  1858. */
  1859. static RangeToPercent(number: number, min: number, max: number): number;
  1860. /**
  1861. * This function returns number that corresponds to the percentage in a given range.
  1862. *
  1863. * PercentToRange(0.34,0,100) will return 34.
  1864. * @param percent to convert to number
  1865. * @param min min range
  1866. * @param max max range
  1867. * @returns the number
  1868. */
  1869. static PercentToRange(percent: number, min: number, max: number): number;
  1870. /**
  1871. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1872. * @param angle The angle to normalize in radian.
  1873. * @return The converted angle.
  1874. */
  1875. static NormalizeRadians(angle: number): number;
  1876. }
  1877. }
  1878. declare module "babylonjs/Maths/math.constants" {
  1879. /**
  1880. * Constant used to convert a value to gamma space
  1881. * @ignorenaming
  1882. */
  1883. export const ToGammaSpace: number;
  1884. /**
  1885. * Constant used to convert a value to linear space
  1886. * @ignorenaming
  1887. */
  1888. export const ToLinearSpace = 2.2;
  1889. /**
  1890. * Constant used to define the minimal number value in Babylon.js
  1891. * @ignorenaming
  1892. */
  1893. let Epsilon: number;
  1894. export { Epsilon };
  1895. }
  1896. declare module "babylonjs/Maths/math.viewport" {
  1897. /**
  1898. * Class used to represent a viewport on screen
  1899. */
  1900. export class Viewport {
  1901. /** viewport left coordinate */
  1902. x: number;
  1903. /** viewport top coordinate */
  1904. y: number;
  1905. /**viewport width */
  1906. width: number;
  1907. /** viewport height */
  1908. height: number;
  1909. /**
  1910. * Creates a Viewport object located at (x, y) and sized (width, height)
  1911. * @param x defines viewport left coordinate
  1912. * @param y defines viewport top coordinate
  1913. * @param width defines the viewport width
  1914. * @param height defines the viewport height
  1915. */
  1916. constructor(
  1917. /** viewport left coordinate */
  1918. x: number,
  1919. /** viewport top coordinate */
  1920. y: number,
  1921. /**viewport width */
  1922. width: number,
  1923. /** viewport height */
  1924. height: number);
  1925. /**
  1926. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1927. * @param renderWidth defines the rendering width
  1928. * @param renderHeight defines the rendering height
  1929. * @returns a new Viewport
  1930. */
  1931. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1932. /**
  1933. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1934. * @param renderWidth defines the rendering width
  1935. * @param renderHeight defines the rendering height
  1936. * @param ref defines the target viewport
  1937. * @returns the current viewport
  1938. */
  1939. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1940. /**
  1941. * Returns a new Viewport copied from the current one
  1942. * @returns a new Viewport
  1943. */
  1944. clone(): Viewport;
  1945. }
  1946. }
  1947. declare module "babylonjs/Misc/arrayTools" {
  1948. /**
  1949. * Class containing a set of static utilities functions for arrays.
  1950. */
  1951. export class ArrayTools {
  1952. /**
  1953. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1954. * @param size the number of element to construct and put in the array
  1955. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1956. * @returns a new array filled with new objects
  1957. */
  1958. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1959. }
  1960. }
  1961. declare module "babylonjs/Maths/math.plane" {
  1962. import { DeepImmutable } from "babylonjs/types";
  1963. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1964. /**
  1965. * Represents a plane by the equation ax + by + cz + d = 0
  1966. */
  1967. export class Plane {
  1968. private static _TmpMatrix;
  1969. /**
  1970. * Normal of the plane (a,b,c)
  1971. */
  1972. normal: Vector3;
  1973. /**
  1974. * d component of the plane
  1975. */
  1976. d: number;
  1977. /**
  1978. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1979. * @param a a component of the plane
  1980. * @param b b component of the plane
  1981. * @param c c component of the plane
  1982. * @param d d component of the plane
  1983. */
  1984. constructor(a: number, b: number, c: number, d: number);
  1985. /**
  1986. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1987. */
  1988. asArray(): number[];
  1989. /**
  1990. * @returns a new plane copied from the current Plane.
  1991. */
  1992. clone(): Plane;
  1993. /**
  1994. * @returns the string "Plane".
  1995. */
  1996. getClassName(): string;
  1997. /**
  1998. * @returns the Plane hash code.
  1999. */
  2000. getHashCode(): number;
  2001. /**
  2002. * Normalize the current Plane in place.
  2003. * @returns the updated Plane.
  2004. */
  2005. normalize(): Plane;
  2006. /**
  2007. * Applies a transformation the plane and returns the result
  2008. * @param transformation the transformation matrix to be applied to the plane
  2009. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2010. */
  2011. transform(transformation: DeepImmutable<Matrix>): Plane;
  2012. /**
  2013. * Compute the dot product between the point and the plane normal
  2014. * @param point point to calculate the dot product with
  2015. * @returns the dot product (float) of the point coordinates and the plane normal.
  2016. */
  2017. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2018. /**
  2019. * Updates the current Plane from the plane defined by the three given points.
  2020. * @param point1 one of the points used to contruct the plane
  2021. * @param point2 one of the points used to contruct the plane
  2022. * @param point3 one of the points used to contruct the plane
  2023. * @returns the updated Plane.
  2024. */
  2025. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2026. /**
  2027. * Checks if the plane is facing a given direction
  2028. * @param direction the direction to check if the plane is facing
  2029. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2030. * @returns True is the vector "direction" is the same side than the plane normal.
  2031. */
  2032. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2033. /**
  2034. * Calculates the distance to a point
  2035. * @param point point to calculate distance to
  2036. * @returns the signed distance (float) from the given point to the Plane.
  2037. */
  2038. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2039. /**
  2040. * Creates a plane from an array
  2041. * @param array the array to create a plane from
  2042. * @returns a new Plane from the given array.
  2043. */
  2044. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2045. /**
  2046. * Creates a plane from three points
  2047. * @param point1 point used to create the plane
  2048. * @param point2 point used to create the plane
  2049. * @param point3 point used to create the plane
  2050. * @returns a new Plane defined by the three given points.
  2051. */
  2052. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2053. /**
  2054. * Creates a plane from an origin point and a normal
  2055. * @param origin origin of the plane to be constructed
  2056. * @param normal normal of the plane to be constructed
  2057. * @returns a new Plane the normal vector to this plane at the given origin point.
  2058. * Note : the vector "normal" is updated because normalized.
  2059. */
  2060. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2061. /**
  2062. * Calculates the distance from a plane and a point
  2063. * @param origin origin of the plane to be constructed
  2064. * @param normal normal of the plane to be constructed
  2065. * @param point point to calculate distance to
  2066. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2067. */
  2068. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2069. }
  2070. }
  2071. declare module "babylonjs/Engines/performanceConfigurator" {
  2072. /** @hidden */
  2073. export class PerformanceConfigurator {
  2074. /** @hidden */
  2075. static MatrixUse64Bits: boolean;
  2076. /** @hidden */
  2077. static MatrixTrackPrecisionChange: boolean;
  2078. /** @hidden */
  2079. static MatrixCurrentType: any;
  2080. /** @hidden */
  2081. static MatrixTrackedMatrices: Array<any> | null;
  2082. /** @hidden */
  2083. static SetMatrixPrecision(use64bits: boolean): void;
  2084. }
  2085. }
  2086. declare module "babylonjs/Maths/math.vector" {
  2087. import { Viewport } from "babylonjs/Maths/math.viewport";
  2088. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2089. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2090. import { Plane } from "babylonjs/Maths/math.plane";
  2091. /**
  2092. * Class representing a vector containing 2 coordinates
  2093. */
  2094. export class Vector2 {
  2095. /** defines the first coordinate */
  2096. x: number;
  2097. /** defines the second coordinate */
  2098. y: number;
  2099. /**
  2100. * Creates a new Vector2 from the given x and y coordinates
  2101. * @param x defines the first coordinate
  2102. * @param y defines the second coordinate
  2103. */
  2104. constructor(
  2105. /** defines the first coordinate */
  2106. x?: number,
  2107. /** defines the second coordinate */
  2108. y?: number);
  2109. /**
  2110. * Gets a string with the Vector2 coordinates
  2111. * @returns a string with the Vector2 coordinates
  2112. */
  2113. toString(): string;
  2114. /**
  2115. * Gets class name
  2116. * @returns the string "Vector2"
  2117. */
  2118. getClassName(): string;
  2119. /**
  2120. * Gets current vector hash code
  2121. * @returns the Vector2 hash code as a number
  2122. */
  2123. getHashCode(): number;
  2124. /**
  2125. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2126. * @param array defines the source array
  2127. * @param index defines the offset in source array
  2128. * @returns the current Vector2
  2129. */
  2130. toArray(array: FloatArray, index?: number): Vector2;
  2131. /**
  2132. * Update the current vector from an array
  2133. * @param array defines the destination array
  2134. * @param index defines the offset in the destination array
  2135. * @returns the current Vector3
  2136. */
  2137. fromArray(array: FloatArray, index?: number): Vector2;
  2138. /**
  2139. * Copy the current vector to an array
  2140. * @returns a new array with 2 elements: the Vector2 coordinates.
  2141. */
  2142. asArray(): number[];
  2143. /**
  2144. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2145. * @param source defines the source Vector2
  2146. * @returns the current updated Vector2
  2147. */
  2148. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2149. /**
  2150. * Sets the Vector2 coordinates with the given floats
  2151. * @param x defines the first coordinate
  2152. * @param y defines the second coordinate
  2153. * @returns the current updated Vector2
  2154. */
  2155. copyFromFloats(x: number, y: number): Vector2;
  2156. /**
  2157. * Sets the Vector2 coordinates with the given floats
  2158. * @param x defines the first coordinate
  2159. * @param y defines the second coordinate
  2160. * @returns the current updated Vector2
  2161. */
  2162. set(x: number, y: number): Vector2;
  2163. /**
  2164. * Add another vector with the current one
  2165. * @param otherVector defines the other vector
  2166. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2167. */
  2168. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2169. /**
  2170. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2171. * @param otherVector defines the other vector
  2172. * @param result defines the target vector
  2173. * @returns the unmodified current Vector2
  2174. */
  2175. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2176. /**
  2177. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2178. * @param otherVector defines the other vector
  2179. * @returns the current updated Vector2
  2180. */
  2181. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2182. /**
  2183. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2184. * @param otherVector defines the other vector
  2185. * @returns a new Vector2
  2186. */
  2187. addVector3(otherVector: Vector3): Vector2;
  2188. /**
  2189. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2190. * @param otherVector defines the other vector
  2191. * @returns a new Vector2
  2192. */
  2193. subtract(otherVector: Vector2): Vector2;
  2194. /**
  2195. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2196. * @param otherVector defines the other vector
  2197. * @param result defines the target vector
  2198. * @returns the unmodified current Vector2
  2199. */
  2200. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2201. /**
  2202. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2203. * @param otherVector defines the other vector
  2204. * @returns the current updated Vector2
  2205. */
  2206. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2207. /**
  2208. * Multiplies in place the current Vector2 coordinates by the given ones
  2209. * @param otherVector defines the other vector
  2210. * @returns the current updated Vector2
  2211. */
  2212. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2213. /**
  2214. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2215. * @param otherVector defines the other vector
  2216. * @returns a new Vector2
  2217. */
  2218. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2221. * @param otherVector defines the other vector
  2222. * @param result defines the target vector
  2223. * @returns the unmodified current Vector2
  2224. */
  2225. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2226. /**
  2227. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2228. * @param x defines the first coordinate
  2229. * @param y defines the second coordinate
  2230. * @returns a new Vector2
  2231. */
  2232. multiplyByFloats(x: number, y: number): Vector2;
  2233. /**
  2234. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2235. * @param otherVector defines the other vector
  2236. * @returns a new Vector2
  2237. */
  2238. divide(otherVector: Vector2): Vector2;
  2239. /**
  2240. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2241. * @param otherVector defines the other vector
  2242. * @param result defines the target vector
  2243. * @returns the unmodified current Vector2
  2244. */
  2245. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2246. /**
  2247. * Divides the current Vector2 coordinates by the given ones
  2248. * @param otherVector defines the other vector
  2249. * @returns the current updated Vector2
  2250. */
  2251. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2252. /**
  2253. * Gets a new Vector2 with current Vector2 negated coordinates
  2254. * @returns a new Vector2
  2255. */
  2256. negate(): Vector2;
  2257. /**
  2258. * Negate this vector in place
  2259. * @returns this
  2260. */
  2261. negateInPlace(): Vector2;
  2262. /**
  2263. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2264. * @param result defines the Vector3 object where to store the result
  2265. * @returns the current Vector2
  2266. */
  2267. negateToRef(result: Vector2): Vector2;
  2268. /**
  2269. * Multiply the Vector2 coordinates by scale
  2270. * @param scale defines the scaling factor
  2271. * @returns the current updated Vector2
  2272. */
  2273. scaleInPlace(scale: number): Vector2;
  2274. /**
  2275. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2276. * @param scale defines the scaling factor
  2277. * @returns a new Vector2
  2278. */
  2279. scale(scale: number): Vector2;
  2280. /**
  2281. * Scale the current Vector2 values by a factor to a given Vector2
  2282. * @param scale defines the scale factor
  2283. * @param result defines the Vector2 object where to store the result
  2284. * @returns the unmodified current Vector2
  2285. */
  2286. scaleToRef(scale: number, result: Vector2): Vector2;
  2287. /**
  2288. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2289. * @param scale defines the scale factor
  2290. * @param result defines the Vector2 object where to store the result
  2291. * @returns the unmodified current Vector2
  2292. */
  2293. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2294. /**
  2295. * Gets a boolean if two vectors are equals
  2296. * @param otherVector defines the other vector
  2297. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2298. */
  2299. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2300. /**
  2301. * Gets a boolean if two vectors are equals (using an epsilon value)
  2302. * @param otherVector defines the other vector
  2303. * @param epsilon defines the minimal distance to consider equality
  2304. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2305. */
  2306. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2307. /**
  2308. * Gets a new Vector2 from current Vector2 floored values
  2309. * @returns a new Vector2
  2310. */
  2311. floor(): Vector2;
  2312. /**
  2313. * Gets a new Vector2 from current Vector2 floored values
  2314. * @returns a new Vector2
  2315. */
  2316. fract(): Vector2;
  2317. /**
  2318. * Gets the length of the vector
  2319. * @returns the vector length (float)
  2320. */
  2321. length(): number;
  2322. /**
  2323. * Gets the vector squared length
  2324. * @returns the vector squared length (float)
  2325. */
  2326. lengthSquared(): number;
  2327. /**
  2328. * Normalize the vector
  2329. * @returns the current updated Vector2
  2330. */
  2331. normalize(): Vector2;
  2332. /**
  2333. * Gets a new Vector2 copied from the Vector2
  2334. * @returns a new Vector2
  2335. */
  2336. clone(): Vector2;
  2337. /**
  2338. * Gets a new Vector2(0, 0)
  2339. * @returns a new Vector2
  2340. */
  2341. static Zero(): Vector2;
  2342. /**
  2343. * Gets a new Vector2(1, 1)
  2344. * @returns a new Vector2
  2345. */
  2346. static One(): Vector2;
  2347. /**
  2348. * Gets a new Vector2 set from the given index element of the given array
  2349. * @param array defines the data source
  2350. * @param offset defines the offset in the data source
  2351. * @returns a new Vector2
  2352. */
  2353. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2354. /**
  2355. * Sets "result" from the given index element of the given array
  2356. * @param array defines the data source
  2357. * @param offset defines the offset in the data source
  2358. * @param result defines the target vector
  2359. */
  2360. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2361. /**
  2362. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2363. * @param value1 defines 1st point of control
  2364. * @param value2 defines 2nd point of control
  2365. * @param value3 defines 3rd point of control
  2366. * @param value4 defines 4th point of control
  2367. * @param amount defines the interpolation factor
  2368. * @returns a new Vector2
  2369. */
  2370. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2371. /**
  2372. * 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".
  2373. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2374. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2375. * @param value defines the value to clamp
  2376. * @param min defines the lower limit
  2377. * @param max defines the upper limit
  2378. * @returns a new Vector2
  2379. */
  2380. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2381. /**
  2382. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2383. * @param value1 defines the 1st control point
  2384. * @param tangent1 defines the outgoing tangent
  2385. * @param value2 defines the 2nd control point
  2386. * @param tangent2 defines the incoming tangent
  2387. * @param amount defines the interpolation factor
  2388. * @returns a new Vector2
  2389. */
  2390. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2391. /**
  2392. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2393. * @param start defines the start vector
  2394. * @param end defines the end vector
  2395. * @param amount defines the interpolation factor
  2396. * @returns a new Vector2
  2397. */
  2398. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2399. /**
  2400. * Gets the dot product of the vector "left" and the vector "right"
  2401. * @param left defines first vector
  2402. * @param right defines second vector
  2403. * @returns the dot product (float)
  2404. */
  2405. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2406. /**
  2407. * Returns a new Vector2 equal to the normalized given vector
  2408. * @param vector defines the vector to normalize
  2409. * @returns a new Vector2
  2410. */
  2411. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2412. /**
  2413. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2414. * @param left defines 1st vector
  2415. * @param right defines 2nd vector
  2416. * @returns a new Vector2
  2417. */
  2418. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2419. /**
  2420. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2421. * @param left defines 1st vector
  2422. * @param right defines 2nd vector
  2423. * @returns a new Vector2
  2424. */
  2425. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2426. /**
  2427. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2428. * @param vector defines the vector to transform
  2429. * @param transformation defines the matrix to apply
  2430. * @returns a new Vector2
  2431. */
  2432. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2433. /**
  2434. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2435. * @param vector defines the vector to transform
  2436. * @param transformation defines the matrix to apply
  2437. * @param result defines the target vector
  2438. */
  2439. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2440. /**
  2441. * Determines if a given vector is included in a triangle
  2442. * @param p defines the vector to test
  2443. * @param p0 defines 1st triangle point
  2444. * @param p1 defines 2nd triangle point
  2445. * @param p2 defines 3rd triangle point
  2446. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2447. */
  2448. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2449. /**
  2450. * Gets the distance between the vectors "value1" and "value2"
  2451. * @param value1 defines first vector
  2452. * @param value2 defines second vector
  2453. * @returns the distance between vectors
  2454. */
  2455. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2456. /**
  2457. * Returns the squared distance between the vectors "value1" and "value2"
  2458. * @param value1 defines first vector
  2459. * @param value2 defines second vector
  2460. * @returns the squared distance between vectors
  2461. */
  2462. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2463. /**
  2464. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2465. * @param value1 defines first vector
  2466. * @param value2 defines second vector
  2467. * @returns a new Vector2
  2468. */
  2469. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2470. /**
  2471. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2472. * @param p defines the middle point
  2473. * @param segA defines one point of the segment
  2474. * @param segB defines the other point of the segment
  2475. * @returns the shortest distance
  2476. */
  2477. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2478. }
  2479. /**
  2480. * Class used to store (x,y,z) vector representation
  2481. * A Vector3 is the main object used in 3D geometry
  2482. * It can represent etiher the coordinates of a point the space, either a direction
  2483. * Reminder: js uses a left handed forward facing system
  2484. */
  2485. export class Vector3 {
  2486. private static _UpReadOnly;
  2487. private static _ZeroReadOnly;
  2488. /** @hidden */
  2489. _x: number;
  2490. /** @hidden */
  2491. _y: number;
  2492. /** @hidden */
  2493. _z: number;
  2494. /** @hidden */
  2495. _isDirty: boolean;
  2496. /** Gets or sets the x coordinate */
  2497. get x(): number;
  2498. set x(value: number);
  2499. /** Gets or sets the y coordinate */
  2500. get y(): number;
  2501. set y(value: number);
  2502. /** Gets or sets the z coordinate */
  2503. get z(): number;
  2504. set z(value: number);
  2505. /**
  2506. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2507. * @param x defines the first coordinates (on X axis)
  2508. * @param y defines the second coordinates (on Y axis)
  2509. * @param z defines the third coordinates (on Z axis)
  2510. */
  2511. constructor(x?: number, y?: number, z?: number);
  2512. /**
  2513. * Creates a string representation of the Vector3
  2514. * @returns a string with the Vector3 coordinates.
  2515. */
  2516. toString(): string;
  2517. /**
  2518. * Gets the class name
  2519. * @returns the string "Vector3"
  2520. */
  2521. getClassName(): string;
  2522. /**
  2523. * Creates the Vector3 hash code
  2524. * @returns a number which tends to be unique between Vector3 instances
  2525. */
  2526. getHashCode(): number;
  2527. /**
  2528. * Creates an array containing three elements : the coordinates of the Vector3
  2529. * @returns a new array of numbers
  2530. */
  2531. asArray(): number[];
  2532. /**
  2533. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2534. * @param array defines the destination array
  2535. * @param index defines the offset in the destination array
  2536. * @returns the current Vector3
  2537. */
  2538. toArray(array: FloatArray, index?: number): Vector3;
  2539. /**
  2540. * Update the current vector from an array
  2541. * @param array defines the destination array
  2542. * @param index defines the offset in the destination array
  2543. * @returns the current Vector3
  2544. */
  2545. fromArray(array: FloatArray, index?: number): Vector3;
  2546. /**
  2547. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2548. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2549. */
  2550. toQuaternion(): Quaternion;
  2551. /**
  2552. * Adds the given vector to the current Vector3
  2553. * @param otherVector defines the second operand
  2554. * @returns the current updated Vector3
  2555. */
  2556. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2557. /**
  2558. * Adds the given coordinates to the current Vector3
  2559. * @param x defines the x coordinate of the operand
  2560. * @param y defines the y coordinate of the operand
  2561. * @param z defines the z coordinate of the operand
  2562. * @returns the current updated Vector3
  2563. */
  2564. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2565. /**
  2566. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2567. * @param otherVector defines the second operand
  2568. * @returns the resulting Vector3
  2569. */
  2570. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2571. /**
  2572. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2573. * @param otherVector defines the second operand
  2574. * @param result defines the Vector3 object where to store the result
  2575. * @returns the current Vector3
  2576. */
  2577. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2578. /**
  2579. * Subtract the given vector from the current Vector3
  2580. * @param otherVector defines the second operand
  2581. * @returns the current updated Vector3
  2582. */
  2583. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2584. /**
  2585. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2586. * @param otherVector defines the second operand
  2587. * @returns the resulting Vector3
  2588. */
  2589. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2590. /**
  2591. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2592. * @param otherVector defines the second operand
  2593. * @param result defines the Vector3 object where to store the result
  2594. * @returns the current Vector3
  2595. */
  2596. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2597. /**
  2598. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2599. * @param x defines the x coordinate of the operand
  2600. * @param y defines the y coordinate of the operand
  2601. * @param z defines the z coordinate of the operand
  2602. * @returns the resulting Vector3
  2603. */
  2604. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2605. /**
  2606. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2607. * @param x defines the x coordinate of the operand
  2608. * @param y defines the y coordinate of the operand
  2609. * @param z defines the z coordinate of the operand
  2610. * @param result defines the Vector3 object where to store the result
  2611. * @returns the current Vector3
  2612. */
  2613. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2614. /**
  2615. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2616. * @returns a new Vector3
  2617. */
  2618. negate(): Vector3;
  2619. /**
  2620. * Negate this vector in place
  2621. * @returns this
  2622. */
  2623. negateInPlace(): Vector3;
  2624. /**
  2625. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2626. * @param result defines the Vector3 object where to store the result
  2627. * @returns the current Vector3
  2628. */
  2629. negateToRef(result: Vector3): Vector3;
  2630. /**
  2631. * Multiplies the Vector3 coordinates by the float "scale"
  2632. * @param scale defines the multiplier factor
  2633. * @returns the current updated Vector3
  2634. */
  2635. scaleInPlace(scale: number): Vector3;
  2636. /**
  2637. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2638. * @param scale defines the multiplier factor
  2639. * @returns a new Vector3
  2640. */
  2641. scale(scale: number): Vector3;
  2642. /**
  2643. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2644. * @param scale defines the multiplier factor
  2645. * @param result defines the Vector3 object where to store the result
  2646. * @returns the current Vector3
  2647. */
  2648. scaleToRef(scale: number, result: Vector3): Vector3;
  2649. /**
  2650. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2651. * @param scale defines the scale factor
  2652. * @param result defines the Vector3 object where to store the result
  2653. * @returns the unmodified current Vector3
  2654. */
  2655. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2656. /**
  2657. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2658. * @param origin defines the origin of the projection ray
  2659. * @param plane defines the plane to project to
  2660. * @returns the projected vector3
  2661. */
  2662. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2663. /**
  2664. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2665. * @param origin defines the origin of the projection ray
  2666. * @param plane defines the plane to project to
  2667. * @param result defines the Vector3 where to store the result
  2668. */
  2669. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2670. /**
  2671. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2672. * @param otherVector defines the second operand
  2673. * @returns true if both vectors are equals
  2674. */
  2675. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2676. /**
  2677. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2678. * @param otherVector defines the second operand
  2679. * @param epsilon defines the minimal distance to define values as equals
  2680. * @returns true if both vectors are distant less than epsilon
  2681. */
  2682. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2683. /**
  2684. * Returns true if the current Vector3 coordinates equals the given floats
  2685. * @param x defines the x coordinate of the operand
  2686. * @param y defines the y coordinate of the operand
  2687. * @param z defines the z coordinate of the operand
  2688. * @returns true if both vectors are equals
  2689. */
  2690. equalsToFloats(x: number, y: number, z: number): boolean;
  2691. /**
  2692. * Multiplies the current Vector3 coordinates by the given ones
  2693. * @param otherVector defines the second operand
  2694. * @returns the current updated Vector3
  2695. */
  2696. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2697. /**
  2698. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2699. * @param otherVector defines the second operand
  2700. * @returns the new Vector3
  2701. */
  2702. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2703. /**
  2704. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2705. * @param otherVector defines the second operand
  2706. * @param result defines the Vector3 object where to store the result
  2707. * @returns the current Vector3
  2708. */
  2709. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2710. /**
  2711. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2712. * @param x defines the x coordinate of the operand
  2713. * @param y defines the y coordinate of the operand
  2714. * @param z defines the z coordinate of the operand
  2715. * @returns the new Vector3
  2716. */
  2717. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2718. /**
  2719. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2720. * @param otherVector defines the second operand
  2721. * @returns the new Vector3
  2722. */
  2723. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2724. /**
  2725. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2726. * @param otherVector defines the second operand
  2727. * @param result defines the Vector3 object where to store the result
  2728. * @returns the current Vector3
  2729. */
  2730. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2731. /**
  2732. * Divides the current Vector3 coordinates by the given ones.
  2733. * @param otherVector defines the second operand
  2734. * @returns the current updated Vector3
  2735. */
  2736. divideInPlace(otherVector: Vector3): Vector3;
  2737. /**
  2738. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2739. * @param other defines the second operand
  2740. * @returns the current updated Vector3
  2741. */
  2742. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2743. /**
  2744. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2745. * @param other defines the second operand
  2746. * @returns the current updated Vector3
  2747. */
  2748. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2749. /**
  2750. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2751. * @param x defines the x coordinate of the operand
  2752. * @param y defines the y coordinate of the operand
  2753. * @param z defines the z coordinate of the operand
  2754. * @returns the current updated Vector3
  2755. */
  2756. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2757. /**
  2758. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2759. * @param x defines the x coordinate of the operand
  2760. * @param y defines the y coordinate of the operand
  2761. * @param z defines the z coordinate of the operand
  2762. * @returns the current updated Vector3
  2763. */
  2764. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2765. /**
  2766. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2767. * Check if is non uniform within a certain amount of decimal places to account for this
  2768. * @param epsilon the amount the values can differ
  2769. * @returns if the the vector is non uniform to a certain number of decimal places
  2770. */
  2771. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2772. /**
  2773. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2774. */
  2775. get isNonUniform(): boolean;
  2776. /**
  2777. * Gets a new Vector3 from current Vector3 floored values
  2778. * @returns a new Vector3
  2779. */
  2780. floor(): Vector3;
  2781. /**
  2782. * Gets a new Vector3 from current Vector3 floored values
  2783. * @returns a new Vector3
  2784. */
  2785. fract(): Vector3;
  2786. /**
  2787. * Gets the length of the Vector3
  2788. * @returns the length of the Vector3
  2789. */
  2790. length(): number;
  2791. /**
  2792. * Gets the squared length of the Vector3
  2793. * @returns squared length of the Vector3
  2794. */
  2795. lengthSquared(): number;
  2796. /**
  2797. * Normalize the current Vector3.
  2798. * Please note that this is an in place operation.
  2799. * @returns the current updated Vector3
  2800. */
  2801. normalize(): Vector3;
  2802. /**
  2803. * Reorders the x y z properties of the vector in place
  2804. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2805. * @returns the current updated vector
  2806. */
  2807. reorderInPlace(order: string): this;
  2808. /**
  2809. * Rotates the vector around 0,0,0 by a quaternion
  2810. * @param quaternion the rotation quaternion
  2811. * @param result vector to store the result
  2812. * @returns the resulting vector
  2813. */
  2814. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2815. /**
  2816. * Rotates a vector around a given point
  2817. * @param quaternion the rotation quaternion
  2818. * @param point the point to rotate around
  2819. * @param result vector to store the result
  2820. * @returns the resulting vector
  2821. */
  2822. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2823. /**
  2824. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2825. * The cross product is then orthogonal to both current and "other"
  2826. * @param other defines the right operand
  2827. * @returns the cross product
  2828. */
  2829. cross(other: Vector3): Vector3;
  2830. /**
  2831. * Normalize the current Vector3 with the given input length.
  2832. * Please note that this is an in place operation.
  2833. * @param len the length of the vector
  2834. * @returns the current updated Vector3
  2835. */
  2836. normalizeFromLength(len: number): Vector3;
  2837. /**
  2838. * Normalize the current Vector3 to a new vector
  2839. * @returns the new Vector3
  2840. */
  2841. normalizeToNew(): Vector3;
  2842. /**
  2843. * Normalize the current Vector3 to the reference
  2844. * @param reference define the Vector3 to update
  2845. * @returns the updated Vector3
  2846. */
  2847. normalizeToRef(reference: Vector3): Vector3;
  2848. /**
  2849. * Creates a new Vector3 copied from the current Vector3
  2850. * @returns the new Vector3
  2851. */
  2852. clone(): Vector3;
  2853. /**
  2854. * Copies the given vector coordinates to the current Vector3 ones
  2855. * @param source defines the source Vector3
  2856. * @returns the current updated Vector3
  2857. */
  2858. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2859. /**
  2860. * Copies the given floats to the current Vector3 coordinates
  2861. * @param x defines the x coordinate of the operand
  2862. * @param y defines the y coordinate of the operand
  2863. * @param z defines the z coordinate of the operand
  2864. * @returns the current updated Vector3
  2865. */
  2866. copyFromFloats(x: number, y: number, z: number): Vector3;
  2867. /**
  2868. * Copies the given floats to the current Vector3 coordinates
  2869. * @param x defines the x coordinate of the operand
  2870. * @param y defines the y coordinate of the operand
  2871. * @param z defines the z coordinate of the operand
  2872. * @returns the current updated Vector3
  2873. */
  2874. set(x: number, y: number, z: number): Vector3;
  2875. /**
  2876. * Copies the given float to the current Vector3 coordinates
  2877. * @param v defines the x, y and z coordinates of the operand
  2878. * @returns the current updated Vector3
  2879. */
  2880. setAll(v: number): Vector3;
  2881. /**
  2882. * Get the clip factor between two vectors
  2883. * @param vector0 defines the first operand
  2884. * @param vector1 defines the second operand
  2885. * @param axis defines the axis to use
  2886. * @param size defines the size along the axis
  2887. * @returns the clip factor
  2888. */
  2889. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2890. /**
  2891. * Get angle between two vectors
  2892. * @param vector0 angle between vector0 and vector1
  2893. * @param vector1 angle between vector0 and vector1
  2894. * @param normal direction of the normal
  2895. * @return the angle between vector0 and vector1
  2896. */
  2897. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2898. /**
  2899. * Returns a new Vector3 set from the index "offset" of the given array
  2900. * @param array defines the source array
  2901. * @param offset defines the offset in the source array
  2902. * @returns the new Vector3
  2903. */
  2904. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2905. /**
  2906. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2907. * @param array defines the source array
  2908. * @param offset defines the offset in the source array
  2909. * @returns the new Vector3
  2910. * @deprecated Please use FromArray instead.
  2911. */
  2912. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2913. /**
  2914. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2915. * @param array defines the source array
  2916. * @param offset defines the offset in the source array
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2920. /**
  2921. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2922. * @param array defines the source array
  2923. * @param offset defines the offset in the source array
  2924. * @param result defines the Vector3 where to store the result
  2925. * @deprecated Please use FromArrayToRef instead.
  2926. */
  2927. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2928. /**
  2929. * Sets the given vector "result" with the given floats.
  2930. * @param x defines the x coordinate of the source
  2931. * @param y defines the y coordinate of the source
  2932. * @param z defines the z coordinate of the source
  2933. * @param result defines the Vector3 where to store the result
  2934. */
  2935. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2936. /**
  2937. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2938. * @returns a new empty Vector3
  2939. */
  2940. static Zero(): Vector3;
  2941. /**
  2942. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2943. * @returns a new unit Vector3
  2944. */
  2945. static One(): Vector3;
  2946. /**
  2947. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2948. * @returns a new up Vector3
  2949. */
  2950. static Up(): Vector3;
  2951. /**
  2952. * Gets a up Vector3 that must not be updated
  2953. */
  2954. static get UpReadOnly(): DeepImmutable<Vector3>;
  2955. /**
  2956. * Gets a zero Vector3 that must not be updated
  2957. */
  2958. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2959. /**
  2960. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2961. * @returns a new down Vector3
  2962. */
  2963. static Down(): Vector3;
  2964. /**
  2965. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2966. * @param rightHandedSystem is the scene right-handed (negative z)
  2967. * @returns a new forward Vector3
  2968. */
  2969. static Forward(rightHandedSystem?: boolean): Vector3;
  2970. /**
  2971. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2972. * @param rightHandedSystem is the scene right-handed (negative-z)
  2973. * @returns a new forward Vector3
  2974. */
  2975. static Backward(rightHandedSystem?: boolean): Vector3;
  2976. /**
  2977. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2978. * @returns a new right Vector3
  2979. */
  2980. static Right(): Vector3;
  2981. /**
  2982. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2983. * @returns a new left Vector3
  2984. */
  2985. static Left(): Vector3;
  2986. /**
  2987. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2988. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2989. * @param vector defines the Vector3 to transform
  2990. * @param transformation defines the transformation matrix
  2991. * @returns the transformed Vector3
  2992. */
  2993. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2994. /**
  2995. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2996. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2997. * @param vector defines the Vector3 to transform
  2998. * @param transformation defines the transformation matrix
  2999. * @param result defines the Vector3 where to store the result
  3000. */
  3001. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3002. /**
  3003. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3004. * This method computes tranformed coordinates only, not transformed direction vectors
  3005. * @param x define the x coordinate of the source vector
  3006. * @param y define the y coordinate of the source vector
  3007. * @param z define the z coordinate of the source vector
  3008. * @param transformation defines the transformation matrix
  3009. * @param result defines the Vector3 where to store the result
  3010. */
  3011. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3012. /**
  3013. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3014. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3015. * @param vector defines the Vector3 to transform
  3016. * @param transformation defines the transformation matrix
  3017. * @returns the new Vector3
  3018. */
  3019. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3020. /**
  3021. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3022. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3023. * @param vector defines the Vector3 to transform
  3024. * @param transformation defines the transformation matrix
  3025. * @param result defines the Vector3 where to store the result
  3026. */
  3027. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3028. /**
  3029. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3030. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3031. * @param x define the x coordinate of the source vector
  3032. * @param y define the y coordinate of the source vector
  3033. * @param z define the z coordinate of the source vector
  3034. * @param transformation defines the transformation matrix
  3035. * @param result defines the Vector3 where to store the result
  3036. */
  3037. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3038. /**
  3039. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3040. * @param value1 defines the first control point
  3041. * @param value2 defines the second control point
  3042. * @param value3 defines the third control point
  3043. * @param value4 defines the fourth control point
  3044. * @param amount defines the amount on the spline to use
  3045. * @returns the new Vector3
  3046. */
  3047. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3048. /**
  3049. * 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"
  3050. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3051. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3052. * @param value defines the current value
  3053. * @param min defines the lower range value
  3054. * @param max defines the upper range value
  3055. * @returns the new Vector3
  3056. */
  3057. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3058. /**
  3059. * 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"
  3060. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3061. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3062. * @param value defines the current value
  3063. * @param min defines the lower range value
  3064. * @param max defines the upper range value
  3065. * @param result defines the Vector3 where to store the result
  3066. */
  3067. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3068. /**
  3069. * Checks if a given vector is inside a specific range
  3070. * @param v defines the vector to test
  3071. * @param min defines the minimum range
  3072. * @param max defines the maximum range
  3073. */
  3074. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3075. /**
  3076. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3077. * @param value1 defines the first control point
  3078. * @param tangent1 defines the first tangent vector
  3079. * @param value2 defines the second control point
  3080. * @param tangent2 defines the second tangent vector
  3081. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3082. * @returns the new Vector3
  3083. */
  3084. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3085. /**
  3086. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3087. * @param start defines the start value
  3088. * @param end defines the end value
  3089. * @param amount max defines amount between both (between 0 and 1)
  3090. * @returns the new Vector3
  3091. */
  3092. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3093. /**
  3094. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3095. * @param start defines the start value
  3096. * @param end defines the end value
  3097. * @param amount max defines amount between both (between 0 and 1)
  3098. * @param result defines the Vector3 where to store the result
  3099. */
  3100. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3101. /**
  3102. * Returns the dot product (float) between the vectors "left" and "right"
  3103. * @param left defines the left operand
  3104. * @param right defines the right operand
  3105. * @returns the dot product
  3106. */
  3107. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3108. /**
  3109. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3110. * The cross product is then orthogonal to both "left" and "right"
  3111. * @param left defines the left operand
  3112. * @param right defines the right operand
  3113. * @returns the cross product
  3114. */
  3115. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3116. /**
  3117. * Sets the given vector "result" with the cross product of "left" and "right"
  3118. * The cross product is then orthogonal to both "left" and "right"
  3119. * @param left defines the left operand
  3120. * @param right defines the right operand
  3121. * @param result defines the Vector3 where to store the result
  3122. */
  3123. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3124. /**
  3125. * Returns a new Vector3 as the normalization of the given vector
  3126. * @param vector defines the Vector3 to normalize
  3127. * @returns the new Vector3
  3128. */
  3129. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3130. /**
  3131. * Sets the given vector "result" with the normalization of the given first vector
  3132. * @param vector defines the Vector3 to normalize
  3133. * @param result defines the Vector3 where to store the result
  3134. */
  3135. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3136. /**
  3137. * Project a Vector3 onto screen space
  3138. * @param vector defines the Vector3 to project
  3139. * @param world defines the world matrix to use
  3140. * @param transform defines the transform (view x projection) matrix to use
  3141. * @param viewport defines the screen viewport to use
  3142. * @returns the new Vector3
  3143. */
  3144. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3145. /** @hidden */
  3146. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3147. /**
  3148. * Unproject from screen space to object space
  3149. * @param source defines the screen space Vector3 to use
  3150. * @param viewportWidth defines the current width of the viewport
  3151. * @param viewportHeight defines the current height of the viewport
  3152. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3153. * @param transform defines the transform (view x projection) matrix to use
  3154. * @returns the new Vector3
  3155. */
  3156. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3157. /**
  3158. * Unproject from screen space to object space
  3159. * @param source defines the screen space Vector3 to use
  3160. * @param viewportWidth defines the current width of the viewport
  3161. * @param viewportHeight defines the current height of the viewport
  3162. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3163. * @param view defines the view matrix to use
  3164. * @param projection defines the projection matrix to use
  3165. * @returns the new Vector3
  3166. */
  3167. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3168. /**
  3169. * Unproject from screen space to object space
  3170. * @param source defines the screen space Vector3 to use
  3171. * @param viewportWidth defines the current width of the viewport
  3172. * @param viewportHeight defines the current height of the viewport
  3173. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3174. * @param view defines the view matrix to use
  3175. * @param projection defines the projection matrix to use
  3176. * @param result defines the Vector3 where to store the result
  3177. */
  3178. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3179. /**
  3180. * Unproject from screen space to object space
  3181. * @param sourceX defines the screen space x coordinate to use
  3182. * @param sourceY defines the screen space y coordinate to use
  3183. * @param sourceZ defines the screen space z coordinate to use
  3184. * @param viewportWidth defines the current width of the viewport
  3185. * @param viewportHeight defines the current height of the viewport
  3186. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3187. * @param view defines the view matrix to use
  3188. * @param projection defines the projection matrix to use
  3189. * @param result defines the Vector3 where to store the result
  3190. */
  3191. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3192. /**
  3193. * Gets the minimal coordinate values between two Vector3
  3194. * @param left defines the first operand
  3195. * @param right defines the second operand
  3196. * @returns the new Vector3
  3197. */
  3198. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3199. /**
  3200. * Gets the maximal coordinate values between two Vector3
  3201. * @param left defines the first operand
  3202. * @param right defines the second operand
  3203. * @returns the new Vector3
  3204. */
  3205. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3206. /**
  3207. * Returns the distance between the vectors "value1" and "value2"
  3208. * @param value1 defines the first operand
  3209. * @param value2 defines the second operand
  3210. * @returns the distance
  3211. */
  3212. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3213. /**
  3214. * Returns the squared distance between the vectors "value1" and "value2"
  3215. * @param value1 defines the first operand
  3216. * @param value2 defines the second operand
  3217. * @returns the squared distance
  3218. */
  3219. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3220. /**
  3221. * Returns a new Vector3 located at the center between "value1" and "value2"
  3222. * @param value1 defines the first operand
  3223. * @param value2 defines the second operand
  3224. * @returns the new Vector3
  3225. */
  3226. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3227. /**
  3228. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3229. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3230. * to something in order to rotate it from its local system to the given target system
  3231. * Note: axis1, axis2 and axis3 are normalized during this operation
  3232. * @param axis1 defines the first axis
  3233. * @param axis2 defines the second axis
  3234. * @param axis3 defines the third axis
  3235. * @returns a new Vector3
  3236. */
  3237. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3238. /**
  3239. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3240. * @param axis1 defines the first axis
  3241. * @param axis2 defines the second axis
  3242. * @param axis3 defines the third axis
  3243. * @param ref defines the Vector3 where to store the result
  3244. */
  3245. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3246. }
  3247. /**
  3248. * Vector4 class created for EulerAngle class conversion to Quaternion
  3249. */
  3250. export class Vector4 {
  3251. /** x value of the vector */
  3252. x: number;
  3253. /** y value of the vector */
  3254. y: number;
  3255. /** z value of the vector */
  3256. z: number;
  3257. /** w value of the vector */
  3258. w: number;
  3259. /**
  3260. * Creates a Vector4 object from the given floats.
  3261. * @param x x value of the vector
  3262. * @param y y value of the vector
  3263. * @param z z value of the vector
  3264. * @param w w value of the vector
  3265. */
  3266. constructor(
  3267. /** x value of the vector */
  3268. x: number,
  3269. /** y value of the vector */
  3270. y: number,
  3271. /** z value of the vector */
  3272. z: number,
  3273. /** w value of the vector */
  3274. w: number);
  3275. /**
  3276. * Returns the string with the Vector4 coordinates.
  3277. * @returns a string containing all the vector values
  3278. */
  3279. toString(): string;
  3280. /**
  3281. * Returns the string "Vector4".
  3282. * @returns "Vector4"
  3283. */
  3284. getClassName(): string;
  3285. /**
  3286. * Returns the Vector4 hash code.
  3287. * @returns a unique hash code
  3288. */
  3289. getHashCode(): number;
  3290. /**
  3291. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3292. * @returns the resulting array
  3293. */
  3294. asArray(): number[];
  3295. /**
  3296. * Populates the given array from the given index with the Vector4 coordinates.
  3297. * @param array array to populate
  3298. * @param index index of the array to start at (default: 0)
  3299. * @returns the Vector4.
  3300. */
  3301. toArray(array: FloatArray, index?: number): Vector4;
  3302. /**
  3303. * Update the current vector from an array
  3304. * @param array defines the destination array
  3305. * @param index defines the offset in the destination array
  3306. * @returns the current Vector3
  3307. */
  3308. fromArray(array: FloatArray, index?: number): Vector4;
  3309. /**
  3310. * Adds the given vector to the current Vector4.
  3311. * @param otherVector the vector to add
  3312. * @returns the updated Vector4.
  3313. */
  3314. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3315. /**
  3316. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3317. * @param otherVector the vector to add
  3318. * @returns the resulting vector
  3319. */
  3320. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3321. /**
  3322. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3323. * @param otherVector the vector to add
  3324. * @param result the vector to store the result
  3325. * @returns the current Vector4.
  3326. */
  3327. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3328. /**
  3329. * Subtract in place the given vector from the current Vector4.
  3330. * @param otherVector the vector to subtract
  3331. * @returns the updated Vector4.
  3332. */
  3333. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3334. /**
  3335. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3336. * @param otherVector the vector to add
  3337. * @returns the new vector with the result
  3338. */
  3339. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3340. /**
  3341. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3342. * @param otherVector the vector to subtract
  3343. * @param result the vector to store the result
  3344. * @returns the current Vector4.
  3345. */
  3346. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3347. /**
  3348. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3349. */
  3350. /**
  3351. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3352. * @param x value to subtract
  3353. * @param y value to subtract
  3354. * @param z value to subtract
  3355. * @param w value to subtract
  3356. * @returns new vector containing the result
  3357. */
  3358. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3359. /**
  3360. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3361. * @param x value to subtract
  3362. * @param y value to subtract
  3363. * @param z value to subtract
  3364. * @param w value to subtract
  3365. * @param result the vector to store the result in
  3366. * @returns the current Vector4.
  3367. */
  3368. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3369. /**
  3370. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3371. * @returns a new vector with the negated values
  3372. */
  3373. negate(): Vector4;
  3374. /**
  3375. * Negate this vector in place
  3376. * @returns this
  3377. */
  3378. negateInPlace(): Vector4;
  3379. /**
  3380. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3381. * @param result defines the Vector3 object where to store the result
  3382. * @returns the current Vector4
  3383. */
  3384. negateToRef(result: Vector4): Vector4;
  3385. /**
  3386. * Multiplies the current Vector4 coordinates by scale (float).
  3387. * @param scale the number to scale with
  3388. * @returns the updated Vector4.
  3389. */
  3390. scaleInPlace(scale: number): Vector4;
  3391. /**
  3392. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3393. * @param scale the number to scale with
  3394. * @returns a new vector with the result
  3395. */
  3396. scale(scale: number): Vector4;
  3397. /**
  3398. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3399. * @param scale the number to scale with
  3400. * @param result a vector to store the result in
  3401. * @returns the current Vector4.
  3402. */
  3403. scaleToRef(scale: number, result: Vector4): Vector4;
  3404. /**
  3405. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3406. * @param scale defines the scale factor
  3407. * @param result defines the Vector4 object where to store the result
  3408. * @returns the unmodified current Vector4
  3409. */
  3410. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3411. /**
  3412. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3413. * @param otherVector the vector to compare against
  3414. * @returns true if they are equal
  3415. */
  3416. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3417. /**
  3418. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3419. * @param otherVector vector to compare against
  3420. * @param epsilon (Default: very small number)
  3421. * @returns true if they are equal
  3422. */
  3423. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3424. /**
  3425. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3426. * @param x x value to compare against
  3427. * @param y y value to compare against
  3428. * @param z z value to compare against
  3429. * @param w w value to compare against
  3430. * @returns true if equal
  3431. */
  3432. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3433. /**
  3434. * Multiplies in place the current Vector4 by the given one.
  3435. * @param otherVector vector to multiple with
  3436. * @returns the updated Vector4.
  3437. */
  3438. multiplyInPlace(otherVector: Vector4): Vector4;
  3439. /**
  3440. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3441. * @param otherVector vector to multiple with
  3442. * @returns resulting new vector
  3443. */
  3444. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3445. /**
  3446. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3447. * @param otherVector vector to multiple with
  3448. * @param result vector to store the result
  3449. * @returns the current Vector4.
  3450. */
  3451. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3452. /**
  3453. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3454. * @param x x value multiply with
  3455. * @param y y value multiply with
  3456. * @param z z value multiply with
  3457. * @param w w value multiply with
  3458. * @returns resulting new vector
  3459. */
  3460. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3461. /**
  3462. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3463. * @param otherVector vector to devide with
  3464. * @returns resulting new vector
  3465. */
  3466. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3467. /**
  3468. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3469. * @param otherVector vector to devide with
  3470. * @param result vector to store the result
  3471. * @returns the current Vector4.
  3472. */
  3473. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3474. /**
  3475. * Divides the current Vector3 coordinates by the given ones.
  3476. * @param otherVector vector to devide with
  3477. * @returns the updated Vector3.
  3478. */
  3479. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3480. /**
  3481. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3482. * @param other defines the second operand
  3483. * @returns the current updated Vector4
  3484. */
  3485. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3486. /**
  3487. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3488. * @param other defines the second operand
  3489. * @returns the current updated Vector4
  3490. */
  3491. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3492. /**
  3493. * Gets a new Vector4 from current Vector4 floored values
  3494. * @returns a new Vector4
  3495. */
  3496. floor(): Vector4;
  3497. /**
  3498. * Gets a new Vector4 from current Vector3 floored values
  3499. * @returns a new Vector4
  3500. */
  3501. fract(): Vector4;
  3502. /**
  3503. * Returns the Vector4 length (float).
  3504. * @returns the length
  3505. */
  3506. length(): number;
  3507. /**
  3508. * Returns the Vector4 squared length (float).
  3509. * @returns the length squared
  3510. */
  3511. lengthSquared(): number;
  3512. /**
  3513. * Normalizes in place the Vector4.
  3514. * @returns the updated Vector4.
  3515. */
  3516. normalize(): Vector4;
  3517. /**
  3518. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3519. * @returns this converted to a new vector3
  3520. */
  3521. toVector3(): Vector3;
  3522. /**
  3523. * Returns a new Vector4 copied from the current one.
  3524. * @returns the new cloned vector
  3525. */
  3526. clone(): Vector4;
  3527. /**
  3528. * Updates the current Vector4 with the given one coordinates.
  3529. * @param source the source vector to copy from
  3530. * @returns the updated Vector4.
  3531. */
  3532. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3533. /**
  3534. * Updates the current Vector4 coordinates with the given floats.
  3535. * @param x float to copy from
  3536. * @param y float to copy from
  3537. * @param z float to copy from
  3538. * @param w float to copy from
  3539. * @returns the updated Vector4.
  3540. */
  3541. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3542. /**
  3543. * Updates the current Vector4 coordinates with the given floats.
  3544. * @param x float to set from
  3545. * @param y float to set from
  3546. * @param z float to set from
  3547. * @param w float to set from
  3548. * @returns the updated Vector4.
  3549. */
  3550. set(x: number, y: number, z: number, w: number): Vector4;
  3551. /**
  3552. * Copies the given float to the current Vector3 coordinates
  3553. * @param v defines the x, y, z and w coordinates of the operand
  3554. * @returns the current updated Vector3
  3555. */
  3556. setAll(v: number): Vector4;
  3557. /**
  3558. * Returns a new Vector4 set from the starting index of the given array.
  3559. * @param array the array to pull values from
  3560. * @param offset the offset into the array to start at
  3561. * @returns the new vector
  3562. */
  3563. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3564. /**
  3565. * Updates the given vector "result" from the starting index of the given array.
  3566. * @param array the array to pull values from
  3567. * @param offset the offset into the array to start at
  3568. * @param result the vector to store the result in
  3569. */
  3570. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3571. /**
  3572. * Updates the given vector "result" from the starting index of the given Float32Array.
  3573. * @param array the array to pull values from
  3574. * @param offset the offset into the array to start at
  3575. * @param result the vector to store the result in
  3576. */
  3577. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3578. /**
  3579. * Updates the given vector "result" coordinates from the given floats.
  3580. * @param x float to set from
  3581. * @param y float to set from
  3582. * @param z float to set from
  3583. * @param w float to set from
  3584. * @param result the vector to the floats in
  3585. */
  3586. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3587. /**
  3588. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3589. * @returns the new vector
  3590. */
  3591. static Zero(): Vector4;
  3592. /**
  3593. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3594. * @returns the new vector
  3595. */
  3596. static One(): Vector4;
  3597. /**
  3598. * Returns a new normalized Vector4 from the given one.
  3599. * @param vector the vector to normalize
  3600. * @returns the vector
  3601. */
  3602. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3603. /**
  3604. * Updates the given vector "result" from the normalization of the given one.
  3605. * @param vector the vector to normalize
  3606. * @param result the vector to store the result in
  3607. */
  3608. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3609. /**
  3610. * Returns a vector with the minimum values from the left and right vectors
  3611. * @param left left vector to minimize
  3612. * @param right right vector to minimize
  3613. * @returns a new vector with the minimum of the left and right vector values
  3614. */
  3615. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3616. /**
  3617. * Returns a vector with the maximum values from the left and right vectors
  3618. * @param left left vector to maximize
  3619. * @param right right vector to maximize
  3620. * @returns a new vector with the maximum of the left and right vector values
  3621. */
  3622. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3623. /**
  3624. * Returns the distance (float) between the vectors "value1" and "value2".
  3625. * @param value1 value to calulate the distance between
  3626. * @param value2 value to calulate the distance between
  3627. * @return the distance between the two vectors
  3628. */
  3629. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3630. /**
  3631. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3632. * @param value1 value to calulate the distance between
  3633. * @param value2 value to calulate the distance between
  3634. * @return the distance between the two vectors squared
  3635. */
  3636. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3637. /**
  3638. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3639. * @param value1 value to calulate the center between
  3640. * @param value2 value to calulate the center between
  3641. * @return the center between the two vectors
  3642. */
  3643. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3644. /**
  3645. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3646. * This methods computes transformed normalized direction vectors only.
  3647. * @param vector the vector to transform
  3648. * @param transformation the transformation matrix to apply
  3649. * @returns the new vector
  3650. */
  3651. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3652. /**
  3653. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3654. * This methods computes transformed normalized direction vectors only.
  3655. * @param vector the vector to transform
  3656. * @param transformation the transformation matrix to apply
  3657. * @param result the vector to store the result in
  3658. */
  3659. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3660. /**
  3661. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3662. * This methods computes transformed normalized direction vectors only.
  3663. * @param x value to transform
  3664. * @param y value to transform
  3665. * @param z value to transform
  3666. * @param w value to transform
  3667. * @param transformation the transformation matrix to apply
  3668. * @param result the vector to store the results in
  3669. */
  3670. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3671. /**
  3672. * Creates a new Vector4 from a Vector3
  3673. * @param source defines the source data
  3674. * @param w defines the 4th component (default is 0)
  3675. * @returns a new Vector4
  3676. */
  3677. static FromVector3(source: Vector3, w?: number): Vector4;
  3678. }
  3679. /**
  3680. * Class used to store quaternion data
  3681. * @see https://en.wikipedia.org/wiki/Quaternion
  3682. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3683. */
  3684. export class Quaternion {
  3685. /** @hidden */
  3686. _x: number;
  3687. /** @hidden */
  3688. _y: number;
  3689. /** @hidden */
  3690. _z: number;
  3691. /** @hidden */
  3692. _w: number;
  3693. /** @hidden */
  3694. _isDirty: boolean;
  3695. /** Gets or sets the x coordinate */
  3696. get x(): number;
  3697. set x(value: number);
  3698. /** Gets or sets the y coordinate */
  3699. get y(): number;
  3700. set y(value: number);
  3701. /** Gets or sets the z coordinate */
  3702. get z(): number;
  3703. set z(value: number);
  3704. /** Gets or sets the w coordinate */
  3705. get w(): number;
  3706. set w(value: number);
  3707. /**
  3708. * Creates a new Quaternion from the given floats
  3709. * @param x defines the first component (0 by default)
  3710. * @param y defines the second component (0 by default)
  3711. * @param z defines the third component (0 by default)
  3712. * @param w defines the fourth component (1.0 by default)
  3713. */
  3714. constructor(x?: number, y?: number, z?: number, w?: number);
  3715. /**
  3716. * Gets a string representation for the current quaternion
  3717. * @returns a string with the Quaternion coordinates
  3718. */
  3719. toString(): string;
  3720. /**
  3721. * Gets the class name of the quaternion
  3722. * @returns the string "Quaternion"
  3723. */
  3724. getClassName(): string;
  3725. /**
  3726. * Gets a hash code for this quaternion
  3727. * @returns the quaternion hash code
  3728. */
  3729. getHashCode(): number;
  3730. /**
  3731. * Copy the quaternion to an array
  3732. * @returns a new array populated with 4 elements from the quaternion coordinates
  3733. */
  3734. asArray(): number[];
  3735. /**
  3736. * Check if two quaternions are equals
  3737. * @param otherQuaternion defines the second operand
  3738. * @return true if the current quaternion and the given one coordinates are strictly equals
  3739. */
  3740. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3741. /**
  3742. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3743. * @param otherQuaternion defines the other quaternion
  3744. * @param epsilon defines the minimal distance to consider equality
  3745. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3746. */
  3747. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3748. /**
  3749. * Clone the current quaternion
  3750. * @returns a new quaternion copied from the current one
  3751. */
  3752. clone(): Quaternion;
  3753. /**
  3754. * Copy a quaternion to the current one
  3755. * @param other defines the other quaternion
  3756. * @returns the updated current quaternion
  3757. */
  3758. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3759. /**
  3760. * Updates the current quaternion with the given float coordinates
  3761. * @param x defines the x coordinate
  3762. * @param y defines the y coordinate
  3763. * @param z defines the z coordinate
  3764. * @param w defines the w coordinate
  3765. * @returns the updated current quaternion
  3766. */
  3767. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3768. /**
  3769. * Updates the current quaternion from the given float coordinates
  3770. * @param x defines the x coordinate
  3771. * @param y defines the y coordinate
  3772. * @param z defines the z coordinate
  3773. * @param w defines the w coordinate
  3774. * @returns the updated current quaternion
  3775. */
  3776. set(x: number, y: number, z: number, w: number): Quaternion;
  3777. /**
  3778. * Adds two quaternions
  3779. * @param other defines the second operand
  3780. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3781. */
  3782. add(other: DeepImmutable<Quaternion>): Quaternion;
  3783. /**
  3784. * Add a quaternion to the current one
  3785. * @param other defines the quaternion to add
  3786. * @returns the current quaternion
  3787. */
  3788. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3789. /**
  3790. * Subtract two quaternions
  3791. * @param other defines the second operand
  3792. * @returns a new quaternion as the subtraction result of the given one from the current one
  3793. */
  3794. subtract(other: Quaternion): Quaternion;
  3795. /**
  3796. * Multiplies the current quaternion by a scale factor
  3797. * @param value defines the scale factor
  3798. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3799. */
  3800. scale(value: number): Quaternion;
  3801. /**
  3802. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3803. * @param scale defines the scale factor
  3804. * @param result defines the Quaternion object where to store the result
  3805. * @returns the unmodified current quaternion
  3806. */
  3807. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3808. /**
  3809. * Multiplies in place the current quaternion by a scale factor
  3810. * @param value defines the scale factor
  3811. * @returns the current modified quaternion
  3812. */
  3813. scaleInPlace(value: number): Quaternion;
  3814. /**
  3815. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3816. * @param scale defines the scale factor
  3817. * @param result defines the Quaternion object where to store the result
  3818. * @returns the unmodified current quaternion
  3819. */
  3820. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3821. /**
  3822. * Multiplies two quaternions
  3823. * @param q1 defines the second operand
  3824. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3825. */
  3826. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3827. /**
  3828. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3829. * @param q1 defines the second operand
  3830. * @param result defines the target quaternion
  3831. * @returns the current quaternion
  3832. */
  3833. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3834. /**
  3835. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3836. * @param q1 defines the second operand
  3837. * @returns the currentupdated quaternion
  3838. */
  3839. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3840. /**
  3841. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3842. * @param ref defines the target quaternion
  3843. * @returns the current quaternion
  3844. */
  3845. conjugateToRef(ref: Quaternion): Quaternion;
  3846. /**
  3847. * Conjugates in place (1-q) the current quaternion
  3848. * @returns the current updated quaternion
  3849. */
  3850. conjugateInPlace(): Quaternion;
  3851. /**
  3852. * Conjugates in place (1-q) the current quaternion
  3853. * @returns a new quaternion
  3854. */
  3855. conjugate(): Quaternion;
  3856. /**
  3857. * Gets length of current quaternion
  3858. * @returns the quaternion length (float)
  3859. */
  3860. length(): number;
  3861. /**
  3862. * Normalize in place the current quaternion
  3863. * @returns the current updated quaternion
  3864. */
  3865. normalize(): Quaternion;
  3866. /**
  3867. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3868. * @param order is a reserved parameter and is ignore for now
  3869. * @returns a new Vector3 containing the Euler angles
  3870. */
  3871. toEulerAngles(order?: string): Vector3;
  3872. /**
  3873. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3874. * @param result defines the vector which will be filled with the Euler angles
  3875. * @param order is a reserved parameter and is ignore for now
  3876. * @returns the current unchanged quaternion
  3877. */
  3878. toEulerAnglesToRef(result: Vector3): Quaternion;
  3879. /**
  3880. * Updates the given rotation matrix with the current quaternion values
  3881. * @param result defines the target matrix
  3882. * @returns the current unchanged quaternion
  3883. */
  3884. toRotationMatrix(result: Matrix): Quaternion;
  3885. /**
  3886. * Updates the current quaternion from the given rotation matrix values
  3887. * @param matrix defines the source matrix
  3888. * @returns the current updated quaternion
  3889. */
  3890. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3891. /**
  3892. * Creates a new quaternion from a rotation matrix
  3893. * @param matrix defines the source matrix
  3894. * @returns a new quaternion created from the given rotation matrix values
  3895. */
  3896. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3897. /**
  3898. * Updates the given quaternion with the given rotation matrix values
  3899. * @param matrix defines the source matrix
  3900. * @param result defines the target quaternion
  3901. */
  3902. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3903. /**
  3904. * Returns the dot product (float) between the quaternions "left" and "right"
  3905. * @param left defines the left operand
  3906. * @param right defines the right operand
  3907. * @returns the dot product
  3908. */
  3909. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3910. /**
  3911. * Checks if the two quaternions are close to each other
  3912. * @param quat0 defines the first quaternion to check
  3913. * @param quat1 defines the second quaternion to check
  3914. * @returns true if the two quaternions are close to each other
  3915. */
  3916. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3917. /**
  3918. * Creates an empty quaternion
  3919. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3920. */
  3921. static Zero(): Quaternion;
  3922. /**
  3923. * Inverse a given quaternion
  3924. * @param q defines the source quaternion
  3925. * @returns a new quaternion as the inverted current quaternion
  3926. */
  3927. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3928. /**
  3929. * Inverse a given quaternion
  3930. * @param q defines the source quaternion
  3931. * @param result the quaternion the result will be stored in
  3932. * @returns the result quaternion
  3933. */
  3934. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3935. /**
  3936. * Creates an identity quaternion
  3937. * @returns the identity quaternion
  3938. */
  3939. static Identity(): Quaternion;
  3940. /**
  3941. * Gets a boolean indicating if the given quaternion is identity
  3942. * @param quaternion defines the quaternion to check
  3943. * @returns true if the quaternion is identity
  3944. */
  3945. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3946. /**
  3947. * Creates a quaternion from a rotation around an axis
  3948. * @param axis defines the axis to use
  3949. * @param angle defines the angle to use
  3950. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3951. */
  3952. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3953. /**
  3954. * Creates a rotation around an axis and stores it into the given quaternion
  3955. * @param axis defines the axis to use
  3956. * @param angle defines the angle to use
  3957. * @param result defines the target quaternion
  3958. * @returns the target quaternion
  3959. */
  3960. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3961. /**
  3962. * Creates a new quaternion from data stored into an array
  3963. * @param array defines the data source
  3964. * @param offset defines the offset in the source array where the data starts
  3965. * @returns a new quaternion
  3966. */
  3967. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3968. /**
  3969. * Updates the given quaternion "result" from the starting index of the given array.
  3970. * @param array the array to pull values from
  3971. * @param offset the offset into the array to start at
  3972. * @param result the quaternion to store the result in
  3973. */
  3974. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3975. /**
  3976. * Create a quaternion from Euler rotation angles
  3977. * @param x Pitch
  3978. * @param y Yaw
  3979. * @param z Roll
  3980. * @returns the new Quaternion
  3981. */
  3982. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3983. /**
  3984. * Updates a quaternion from Euler rotation angles
  3985. * @param x Pitch
  3986. * @param y Yaw
  3987. * @param z Roll
  3988. * @param result the quaternion to store the result
  3989. * @returns the updated quaternion
  3990. */
  3991. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3992. /**
  3993. * Create a quaternion from Euler rotation vector
  3994. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3995. * @returns the new Quaternion
  3996. */
  3997. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3998. /**
  3999. * Updates a quaternion from Euler rotation vector
  4000. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4001. * @param result the quaternion to store the result
  4002. * @returns the updated quaternion
  4003. */
  4004. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4005. /**
  4006. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4007. * @param yaw defines the rotation around Y axis
  4008. * @param pitch defines the rotation around X axis
  4009. * @param roll defines the rotation around Z axis
  4010. * @returns the new quaternion
  4011. */
  4012. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4013. /**
  4014. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4015. * @param yaw defines the rotation around Y axis
  4016. * @param pitch defines the rotation around X axis
  4017. * @param roll defines the rotation around Z axis
  4018. * @param result defines the target quaternion
  4019. */
  4020. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4021. /**
  4022. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4023. * @param alpha defines the rotation around first axis
  4024. * @param beta defines the rotation around second axis
  4025. * @param gamma defines the rotation around third axis
  4026. * @returns the new quaternion
  4027. */
  4028. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4029. /**
  4030. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4031. * @param alpha defines the rotation around first axis
  4032. * @param beta defines the rotation around second axis
  4033. * @param gamma defines the rotation around third axis
  4034. * @param result defines the target quaternion
  4035. */
  4036. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4037. /**
  4038. * 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)
  4039. * @param axis1 defines the first axis
  4040. * @param axis2 defines the second axis
  4041. * @param axis3 defines the third axis
  4042. * @returns the new quaternion
  4043. */
  4044. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4045. /**
  4046. * 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
  4047. * @param axis1 defines the first axis
  4048. * @param axis2 defines the second axis
  4049. * @param axis3 defines the third axis
  4050. * @param ref defines the target quaternion
  4051. */
  4052. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4053. /**
  4054. * Interpolates between two quaternions
  4055. * @param left defines first quaternion
  4056. * @param right defines second quaternion
  4057. * @param amount defines the gradient to use
  4058. * @returns the new interpolated quaternion
  4059. */
  4060. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4061. /**
  4062. * Interpolates between two quaternions and stores it into a target quaternion
  4063. * @param left defines first quaternion
  4064. * @param right defines second quaternion
  4065. * @param amount defines the gradient to use
  4066. * @param result defines the target quaternion
  4067. */
  4068. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4069. /**
  4070. * Interpolate between two quaternions using Hermite interpolation
  4071. * @param value1 defines first quaternion
  4072. * @param tangent1 defines the incoming tangent
  4073. * @param value2 defines second quaternion
  4074. * @param tangent2 defines the outgoing tangent
  4075. * @param amount defines the target quaternion
  4076. * @returns the new interpolated quaternion
  4077. */
  4078. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4079. }
  4080. /**
  4081. * Class used to store matrix data (4x4)
  4082. */
  4083. export class Matrix {
  4084. /**
  4085. * Gets the precision of matrix computations
  4086. */
  4087. static get Use64Bits(): boolean;
  4088. private static _updateFlagSeed;
  4089. private static _identityReadOnly;
  4090. private _isIdentity;
  4091. private _isIdentityDirty;
  4092. private _isIdentity3x2;
  4093. private _isIdentity3x2Dirty;
  4094. /**
  4095. * Gets the update flag of the matrix which is an unique number for the matrix.
  4096. * It will be incremented every time the matrix data change.
  4097. * You can use it to speed the comparison between two versions of the same matrix.
  4098. */
  4099. updateFlag: number;
  4100. private readonly _m;
  4101. /**
  4102. * Gets the internal data of the matrix
  4103. */
  4104. get m(): DeepImmutable<Float32Array | Array<number>>;
  4105. /** @hidden */
  4106. _markAsUpdated(): void;
  4107. /** @hidden */
  4108. private _updateIdentityStatus;
  4109. /**
  4110. * Creates an empty matrix (filled with zeros)
  4111. */
  4112. constructor();
  4113. /**
  4114. * Check if the current matrix is identity
  4115. * @returns true is the matrix is the identity matrix
  4116. */
  4117. isIdentity(): boolean;
  4118. /**
  4119. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4120. * @returns true is the matrix is the identity matrix
  4121. */
  4122. isIdentityAs3x2(): boolean;
  4123. /**
  4124. * Gets the determinant of the matrix
  4125. * @returns the matrix determinant
  4126. */
  4127. determinant(): number;
  4128. /**
  4129. * Returns the matrix as a Float32Array or Array<number>
  4130. * @returns the matrix underlying array
  4131. */
  4132. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4133. /**
  4134. * Returns the matrix as a Float32Array or Array<number>
  4135. * @returns the matrix underlying array.
  4136. */
  4137. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4138. /**
  4139. * Inverts the current matrix in place
  4140. * @returns the current inverted matrix
  4141. */
  4142. invert(): Matrix;
  4143. /**
  4144. * Sets all the matrix elements to zero
  4145. * @returns the current matrix
  4146. */
  4147. reset(): Matrix;
  4148. /**
  4149. * Adds the current matrix with a second one
  4150. * @param other defines the matrix to add
  4151. * @returns a new matrix as the addition of the current matrix and the given one
  4152. */
  4153. add(other: DeepImmutable<Matrix>): Matrix;
  4154. /**
  4155. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4156. * @param other defines the matrix to add
  4157. * @param result defines the target matrix
  4158. * @returns the current matrix
  4159. */
  4160. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4161. /**
  4162. * Adds in place the given matrix to the current matrix
  4163. * @param other defines the second operand
  4164. * @returns the current updated matrix
  4165. */
  4166. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4167. /**
  4168. * Sets the given matrix to the current inverted Matrix
  4169. * @param other defines the target matrix
  4170. * @returns the unmodified current matrix
  4171. */
  4172. invertToRef(other: Matrix): Matrix;
  4173. /**
  4174. * add a value at the specified position in the current Matrix
  4175. * @param index the index of the value within the matrix. between 0 and 15.
  4176. * @param value the value to be added
  4177. * @returns the current updated matrix
  4178. */
  4179. addAtIndex(index: number, value: number): Matrix;
  4180. /**
  4181. * mutiply the specified position in the current Matrix by a value
  4182. * @param index the index of the value within the matrix. between 0 and 15.
  4183. * @param value the value to be added
  4184. * @returns the current updated matrix
  4185. */
  4186. multiplyAtIndex(index: number, value: number): Matrix;
  4187. /**
  4188. * Inserts the translation vector (using 3 floats) in the current matrix
  4189. * @param x defines the 1st component of the translation
  4190. * @param y defines the 2nd component of the translation
  4191. * @param z defines the 3rd component of the translation
  4192. * @returns the current updated matrix
  4193. */
  4194. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4195. /**
  4196. * Adds the translation vector (using 3 floats) in the current matrix
  4197. * @param x defines the 1st component of the translation
  4198. * @param y defines the 2nd component of the translation
  4199. * @param z defines the 3rd component of the translation
  4200. * @returns the current updated matrix
  4201. */
  4202. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4203. /**
  4204. * Inserts the translation vector in the current matrix
  4205. * @param vector3 defines the translation to insert
  4206. * @returns the current updated matrix
  4207. */
  4208. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4209. /**
  4210. * Gets the translation value of the current matrix
  4211. * @returns a new Vector3 as the extracted translation from the matrix
  4212. */
  4213. getTranslation(): Vector3;
  4214. /**
  4215. * Fill a Vector3 with the extracted translation from the matrix
  4216. * @param result defines the Vector3 where to store the translation
  4217. * @returns the current matrix
  4218. */
  4219. getTranslationToRef(result: Vector3): Matrix;
  4220. /**
  4221. * Remove rotation and scaling part from the matrix
  4222. * @returns the updated matrix
  4223. */
  4224. removeRotationAndScaling(): Matrix;
  4225. /**
  4226. * Multiply two matrices
  4227. * @param other defines the second operand
  4228. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4229. */
  4230. multiply(other: DeepImmutable<Matrix>): Matrix;
  4231. /**
  4232. * Copy the current matrix from the given one
  4233. * @param other defines the source matrix
  4234. * @returns the current updated matrix
  4235. */
  4236. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4237. /**
  4238. * Populates the given array from the starting index with the current matrix values
  4239. * @param array defines the target array
  4240. * @param offset defines the offset in the target array where to start storing values
  4241. * @returns the current matrix
  4242. */
  4243. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4244. /**
  4245. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4246. * @param other defines the second operand
  4247. * @param result defines the matrix where to store the multiplication
  4248. * @returns the current matrix
  4249. */
  4250. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4251. /**
  4252. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4253. * @param other defines the second operand
  4254. * @param result defines the array where to store the multiplication
  4255. * @param offset defines the offset in the target array where to start storing values
  4256. * @returns the current matrix
  4257. */
  4258. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4259. /**
  4260. * Check equality between this matrix and a second one
  4261. * @param value defines the second matrix to compare
  4262. * @returns true is the current matrix and the given one values are strictly equal
  4263. */
  4264. equals(value: DeepImmutable<Matrix>): boolean;
  4265. /**
  4266. * Clone the current matrix
  4267. * @returns a new matrix from the current matrix
  4268. */
  4269. clone(): Matrix;
  4270. /**
  4271. * Returns the name of the current matrix class
  4272. * @returns the string "Matrix"
  4273. */
  4274. getClassName(): string;
  4275. /**
  4276. * Gets the hash code of the current matrix
  4277. * @returns the hash code
  4278. */
  4279. getHashCode(): number;
  4280. /**
  4281. * Decomposes the current Matrix into a translation, rotation and scaling components
  4282. * @param scale defines the scale vector3 given as a reference to update
  4283. * @param rotation defines the rotation quaternion given as a reference to update
  4284. * @param translation defines the translation vector3 given as a reference to update
  4285. * @returns true if operation was successful
  4286. */
  4287. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4288. /**
  4289. * Gets specific row of the matrix
  4290. * @param index defines the number of the row to get
  4291. * @returns the index-th row of the current matrix as a new Vector4
  4292. */
  4293. getRow(index: number): Nullable<Vector4>;
  4294. /**
  4295. * Sets the index-th row of the current matrix to the vector4 values
  4296. * @param index defines the number of the row to set
  4297. * @param row defines the target vector4
  4298. * @returns the updated current matrix
  4299. */
  4300. setRow(index: number, row: Vector4): Matrix;
  4301. /**
  4302. * Compute the transpose of the matrix
  4303. * @returns the new transposed matrix
  4304. */
  4305. transpose(): Matrix;
  4306. /**
  4307. * Compute the transpose of the matrix and store it in a given matrix
  4308. * @param result defines the target matrix
  4309. * @returns the current matrix
  4310. */
  4311. transposeToRef(result: Matrix): Matrix;
  4312. /**
  4313. * Sets the index-th row of the current matrix with the given 4 x float values
  4314. * @param index defines the row index
  4315. * @param x defines the x component to set
  4316. * @param y defines the y component to set
  4317. * @param z defines the z component to set
  4318. * @param w defines the w component to set
  4319. * @returns the updated current matrix
  4320. */
  4321. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4322. /**
  4323. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4324. * @param scale defines the scale factor
  4325. * @returns a new matrix
  4326. */
  4327. scale(scale: number): Matrix;
  4328. /**
  4329. * Scale the current matrix values by a factor to a given result matrix
  4330. * @param scale defines the scale factor
  4331. * @param result defines the matrix to store the result
  4332. * @returns the current matrix
  4333. */
  4334. scaleToRef(scale: number, result: Matrix): Matrix;
  4335. /**
  4336. * Scale the current matrix values by a factor and add the result to a given matrix
  4337. * @param scale defines the scale factor
  4338. * @param result defines the Matrix to store the result
  4339. * @returns the current matrix
  4340. */
  4341. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4342. /**
  4343. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4344. * @param ref matrix to store the result
  4345. */
  4346. toNormalMatrix(ref: Matrix): void;
  4347. /**
  4348. * Gets only rotation part of the current matrix
  4349. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4350. */
  4351. getRotationMatrix(): Matrix;
  4352. /**
  4353. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4354. * @param result defines the target matrix to store data to
  4355. * @returns the current matrix
  4356. */
  4357. getRotationMatrixToRef(result: Matrix): Matrix;
  4358. /**
  4359. * Toggles model matrix from being right handed to left handed in place and vice versa
  4360. */
  4361. toggleModelMatrixHandInPlace(): void;
  4362. /**
  4363. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4364. */
  4365. toggleProjectionMatrixHandInPlace(): void;
  4366. /**
  4367. * Creates a matrix from an array
  4368. * @param array defines the source array
  4369. * @param offset defines an offset in the source array
  4370. * @returns a new Matrix set from the starting index of the given array
  4371. */
  4372. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4373. /**
  4374. * Copy the content of an array into a given matrix
  4375. * @param array defines the source array
  4376. * @param offset defines an offset in the source array
  4377. * @param result defines the target matrix
  4378. */
  4379. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4380. /**
  4381. * Stores an array into a matrix after having multiplied each component by a given factor
  4382. * @param array defines the source array
  4383. * @param offset defines the offset in the source array
  4384. * @param scale defines the scaling factor
  4385. * @param result defines the target matrix
  4386. */
  4387. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4388. /**
  4389. * Gets an identity matrix that must not be updated
  4390. */
  4391. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4392. /**
  4393. * Stores a list of values (16) inside a given matrix
  4394. * @param initialM11 defines 1st value of 1st row
  4395. * @param initialM12 defines 2nd value of 1st row
  4396. * @param initialM13 defines 3rd value of 1st row
  4397. * @param initialM14 defines 4th value of 1st row
  4398. * @param initialM21 defines 1st value of 2nd row
  4399. * @param initialM22 defines 2nd value of 2nd row
  4400. * @param initialM23 defines 3rd value of 2nd row
  4401. * @param initialM24 defines 4th value of 2nd row
  4402. * @param initialM31 defines 1st value of 3rd row
  4403. * @param initialM32 defines 2nd value of 3rd row
  4404. * @param initialM33 defines 3rd value of 3rd row
  4405. * @param initialM34 defines 4th value of 3rd row
  4406. * @param initialM41 defines 1st value of 4th row
  4407. * @param initialM42 defines 2nd value of 4th row
  4408. * @param initialM43 defines 3rd value of 4th row
  4409. * @param initialM44 defines 4th value of 4th row
  4410. * @param result defines the target matrix
  4411. */
  4412. 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;
  4413. /**
  4414. * Creates new matrix from a list of values (16)
  4415. * @param initialM11 defines 1st value of 1st row
  4416. * @param initialM12 defines 2nd value of 1st row
  4417. * @param initialM13 defines 3rd value of 1st row
  4418. * @param initialM14 defines 4th value of 1st row
  4419. * @param initialM21 defines 1st value of 2nd row
  4420. * @param initialM22 defines 2nd value of 2nd row
  4421. * @param initialM23 defines 3rd value of 2nd row
  4422. * @param initialM24 defines 4th value of 2nd row
  4423. * @param initialM31 defines 1st value of 3rd row
  4424. * @param initialM32 defines 2nd value of 3rd row
  4425. * @param initialM33 defines 3rd value of 3rd row
  4426. * @param initialM34 defines 4th value of 3rd row
  4427. * @param initialM41 defines 1st value of 4th row
  4428. * @param initialM42 defines 2nd value of 4th row
  4429. * @param initialM43 defines 3rd value of 4th row
  4430. * @param initialM44 defines 4th value of 4th row
  4431. * @returns the new matrix
  4432. */
  4433. 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;
  4434. /**
  4435. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4436. * @param scale defines the scale vector3
  4437. * @param rotation defines the rotation quaternion
  4438. * @param translation defines the translation vector3
  4439. * @returns a new matrix
  4440. */
  4441. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4442. /**
  4443. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4444. * @param scale defines the scale vector3
  4445. * @param rotation defines the rotation quaternion
  4446. * @param translation defines the translation vector3
  4447. * @param result defines the target matrix
  4448. */
  4449. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4450. /**
  4451. * Creates a new identity matrix
  4452. * @returns a new identity matrix
  4453. */
  4454. static Identity(): Matrix;
  4455. /**
  4456. * Creates a new identity matrix and stores the result in a given matrix
  4457. * @param result defines the target matrix
  4458. */
  4459. static IdentityToRef(result: Matrix): void;
  4460. /**
  4461. * Creates a new zero matrix
  4462. * @returns a new zero matrix
  4463. */
  4464. static Zero(): Matrix;
  4465. /**
  4466. * Creates a new rotation matrix for "angle" radians around the X axis
  4467. * @param angle defines the angle (in radians) to use
  4468. * @return the new matrix
  4469. */
  4470. static RotationX(angle: number): Matrix;
  4471. /**
  4472. * Creates a new matrix as the invert of a given matrix
  4473. * @param source defines the source matrix
  4474. * @returns the new matrix
  4475. */
  4476. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4477. /**
  4478. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4479. * @param angle defines the angle (in radians) to use
  4480. * @param result defines the target matrix
  4481. */
  4482. static RotationXToRef(angle: number, result: Matrix): void;
  4483. /**
  4484. * Creates a new rotation matrix for "angle" radians around the Y axis
  4485. * @param angle defines the angle (in radians) to use
  4486. * @return the new matrix
  4487. */
  4488. static RotationY(angle: number): Matrix;
  4489. /**
  4490. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4491. * @param angle defines the angle (in radians) to use
  4492. * @param result defines the target matrix
  4493. */
  4494. static RotationYToRef(angle: number, result: Matrix): void;
  4495. /**
  4496. * Creates a new rotation matrix for "angle" radians around the Z axis
  4497. * @param angle defines the angle (in radians) to use
  4498. * @return the new matrix
  4499. */
  4500. static RotationZ(angle: number): Matrix;
  4501. /**
  4502. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4503. * @param angle defines the angle (in radians) to use
  4504. * @param result defines the target matrix
  4505. */
  4506. static RotationZToRef(angle: number, result: Matrix): void;
  4507. /**
  4508. * Creates a new rotation matrix for "angle" radians around the given axis
  4509. * @param axis defines the axis to use
  4510. * @param angle defines the angle (in radians) to use
  4511. * @return the new matrix
  4512. */
  4513. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4514. /**
  4515. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4516. * @param axis defines the axis to use
  4517. * @param angle defines the angle (in radians) to use
  4518. * @param result defines the target matrix
  4519. */
  4520. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4521. /**
  4522. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4523. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4524. * @param from defines the vector to align
  4525. * @param to defines the vector to align to
  4526. * @param result defines the target matrix
  4527. */
  4528. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4529. /**
  4530. * Creates a rotation matrix
  4531. * @param yaw defines the yaw angle in radians (Y axis)
  4532. * @param pitch defines the pitch angle in radians (X axis)
  4533. * @param roll defines the roll angle in radians (Z axis)
  4534. * @returns the new rotation matrix
  4535. */
  4536. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4537. /**
  4538. * Creates a rotation matrix and stores it in a given matrix
  4539. * @param yaw defines the yaw angle in radians (Y axis)
  4540. * @param pitch defines the pitch angle in radians (X axis)
  4541. * @param roll defines the roll angle in radians (Z axis)
  4542. * @param result defines the target matrix
  4543. */
  4544. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4545. /**
  4546. * Creates a scaling matrix
  4547. * @param x defines the scale factor on X axis
  4548. * @param y defines the scale factor on Y axis
  4549. * @param z defines the scale factor on Z axis
  4550. * @returns the new matrix
  4551. */
  4552. static Scaling(x: number, y: number, z: number): Matrix;
  4553. /**
  4554. * Creates a scaling matrix and stores it in a given matrix
  4555. * @param x defines the scale factor on X axis
  4556. * @param y defines the scale factor on Y axis
  4557. * @param z defines the scale factor on Z axis
  4558. * @param result defines the target matrix
  4559. */
  4560. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4561. /**
  4562. * Creates a translation matrix
  4563. * @param x defines the translation on X axis
  4564. * @param y defines the translation on Y axis
  4565. * @param z defines the translationon Z axis
  4566. * @returns the new matrix
  4567. */
  4568. static Translation(x: number, y: number, z: number): Matrix;
  4569. /**
  4570. * Creates a translation matrix and stores it in a given matrix
  4571. * @param x defines the translation on X axis
  4572. * @param y defines the translation on Y axis
  4573. * @param z defines the translationon Z axis
  4574. * @param result defines the target matrix
  4575. */
  4576. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4577. /**
  4578. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4579. * @param startValue defines the start value
  4580. * @param endValue defines the end value
  4581. * @param gradient defines the gradient factor
  4582. * @returns the new matrix
  4583. */
  4584. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4585. /**
  4586. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4587. * @param startValue defines the start value
  4588. * @param endValue defines the end value
  4589. * @param gradient defines the gradient factor
  4590. * @param result defines the Matrix object where to store data
  4591. */
  4592. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4593. /**
  4594. * Builds a new matrix whose values are computed by:
  4595. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4596. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4597. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4598. * @param startValue defines the first matrix
  4599. * @param endValue defines the second matrix
  4600. * @param gradient defines the gradient between the two matrices
  4601. * @returns the new matrix
  4602. */
  4603. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4604. /**
  4605. * Update a matrix to values which are computed by:
  4606. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4607. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4608. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4609. * @param startValue defines the first matrix
  4610. * @param endValue defines the second matrix
  4611. * @param gradient defines the gradient between the two matrices
  4612. * @param result defines the target matrix
  4613. */
  4614. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4615. /**
  4616. * 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"
  4617. * This function works in left handed mode
  4618. * @param eye defines the final position of the entity
  4619. * @param target defines where the entity should look at
  4620. * @param up defines the up vector for the entity
  4621. * @returns the new matrix
  4622. */
  4623. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4624. /**
  4625. * 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".
  4626. * This function works in left handed mode
  4627. * @param eye defines the final position of the entity
  4628. * @param target defines where the entity should look at
  4629. * @param up defines the up vector for the entity
  4630. * @param result defines the target matrix
  4631. */
  4632. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4633. /**
  4634. * 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"
  4635. * This function works in right handed mode
  4636. * @param eye defines the final position of the entity
  4637. * @param target defines where the entity should look at
  4638. * @param up defines the up vector for the entity
  4639. * @returns the new matrix
  4640. */
  4641. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4642. /**
  4643. * 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".
  4644. * This function works in right handed mode
  4645. * @param eye defines the final position of the entity
  4646. * @param target defines where the entity should look at
  4647. * @param up defines the up vector for the entity
  4648. * @param result defines the target matrix
  4649. */
  4650. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4651. /**
  4652. * Create a left-handed orthographic projection matrix
  4653. * @param width defines the viewport width
  4654. * @param height defines the viewport height
  4655. * @param znear defines the near clip plane
  4656. * @param zfar defines the far clip plane
  4657. * @returns a new matrix as a left-handed orthographic projection matrix
  4658. */
  4659. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4660. /**
  4661. * Store a left-handed orthographic projection to a given matrix
  4662. * @param width defines the viewport width
  4663. * @param height defines the viewport height
  4664. * @param znear defines the near clip plane
  4665. * @param zfar defines the far clip plane
  4666. * @param result defines the target matrix
  4667. */
  4668. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4669. /**
  4670. * Create a left-handed orthographic projection matrix
  4671. * @param left defines the viewport left coordinate
  4672. * @param right defines the viewport right coordinate
  4673. * @param bottom defines the viewport bottom coordinate
  4674. * @param top defines the viewport top coordinate
  4675. * @param znear defines the near clip plane
  4676. * @param zfar defines the far clip plane
  4677. * @returns a new matrix as a left-handed orthographic projection matrix
  4678. */
  4679. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4680. /**
  4681. * Stores a left-handed orthographic projection into a given matrix
  4682. * @param left defines the viewport left coordinate
  4683. * @param right defines the viewport right coordinate
  4684. * @param bottom defines the viewport bottom coordinate
  4685. * @param top defines the viewport top coordinate
  4686. * @param znear defines the near clip plane
  4687. * @param zfar defines the far clip plane
  4688. * @param result defines the target matrix
  4689. */
  4690. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4691. /**
  4692. * Creates a right-handed orthographic projection matrix
  4693. * @param left defines the viewport left coordinate
  4694. * @param right defines the viewport right coordinate
  4695. * @param bottom defines the viewport bottom coordinate
  4696. * @param top defines the viewport top coordinate
  4697. * @param znear defines the near clip plane
  4698. * @param zfar defines the far clip plane
  4699. * @returns a new matrix as a right-handed orthographic projection matrix
  4700. */
  4701. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4702. /**
  4703. * Stores a right-handed orthographic projection into a given matrix
  4704. * @param left defines the viewport left coordinate
  4705. * @param right defines the viewport right coordinate
  4706. * @param bottom defines the viewport bottom coordinate
  4707. * @param top defines the viewport top coordinate
  4708. * @param znear defines the near clip plane
  4709. * @param zfar defines the far clip plane
  4710. * @param result defines the target matrix
  4711. */
  4712. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4713. /**
  4714. * Creates a left-handed perspective projection matrix
  4715. * @param width defines the viewport width
  4716. * @param height defines the viewport height
  4717. * @param znear defines the near clip plane
  4718. * @param zfar defines the far clip plane
  4719. * @returns a new matrix as a left-handed perspective projection matrix
  4720. */
  4721. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4722. /**
  4723. * Creates a left-handed perspective projection matrix
  4724. * @param fov defines the horizontal field of view
  4725. * @param aspect defines the aspect ratio
  4726. * @param znear defines the near clip plane
  4727. * @param zfar defines the far clip plane
  4728. * @returns a new matrix as a left-handed perspective projection matrix
  4729. */
  4730. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4731. /**
  4732. * Stores a left-handed perspective projection into a given matrix
  4733. * @param fov defines the horizontal field of view
  4734. * @param aspect defines the aspect ratio
  4735. * @param znear defines the near clip plane
  4736. * @param zfar defines the far clip plane
  4737. * @param result defines the target matrix
  4738. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4739. */
  4740. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4741. /**
  4742. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4743. * @param fov defines the horizontal field of view
  4744. * @param aspect defines the aspect ratio
  4745. * @param znear defines the near clip plane
  4746. * @param zfar not used as infinity is used as far clip
  4747. * @param result defines the target matrix
  4748. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4749. */
  4750. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4751. /**
  4752. * Creates a right-handed perspective projection matrix
  4753. * @param fov defines the horizontal field of view
  4754. * @param aspect defines the aspect ratio
  4755. * @param znear defines the near clip plane
  4756. * @param zfar defines the far clip plane
  4757. * @returns a new matrix as a right-handed perspective projection matrix
  4758. */
  4759. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4760. /**
  4761. * Stores a right-handed perspective projection into a given matrix
  4762. * @param fov defines the horizontal field of view
  4763. * @param aspect defines the aspect ratio
  4764. * @param znear defines the near clip plane
  4765. * @param zfar defines the far clip plane
  4766. * @param result defines the target matrix
  4767. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4768. */
  4769. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4770. /**
  4771. * Stores a right-handed perspective projection into a given matrix
  4772. * @param fov defines the horizontal field of view
  4773. * @param aspect defines the aspect ratio
  4774. * @param znear defines the near clip plane
  4775. * @param zfar not used as infinity is used as far clip
  4776. * @param result defines the target matrix
  4777. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4778. */
  4779. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4780. /**
  4781. * Stores a perspective projection for WebVR info a given matrix
  4782. * @param fov defines the field of view
  4783. * @param znear defines the near clip plane
  4784. * @param zfar defines the far clip plane
  4785. * @param result defines the target matrix
  4786. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4787. */
  4788. static PerspectiveFovWebVRToRef(fov: {
  4789. upDegrees: number;
  4790. downDegrees: number;
  4791. leftDegrees: number;
  4792. rightDegrees: number;
  4793. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4794. /**
  4795. * Computes a complete transformation matrix
  4796. * @param viewport defines the viewport to use
  4797. * @param world defines the world matrix
  4798. * @param view defines the view matrix
  4799. * @param projection defines the projection matrix
  4800. * @param zmin defines the near clip plane
  4801. * @param zmax defines the far clip plane
  4802. * @returns the transformation matrix
  4803. */
  4804. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4805. /**
  4806. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4807. * @param matrix defines the matrix to use
  4808. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4809. */
  4810. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4811. /**
  4812. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4813. * @param matrix defines the matrix to use
  4814. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4815. */
  4816. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4817. /**
  4818. * Compute the transpose of a given matrix
  4819. * @param matrix defines the matrix to transpose
  4820. * @returns the new matrix
  4821. */
  4822. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4823. /**
  4824. * Compute the transpose of a matrix and store it in a target matrix
  4825. * @param matrix defines the matrix to transpose
  4826. * @param result defines the target matrix
  4827. */
  4828. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4829. /**
  4830. * Computes a reflection matrix from a plane
  4831. * @param plane defines the reflection plane
  4832. * @returns a new matrix
  4833. */
  4834. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4835. /**
  4836. * Computes a reflection matrix from a plane
  4837. * @param plane defines the reflection plane
  4838. * @param result defines the target matrix
  4839. */
  4840. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4841. /**
  4842. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4843. * @param xaxis defines the value of the 1st axis
  4844. * @param yaxis defines the value of the 2nd axis
  4845. * @param zaxis defines the value of the 3rd axis
  4846. * @param result defines the target matrix
  4847. */
  4848. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4849. /**
  4850. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4851. * @param quat defines the quaternion to use
  4852. * @param result defines the target matrix
  4853. */
  4854. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4855. }
  4856. /**
  4857. * @hidden
  4858. */
  4859. export class TmpVectors {
  4860. static Vector2: Vector2[];
  4861. static Vector3: Vector3[];
  4862. static Vector4: Vector4[];
  4863. static Quaternion: Quaternion[];
  4864. static Matrix: Matrix[];
  4865. }
  4866. }
  4867. declare module "babylonjs/Maths/math.path" {
  4868. import { DeepImmutable, Nullable } from "babylonjs/types";
  4869. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4870. /**
  4871. * Defines potential orientation for back face culling
  4872. */
  4873. export enum Orientation {
  4874. /**
  4875. * Clockwise
  4876. */
  4877. CW = 0,
  4878. /** Counter clockwise */
  4879. CCW = 1
  4880. }
  4881. /** Class used to represent a Bezier curve */
  4882. export class BezierCurve {
  4883. /**
  4884. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4885. * @param t defines the time
  4886. * @param x1 defines the left coordinate on X axis
  4887. * @param y1 defines the left coordinate on Y axis
  4888. * @param x2 defines the right coordinate on X axis
  4889. * @param y2 defines the right coordinate on Y axis
  4890. * @returns the interpolated value
  4891. */
  4892. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4893. }
  4894. /**
  4895. * Defines angle representation
  4896. */
  4897. export class Angle {
  4898. private _radians;
  4899. /**
  4900. * Creates an Angle object of "radians" radians (float).
  4901. * @param radians the angle in radians
  4902. */
  4903. constructor(radians: number);
  4904. /**
  4905. * Get value in degrees
  4906. * @returns the Angle value in degrees (float)
  4907. */
  4908. degrees(): number;
  4909. /**
  4910. * Get value in radians
  4911. * @returns the Angle value in radians (float)
  4912. */
  4913. radians(): number;
  4914. /**
  4915. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4916. * @param a defines first point as the origin
  4917. * @param b defines point
  4918. * @returns a new Angle
  4919. */
  4920. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4921. /**
  4922. * Gets a new Angle object from the given float in radians
  4923. * @param radians defines the angle value in radians
  4924. * @returns a new Angle
  4925. */
  4926. static FromRadians(radians: number): Angle;
  4927. /**
  4928. * Gets a new Angle object from the given float in degrees
  4929. * @param degrees defines the angle value in degrees
  4930. * @returns a new Angle
  4931. */
  4932. static FromDegrees(degrees: number): Angle;
  4933. }
  4934. /**
  4935. * This represents an arc in a 2d space.
  4936. */
  4937. export class Arc2 {
  4938. /** Defines the start point of the arc */
  4939. startPoint: Vector2;
  4940. /** Defines the mid point of the arc */
  4941. midPoint: Vector2;
  4942. /** Defines the end point of the arc */
  4943. endPoint: Vector2;
  4944. /**
  4945. * Defines the center point of the arc.
  4946. */
  4947. centerPoint: Vector2;
  4948. /**
  4949. * Defines the radius of the arc.
  4950. */
  4951. radius: number;
  4952. /**
  4953. * Defines the angle of the arc (from mid point to end point).
  4954. */
  4955. angle: Angle;
  4956. /**
  4957. * Defines the start angle of the arc (from start point to middle point).
  4958. */
  4959. startAngle: Angle;
  4960. /**
  4961. * Defines the orientation of the arc (clock wise/counter clock wise).
  4962. */
  4963. orientation: Orientation;
  4964. /**
  4965. * Creates an Arc object from the three given points : start, middle and end.
  4966. * @param startPoint Defines the start point of the arc
  4967. * @param midPoint Defines the midlle point of the arc
  4968. * @param endPoint Defines the end point of the arc
  4969. */
  4970. constructor(
  4971. /** Defines the start point of the arc */
  4972. startPoint: Vector2,
  4973. /** Defines the mid point of the arc */
  4974. midPoint: Vector2,
  4975. /** Defines the end point of the arc */
  4976. endPoint: Vector2);
  4977. }
  4978. /**
  4979. * Represents a 2D path made up of multiple 2D points
  4980. */
  4981. export class Path2 {
  4982. private _points;
  4983. private _length;
  4984. /**
  4985. * If the path start and end point are the same
  4986. */
  4987. closed: boolean;
  4988. /**
  4989. * Creates a Path2 object from the starting 2D coordinates x and y.
  4990. * @param x the starting points x value
  4991. * @param y the starting points y value
  4992. */
  4993. constructor(x: number, y: number);
  4994. /**
  4995. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4996. * @param x the added points x value
  4997. * @param y the added points y value
  4998. * @returns the updated Path2.
  4999. */
  5000. addLineTo(x: number, y: number): Path2;
  5001. /**
  5002. * 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.
  5003. * @param midX middle point x value
  5004. * @param midY middle point y value
  5005. * @param endX end point x value
  5006. * @param endY end point y value
  5007. * @param numberOfSegments (default: 36)
  5008. * @returns the updated Path2.
  5009. */
  5010. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5011. /**
  5012. * Closes the Path2.
  5013. * @returns the Path2.
  5014. */
  5015. close(): Path2;
  5016. /**
  5017. * Gets the sum of the distance between each sequential point in the path
  5018. * @returns the Path2 total length (float).
  5019. */
  5020. length(): number;
  5021. /**
  5022. * Gets the points which construct the path
  5023. * @returns the Path2 internal array of points.
  5024. */
  5025. getPoints(): Vector2[];
  5026. /**
  5027. * Retreives the point at the distance aways from the starting point
  5028. * @param normalizedLengthPosition the length along the path to retreive the point from
  5029. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5030. */
  5031. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5032. /**
  5033. * Creates a new path starting from an x and y position
  5034. * @param x starting x value
  5035. * @param y starting y value
  5036. * @returns a new Path2 starting at the coordinates (x, y).
  5037. */
  5038. static StartingAt(x: number, y: number): Path2;
  5039. }
  5040. /**
  5041. * Represents a 3D path made up of multiple 3D points
  5042. */
  5043. export class Path3D {
  5044. /**
  5045. * an array of Vector3, the curve axis of the Path3D
  5046. */
  5047. path: Vector3[];
  5048. private _curve;
  5049. private _distances;
  5050. private _tangents;
  5051. private _normals;
  5052. private _binormals;
  5053. private _raw;
  5054. private _alignTangentsWithPath;
  5055. private readonly _pointAtData;
  5056. /**
  5057. * new Path3D(path, normal, raw)
  5058. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5059. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5060. * @param path an array of Vector3, the curve axis of the Path3D
  5061. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5062. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5063. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5064. */
  5065. constructor(
  5066. /**
  5067. * an array of Vector3, the curve axis of the Path3D
  5068. */
  5069. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5070. /**
  5071. * Returns the Path3D array of successive Vector3 designing its curve.
  5072. * @returns the Path3D array of successive Vector3 designing its curve.
  5073. */
  5074. getCurve(): Vector3[];
  5075. /**
  5076. * Returns the Path3D array of successive Vector3 designing its curve.
  5077. * @returns the Path3D array of successive Vector3 designing its curve.
  5078. */
  5079. getPoints(): Vector3[];
  5080. /**
  5081. * @returns the computed length (float) of the path.
  5082. */
  5083. length(): number;
  5084. /**
  5085. * Returns an array populated with tangent vectors on each Path3D curve point.
  5086. * @returns an array populated with tangent vectors on each Path3D curve point.
  5087. */
  5088. getTangents(): Vector3[];
  5089. /**
  5090. * Returns an array populated with normal vectors on each Path3D curve point.
  5091. * @returns an array populated with normal vectors on each Path3D curve point.
  5092. */
  5093. getNormals(): Vector3[];
  5094. /**
  5095. * Returns an array populated with binormal vectors on each Path3D curve point.
  5096. * @returns an array populated with binormal vectors on each Path3D curve point.
  5097. */
  5098. getBinormals(): Vector3[];
  5099. /**
  5100. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5101. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5102. */
  5103. getDistances(): number[];
  5104. /**
  5105. * Returns an interpolated point along this path
  5106. * @param position the position of the point along this path, from 0.0 to 1.0
  5107. * @returns a new Vector3 as the point
  5108. */
  5109. getPointAt(position: number): Vector3;
  5110. /**
  5111. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5112. * @param position the position of the point along this path, from 0.0 to 1.0
  5113. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5114. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5115. */
  5116. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5117. /**
  5118. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5119. * @param position the position of the point along this path, from 0.0 to 1.0
  5120. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5121. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5122. */
  5123. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5124. /**
  5125. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5126. * @param position the position of the point along this path, from 0.0 to 1.0
  5127. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5128. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5129. */
  5130. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5131. /**
  5132. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5133. * @param position the position of the point along this path, from 0.0 to 1.0
  5134. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5135. */
  5136. getDistanceAt(position: number): number;
  5137. /**
  5138. * Returns the array index of the previous point of an interpolated point along this path
  5139. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5140. * @returns the array index
  5141. */
  5142. getPreviousPointIndexAt(position: number): number;
  5143. /**
  5144. * 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)
  5145. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5146. * @returns the sub position
  5147. */
  5148. getSubPositionAt(position: number): number;
  5149. /**
  5150. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5151. * @param target the vector of which to get the closest position to
  5152. * @returns the position of the closest virtual point on this path to the target vector
  5153. */
  5154. getClosestPositionTo(target: Vector3): number;
  5155. /**
  5156. * Returns a sub path (slice) of this path
  5157. * @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
  5158. * @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
  5159. * @returns a sub path (slice) of this path
  5160. */
  5161. slice(start?: number, end?: number): Path3D;
  5162. /**
  5163. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5164. * @param path path which all values are copied into the curves points
  5165. * @param firstNormal which should be projected onto the curve
  5166. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5167. * @returns the same object updated.
  5168. */
  5169. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5170. private _compute;
  5171. private _getFirstNonNullVector;
  5172. private _getLastNonNullVector;
  5173. private _normalVector;
  5174. /**
  5175. * Updates the point at data for an interpolated point along this curve
  5176. * @param position the position of the point along this curve, from 0.0 to 1.0
  5177. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5178. * @returns the (updated) point at data
  5179. */
  5180. private _updatePointAtData;
  5181. /**
  5182. * Updates the point at data from the specified parameters
  5183. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5184. * @param point the interpolated point
  5185. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5186. */
  5187. private _setPointAtData;
  5188. /**
  5189. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5190. */
  5191. private _updateInterpolationMatrix;
  5192. }
  5193. /**
  5194. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5195. * A Curve3 is designed from a series of successive Vector3.
  5196. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5197. */
  5198. export class Curve3 {
  5199. private _points;
  5200. private _length;
  5201. /**
  5202. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5203. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5204. * @param v1 (Vector3) the control point
  5205. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5206. * @param nbPoints (integer) the wanted number of points in the curve
  5207. * @returns the created Curve3
  5208. */
  5209. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5210. /**
  5211. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5212. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5213. * @param v1 (Vector3) the first control point
  5214. * @param v2 (Vector3) the second control point
  5215. * @param v3 (Vector3) the end point of the Cubic Bezier
  5216. * @param nbPoints (integer) the wanted number of points in the curve
  5217. * @returns the created Curve3
  5218. */
  5219. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5220. /**
  5221. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5222. * @param p1 (Vector3) the origin point of the Hermite Spline
  5223. * @param t1 (Vector3) the tangent vector at the origin point
  5224. * @param p2 (Vector3) the end point of the Hermite Spline
  5225. * @param t2 (Vector3) the tangent vector at the end point
  5226. * @param nbPoints (integer) the wanted number of points in the curve
  5227. * @returns the created Curve3
  5228. */
  5229. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5230. /**
  5231. * Returns a Curve3 object along a CatmullRom Spline curve :
  5232. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5233. * @param nbPoints (integer) the wanted number of points between each curve control points
  5234. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5235. * @returns the created Curve3
  5236. */
  5237. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5238. /**
  5239. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5240. * A Curve3 is designed from a series of successive Vector3.
  5241. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5242. * @param points points which make up the curve
  5243. */
  5244. constructor(points: Vector3[]);
  5245. /**
  5246. * @returns the Curve3 stored array of successive Vector3
  5247. */
  5248. getPoints(): Vector3[];
  5249. /**
  5250. * @returns the computed length (float) of the curve.
  5251. */
  5252. length(): number;
  5253. /**
  5254. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5255. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5256. * curveA and curveB keep unchanged.
  5257. * @param curve the curve to continue from this curve
  5258. * @returns the newly constructed curve
  5259. */
  5260. continue(curve: DeepImmutable<Curve3>): Curve3;
  5261. private _computeLength;
  5262. }
  5263. }
  5264. declare module "babylonjs/Animations/easing" {
  5265. /**
  5266. * This represents the main contract an easing function should follow.
  5267. * Easing functions are used throughout the animation system.
  5268. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5269. */
  5270. export interface IEasingFunction {
  5271. /**
  5272. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5273. * of the easing function.
  5274. * The link below provides some of the most common examples of easing functions.
  5275. * @see https://easings.net/
  5276. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5277. * @returns the corresponding value on the curve defined by the easing function
  5278. */
  5279. ease(gradient: number): number;
  5280. }
  5281. /**
  5282. * Base class used for every default easing function.
  5283. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5284. */
  5285. export class EasingFunction implements IEasingFunction {
  5286. /**
  5287. * Interpolation follows the mathematical formula associated with the easing function.
  5288. */
  5289. static readonly EASINGMODE_EASEIN: number;
  5290. /**
  5291. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5292. */
  5293. static readonly EASINGMODE_EASEOUT: number;
  5294. /**
  5295. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5296. */
  5297. static readonly EASINGMODE_EASEINOUT: number;
  5298. private _easingMode;
  5299. /**
  5300. * Sets the easing mode of the current function.
  5301. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5302. */
  5303. setEasingMode(easingMode: number): void;
  5304. /**
  5305. * Gets the current easing mode.
  5306. * @returns the easing mode
  5307. */
  5308. getEasingMode(): number;
  5309. /**
  5310. * @hidden
  5311. */
  5312. easeInCore(gradient: number): number;
  5313. /**
  5314. * Given an input gradient between 0 and 1, this returns the corresponding value
  5315. * of the easing function.
  5316. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5317. * @returns the corresponding value on the curve defined by the easing function
  5318. */
  5319. ease(gradient: number): number;
  5320. }
  5321. /**
  5322. * Easing function with a circle shape (see link below).
  5323. * @see https://easings.net/#easeInCirc
  5324. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5325. */
  5326. export class CircleEase extends EasingFunction implements IEasingFunction {
  5327. /** @hidden */
  5328. easeInCore(gradient: number): number;
  5329. }
  5330. /**
  5331. * Easing function with a ease back shape (see link below).
  5332. * @see https://easings.net/#easeInBack
  5333. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5334. */
  5335. export class BackEase extends EasingFunction implements IEasingFunction {
  5336. /** Defines the amplitude of the function */
  5337. amplitude: number;
  5338. /**
  5339. * Instantiates a back ease easing
  5340. * @see https://easings.net/#easeInBack
  5341. * @param amplitude Defines the amplitude of the function
  5342. */
  5343. constructor(
  5344. /** Defines the amplitude of the function */
  5345. amplitude?: number);
  5346. /** @hidden */
  5347. easeInCore(gradient: number): number;
  5348. }
  5349. /**
  5350. * Easing function with a bouncing shape (see link below).
  5351. * @see https://easings.net/#easeInBounce
  5352. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5353. */
  5354. export class BounceEase extends EasingFunction implements IEasingFunction {
  5355. /** Defines the number of bounces */
  5356. bounces: number;
  5357. /** Defines the amplitude of the bounce */
  5358. bounciness: number;
  5359. /**
  5360. * Instantiates a bounce easing
  5361. * @see https://easings.net/#easeInBounce
  5362. * @param bounces Defines the number of bounces
  5363. * @param bounciness Defines the amplitude of the bounce
  5364. */
  5365. constructor(
  5366. /** Defines the number of bounces */
  5367. bounces?: number,
  5368. /** Defines the amplitude of the bounce */
  5369. bounciness?: number);
  5370. /** @hidden */
  5371. easeInCore(gradient: number): number;
  5372. }
  5373. /**
  5374. * Easing function with a power of 3 shape (see link below).
  5375. * @see https://easings.net/#easeInCubic
  5376. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5377. */
  5378. export class CubicEase extends EasingFunction implements IEasingFunction {
  5379. /** @hidden */
  5380. easeInCore(gradient: number): number;
  5381. }
  5382. /**
  5383. * Easing function with an elastic shape (see link below).
  5384. * @see https://easings.net/#easeInElastic
  5385. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5386. */
  5387. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5388. /** Defines the number of oscillations*/
  5389. oscillations: number;
  5390. /** Defines the amplitude of the oscillations*/
  5391. springiness: number;
  5392. /**
  5393. * Instantiates an elastic easing function
  5394. * @see https://easings.net/#easeInElastic
  5395. * @param oscillations Defines the number of oscillations
  5396. * @param springiness Defines the amplitude of the oscillations
  5397. */
  5398. constructor(
  5399. /** Defines the number of oscillations*/
  5400. oscillations?: number,
  5401. /** Defines the amplitude of the oscillations*/
  5402. springiness?: number);
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with an exponential shape (see link below).
  5408. * @see https://easings.net/#easeInExpo
  5409. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5412. /** Defines the exponent of the function */
  5413. exponent: number;
  5414. /**
  5415. * Instantiates an exponential easing function
  5416. * @see https://easings.net/#easeInExpo
  5417. * @param exponent Defines the exponent of the function
  5418. */
  5419. constructor(
  5420. /** Defines the exponent of the function */
  5421. exponent?: number);
  5422. /** @hidden */
  5423. easeInCore(gradient: number): number;
  5424. }
  5425. /**
  5426. * Easing function with a power shape (see link below).
  5427. * @see https://easings.net/#easeInQuad
  5428. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5429. */
  5430. export class PowerEase extends EasingFunction implements IEasingFunction {
  5431. /** Defines the power of the function */
  5432. power: number;
  5433. /**
  5434. * Instantiates an power base easing function
  5435. * @see https://easings.net/#easeInQuad
  5436. * @param power Defines the power of the function
  5437. */
  5438. constructor(
  5439. /** Defines the power of the function */
  5440. power?: number);
  5441. /** @hidden */
  5442. easeInCore(gradient: number): number;
  5443. }
  5444. /**
  5445. * Easing function with a power of 2 shape (see link below).
  5446. * @see https://easings.net/#easeInQuad
  5447. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5448. */
  5449. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5450. /** @hidden */
  5451. easeInCore(gradient: number): number;
  5452. }
  5453. /**
  5454. * Easing function with a power of 4 shape (see link below).
  5455. * @see https://easings.net/#easeInQuart
  5456. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5457. */
  5458. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5459. /** @hidden */
  5460. easeInCore(gradient: number): number;
  5461. }
  5462. /**
  5463. * Easing function with a power of 5 shape (see link below).
  5464. * @see https://easings.net/#easeInQuint
  5465. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5466. */
  5467. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5468. /** @hidden */
  5469. easeInCore(gradient: number): number;
  5470. }
  5471. /**
  5472. * Easing function with a sin shape (see link below).
  5473. * @see https://easings.net/#easeInSine
  5474. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5475. */
  5476. export class SineEase extends EasingFunction implements IEasingFunction {
  5477. /** @hidden */
  5478. easeInCore(gradient: number): number;
  5479. }
  5480. /**
  5481. * Easing function with a bezier shape (see link below).
  5482. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5483. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5484. */
  5485. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5486. /** Defines the x component of the start tangent in the bezier curve */
  5487. x1: number;
  5488. /** Defines the y component of the start tangent in the bezier curve */
  5489. y1: number;
  5490. /** Defines the x component of the end tangent in the bezier curve */
  5491. x2: number;
  5492. /** Defines the y component of the end tangent in the bezier curve */
  5493. y2: number;
  5494. /**
  5495. * Instantiates a bezier function
  5496. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5497. * @param x1 Defines the x component of the start tangent in the bezier curve
  5498. * @param y1 Defines the y component of the start tangent in the bezier curve
  5499. * @param x2 Defines the x component of the end tangent in the bezier curve
  5500. * @param y2 Defines the y component of the end tangent in the bezier curve
  5501. */
  5502. constructor(
  5503. /** Defines the x component of the start tangent in the bezier curve */
  5504. x1?: number,
  5505. /** Defines the y component of the start tangent in the bezier curve */
  5506. y1?: number,
  5507. /** Defines the x component of the end tangent in the bezier curve */
  5508. x2?: number,
  5509. /** Defines the y component of the end tangent in the bezier curve */
  5510. y2?: number);
  5511. /** @hidden */
  5512. easeInCore(gradient: number): number;
  5513. }
  5514. }
  5515. declare module "babylonjs/Maths/math.color" {
  5516. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5517. /**
  5518. * Class used to hold a RBG color
  5519. */
  5520. export class Color3 {
  5521. /**
  5522. * Defines the red component (between 0 and 1, default is 0)
  5523. */
  5524. r: number;
  5525. /**
  5526. * Defines the green component (between 0 and 1, default is 0)
  5527. */
  5528. g: number;
  5529. /**
  5530. * Defines the blue component (between 0 and 1, default is 0)
  5531. */
  5532. b: number;
  5533. /**
  5534. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5535. * @param r defines the red component (between 0 and 1, default is 0)
  5536. * @param g defines the green component (between 0 and 1, default is 0)
  5537. * @param b defines the blue component (between 0 and 1, default is 0)
  5538. */
  5539. constructor(
  5540. /**
  5541. * Defines the red component (between 0 and 1, default is 0)
  5542. */
  5543. r?: number,
  5544. /**
  5545. * Defines the green component (between 0 and 1, default is 0)
  5546. */
  5547. g?: number,
  5548. /**
  5549. * Defines the blue component (between 0 and 1, default is 0)
  5550. */
  5551. b?: number);
  5552. /**
  5553. * Creates a string with the Color3 current values
  5554. * @returns the string representation of the Color3 object
  5555. */
  5556. toString(): string;
  5557. /**
  5558. * Returns the string "Color3"
  5559. * @returns "Color3"
  5560. */
  5561. getClassName(): string;
  5562. /**
  5563. * Compute the Color3 hash code
  5564. * @returns an unique number that can be used to hash Color3 objects
  5565. */
  5566. getHashCode(): number;
  5567. /**
  5568. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5569. * @param array defines the array where to store the r,g,b components
  5570. * @param index defines an optional index in the target array to define where to start storing values
  5571. * @returns the current Color3 object
  5572. */
  5573. toArray(array: FloatArray, index?: number): Color3;
  5574. /**
  5575. * Update the current color with values stored in an array from the starting index of the given array
  5576. * @param array defines the source array
  5577. * @param offset defines an offset in the source array
  5578. * @returns the current Color3 object
  5579. */
  5580. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5581. /**
  5582. * Returns a new Color4 object from the current Color3 and the given alpha
  5583. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5584. * @returns a new Color4 object
  5585. */
  5586. toColor4(alpha?: number): Color4;
  5587. /**
  5588. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5589. * @returns the new array
  5590. */
  5591. asArray(): number[];
  5592. /**
  5593. * Returns the luminance value
  5594. * @returns a float value
  5595. */
  5596. toLuminance(): number;
  5597. /**
  5598. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5599. * @param otherColor defines the second operand
  5600. * @returns the new Color3 object
  5601. */
  5602. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5603. /**
  5604. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5605. * @param otherColor defines the second operand
  5606. * @param result defines the Color3 object where to store the result
  5607. * @returns the current Color3
  5608. */
  5609. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5610. /**
  5611. * Determines equality between Color3 objects
  5612. * @param otherColor defines the second operand
  5613. * @returns true if the rgb values are equal to the given ones
  5614. */
  5615. equals(otherColor: DeepImmutable<Color3>): boolean;
  5616. /**
  5617. * Determines equality between the current Color3 object and a set of r,b,g values
  5618. * @param r defines the red component to check
  5619. * @param g defines the green component to check
  5620. * @param b defines the blue component to check
  5621. * @returns true if the rgb values are equal to the given ones
  5622. */
  5623. equalsFloats(r: number, g: number, b: number): boolean;
  5624. /**
  5625. * Multiplies in place each rgb value by scale
  5626. * @param scale defines the scaling factor
  5627. * @returns the updated Color3
  5628. */
  5629. scale(scale: number): Color3;
  5630. /**
  5631. * Multiplies the rgb values by scale and stores the result into "result"
  5632. * @param scale defines the scaling factor
  5633. * @param result defines the Color3 object where to store the result
  5634. * @returns the unmodified current Color3
  5635. */
  5636. scaleToRef(scale: number, result: Color3): Color3;
  5637. /**
  5638. * Scale the current Color3 values by a factor and add the result to a given Color3
  5639. * @param scale defines the scale factor
  5640. * @param result defines color to store the result into
  5641. * @returns the unmodified current Color3
  5642. */
  5643. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5644. /**
  5645. * Clamps the rgb values by the min and max values and stores the result into "result"
  5646. * @param min defines minimum clamping value (default is 0)
  5647. * @param max defines maximum clamping value (default is 1)
  5648. * @param result defines color to store the result into
  5649. * @returns the original Color3
  5650. */
  5651. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5652. /**
  5653. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5654. * @param otherColor defines the second operand
  5655. * @returns the new Color3
  5656. */
  5657. add(otherColor: DeepImmutable<Color3>): Color3;
  5658. /**
  5659. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5660. * @param otherColor defines the second operand
  5661. * @param result defines Color3 object to store the result into
  5662. * @returns the unmodified current Color3
  5663. */
  5664. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5665. /**
  5666. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5667. * @param otherColor defines the second operand
  5668. * @returns the new Color3
  5669. */
  5670. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5671. /**
  5672. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5673. * @param otherColor defines the second operand
  5674. * @param result defines Color3 object to store the result into
  5675. * @returns the unmodified current Color3
  5676. */
  5677. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5678. /**
  5679. * Copy the current object
  5680. * @returns a new Color3 copied the current one
  5681. */
  5682. clone(): Color3;
  5683. /**
  5684. * Copies the rgb values from the source in the current Color3
  5685. * @param source defines the source Color3 object
  5686. * @returns the updated Color3 object
  5687. */
  5688. copyFrom(source: DeepImmutable<Color3>): Color3;
  5689. /**
  5690. * Updates the Color3 rgb values from the given floats
  5691. * @param r defines the red component to read from
  5692. * @param g defines the green component to read from
  5693. * @param b defines the blue component to read from
  5694. * @returns the current Color3 object
  5695. */
  5696. copyFromFloats(r: number, g: number, b: number): Color3;
  5697. /**
  5698. * Updates the Color3 rgb values from the given floats
  5699. * @param r defines the red component to read from
  5700. * @param g defines the green component to read from
  5701. * @param b defines the blue component to read from
  5702. * @returns the current Color3 object
  5703. */
  5704. set(r: number, g: number, b: number): Color3;
  5705. /**
  5706. * Compute the Color3 hexadecimal code as a string
  5707. * @returns a string containing the hexadecimal representation of the Color3 object
  5708. */
  5709. toHexString(): string;
  5710. /**
  5711. * Computes a new Color3 converted from the current one to linear space
  5712. * @returns a new Color3 object
  5713. */
  5714. toLinearSpace(): Color3;
  5715. /**
  5716. * Converts current color in rgb space to HSV values
  5717. * @returns a new color3 representing the HSV values
  5718. */
  5719. toHSV(): Color3;
  5720. /**
  5721. * Converts current color in rgb space to HSV values
  5722. * @param result defines the Color3 where to store the HSV values
  5723. */
  5724. toHSVToRef(result: Color3): void;
  5725. /**
  5726. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5727. * @param convertedColor defines the Color3 object where to store the linear space version
  5728. * @returns the unmodified Color3
  5729. */
  5730. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5731. /**
  5732. * Computes a new Color3 converted from the current one to gamma space
  5733. * @returns a new Color3 object
  5734. */
  5735. toGammaSpace(): Color3;
  5736. /**
  5737. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5738. * @param convertedColor defines the Color3 object where to store the gamma space version
  5739. * @returns the unmodified Color3
  5740. */
  5741. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5742. private static _BlackReadOnly;
  5743. /**
  5744. * Convert Hue, saturation and value to a Color3 (RGB)
  5745. * @param hue defines the hue
  5746. * @param saturation defines the saturation
  5747. * @param value defines the value
  5748. * @param result defines the Color3 where to store the RGB values
  5749. */
  5750. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5751. /**
  5752. * Creates a new Color3 from the string containing valid hexadecimal values
  5753. * @param hex defines a string containing valid hexadecimal values
  5754. * @returns a new Color3 object
  5755. */
  5756. static FromHexString(hex: string): Color3;
  5757. /**
  5758. * Creates a new Color3 from the starting index of the given array
  5759. * @param array defines the source array
  5760. * @param offset defines an offset in the source array
  5761. * @returns a new Color3 object
  5762. */
  5763. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5764. /**
  5765. * Creates a new Color3 from the starting index element of the given array
  5766. * @param array defines the source array to read from
  5767. * @param offset defines the offset in the source array
  5768. * @param result defines the target Color3 object
  5769. */
  5770. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5771. /**
  5772. * Creates a new Color3 from integer values (< 256)
  5773. * @param r defines the red component to read from (value between 0 and 255)
  5774. * @param g defines the green component to read from (value between 0 and 255)
  5775. * @param b defines the blue component to read from (value between 0 and 255)
  5776. * @returns a new Color3 object
  5777. */
  5778. static FromInts(r: number, g: number, b: number): Color3;
  5779. /**
  5780. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5781. * @param start defines the start Color3 value
  5782. * @param end defines the end Color3 value
  5783. * @param amount defines the gradient value between start and end
  5784. * @returns a new Color3 object
  5785. */
  5786. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5787. /**
  5788. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5789. * @param left defines the start value
  5790. * @param right defines the end value
  5791. * @param amount defines the gradient factor
  5792. * @param result defines the Color3 object where to store the result
  5793. */
  5794. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5795. /**
  5796. * Returns a Color3 value containing a red color
  5797. * @returns a new Color3 object
  5798. */
  5799. static Red(): Color3;
  5800. /**
  5801. * Returns a Color3 value containing a green color
  5802. * @returns a new Color3 object
  5803. */
  5804. static Green(): Color3;
  5805. /**
  5806. * Returns a Color3 value containing a blue color
  5807. * @returns a new Color3 object
  5808. */
  5809. static Blue(): Color3;
  5810. /**
  5811. * Returns a Color3 value containing a black color
  5812. * @returns a new Color3 object
  5813. */
  5814. static Black(): Color3;
  5815. /**
  5816. * Gets a Color3 value containing a black color that must not be updated
  5817. */
  5818. static get BlackReadOnly(): DeepImmutable<Color3>;
  5819. /**
  5820. * Returns a Color3 value containing a white color
  5821. * @returns a new Color3 object
  5822. */
  5823. static White(): Color3;
  5824. /**
  5825. * Returns a Color3 value containing a purple color
  5826. * @returns a new Color3 object
  5827. */
  5828. static Purple(): Color3;
  5829. /**
  5830. * Returns a Color3 value containing a magenta color
  5831. * @returns a new Color3 object
  5832. */
  5833. static Magenta(): Color3;
  5834. /**
  5835. * Returns a Color3 value containing a yellow color
  5836. * @returns a new Color3 object
  5837. */
  5838. static Yellow(): Color3;
  5839. /**
  5840. * Returns a Color3 value containing a gray color
  5841. * @returns a new Color3 object
  5842. */
  5843. static Gray(): Color3;
  5844. /**
  5845. * Returns a Color3 value containing a teal color
  5846. * @returns a new Color3 object
  5847. */
  5848. static Teal(): Color3;
  5849. /**
  5850. * Returns a Color3 value containing a random color
  5851. * @returns a new Color3 object
  5852. */
  5853. static Random(): Color3;
  5854. }
  5855. /**
  5856. * Class used to hold a RBGA color
  5857. */
  5858. export class Color4 {
  5859. /**
  5860. * Defines the red component (between 0 and 1, default is 0)
  5861. */
  5862. r: number;
  5863. /**
  5864. * Defines the green component (between 0 and 1, default is 0)
  5865. */
  5866. g: number;
  5867. /**
  5868. * Defines the blue component (between 0 and 1, default is 0)
  5869. */
  5870. b: number;
  5871. /**
  5872. * Defines the alpha component (between 0 and 1, default is 1)
  5873. */
  5874. a: number;
  5875. /**
  5876. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5877. * @param r defines the red component (between 0 and 1, default is 0)
  5878. * @param g defines the green component (between 0 and 1, default is 0)
  5879. * @param b defines the blue component (between 0 and 1, default is 0)
  5880. * @param a defines the alpha component (between 0 and 1, default is 1)
  5881. */
  5882. constructor(
  5883. /**
  5884. * Defines the red component (between 0 and 1, default is 0)
  5885. */
  5886. r?: number,
  5887. /**
  5888. * Defines the green component (between 0 and 1, default is 0)
  5889. */
  5890. g?: number,
  5891. /**
  5892. * Defines the blue component (between 0 and 1, default is 0)
  5893. */
  5894. b?: number,
  5895. /**
  5896. * Defines the alpha component (between 0 and 1, default is 1)
  5897. */
  5898. a?: number);
  5899. /**
  5900. * Adds in place the given Color4 values to the current Color4 object
  5901. * @param right defines the second operand
  5902. * @returns the current updated Color4 object
  5903. */
  5904. addInPlace(right: DeepImmutable<Color4>): Color4;
  5905. /**
  5906. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5907. * @returns the new array
  5908. */
  5909. asArray(): number[];
  5910. /**
  5911. * Stores from the starting index in the given array the Color4 successive values
  5912. * @param array defines the array where to store the r,g,b components
  5913. * @param index defines an optional index in the target array to define where to start storing values
  5914. * @returns the current Color4 object
  5915. */
  5916. toArray(array: number[], index?: number): Color4;
  5917. /**
  5918. * Update the current color with values stored in an array from the starting index of the given array
  5919. * @param array defines the source array
  5920. * @param offset defines an offset in the source array
  5921. * @returns the current Color4 object
  5922. */
  5923. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5924. /**
  5925. * Determines equality between Color4 objects
  5926. * @param otherColor defines the second operand
  5927. * @returns true if the rgba values are equal to the given ones
  5928. */
  5929. equals(otherColor: DeepImmutable<Color4>): boolean;
  5930. /**
  5931. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5932. * @param right defines the second operand
  5933. * @returns a new Color4 object
  5934. */
  5935. add(right: DeepImmutable<Color4>): Color4;
  5936. /**
  5937. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5938. * @param right defines the second operand
  5939. * @returns a new Color4 object
  5940. */
  5941. subtract(right: DeepImmutable<Color4>): Color4;
  5942. /**
  5943. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5944. * @param right defines the second operand
  5945. * @param result defines the Color4 object where to store the result
  5946. * @returns the current Color4 object
  5947. */
  5948. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5949. /**
  5950. * Creates a new Color4 with the current Color4 values multiplied by scale
  5951. * @param scale defines the scaling factor to apply
  5952. * @returns a new Color4 object
  5953. */
  5954. scale(scale: number): Color4;
  5955. /**
  5956. * Multiplies the current Color4 values by scale and stores the result in "result"
  5957. * @param scale defines the scaling factor to apply
  5958. * @param result defines the Color4 object where to store the result
  5959. * @returns the current unmodified Color4
  5960. */
  5961. scaleToRef(scale: number, result: Color4): Color4;
  5962. /**
  5963. * Scale the current Color4 values by a factor and add the result to a given Color4
  5964. * @param scale defines the scale factor
  5965. * @param result defines the Color4 object where to store the result
  5966. * @returns the unmodified current Color4
  5967. */
  5968. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5969. /**
  5970. * Clamps the rgb values by the min and max values and stores the result into "result"
  5971. * @param min defines minimum clamping value (default is 0)
  5972. * @param max defines maximum clamping value (default is 1)
  5973. * @param result defines color to store the result into.
  5974. * @returns the cuurent Color4
  5975. */
  5976. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5977. /**
  5978. * Multipy an Color4 value by another and return a new Color4 object
  5979. * @param color defines the Color4 value to multiply by
  5980. * @returns a new Color4 object
  5981. */
  5982. multiply(color: Color4): Color4;
  5983. /**
  5984. * Multipy a Color4 value by another and push the result in a reference value
  5985. * @param color defines the Color4 value to multiply by
  5986. * @param result defines the Color4 to fill the result in
  5987. * @returns the result Color4
  5988. */
  5989. multiplyToRef(color: Color4, result: Color4): Color4;
  5990. /**
  5991. * Creates a string with the Color4 current values
  5992. * @returns the string representation of the Color4 object
  5993. */
  5994. toString(): string;
  5995. /**
  5996. * Returns the string "Color4"
  5997. * @returns "Color4"
  5998. */
  5999. getClassName(): string;
  6000. /**
  6001. * Compute the Color4 hash code
  6002. * @returns an unique number that can be used to hash Color4 objects
  6003. */
  6004. getHashCode(): number;
  6005. /**
  6006. * Creates a new Color4 copied from the current one
  6007. * @returns a new Color4 object
  6008. */
  6009. clone(): Color4;
  6010. /**
  6011. * Copies the given Color4 values into the current one
  6012. * @param source defines the source Color4 object
  6013. * @returns the current updated Color4 object
  6014. */
  6015. copyFrom(source: Color4): Color4;
  6016. /**
  6017. * Copies the given float values into the current one
  6018. * @param r defines the red component to read from
  6019. * @param g defines the green component to read from
  6020. * @param b defines the blue component to read from
  6021. * @param a defines the alpha component to read from
  6022. * @returns the current updated Color4 object
  6023. */
  6024. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6025. /**
  6026. * Copies the given float values into the current one
  6027. * @param r defines the red component to read from
  6028. * @param g defines the green component to read from
  6029. * @param b defines the blue component to read from
  6030. * @param a defines the alpha component to read from
  6031. * @returns the current updated Color4 object
  6032. */
  6033. set(r: number, g: number, b: number, a: number): Color4;
  6034. /**
  6035. * Compute the Color4 hexadecimal code as a string
  6036. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6037. * @returns a string containing the hexadecimal representation of the Color4 object
  6038. */
  6039. toHexString(returnAsColor3?: boolean): string;
  6040. /**
  6041. * Computes a new Color4 converted from the current one to linear space
  6042. * @returns a new Color4 object
  6043. */
  6044. toLinearSpace(): Color4;
  6045. /**
  6046. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6047. * @param convertedColor defines the Color4 object where to store the linear space version
  6048. * @returns the unmodified Color4
  6049. */
  6050. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6051. /**
  6052. * Computes a new Color4 converted from the current one to gamma space
  6053. * @returns a new Color4 object
  6054. */
  6055. toGammaSpace(): Color4;
  6056. /**
  6057. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6058. * @param convertedColor defines the Color4 object where to store the gamma space version
  6059. * @returns the unmodified Color4
  6060. */
  6061. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6062. /**
  6063. * Creates a new Color4 from the string containing valid hexadecimal values
  6064. * @param hex defines a string containing valid hexadecimal values
  6065. * @returns a new Color4 object
  6066. */
  6067. static FromHexString(hex: string): Color4;
  6068. /**
  6069. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6070. * @param left defines the start value
  6071. * @param right defines the end value
  6072. * @param amount defines the gradient factor
  6073. * @returns a new Color4 object
  6074. */
  6075. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6076. /**
  6077. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6078. * @param left defines the start value
  6079. * @param right defines the end value
  6080. * @param amount defines the gradient factor
  6081. * @param result defines the Color4 object where to store data
  6082. */
  6083. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6084. /**
  6085. * Creates a new Color4 from a Color3 and an alpha value
  6086. * @param color3 defines the source Color3 to read from
  6087. * @param alpha defines the alpha component (1.0 by default)
  6088. * @returns a new Color4 object
  6089. */
  6090. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6091. /**
  6092. * Creates a new Color4 from the starting index element of the given array
  6093. * @param array defines the source array to read from
  6094. * @param offset defines the offset in the source array
  6095. * @returns a new Color4 object
  6096. */
  6097. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6098. /**
  6099. * Creates a new Color4 from the starting index element of the given array
  6100. * @param array defines the source array to read from
  6101. * @param offset defines the offset in the source array
  6102. * @param result defines the target Color4 object
  6103. */
  6104. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6105. /**
  6106. * Creates a new Color3 from integer values (< 256)
  6107. * @param r defines the red component to read from (value between 0 and 255)
  6108. * @param g defines the green component to read from (value between 0 and 255)
  6109. * @param b defines the blue component to read from (value between 0 and 255)
  6110. * @param a defines the alpha component to read from (value between 0 and 255)
  6111. * @returns a new Color3 object
  6112. */
  6113. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6114. /**
  6115. * Check the content of a given array and convert it to an array containing RGBA data
  6116. * If the original array was already containing count * 4 values then it is returned directly
  6117. * @param colors defines the array to check
  6118. * @param count defines the number of RGBA data to expect
  6119. * @returns an array containing count * 4 values (RGBA)
  6120. */
  6121. static CheckColors4(colors: number[], count: number): number[];
  6122. }
  6123. /**
  6124. * @hidden
  6125. */
  6126. export class TmpColors {
  6127. static Color3: Color3[];
  6128. static Color4: Color4[];
  6129. }
  6130. }
  6131. declare module "babylonjs/Animations/animationKey" {
  6132. /**
  6133. * Defines an interface which represents an animation key frame
  6134. */
  6135. export interface IAnimationKey {
  6136. /**
  6137. * Frame of the key frame
  6138. */
  6139. frame: number;
  6140. /**
  6141. * Value at the specifies key frame
  6142. */
  6143. value: any;
  6144. /**
  6145. * The input tangent for the cubic hermite spline
  6146. */
  6147. inTangent?: any;
  6148. /**
  6149. * The output tangent for the cubic hermite spline
  6150. */
  6151. outTangent?: any;
  6152. /**
  6153. * The animation interpolation type
  6154. */
  6155. interpolation?: AnimationKeyInterpolation;
  6156. }
  6157. /**
  6158. * Enum for the animation key frame interpolation type
  6159. */
  6160. export enum AnimationKeyInterpolation {
  6161. /**
  6162. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6163. */
  6164. STEP = 1
  6165. }
  6166. }
  6167. declare module "babylonjs/Animations/animationRange" {
  6168. /**
  6169. * Represents the range of an animation
  6170. */
  6171. export class AnimationRange {
  6172. /**The name of the animation range**/
  6173. name: string;
  6174. /**The starting frame of the animation */
  6175. from: number;
  6176. /**The ending frame of the animation*/
  6177. to: number;
  6178. /**
  6179. * Initializes the range of an animation
  6180. * @param name The name of the animation range
  6181. * @param from The starting frame of the animation
  6182. * @param to The ending frame of the animation
  6183. */
  6184. constructor(
  6185. /**The name of the animation range**/
  6186. name: string,
  6187. /**The starting frame of the animation */
  6188. from: number,
  6189. /**The ending frame of the animation*/
  6190. to: number);
  6191. /**
  6192. * Makes a copy of the animation range
  6193. * @returns A copy of the animation range
  6194. */
  6195. clone(): AnimationRange;
  6196. }
  6197. }
  6198. declare module "babylonjs/Animations/animationEvent" {
  6199. /**
  6200. * Composed of a frame, and an action function
  6201. */
  6202. export class AnimationEvent {
  6203. /** The frame for which the event is triggered **/
  6204. frame: number;
  6205. /** The event to perform when triggered **/
  6206. action: (currentFrame: number) => void;
  6207. /** Specifies if the event should be triggered only once**/
  6208. onlyOnce?: boolean | undefined;
  6209. /**
  6210. * Specifies if the animation event is done
  6211. */
  6212. isDone: boolean;
  6213. /**
  6214. * Initializes the animation event
  6215. * @param frame The frame for which the event is triggered
  6216. * @param action The event to perform when triggered
  6217. * @param onlyOnce Specifies if the event should be triggered only once
  6218. */
  6219. constructor(
  6220. /** The frame for which the event is triggered **/
  6221. frame: number,
  6222. /** The event to perform when triggered **/
  6223. action: (currentFrame: number) => void,
  6224. /** Specifies if the event should be triggered only once**/
  6225. onlyOnce?: boolean | undefined);
  6226. /** @hidden */
  6227. _clone(): AnimationEvent;
  6228. }
  6229. }
  6230. declare module "babylonjs/Behaviors/behavior" {
  6231. import { Nullable } from "babylonjs/types";
  6232. /**
  6233. * Interface used to define a behavior
  6234. */
  6235. export interface Behavior<T> {
  6236. /** gets or sets behavior's name */
  6237. name: string;
  6238. /**
  6239. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6240. */
  6241. init(): void;
  6242. /**
  6243. * Called when the behavior is attached to a target
  6244. * @param target defines the target where the behavior is attached to
  6245. */
  6246. attach(target: T): void;
  6247. /**
  6248. * Called when the behavior is detached from its target
  6249. */
  6250. detach(): void;
  6251. }
  6252. /**
  6253. * Interface implemented by classes supporting behaviors
  6254. */
  6255. export interface IBehaviorAware<T> {
  6256. /**
  6257. * Attach a behavior
  6258. * @param behavior defines the behavior to attach
  6259. * @returns the current host
  6260. */
  6261. addBehavior(behavior: Behavior<T>): T;
  6262. /**
  6263. * Remove a behavior from the current object
  6264. * @param behavior defines the behavior to detach
  6265. * @returns the current host
  6266. */
  6267. removeBehavior(behavior: Behavior<T>): T;
  6268. /**
  6269. * Gets a behavior using its name to search
  6270. * @param name defines the name to search
  6271. * @returns the behavior or null if not found
  6272. */
  6273. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6274. }
  6275. }
  6276. declare module "babylonjs/Misc/smartArray" {
  6277. /**
  6278. * Defines an array and its length.
  6279. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6280. */
  6281. export interface ISmartArrayLike<T> {
  6282. /**
  6283. * The data of the array.
  6284. */
  6285. data: Array<T>;
  6286. /**
  6287. * The active length of the array.
  6288. */
  6289. length: number;
  6290. }
  6291. /**
  6292. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6293. */
  6294. export class SmartArray<T> implements ISmartArrayLike<T> {
  6295. /**
  6296. * The full set of data from the array.
  6297. */
  6298. data: Array<T>;
  6299. /**
  6300. * The active length of the array.
  6301. */
  6302. length: number;
  6303. protected _id: number;
  6304. /**
  6305. * Instantiates a Smart Array.
  6306. * @param capacity defines the default capacity of the array.
  6307. */
  6308. constructor(capacity: number);
  6309. /**
  6310. * Pushes a value at the end of the active data.
  6311. * @param value defines the object to push in the array.
  6312. */
  6313. push(value: T): void;
  6314. /**
  6315. * Iterates over the active data and apply the lambda to them.
  6316. * @param func defines the action to apply on each value.
  6317. */
  6318. forEach(func: (content: T) => void): void;
  6319. /**
  6320. * Sorts the full sets of data.
  6321. * @param compareFn defines the comparison function to apply.
  6322. */
  6323. sort(compareFn: (a: T, b: T) => number): void;
  6324. /**
  6325. * Resets the active data to an empty array.
  6326. */
  6327. reset(): void;
  6328. /**
  6329. * Releases all the data from the array as well as the array.
  6330. */
  6331. dispose(): void;
  6332. /**
  6333. * Concats the active data with a given array.
  6334. * @param array defines the data to concatenate with.
  6335. */
  6336. concat(array: any): void;
  6337. /**
  6338. * Returns the position of a value in the active data.
  6339. * @param value defines the value to find the index for
  6340. * @returns the index if found in the active data otherwise -1
  6341. */
  6342. indexOf(value: T): number;
  6343. /**
  6344. * Returns whether an element is part of the active data.
  6345. * @param value defines the value to look for
  6346. * @returns true if found in the active data otherwise false
  6347. */
  6348. contains(value: T): boolean;
  6349. private static _GlobalId;
  6350. }
  6351. /**
  6352. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6353. * The data in this array can only be present once
  6354. */
  6355. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6356. private _duplicateId;
  6357. /**
  6358. * Pushes a value at the end of the active data.
  6359. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6360. * @param value defines the object to push in the array.
  6361. */
  6362. push(value: T): void;
  6363. /**
  6364. * Pushes a value at the end of the active data.
  6365. * If the data is already present, it won t be added again
  6366. * @param value defines the object to push in the array.
  6367. * @returns true if added false if it was already present
  6368. */
  6369. pushNoDuplicate(value: T): boolean;
  6370. /**
  6371. * Resets the active data to an empty array.
  6372. */
  6373. reset(): void;
  6374. /**
  6375. * Concats the active data with a given array.
  6376. * This ensures no dupplicate will be present in the result.
  6377. * @param array defines the data to concatenate with.
  6378. */
  6379. concatWithNoDuplicate(array: any): void;
  6380. }
  6381. }
  6382. declare module "babylonjs/Cameras/cameraInputsManager" {
  6383. import { Nullable } from "babylonjs/types";
  6384. import { Camera } from "babylonjs/Cameras/camera";
  6385. /**
  6386. * @ignore
  6387. * This is a list of all the different input types that are available in the application.
  6388. * Fo instance: ArcRotateCameraGamepadInput...
  6389. */
  6390. export var CameraInputTypes: {};
  6391. /**
  6392. * This is the contract to implement in order to create a new input class.
  6393. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6394. */
  6395. export interface ICameraInput<TCamera extends Camera> {
  6396. /**
  6397. * Defines the camera the input is attached to.
  6398. */
  6399. camera: Nullable<TCamera>;
  6400. /**
  6401. * Gets the class name of the current intput.
  6402. * @returns the class name
  6403. */
  6404. getClassName(): string;
  6405. /**
  6406. * Get the friendly name associated with the input class.
  6407. * @returns the input friendly name
  6408. */
  6409. getSimpleName(): string;
  6410. /**
  6411. * Attach the input controls to a specific dom element to get the input from.
  6412. * @param element Defines the element the controls should be listened from
  6413. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6414. */
  6415. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6416. /**
  6417. * Detach the current controls from the specified dom element.
  6418. * @param element Defines the element to stop listening the inputs from
  6419. */
  6420. detachControl(element: Nullable<HTMLElement>): void;
  6421. /**
  6422. * Update the current camera state depending on the inputs that have been used this frame.
  6423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6424. */
  6425. checkInputs?: () => void;
  6426. }
  6427. /**
  6428. * Represents a map of input types to input instance or input index to input instance.
  6429. */
  6430. export interface CameraInputsMap<TCamera extends Camera> {
  6431. /**
  6432. * Accessor to the input by input type.
  6433. */
  6434. [name: string]: ICameraInput<TCamera>;
  6435. /**
  6436. * Accessor to the input by input index.
  6437. */
  6438. [idx: number]: ICameraInput<TCamera>;
  6439. }
  6440. /**
  6441. * This represents the input manager used within a camera.
  6442. * It helps dealing with all the different kind of input attached to a camera.
  6443. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6444. */
  6445. export class CameraInputsManager<TCamera extends Camera> {
  6446. /**
  6447. * Defines the list of inputs attahed to the camera.
  6448. */
  6449. attached: CameraInputsMap<TCamera>;
  6450. /**
  6451. * Defines the dom element the camera is collecting inputs from.
  6452. * This is null if the controls have not been attached.
  6453. */
  6454. attachedElement: Nullable<HTMLElement>;
  6455. /**
  6456. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6457. */
  6458. noPreventDefault: boolean;
  6459. /**
  6460. * Defined the camera the input manager belongs to.
  6461. */
  6462. camera: TCamera;
  6463. /**
  6464. * Update the current camera state depending on the inputs that have been used this frame.
  6465. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6466. */
  6467. checkInputs: () => void;
  6468. /**
  6469. * Instantiate a new Camera Input Manager.
  6470. * @param camera Defines the camera the input manager blongs to
  6471. */
  6472. constructor(camera: TCamera);
  6473. /**
  6474. * Add an input method to a camera
  6475. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6476. * @param input camera input method
  6477. */
  6478. add(input: ICameraInput<TCamera>): void;
  6479. /**
  6480. * Remove a specific input method from a camera
  6481. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6482. * @param inputToRemove camera input method
  6483. */
  6484. remove(inputToRemove: ICameraInput<TCamera>): void;
  6485. /**
  6486. * Remove a specific input type from a camera
  6487. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6488. * @param inputType the type of the input to remove
  6489. */
  6490. removeByType(inputType: string): void;
  6491. private _addCheckInputs;
  6492. /**
  6493. * Attach the input controls to the currently attached dom element to listen the events from.
  6494. * @param input Defines the input to attach
  6495. */
  6496. attachInput(input: ICameraInput<TCamera>): void;
  6497. /**
  6498. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6499. * @param element Defines the dom element to collect the events from
  6500. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6501. */
  6502. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6503. /**
  6504. * Detach the current manager inputs controls from a specific dom element.
  6505. * @param element Defines the dom element to collect the events from
  6506. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6507. */
  6508. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6509. /**
  6510. * Rebuild the dynamic inputCheck function from the current list of
  6511. * defined inputs in the manager.
  6512. */
  6513. rebuildInputCheck(): void;
  6514. /**
  6515. * Remove all attached input methods from a camera
  6516. */
  6517. clear(): void;
  6518. /**
  6519. * Serialize the current input manager attached to a camera.
  6520. * This ensures than once parsed,
  6521. * the input associated to the camera will be identical to the current ones
  6522. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6523. */
  6524. serialize(serializedCamera: any): void;
  6525. /**
  6526. * Parses an input manager serialized JSON to restore the previous list of inputs
  6527. * and states associated to a camera.
  6528. * @param parsedCamera Defines the JSON to parse
  6529. */
  6530. parse(parsedCamera: any): void;
  6531. }
  6532. }
  6533. declare module "babylonjs/Meshes/buffer" {
  6534. import { Nullable, DataArray } from "babylonjs/types";
  6535. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6536. /**
  6537. * Class used to store data that will be store in GPU memory
  6538. */
  6539. export class Buffer {
  6540. private _engine;
  6541. private _buffer;
  6542. /** @hidden */
  6543. _data: Nullable<DataArray>;
  6544. private _updatable;
  6545. private _instanced;
  6546. private _divisor;
  6547. /**
  6548. * Gets the byte stride.
  6549. */
  6550. readonly byteStride: number;
  6551. /**
  6552. * Constructor
  6553. * @param engine the engine
  6554. * @param data the data to use for this buffer
  6555. * @param updatable whether the data is updatable
  6556. * @param stride the stride (optional)
  6557. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6558. * @param instanced whether the buffer is instanced (optional)
  6559. * @param useBytes set to true if the stride in in bytes (optional)
  6560. * @param divisor sets an optional divisor for instances (1 by default)
  6561. */
  6562. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6563. /**
  6564. * Create a new VertexBuffer based on the current buffer
  6565. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6566. * @param offset defines offset in the buffer (0 by default)
  6567. * @param size defines the size in floats of attributes (position is 3 for instance)
  6568. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6569. * @param instanced defines if the vertex buffer contains indexed data
  6570. * @param useBytes defines if the offset and stride are in bytes *
  6571. * @param divisor sets an optional divisor for instances (1 by default)
  6572. * @returns the new vertex buffer
  6573. */
  6574. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6575. /**
  6576. * Gets a boolean indicating if the Buffer is updatable?
  6577. * @returns true if the buffer is updatable
  6578. */
  6579. isUpdatable(): boolean;
  6580. /**
  6581. * Gets current buffer's data
  6582. * @returns a DataArray or null
  6583. */
  6584. getData(): Nullable<DataArray>;
  6585. /**
  6586. * Gets underlying native buffer
  6587. * @returns underlying native buffer
  6588. */
  6589. getBuffer(): Nullable<DataBuffer>;
  6590. /**
  6591. * Gets the stride in float32 units (i.e. byte stride / 4).
  6592. * May not be an integer if the byte stride is not divisible by 4.
  6593. * @returns the stride in float32 units
  6594. * @deprecated Please use byteStride instead.
  6595. */
  6596. getStrideSize(): number;
  6597. /**
  6598. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6599. * @param data defines the data to store
  6600. */
  6601. create(data?: Nullable<DataArray>): void;
  6602. /** @hidden */
  6603. _rebuild(): void;
  6604. /**
  6605. * Update current buffer data
  6606. * @param data defines the data to store
  6607. */
  6608. update(data: DataArray): void;
  6609. /**
  6610. * Updates the data directly.
  6611. * @param data the new data
  6612. * @param offset the new offset
  6613. * @param vertexCount the vertex count (optional)
  6614. * @param useBytes set to true if the offset is in bytes
  6615. */
  6616. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6617. /**
  6618. * Release all resources
  6619. */
  6620. dispose(): void;
  6621. }
  6622. /**
  6623. * Specialized buffer used to store vertex data
  6624. */
  6625. export class VertexBuffer {
  6626. /** @hidden */
  6627. _buffer: Buffer;
  6628. private _kind;
  6629. private _size;
  6630. private _ownsBuffer;
  6631. private _instanced;
  6632. private _instanceDivisor;
  6633. /**
  6634. * The byte type.
  6635. */
  6636. static readonly BYTE: number;
  6637. /**
  6638. * The unsigned byte type.
  6639. */
  6640. static readonly UNSIGNED_BYTE: number;
  6641. /**
  6642. * The short type.
  6643. */
  6644. static readonly SHORT: number;
  6645. /**
  6646. * The unsigned short type.
  6647. */
  6648. static readonly UNSIGNED_SHORT: number;
  6649. /**
  6650. * The integer type.
  6651. */
  6652. static readonly INT: number;
  6653. /**
  6654. * The unsigned integer type.
  6655. */
  6656. static readonly UNSIGNED_INT: number;
  6657. /**
  6658. * The float type.
  6659. */
  6660. static readonly FLOAT: number;
  6661. /**
  6662. * Gets or sets the instance divisor when in instanced mode
  6663. */
  6664. get instanceDivisor(): number;
  6665. set instanceDivisor(value: number);
  6666. /**
  6667. * Gets the byte stride.
  6668. */
  6669. readonly byteStride: number;
  6670. /**
  6671. * Gets the byte offset.
  6672. */
  6673. readonly byteOffset: number;
  6674. /**
  6675. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6676. */
  6677. readonly normalized: boolean;
  6678. /**
  6679. * Gets the data type of each component in the array.
  6680. */
  6681. readonly type: number;
  6682. /**
  6683. * Constructor
  6684. * @param engine the engine
  6685. * @param data the data to use for this vertex buffer
  6686. * @param kind the vertex buffer kind
  6687. * @param updatable whether the data is updatable
  6688. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6689. * @param stride the stride (optional)
  6690. * @param instanced whether the buffer is instanced (optional)
  6691. * @param offset the offset of the data (optional)
  6692. * @param size the number of components (optional)
  6693. * @param type the type of the component (optional)
  6694. * @param normalized whether the data contains normalized data (optional)
  6695. * @param useBytes set to true if stride and offset are in bytes (optional)
  6696. * @param divisor defines the instance divisor to use (1 by default)
  6697. */
  6698. 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);
  6699. /** @hidden */
  6700. _rebuild(): void;
  6701. /**
  6702. * Returns the kind of the VertexBuffer (string)
  6703. * @returns a string
  6704. */
  6705. getKind(): string;
  6706. /**
  6707. * Gets a boolean indicating if the VertexBuffer is updatable?
  6708. * @returns true if the buffer is updatable
  6709. */
  6710. isUpdatable(): boolean;
  6711. /**
  6712. * Gets current buffer's data
  6713. * @returns a DataArray or null
  6714. */
  6715. getData(): Nullable<DataArray>;
  6716. /**
  6717. * Gets underlying native buffer
  6718. * @returns underlying native buffer
  6719. */
  6720. getBuffer(): Nullable<DataBuffer>;
  6721. /**
  6722. * Gets the stride in float32 units (i.e. byte stride / 4).
  6723. * May not be an integer if the byte stride is not divisible by 4.
  6724. * @returns the stride in float32 units
  6725. * @deprecated Please use byteStride instead.
  6726. */
  6727. getStrideSize(): number;
  6728. /**
  6729. * Returns the offset as a multiple of the type byte length.
  6730. * @returns the offset in bytes
  6731. * @deprecated Please use byteOffset instead.
  6732. */
  6733. getOffset(): number;
  6734. /**
  6735. * Returns the number of components per vertex attribute (integer)
  6736. * @returns the size in float
  6737. */
  6738. getSize(): number;
  6739. /**
  6740. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6741. * @returns true if this buffer is instanced
  6742. */
  6743. getIsInstanced(): boolean;
  6744. /**
  6745. * Returns the instancing divisor, zero for non-instanced (integer).
  6746. * @returns a number
  6747. */
  6748. getInstanceDivisor(): number;
  6749. /**
  6750. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6751. * @param data defines the data to store
  6752. */
  6753. create(data?: DataArray): void;
  6754. /**
  6755. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6756. * This function will create a new buffer if the current one is not updatable
  6757. * @param data defines the data to store
  6758. */
  6759. update(data: DataArray): void;
  6760. /**
  6761. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6762. * Returns the directly updated WebGLBuffer.
  6763. * @param data the new data
  6764. * @param offset the new offset
  6765. * @param useBytes set to true if the offset is in bytes
  6766. */
  6767. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6768. /**
  6769. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6770. */
  6771. dispose(): void;
  6772. /**
  6773. * Enumerates each value of this vertex buffer as numbers.
  6774. * @param count the number of values to enumerate
  6775. * @param callback the callback function called for each value
  6776. */
  6777. forEach(count: number, callback: (value: number, index: number) => void): void;
  6778. /**
  6779. * Positions
  6780. */
  6781. static readonly PositionKind: string;
  6782. /**
  6783. * Normals
  6784. */
  6785. static readonly NormalKind: string;
  6786. /**
  6787. * Tangents
  6788. */
  6789. static readonly TangentKind: string;
  6790. /**
  6791. * Texture coordinates
  6792. */
  6793. static readonly UVKind: string;
  6794. /**
  6795. * Texture coordinates 2
  6796. */
  6797. static readonly UV2Kind: string;
  6798. /**
  6799. * Texture coordinates 3
  6800. */
  6801. static readonly UV3Kind: string;
  6802. /**
  6803. * Texture coordinates 4
  6804. */
  6805. static readonly UV4Kind: string;
  6806. /**
  6807. * Texture coordinates 5
  6808. */
  6809. static readonly UV5Kind: string;
  6810. /**
  6811. * Texture coordinates 6
  6812. */
  6813. static readonly UV6Kind: string;
  6814. /**
  6815. * Colors
  6816. */
  6817. static readonly ColorKind: string;
  6818. /**
  6819. * Matrix indices (for bones)
  6820. */
  6821. static readonly MatricesIndicesKind: string;
  6822. /**
  6823. * Matrix weights (for bones)
  6824. */
  6825. static readonly MatricesWeightsKind: string;
  6826. /**
  6827. * Additional matrix indices (for bones)
  6828. */
  6829. static readonly MatricesIndicesExtraKind: string;
  6830. /**
  6831. * Additional matrix weights (for bones)
  6832. */
  6833. static readonly MatricesWeightsExtraKind: string;
  6834. /**
  6835. * Deduces the stride given a kind.
  6836. * @param kind The kind string to deduce
  6837. * @returns The deduced stride
  6838. */
  6839. static DeduceStride(kind: string): number;
  6840. /**
  6841. * Gets the byte length of the given type.
  6842. * @param type the type
  6843. * @returns the number of bytes
  6844. */
  6845. static GetTypeByteLength(type: number): number;
  6846. /**
  6847. * Enumerates each value of the given parameters as numbers.
  6848. * @param data the data to enumerate
  6849. * @param byteOffset the byte offset of the data
  6850. * @param byteStride the byte stride of the data
  6851. * @param componentCount the number of components per element
  6852. * @param componentType the type of the component
  6853. * @param count the number of values to enumerate
  6854. * @param normalized whether the data is normalized
  6855. * @param callback the callback function called for each value
  6856. */
  6857. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6858. private static _GetFloatValue;
  6859. }
  6860. }
  6861. declare module "babylonjs/Collisions/intersectionInfo" {
  6862. import { Nullable } from "babylonjs/types";
  6863. /**
  6864. * @hidden
  6865. */
  6866. export class IntersectionInfo {
  6867. bu: Nullable<number>;
  6868. bv: Nullable<number>;
  6869. distance: number;
  6870. faceId: number;
  6871. subMeshId: number;
  6872. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6873. }
  6874. }
  6875. declare module "babylonjs/Culling/boundingSphere" {
  6876. import { DeepImmutable } from "babylonjs/types";
  6877. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6878. import { Plane } from "babylonjs/Maths/math.plane";
  6879. /**
  6880. * Class used to store bounding sphere information
  6881. */
  6882. export class BoundingSphere {
  6883. /**
  6884. * Gets the center of the bounding sphere in local space
  6885. */
  6886. readonly center: Vector3;
  6887. /**
  6888. * Radius of the bounding sphere in local space
  6889. */
  6890. radius: number;
  6891. /**
  6892. * Gets the center of the bounding sphere in world space
  6893. */
  6894. readonly centerWorld: Vector3;
  6895. /**
  6896. * Radius of the bounding sphere in world space
  6897. */
  6898. radiusWorld: number;
  6899. /**
  6900. * Gets the minimum vector in local space
  6901. */
  6902. readonly minimum: Vector3;
  6903. /**
  6904. * Gets the maximum vector in local space
  6905. */
  6906. readonly maximum: Vector3;
  6907. private _worldMatrix;
  6908. private static readonly TmpVector3;
  6909. /**
  6910. * Creates a new bounding sphere
  6911. * @param min defines the minimum vector (in local space)
  6912. * @param max defines the maximum vector (in local space)
  6913. * @param worldMatrix defines the new world matrix
  6914. */
  6915. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6916. /**
  6917. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6918. * @param min defines the new minimum vector (in local space)
  6919. * @param max defines the new maximum vector (in local space)
  6920. * @param worldMatrix defines the new world matrix
  6921. */
  6922. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6923. /**
  6924. * Scale the current bounding sphere by applying a scale factor
  6925. * @param factor defines the scale factor to apply
  6926. * @returns the current bounding box
  6927. */
  6928. scale(factor: number): BoundingSphere;
  6929. /**
  6930. * Gets the world matrix of the bounding box
  6931. * @returns a matrix
  6932. */
  6933. getWorldMatrix(): DeepImmutable<Matrix>;
  6934. /** @hidden */
  6935. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6936. /**
  6937. * Tests if the bounding sphere is intersecting the frustum planes
  6938. * @param frustumPlanes defines the frustum planes to test
  6939. * @returns true if there is an intersection
  6940. */
  6941. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6942. /**
  6943. * Tests if the bounding sphere center is in between the frustum planes.
  6944. * Used for optimistic fast inclusion.
  6945. * @param frustumPlanes defines the frustum planes to test
  6946. * @returns true if the sphere center is in between the frustum planes
  6947. */
  6948. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6949. /**
  6950. * Tests if a point is inside the bounding sphere
  6951. * @param point defines the point to test
  6952. * @returns true if the point is inside the bounding sphere
  6953. */
  6954. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6955. /**
  6956. * Checks if two sphere intersct
  6957. * @param sphere0 sphere 0
  6958. * @param sphere1 sphere 1
  6959. * @returns true if the speres intersect
  6960. */
  6961. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6962. }
  6963. }
  6964. declare module "babylonjs/Culling/boundingBox" {
  6965. import { DeepImmutable } from "babylonjs/types";
  6966. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6967. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6968. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6969. import { Plane } from "babylonjs/Maths/math.plane";
  6970. /**
  6971. * Class used to store bounding box information
  6972. */
  6973. export class BoundingBox implements ICullable {
  6974. /**
  6975. * Gets the 8 vectors representing the bounding box in local space
  6976. */
  6977. readonly vectors: Vector3[];
  6978. /**
  6979. * Gets the center of the bounding box in local space
  6980. */
  6981. readonly center: Vector3;
  6982. /**
  6983. * Gets the center of the bounding box in world space
  6984. */
  6985. readonly centerWorld: Vector3;
  6986. /**
  6987. * Gets the extend size in local space
  6988. */
  6989. readonly extendSize: Vector3;
  6990. /**
  6991. * Gets the extend size in world space
  6992. */
  6993. readonly extendSizeWorld: Vector3;
  6994. /**
  6995. * Gets the OBB (object bounding box) directions
  6996. */
  6997. readonly directions: Vector3[];
  6998. /**
  6999. * Gets the 8 vectors representing the bounding box in world space
  7000. */
  7001. readonly vectorsWorld: Vector3[];
  7002. /**
  7003. * Gets the minimum vector in world space
  7004. */
  7005. readonly minimumWorld: Vector3;
  7006. /**
  7007. * Gets the maximum vector in world space
  7008. */
  7009. readonly maximumWorld: Vector3;
  7010. /**
  7011. * Gets the minimum vector in local space
  7012. */
  7013. readonly minimum: Vector3;
  7014. /**
  7015. * Gets the maximum vector in local space
  7016. */
  7017. readonly maximum: Vector3;
  7018. private _worldMatrix;
  7019. private static readonly TmpVector3;
  7020. /**
  7021. * @hidden
  7022. */
  7023. _tag: number;
  7024. /**
  7025. * Creates a new bounding box
  7026. * @param min defines the minimum vector (in local space)
  7027. * @param max defines the maximum vector (in local space)
  7028. * @param worldMatrix defines the new world matrix
  7029. */
  7030. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7031. /**
  7032. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7033. * @param min defines the new minimum vector (in local space)
  7034. * @param max defines the new maximum vector (in local space)
  7035. * @param worldMatrix defines the new world matrix
  7036. */
  7037. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7038. /**
  7039. * Scale the current bounding box by applying a scale factor
  7040. * @param factor defines the scale factor to apply
  7041. * @returns the current bounding box
  7042. */
  7043. scale(factor: number): BoundingBox;
  7044. /**
  7045. * Gets the world matrix of the bounding box
  7046. * @returns a matrix
  7047. */
  7048. getWorldMatrix(): DeepImmutable<Matrix>;
  7049. /** @hidden */
  7050. _update(world: DeepImmutable<Matrix>): void;
  7051. /**
  7052. * Tests if the bounding box is intersecting the frustum planes
  7053. * @param frustumPlanes defines the frustum planes to test
  7054. * @returns true if there is an intersection
  7055. */
  7056. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7057. /**
  7058. * Tests if the bounding box is entirely inside the frustum planes
  7059. * @param frustumPlanes defines the frustum planes to test
  7060. * @returns true if there is an inclusion
  7061. */
  7062. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7063. /**
  7064. * Tests if a point is inside the bounding box
  7065. * @param point defines the point to test
  7066. * @returns true if the point is inside the bounding box
  7067. */
  7068. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7069. /**
  7070. * Tests if the bounding box intersects with a bounding sphere
  7071. * @param sphere defines the sphere to test
  7072. * @returns true if there is an intersection
  7073. */
  7074. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7075. /**
  7076. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7077. * @param min defines the min vector to use
  7078. * @param max defines the max vector to use
  7079. * @returns true if there is an intersection
  7080. */
  7081. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7082. /**
  7083. * Tests if two bounding boxes are intersections
  7084. * @param box0 defines the first box to test
  7085. * @param box1 defines the second box to test
  7086. * @returns true if there is an intersection
  7087. */
  7088. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7089. /**
  7090. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7091. * @param minPoint defines the minimum vector of the bounding box
  7092. * @param maxPoint defines the maximum vector of the bounding box
  7093. * @param sphereCenter defines the sphere center
  7094. * @param sphereRadius defines the sphere radius
  7095. * @returns true if there is an intersection
  7096. */
  7097. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7098. /**
  7099. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7100. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7101. * @param frustumPlanes defines the frustum planes to test
  7102. * @return true if there is an inclusion
  7103. */
  7104. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7105. /**
  7106. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7107. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7108. * @param frustumPlanes defines the frustum planes to test
  7109. * @return true if there is an intersection
  7110. */
  7111. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7112. }
  7113. }
  7114. declare module "babylonjs/Collisions/collider" {
  7115. import { Nullable, IndicesArray } from "babylonjs/types";
  7116. import { Vector3 } from "babylonjs/Maths/math.vector";
  7117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7118. import { Plane } from "babylonjs/Maths/math.plane";
  7119. /** @hidden */
  7120. export class Collider {
  7121. /** Define if a collision was found */
  7122. collisionFound: boolean;
  7123. /**
  7124. * Define last intersection point in local space
  7125. */
  7126. intersectionPoint: Vector3;
  7127. /**
  7128. * Define last collided mesh
  7129. */
  7130. collidedMesh: Nullable<AbstractMesh>;
  7131. private _collisionPoint;
  7132. private _planeIntersectionPoint;
  7133. private _tempVector;
  7134. private _tempVector2;
  7135. private _tempVector3;
  7136. private _tempVector4;
  7137. private _edge;
  7138. private _baseToVertex;
  7139. private _destinationPoint;
  7140. private _slidePlaneNormal;
  7141. private _displacementVector;
  7142. /** @hidden */
  7143. _radius: Vector3;
  7144. /** @hidden */
  7145. _retry: number;
  7146. private _velocity;
  7147. private _basePoint;
  7148. private _epsilon;
  7149. /** @hidden */
  7150. _velocityWorldLength: number;
  7151. /** @hidden */
  7152. _basePointWorld: Vector3;
  7153. private _velocityWorld;
  7154. private _normalizedVelocity;
  7155. /** @hidden */
  7156. _initialVelocity: Vector3;
  7157. /** @hidden */
  7158. _initialPosition: Vector3;
  7159. private _nearestDistance;
  7160. private _collisionMask;
  7161. get collisionMask(): number;
  7162. set collisionMask(mask: number);
  7163. /**
  7164. * Gets the plane normal used to compute the sliding response (in local space)
  7165. */
  7166. get slidePlaneNormal(): Vector3;
  7167. /** @hidden */
  7168. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7169. /** @hidden */
  7170. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7171. /** @hidden */
  7172. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7173. /** @hidden */
  7174. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7175. /** @hidden */
  7176. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7177. /** @hidden */
  7178. _getResponse(pos: Vector3, vel: Vector3): void;
  7179. }
  7180. }
  7181. declare module "babylonjs/Culling/boundingInfo" {
  7182. import { DeepImmutable } from "babylonjs/types";
  7183. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7184. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7185. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7186. import { Plane } from "babylonjs/Maths/math.plane";
  7187. import { Collider } from "babylonjs/Collisions/collider";
  7188. /**
  7189. * Interface for cullable objects
  7190. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7191. */
  7192. export interface ICullable {
  7193. /**
  7194. * Checks if the object or part of the object is in the frustum
  7195. * @param frustumPlanes Camera near/planes
  7196. * @returns true if the object is in frustum otherwise false
  7197. */
  7198. isInFrustum(frustumPlanes: Plane[]): boolean;
  7199. /**
  7200. * Checks if a cullable object (mesh...) is in the camera frustum
  7201. * Unlike isInFrustum this cheks the full bounding box
  7202. * @param frustumPlanes Camera near/planes
  7203. * @returns true if the object is in frustum otherwise false
  7204. */
  7205. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7206. }
  7207. /**
  7208. * Info for a bounding data of a mesh
  7209. */
  7210. export class BoundingInfo implements ICullable {
  7211. /**
  7212. * Bounding box for the mesh
  7213. */
  7214. readonly boundingBox: BoundingBox;
  7215. /**
  7216. * Bounding sphere for the mesh
  7217. */
  7218. readonly boundingSphere: BoundingSphere;
  7219. private _isLocked;
  7220. private static readonly TmpVector3;
  7221. /**
  7222. * Constructs bounding info
  7223. * @param minimum min vector of the bounding box/sphere
  7224. * @param maximum max vector of the bounding box/sphere
  7225. * @param worldMatrix defines the new world matrix
  7226. */
  7227. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7228. /**
  7229. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7230. * @param min defines the new minimum vector (in local space)
  7231. * @param max defines the new maximum vector (in local space)
  7232. * @param worldMatrix defines the new world matrix
  7233. */
  7234. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7235. /**
  7236. * min vector of the bounding box/sphere
  7237. */
  7238. get minimum(): Vector3;
  7239. /**
  7240. * max vector of the bounding box/sphere
  7241. */
  7242. get maximum(): Vector3;
  7243. /**
  7244. * If the info is locked and won't be updated to avoid perf overhead
  7245. */
  7246. get isLocked(): boolean;
  7247. set isLocked(value: boolean);
  7248. /**
  7249. * Updates the bounding sphere and box
  7250. * @param world world matrix to be used to update
  7251. */
  7252. update(world: DeepImmutable<Matrix>): void;
  7253. /**
  7254. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7255. * @param center New center of the bounding info
  7256. * @param extend New extend of the bounding info
  7257. * @returns the current bounding info
  7258. */
  7259. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7260. /**
  7261. * Scale the current bounding info by applying a scale factor
  7262. * @param factor defines the scale factor to apply
  7263. * @returns the current bounding info
  7264. */
  7265. scale(factor: number): BoundingInfo;
  7266. /**
  7267. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7268. * @param frustumPlanes defines the frustum to test
  7269. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7270. * @returns true if the bounding info is in the frustum planes
  7271. */
  7272. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7273. /**
  7274. * Gets the world distance between the min and max points of the bounding box
  7275. */
  7276. get diagonalLength(): number;
  7277. /**
  7278. * Checks if a cullable object (mesh...) is in the camera frustum
  7279. * Unlike isInFrustum this cheks the full bounding box
  7280. * @param frustumPlanes Camera near/planes
  7281. * @returns true if the object is in frustum otherwise false
  7282. */
  7283. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7284. /** @hidden */
  7285. _checkCollision(collider: Collider): boolean;
  7286. /**
  7287. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7288. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7289. * @param point the point to check intersection with
  7290. * @returns if the point intersects
  7291. */
  7292. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7293. /**
  7294. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7295. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7296. * @param boundingInfo the bounding info to check intersection with
  7297. * @param precise if the intersection should be done using OBB
  7298. * @returns if the bounding info intersects
  7299. */
  7300. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7301. }
  7302. }
  7303. declare module "babylonjs/Maths/math.functions" {
  7304. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7305. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7306. /**
  7307. * Extracts minimum and maximum values from a list of indexed positions
  7308. * @param positions defines the positions to use
  7309. * @param indices defines the indices to the positions
  7310. * @param indexStart defines the start index
  7311. * @param indexCount defines the end index
  7312. * @param bias defines bias value to add to the result
  7313. * @return minimum and maximum values
  7314. */
  7315. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7316. minimum: Vector3;
  7317. maximum: Vector3;
  7318. };
  7319. /**
  7320. * Extracts minimum and maximum values from a list of positions
  7321. * @param positions defines the positions to use
  7322. * @param start defines the start index in the positions array
  7323. * @param count defines the number of positions to handle
  7324. * @param bias defines bias value to add to the result
  7325. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7326. * @return minimum and maximum values
  7327. */
  7328. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7329. minimum: Vector3;
  7330. maximum: Vector3;
  7331. };
  7332. }
  7333. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7334. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7335. /** @hidden */
  7336. export class WebGLDataBuffer extends DataBuffer {
  7337. private _buffer;
  7338. constructor(resource: WebGLBuffer);
  7339. get underlyingResource(): any;
  7340. }
  7341. }
  7342. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7343. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7344. import { Nullable } from "babylonjs/types";
  7345. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7346. /** @hidden */
  7347. export class WebGLPipelineContext implements IPipelineContext {
  7348. engine: ThinEngine;
  7349. program: Nullable<WebGLProgram>;
  7350. context?: WebGLRenderingContext;
  7351. vertexShader?: WebGLShader;
  7352. fragmentShader?: WebGLShader;
  7353. isParallelCompiled: boolean;
  7354. onCompiled?: () => void;
  7355. transformFeedback?: WebGLTransformFeedback | null;
  7356. vertexCompilationError: Nullable<string>;
  7357. fragmentCompilationError: Nullable<string>;
  7358. programLinkError: Nullable<string>;
  7359. programValidationError: Nullable<string>;
  7360. get isAsync(): boolean;
  7361. get isReady(): boolean;
  7362. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7363. _getVertexShaderCode(): string | null;
  7364. _getFragmentShaderCode(): string | null;
  7365. }
  7366. }
  7367. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7368. import { FloatArray, Nullable } from "babylonjs/types";
  7369. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7370. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7371. module "babylonjs/Engines/thinEngine" {
  7372. interface ThinEngine {
  7373. /**
  7374. * Create an uniform buffer
  7375. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7376. * @param elements defines the content of the uniform buffer
  7377. * @returns the webGL uniform buffer
  7378. */
  7379. createUniformBuffer(elements: FloatArray): DataBuffer;
  7380. /**
  7381. * Create a dynamic uniform buffer
  7382. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7383. * @param elements defines the content of the uniform buffer
  7384. * @returns the webGL uniform buffer
  7385. */
  7386. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7387. /**
  7388. * Update an existing uniform buffer
  7389. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7390. * @param uniformBuffer defines the target uniform buffer
  7391. * @param elements defines the content to update
  7392. * @param offset defines the offset in the uniform buffer where update should start
  7393. * @param count defines the size of the data to update
  7394. */
  7395. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7396. /**
  7397. * Bind an uniform buffer to the current webGL context
  7398. * @param buffer defines the buffer to bind
  7399. */
  7400. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7401. /**
  7402. * Bind a buffer to the current webGL context at a given location
  7403. * @param buffer defines the buffer to bind
  7404. * @param location defines the index where to bind the buffer
  7405. */
  7406. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7407. /**
  7408. * Bind a specific block at a given index in a specific shader program
  7409. * @param pipelineContext defines the pipeline context to use
  7410. * @param blockName defines the block name
  7411. * @param index defines the index where to bind the block
  7412. */
  7413. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7414. }
  7415. }
  7416. }
  7417. declare module "babylonjs/Materials/uniformBuffer" {
  7418. import { Nullable, FloatArray } from "babylonjs/types";
  7419. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7420. import { Engine } from "babylonjs/Engines/engine";
  7421. import { Effect } from "babylonjs/Materials/effect";
  7422. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7423. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7424. import { Color3 } from "babylonjs/Maths/math.color";
  7425. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7426. /**
  7427. * Uniform buffer objects.
  7428. *
  7429. * Handles blocks of uniform on the GPU.
  7430. *
  7431. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7432. *
  7433. * For more information, please refer to :
  7434. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7435. */
  7436. export class UniformBuffer {
  7437. private _engine;
  7438. private _buffer;
  7439. private _data;
  7440. private _bufferData;
  7441. private _dynamic?;
  7442. private _uniformLocations;
  7443. private _uniformSizes;
  7444. private _uniformLocationPointer;
  7445. private _needSync;
  7446. private _noUBO;
  7447. private _currentEffect;
  7448. /** @hidden */
  7449. _alreadyBound: boolean;
  7450. private static _MAX_UNIFORM_SIZE;
  7451. private static _tempBuffer;
  7452. /**
  7453. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7454. * This is dynamic to allow compat with webgl 1 and 2.
  7455. * You will need to pass the name of the uniform as well as the value.
  7456. */
  7457. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7458. /**
  7459. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7460. * This is dynamic to allow compat with webgl 1 and 2.
  7461. * You will need to pass the name of the uniform as well as the value.
  7462. */
  7463. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7464. /**
  7465. * Lambda to Update a single float in a uniform buffer.
  7466. * This is dynamic to allow compat with webgl 1 and 2.
  7467. * You will need to pass the name of the uniform as well as the value.
  7468. */
  7469. updateFloat: (name: string, x: number) => void;
  7470. /**
  7471. * Lambda to Update a vec2 of float in a uniform buffer.
  7472. * This is dynamic to allow compat with webgl 1 and 2.
  7473. * You will need to pass the name of the uniform as well as the value.
  7474. */
  7475. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7476. /**
  7477. * Lambda to Update a vec3 of float in a uniform buffer.
  7478. * This is dynamic to allow compat with webgl 1 and 2.
  7479. * You will need to pass the name of the uniform as well as the value.
  7480. */
  7481. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7482. /**
  7483. * Lambda to Update a vec4 of float in a uniform buffer.
  7484. * This is dynamic to allow compat with webgl 1 and 2.
  7485. * You will need to pass the name of the uniform as well as the value.
  7486. */
  7487. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7488. /**
  7489. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7490. * This is dynamic to allow compat with webgl 1 and 2.
  7491. * You will need to pass the name of the uniform as well as the value.
  7492. */
  7493. updateMatrix: (name: string, mat: Matrix) => void;
  7494. /**
  7495. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7496. * This is dynamic to allow compat with webgl 1 and 2.
  7497. * You will need to pass the name of the uniform as well as the value.
  7498. */
  7499. updateVector3: (name: string, vector: Vector3) => void;
  7500. /**
  7501. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7502. * This is dynamic to allow compat with webgl 1 and 2.
  7503. * You will need to pass the name of the uniform as well as the value.
  7504. */
  7505. updateVector4: (name: string, vector: Vector4) => void;
  7506. /**
  7507. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7508. * This is dynamic to allow compat with webgl 1 and 2.
  7509. * You will need to pass the name of the uniform as well as the value.
  7510. */
  7511. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7512. /**
  7513. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7514. * This is dynamic to allow compat with webgl 1 and 2.
  7515. * You will need to pass the name of the uniform as well as the value.
  7516. */
  7517. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7518. /**
  7519. * Instantiates a new Uniform buffer objects.
  7520. *
  7521. * Handles blocks of uniform on the GPU.
  7522. *
  7523. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7524. *
  7525. * For more information, please refer to :
  7526. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7527. * @param engine Define the engine the buffer is associated with
  7528. * @param data Define the data contained in the buffer
  7529. * @param dynamic Define if the buffer is updatable
  7530. */
  7531. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7532. /**
  7533. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7534. * or just falling back on setUniformXXX calls.
  7535. */
  7536. get useUbo(): boolean;
  7537. /**
  7538. * Indicates if the WebGL underlying uniform buffer is in sync
  7539. * with the javascript cache data.
  7540. */
  7541. get isSync(): boolean;
  7542. /**
  7543. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7544. * Also, a dynamic UniformBuffer will disable cache verification and always
  7545. * update the underlying WebGL uniform buffer to the GPU.
  7546. * @returns if Dynamic, otherwise false
  7547. */
  7548. isDynamic(): boolean;
  7549. /**
  7550. * The data cache on JS side.
  7551. * @returns the underlying data as a float array
  7552. */
  7553. getData(): Float32Array;
  7554. /**
  7555. * The underlying WebGL Uniform buffer.
  7556. * @returns the webgl buffer
  7557. */
  7558. getBuffer(): Nullable<DataBuffer>;
  7559. /**
  7560. * std140 layout specifies how to align data within an UBO structure.
  7561. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7562. * for specs.
  7563. */
  7564. private _fillAlignment;
  7565. /**
  7566. * Adds an uniform in the buffer.
  7567. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7568. * for the layout to be correct !
  7569. * @param name Name of the uniform, as used in the uniform block in the shader.
  7570. * @param size Data size, or data directly.
  7571. */
  7572. addUniform(name: string, size: number | number[]): void;
  7573. /**
  7574. * Adds a Matrix 4x4 to the uniform buffer.
  7575. * @param name Name of the uniform, as used in the uniform block in the shader.
  7576. * @param mat A 4x4 matrix.
  7577. */
  7578. addMatrix(name: string, mat: Matrix): void;
  7579. /**
  7580. * Adds a vec2 to the uniform buffer.
  7581. * @param name Name of the uniform, as used in the uniform block in the shader.
  7582. * @param x Define the x component value of the vec2
  7583. * @param y Define the y component value of the vec2
  7584. */
  7585. addFloat2(name: string, x: number, y: number): void;
  7586. /**
  7587. * Adds a vec3 to the uniform buffer.
  7588. * @param name Name of the uniform, as used in the uniform block in the shader.
  7589. * @param x Define the x component value of the vec3
  7590. * @param y Define the y component value of the vec3
  7591. * @param z Define the z component value of the vec3
  7592. */
  7593. addFloat3(name: string, x: number, y: number, z: number): void;
  7594. /**
  7595. * Adds a vec3 to the uniform buffer.
  7596. * @param name Name of the uniform, as used in the uniform block in the shader.
  7597. * @param color Define the vec3 from a Color
  7598. */
  7599. addColor3(name: string, color: Color3): void;
  7600. /**
  7601. * Adds a vec4 to the uniform buffer.
  7602. * @param name Name of the uniform, as used in the uniform block in the shader.
  7603. * @param color Define the rgb components from a Color
  7604. * @param alpha Define the a component of the vec4
  7605. */
  7606. addColor4(name: string, color: Color3, alpha: number): void;
  7607. /**
  7608. * Adds a vec3 to the uniform buffer.
  7609. * @param name Name of the uniform, as used in the uniform block in the shader.
  7610. * @param vector Define the vec3 components from a Vector
  7611. */
  7612. addVector3(name: string, vector: Vector3): void;
  7613. /**
  7614. * Adds a Matrix 3x3 to the uniform buffer.
  7615. * @param name Name of the uniform, as used in the uniform block in the shader.
  7616. */
  7617. addMatrix3x3(name: string): void;
  7618. /**
  7619. * Adds a Matrix 2x2 to the uniform buffer.
  7620. * @param name Name of the uniform, as used in the uniform block in the shader.
  7621. */
  7622. addMatrix2x2(name: string): void;
  7623. /**
  7624. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7625. */
  7626. create(): void;
  7627. /** @hidden */
  7628. _rebuild(): void;
  7629. /**
  7630. * Updates the WebGL Uniform Buffer on the GPU.
  7631. * If the `dynamic` flag is set to true, no cache comparison is done.
  7632. * Otherwise, the buffer will be updated only if the cache differs.
  7633. */
  7634. update(): void;
  7635. /**
  7636. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7637. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7638. * @param data Define the flattened data
  7639. * @param size Define the size of the data.
  7640. */
  7641. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7642. private _valueCache;
  7643. private _cacheMatrix;
  7644. private _updateMatrix3x3ForUniform;
  7645. private _updateMatrix3x3ForEffect;
  7646. private _updateMatrix2x2ForEffect;
  7647. private _updateMatrix2x2ForUniform;
  7648. private _updateFloatForEffect;
  7649. private _updateFloatForUniform;
  7650. private _updateFloat2ForEffect;
  7651. private _updateFloat2ForUniform;
  7652. private _updateFloat3ForEffect;
  7653. private _updateFloat3ForUniform;
  7654. private _updateFloat4ForEffect;
  7655. private _updateFloat4ForUniform;
  7656. private _updateMatrixForEffect;
  7657. private _updateMatrixForUniform;
  7658. private _updateVector3ForEffect;
  7659. private _updateVector3ForUniform;
  7660. private _updateVector4ForEffect;
  7661. private _updateVector4ForUniform;
  7662. private _updateColor3ForEffect;
  7663. private _updateColor3ForUniform;
  7664. private _updateColor4ForEffect;
  7665. private _updateColor4ForUniform;
  7666. /**
  7667. * Sets a sampler uniform on the effect.
  7668. * @param name Define the name of the sampler.
  7669. * @param texture Define the texture to set in the sampler
  7670. */
  7671. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7672. /**
  7673. * Directly updates the value of the uniform in the cache AND on the GPU.
  7674. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7675. * @param data Define the flattened data
  7676. */
  7677. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7678. /**
  7679. * Binds this uniform buffer to an effect.
  7680. * @param effect Define the effect to bind the buffer to
  7681. * @param name Name of the uniform block in the shader.
  7682. */
  7683. bindToEffect(effect: Effect, name: string): void;
  7684. /**
  7685. * Disposes the uniform buffer.
  7686. */
  7687. dispose(): void;
  7688. }
  7689. }
  7690. declare module "babylonjs/Misc/iInspectable" {
  7691. /**
  7692. * Enum that determines the text-wrapping mode to use.
  7693. */
  7694. export enum InspectableType {
  7695. /**
  7696. * Checkbox for booleans
  7697. */
  7698. Checkbox = 0,
  7699. /**
  7700. * Sliders for numbers
  7701. */
  7702. Slider = 1,
  7703. /**
  7704. * Vector3
  7705. */
  7706. Vector3 = 2,
  7707. /**
  7708. * Quaternions
  7709. */
  7710. Quaternion = 3,
  7711. /**
  7712. * Color3
  7713. */
  7714. Color3 = 4,
  7715. /**
  7716. * String
  7717. */
  7718. String = 5
  7719. }
  7720. /**
  7721. * Interface used to define custom inspectable properties.
  7722. * This interface is used by the inspector to display custom property grids
  7723. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7724. */
  7725. export interface IInspectable {
  7726. /**
  7727. * Gets the label to display
  7728. */
  7729. label: string;
  7730. /**
  7731. * Gets the name of the property to edit
  7732. */
  7733. propertyName: string;
  7734. /**
  7735. * Gets the type of the editor to use
  7736. */
  7737. type: InspectableType;
  7738. /**
  7739. * Gets the minimum value of the property when using in "slider" mode
  7740. */
  7741. min?: number;
  7742. /**
  7743. * Gets the maximum value of the property when using in "slider" mode
  7744. */
  7745. max?: number;
  7746. /**
  7747. * Gets the setp to use when using in "slider" mode
  7748. */
  7749. step?: number;
  7750. }
  7751. }
  7752. declare module "babylonjs/Misc/timingTools" {
  7753. /**
  7754. * Class used to provide helper for timing
  7755. */
  7756. export class TimingTools {
  7757. /**
  7758. * Polyfill for setImmediate
  7759. * @param action defines the action to execute after the current execution block
  7760. */
  7761. static SetImmediate(action: () => void): void;
  7762. }
  7763. }
  7764. declare module "babylonjs/Misc/instantiationTools" {
  7765. /**
  7766. * Class used to enable instatition of objects by class name
  7767. */
  7768. export class InstantiationTools {
  7769. /**
  7770. * Use this object to register external classes like custom textures or material
  7771. * to allow the laoders to instantiate them
  7772. */
  7773. static RegisteredExternalClasses: {
  7774. [key: string]: Object;
  7775. };
  7776. /**
  7777. * Tries to instantiate a new object from a given class name
  7778. * @param className defines the class name to instantiate
  7779. * @returns the new object or null if the system was not able to do the instantiation
  7780. */
  7781. static Instantiate(className: string): any;
  7782. }
  7783. }
  7784. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7785. /**
  7786. * Define options used to create a depth texture
  7787. */
  7788. export class DepthTextureCreationOptions {
  7789. /** Specifies whether or not a stencil should be allocated in the texture */
  7790. generateStencil?: boolean;
  7791. /** Specifies whether or not bilinear filtering is enable on the texture */
  7792. bilinearFiltering?: boolean;
  7793. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7794. comparisonFunction?: number;
  7795. /** Specifies if the created texture is a cube texture */
  7796. isCube?: boolean;
  7797. }
  7798. }
  7799. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7800. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7801. import { Nullable } from "babylonjs/types";
  7802. import { Scene } from "babylonjs/scene";
  7803. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7804. module "babylonjs/Engines/thinEngine" {
  7805. interface ThinEngine {
  7806. /**
  7807. * Creates a depth stencil cube texture.
  7808. * This is only available in WebGL 2.
  7809. * @param size The size of face edge in the cube texture.
  7810. * @param options The options defining the cube texture.
  7811. * @returns The cube texture
  7812. */
  7813. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7814. /**
  7815. * Creates a cube texture
  7816. * @param rootUrl defines the url where the files to load is located
  7817. * @param scene defines the current scene
  7818. * @param files defines the list of files to load (1 per face)
  7819. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7820. * @param onLoad defines an optional callback raised when the texture is loaded
  7821. * @param onError defines an optional callback raised if there is an issue to load the texture
  7822. * @param format defines the format of the data
  7823. * @param forcedExtension defines the extension to use to pick the right loader
  7824. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7825. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7826. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7827. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7828. * @returns the cube texture as an InternalTexture
  7829. */
  7830. 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;
  7831. /**
  7832. * Creates a cube texture
  7833. * @param rootUrl defines the url where the files to load is located
  7834. * @param scene defines the current scene
  7835. * @param files defines the list of files to load (1 per face)
  7836. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7837. * @param onLoad defines an optional callback raised when the texture is loaded
  7838. * @param onError defines an optional callback raised if there is an issue to load the texture
  7839. * @param format defines the format of the data
  7840. * @param forcedExtension defines the extension to use to pick the right loader
  7841. * @returns the cube texture as an InternalTexture
  7842. */
  7843. 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;
  7844. /**
  7845. * Creates a cube texture
  7846. * @param rootUrl defines the url where the files to load is located
  7847. * @param scene defines the current scene
  7848. * @param files defines the list of files to load (1 per face)
  7849. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7850. * @param onLoad defines an optional callback raised when the texture is loaded
  7851. * @param onError defines an optional callback raised if there is an issue to load the texture
  7852. * @param format defines the format of the data
  7853. * @param forcedExtension defines the extension to use to pick the right loader
  7854. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7855. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7856. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7857. * @returns the cube texture as an InternalTexture
  7858. */
  7859. 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;
  7860. /** @hidden */
  7861. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7862. /** @hidden */
  7863. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7864. /** @hidden */
  7865. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7866. /** @hidden */
  7867. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7868. /**
  7869. * @hidden
  7870. */
  7871. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7872. }
  7873. }
  7874. }
  7875. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7876. import { Nullable } from "babylonjs/types";
  7877. import { Scene } from "babylonjs/scene";
  7878. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7879. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7880. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7881. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7882. import { Observable } from "babylonjs/Misc/observable";
  7883. /**
  7884. * Class for creating a cube texture
  7885. */
  7886. export class CubeTexture extends BaseTexture {
  7887. private _delayedOnLoad;
  7888. /**
  7889. * Observable triggered once the texture has been loaded.
  7890. */
  7891. onLoadObservable: Observable<CubeTexture>;
  7892. /**
  7893. * The url of the texture
  7894. */
  7895. url: string;
  7896. /**
  7897. * Gets or sets the center of the bounding box associated with the cube texture.
  7898. * It must define where the camera used to render the texture was set
  7899. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7900. */
  7901. boundingBoxPosition: Vector3;
  7902. private _boundingBoxSize;
  7903. /**
  7904. * Gets or sets the size of the bounding box associated with the cube texture
  7905. * When defined, the cubemap will switch to local mode
  7906. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7907. * @example https://www.babylonjs-playground.com/#RNASML
  7908. */
  7909. set boundingBoxSize(value: Vector3);
  7910. /**
  7911. * Returns the bounding box size
  7912. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7913. */
  7914. get boundingBoxSize(): Vector3;
  7915. protected _rotationY: number;
  7916. /**
  7917. * Sets texture matrix rotation angle around Y axis in radians.
  7918. */
  7919. set rotationY(value: number);
  7920. /**
  7921. * Gets texture matrix rotation angle around Y axis radians.
  7922. */
  7923. get rotationY(): number;
  7924. /**
  7925. * Are mip maps generated for this texture or not.
  7926. */
  7927. get noMipmap(): boolean;
  7928. private _noMipmap;
  7929. private _files;
  7930. protected _forcedExtension: Nullable<string>;
  7931. private _extensions;
  7932. private _textureMatrix;
  7933. private _format;
  7934. private _createPolynomials;
  7935. /**
  7936. * Creates a cube texture from an array of image urls
  7937. * @param files defines an array of image urls
  7938. * @param scene defines the hosting scene
  7939. * @param noMipmap specifies if mip maps are not used
  7940. * @returns a cube texture
  7941. */
  7942. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7943. /**
  7944. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7945. * @param url defines the url of the prefiltered texture
  7946. * @param scene defines the scene the texture is attached to
  7947. * @param forcedExtension defines the extension of the file if different from the url
  7948. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7949. * @return the prefiltered texture
  7950. */
  7951. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7952. /**
  7953. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7954. * as prefiltered data.
  7955. * @param rootUrl defines the url of the texture or the root name of the six images
  7956. * @param null defines the scene or engine the texture is attached to
  7957. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7958. * @param noMipmap defines if mipmaps should be created or not
  7959. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7960. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7961. * @param onError defines a callback triggered in case of error during load
  7962. * @param format defines the internal format to use for the texture once loaded
  7963. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7964. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7965. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7966. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7967. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7968. * @return the cube texture
  7969. */
  7970. 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);
  7971. /**
  7972. * Get the current class name of the texture useful for serialization or dynamic coding.
  7973. * @returns "CubeTexture"
  7974. */
  7975. getClassName(): string;
  7976. /**
  7977. * Update the url (and optional buffer) of this texture if url was null during construction.
  7978. * @param url the url of the texture
  7979. * @param forcedExtension defines the extension to use
  7980. * @param onLoad callback called when the texture is loaded (defaults to null)
  7981. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7982. */
  7983. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7984. /**
  7985. * Delays loading of the cube texture
  7986. * @param forcedExtension defines the extension to use
  7987. */
  7988. delayLoad(forcedExtension?: string): void;
  7989. /**
  7990. * Returns the reflection texture matrix
  7991. * @returns the reflection texture matrix
  7992. */
  7993. getReflectionTextureMatrix(): Matrix;
  7994. /**
  7995. * Sets the reflection texture matrix
  7996. * @param value Reflection texture matrix
  7997. */
  7998. setReflectionTextureMatrix(value: Matrix): void;
  7999. /**
  8000. * Parses text to create a cube texture
  8001. * @param parsedTexture define the serialized text to read from
  8002. * @param scene defines the hosting scene
  8003. * @param rootUrl defines the root url of the cube texture
  8004. * @returns a cube texture
  8005. */
  8006. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8007. /**
  8008. * Makes a clone, or deep copy, of the cube texture
  8009. * @returns a new cube texture
  8010. */
  8011. clone(): CubeTexture;
  8012. }
  8013. }
  8014. declare module "babylonjs/Materials/materialDefines" {
  8015. /**
  8016. * Manages the defines for the Material
  8017. */
  8018. export class MaterialDefines {
  8019. /** @hidden */
  8020. protected _keys: string[];
  8021. private _isDirty;
  8022. /** @hidden */
  8023. _renderId: number;
  8024. /** @hidden */
  8025. _areLightsDirty: boolean;
  8026. /** @hidden */
  8027. _areLightsDisposed: boolean;
  8028. /** @hidden */
  8029. _areAttributesDirty: boolean;
  8030. /** @hidden */
  8031. _areTexturesDirty: boolean;
  8032. /** @hidden */
  8033. _areFresnelDirty: boolean;
  8034. /** @hidden */
  8035. _areMiscDirty: boolean;
  8036. /** @hidden */
  8037. _areImageProcessingDirty: boolean;
  8038. /** @hidden */
  8039. _normals: boolean;
  8040. /** @hidden */
  8041. _uvs: boolean;
  8042. /** @hidden */
  8043. _needNormals: boolean;
  8044. /** @hidden */
  8045. _needUVs: boolean;
  8046. [id: string]: any;
  8047. /**
  8048. * Specifies if the material needs to be re-calculated
  8049. */
  8050. get isDirty(): boolean;
  8051. /**
  8052. * Marks the material to indicate that it has been re-calculated
  8053. */
  8054. markAsProcessed(): void;
  8055. /**
  8056. * Marks the material to indicate that it needs to be re-calculated
  8057. */
  8058. markAsUnprocessed(): void;
  8059. /**
  8060. * Marks the material to indicate all of its defines need to be re-calculated
  8061. */
  8062. markAllAsDirty(): void;
  8063. /**
  8064. * Marks the material to indicate that image processing needs to be re-calculated
  8065. */
  8066. markAsImageProcessingDirty(): void;
  8067. /**
  8068. * Marks the material to indicate the lights need to be re-calculated
  8069. * @param disposed Defines whether the light is dirty due to dispose or not
  8070. */
  8071. markAsLightDirty(disposed?: boolean): void;
  8072. /**
  8073. * Marks the attribute state as changed
  8074. */
  8075. markAsAttributesDirty(): void;
  8076. /**
  8077. * Marks the texture state as changed
  8078. */
  8079. markAsTexturesDirty(): void;
  8080. /**
  8081. * Marks the fresnel state as changed
  8082. */
  8083. markAsFresnelDirty(): void;
  8084. /**
  8085. * Marks the misc state as changed
  8086. */
  8087. markAsMiscDirty(): void;
  8088. /**
  8089. * Rebuilds the material defines
  8090. */
  8091. rebuild(): void;
  8092. /**
  8093. * Specifies if two material defines are equal
  8094. * @param other - A material define instance to compare to
  8095. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8096. */
  8097. isEqual(other: MaterialDefines): boolean;
  8098. /**
  8099. * Clones this instance's defines to another instance
  8100. * @param other - material defines to clone values to
  8101. */
  8102. cloneTo(other: MaterialDefines): void;
  8103. /**
  8104. * Resets the material define values
  8105. */
  8106. reset(): void;
  8107. /**
  8108. * Converts the material define values to a string
  8109. * @returns - String of material define information
  8110. */
  8111. toString(): string;
  8112. }
  8113. }
  8114. declare module "babylonjs/Materials/colorCurves" {
  8115. import { Effect } from "babylonjs/Materials/effect";
  8116. /**
  8117. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8118. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8119. * 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;
  8120. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8121. */
  8122. export class ColorCurves {
  8123. private _dirty;
  8124. private _tempColor;
  8125. private _globalCurve;
  8126. private _highlightsCurve;
  8127. private _midtonesCurve;
  8128. private _shadowsCurve;
  8129. private _positiveCurve;
  8130. private _negativeCurve;
  8131. private _globalHue;
  8132. private _globalDensity;
  8133. private _globalSaturation;
  8134. private _globalExposure;
  8135. /**
  8136. * Gets the global Hue value.
  8137. * 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).
  8138. */
  8139. get globalHue(): number;
  8140. /**
  8141. * Sets the global Hue value.
  8142. * 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).
  8143. */
  8144. set globalHue(value: number);
  8145. /**
  8146. * Gets the global Density value.
  8147. * 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.
  8148. * Values less than zero provide a filter of opposite hue.
  8149. */
  8150. get globalDensity(): number;
  8151. /**
  8152. * Sets the global Density value.
  8153. * 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.
  8154. * Values less than zero provide a filter of opposite hue.
  8155. */
  8156. set globalDensity(value: number);
  8157. /**
  8158. * Gets the global Saturation value.
  8159. * 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.
  8160. */
  8161. get globalSaturation(): number;
  8162. /**
  8163. * Sets the global Saturation value.
  8164. * 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.
  8165. */
  8166. set globalSaturation(value: number);
  8167. /**
  8168. * Gets the global Exposure value.
  8169. * 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.
  8170. */
  8171. get globalExposure(): number;
  8172. /**
  8173. * Sets the global Exposure value.
  8174. * 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.
  8175. */
  8176. set globalExposure(value: number);
  8177. private _highlightsHue;
  8178. private _highlightsDensity;
  8179. private _highlightsSaturation;
  8180. private _highlightsExposure;
  8181. /**
  8182. * Gets the highlights Hue value.
  8183. * 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).
  8184. */
  8185. get highlightsHue(): number;
  8186. /**
  8187. * Sets the highlights Hue value.
  8188. * 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).
  8189. */
  8190. set highlightsHue(value: number);
  8191. /**
  8192. * Gets the highlights Density value.
  8193. * 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.
  8194. * Values less than zero provide a filter of opposite hue.
  8195. */
  8196. get highlightsDensity(): number;
  8197. /**
  8198. * Sets the highlights Density value.
  8199. * 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.
  8200. * Values less than zero provide a filter of opposite hue.
  8201. */
  8202. set highlightsDensity(value: number);
  8203. /**
  8204. * Gets the highlights Saturation value.
  8205. * 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.
  8206. */
  8207. get highlightsSaturation(): number;
  8208. /**
  8209. * Sets the highlights Saturation value.
  8210. * 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.
  8211. */
  8212. set highlightsSaturation(value: number);
  8213. /**
  8214. * Gets the highlights Exposure value.
  8215. * 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.
  8216. */
  8217. get highlightsExposure(): number;
  8218. /**
  8219. * Sets the highlights Exposure value.
  8220. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8221. */
  8222. set highlightsExposure(value: number);
  8223. private _midtonesHue;
  8224. private _midtonesDensity;
  8225. private _midtonesSaturation;
  8226. private _midtonesExposure;
  8227. /**
  8228. * Gets the midtones Hue value.
  8229. * 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).
  8230. */
  8231. get midtonesHue(): number;
  8232. /**
  8233. * Sets the midtones Hue value.
  8234. * 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).
  8235. */
  8236. set midtonesHue(value: number);
  8237. /**
  8238. * Gets the midtones Density value.
  8239. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8240. * Values less than zero provide a filter of opposite hue.
  8241. */
  8242. get midtonesDensity(): number;
  8243. /**
  8244. * Sets the midtones Density value.
  8245. * 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.
  8246. * Values less than zero provide a filter of opposite hue.
  8247. */
  8248. set midtonesDensity(value: number);
  8249. /**
  8250. * Gets the midtones Saturation value.
  8251. * 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.
  8252. */
  8253. get midtonesSaturation(): number;
  8254. /**
  8255. * Sets the midtones Saturation value.
  8256. * 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.
  8257. */
  8258. set midtonesSaturation(value: number);
  8259. /**
  8260. * Gets the midtones Exposure value.
  8261. * 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.
  8262. */
  8263. get midtonesExposure(): number;
  8264. /**
  8265. * Sets the midtones Exposure value.
  8266. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8267. */
  8268. set midtonesExposure(value: number);
  8269. private _shadowsHue;
  8270. private _shadowsDensity;
  8271. private _shadowsSaturation;
  8272. private _shadowsExposure;
  8273. /**
  8274. * Gets the shadows Hue value.
  8275. * 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).
  8276. */
  8277. get shadowsHue(): number;
  8278. /**
  8279. * Sets the shadows Hue value.
  8280. * 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).
  8281. */
  8282. set shadowsHue(value: number);
  8283. /**
  8284. * Gets the shadows Density value.
  8285. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8286. * Values less than zero provide a filter of opposite hue.
  8287. */
  8288. get shadowsDensity(): number;
  8289. /**
  8290. * Sets the shadows Density value.
  8291. * 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.
  8292. * Values less than zero provide a filter of opposite hue.
  8293. */
  8294. set shadowsDensity(value: number);
  8295. /**
  8296. * Gets the shadows Saturation value.
  8297. * 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.
  8298. */
  8299. get shadowsSaturation(): number;
  8300. /**
  8301. * Sets the shadows Saturation value.
  8302. * 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.
  8303. */
  8304. set shadowsSaturation(value: number);
  8305. /**
  8306. * Gets the shadows Exposure value.
  8307. * 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.
  8308. */
  8309. get shadowsExposure(): number;
  8310. /**
  8311. * Sets the shadows Exposure value.
  8312. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8313. */
  8314. set shadowsExposure(value: number);
  8315. /**
  8316. * Returns the class name
  8317. * @returns The class name
  8318. */
  8319. getClassName(): string;
  8320. /**
  8321. * Binds the color curves to the shader.
  8322. * @param colorCurves The color curve to bind
  8323. * @param effect The effect to bind to
  8324. * @param positiveUniform The positive uniform shader parameter
  8325. * @param neutralUniform The neutral uniform shader parameter
  8326. * @param negativeUniform The negative uniform shader parameter
  8327. */
  8328. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8329. /**
  8330. * Prepare the list of uniforms associated with the ColorCurves effects.
  8331. * @param uniformsList The list of uniforms used in the effect
  8332. */
  8333. static PrepareUniforms(uniformsList: string[]): void;
  8334. /**
  8335. * Returns color grading data based on a hue, density, saturation and exposure value.
  8336. * @param filterHue The hue of the color filter.
  8337. * @param filterDensity The density of the color filter.
  8338. * @param saturation The saturation.
  8339. * @param exposure The exposure.
  8340. * @param result The result data container.
  8341. */
  8342. private getColorGradingDataToRef;
  8343. /**
  8344. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8345. * @param value The input slider value in range [-100,100].
  8346. * @returns Adjusted value.
  8347. */
  8348. private static applyColorGradingSliderNonlinear;
  8349. /**
  8350. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8351. * @param hue The hue (H) input.
  8352. * @param saturation The saturation (S) input.
  8353. * @param brightness The brightness (B) input.
  8354. * @result An RGBA color represented as Vector4.
  8355. */
  8356. private static fromHSBToRef;
  8357. /**
  8358. * Returns a value clamped between min and max
  8359. * @param value The value to clamp
  8360. * @param min The minimum of value
  8361. * @param max The maximum of value
  8362. * @returns The clamped value.
  8363. */
  8364. private static clamp;
  8365. /**
  8366. * Clones the current color curve instance.
  8367. * @return The cloned curves
  8368. */
  8369. clone(): ColorCurves;
  8370. /**
  8371. * Serializes the current color curve instance to a json representation.
  8372. * @return a JSON representation
  8373. */
  8374. serialize(): any;
  8375. /**
  8376. * Parses the color curve from a json representation.
  8377. * @param source the JSON source to parse
  8378. * @return The parsed curves
  8379. */
  8380. static Parse(source: any): ColorCurves;
  8381. }
  8382. }
  8383. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8384. import { Observable } from "babylonjs/Misc/observable";
  8385. import { Nullable } from "babylonjs/types";
  8386. import { Color4 } from "babylonjs/Maths/math.color";
  8387. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8388. import { Effect } from "babylonjs/Materials/effect";
  8389. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8390. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8391. /**
  8392. * Interface to follow in your material defines to integrate easily the
  8393. * Image proccessing functions.
  8394. * @hidden
  8395. */
  8396. export interface IImageProcessingConfigurationDefines {
  8397. IMAGEPROCESSING: boolean;
  8398. VIGNETTE: boolean;
  8399. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8400. VIGNETTEBLENDMODEOPAQUE: boolean;
  8401. TONEMAPPING: boolean;
  8402. TONEMAPPING_ACES: boolean;
  8403. CONTRAST: boolean;
  8404. EXPOSURE: boolean;
  8405. COLORCURVES: boolean;
  8406. COLORGRADING: boolean;
  8407. COLORGRADING3D: boolean;
  8408. SAMPLER3DGREENDEPTH: boolean;
  8409. SAMPLER3DBGRMAP: boolean;
  8410. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8411. }
  8412. /**
  8413. * @hidden
  8414. */
  8415. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8416. IMAGEPROCESSING: boolean;
  8417. VIGNETTE: boolean;
  8418. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8419. VIGNETTEBLENDMODEOPAQUE: boolean;
  8420. TONEMAPPING: boolean;
  8421. TONEMAPPING_ACES: boolean;
  8422. CONTRAST: boolean;
  8423. COLORCURVES: boolean;
  8424. COLORGRADING: boolean;
  8425. COLORGRADING3D: boolean;
  8426. SAMPLER3DGREENDEPTH: boolean;
  8427. SAMPLER3DBGRMAP: boolean;
  8428. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8429. EXPOSURE: boolean;
  8430. constructor();
  8431. }
  8432. /**
  8433. * This groups together the common properties used for image processing either in direct forward pass
  8434. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8435. * or not.
  8436. */
  8437. export class ImageProcessingConfiguration {
  8438. /**
  8439. * Default tone mapping applied in BabylonJS.
  8440. */
  8441. static readonly TONEMAPPING_STANDARD: number;
  8442. /**
  8443. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8444. * to other engines rendering to increase portability.
  8445. */
  8446. static readonly TONEMAPPING_ACES: number;
  8447. /**
  8448. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8449. */
  8450. colorCurves: Nullable<ColorCurves>;
  8451. private _colorCurvesEnabled;
  8452. /**
  8453. * Gets wether the color curves effect is enabled.
  8454. */
  8455. get colorCurvesEnabled(): boolean;
  8456. /**
  8457. * Sets wether the color curves effect is enabled.
  8458. */
  8459. set colorCurvesEnabled(value: boolean);
  8460. private _colorGradingTexture;
  8461. /**
  8462. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8463. */
  8464. get colorGradingTexture(): Nullable<BaseTexture>;
  8465. /**
  8466. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8467. */
  8468. set colorGradingTexture(value: Nullable<BaseTexture>);
  8469. private _colorGradingEnabled;
  8470. /**
  8471. * Gets wether the color grading effect is enabled.
  8472. */
  8473. get colorGradingEnabled(): boolean;
  8474. /**
  8475. * Sets wether the color grading effect is enabled.
  8476. */
  8477. set colorGradingEnabled(value: boolean);
  8478. private _colorGradingWithGreenDepth;
  8479. /**
  8480. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8481. */
  8482. get colorGradingWithGreenDepth(): boolean;
  8483. /**
  8484. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8485. */
  8486. set colorGradingWithGreenDepth(value: boolean);
  8487. private _colorGradingBGR;
  8488. /**
  8489. * Gets wether the color grading texture contains BGR values.
  8490. */
  8491. get colorGradingBGR(): boolean;
  8492. /**
  8493. * Sets wether the color grading texture contains BGR values.
  8494. */
  8495. set colorGradingBGR(value: boolean);
  8496. /** @hidden */
  8497. _exposure: number;
  8498. /**
  8499. * Gets the Exposure used in the effect.
  8500. */
  8501. get exposure(): number;
  8502. /**
  8503. * Sets the Exposure used in the effect.
  8504. */
  8505. set exposure(value: number);
  8506. private _toneMappingEnabled;
  8507. /**
  8508. * Gets wether the tone mapping effect is enabled.
  8509. */
  8510. get toneMappingEnabled(): boolean;
  8511. /**
  8512. * Sets wether the tone mapping effect is enabled.
  8513. */
  8514. set toneMappingEnabled(value: boolean);
  8515. private _toneMappingType;
  8516. /**
  8517. * Gets the type of tone mapping effect.
  8518. */
  8519. get toneMappingType(): number;
  8520. /**
  8521. * Sets the type of tone mapping effect used in BabylonJS.
  8522. */
  8523. set toneMappingType(value: number);
  8524. protected _contrast: number;
  8525. /**
  8526. * Gets the contrast used in the effect.
  8527. */
  8528. get contrast(): number;
  8529. /**
  8530. * Sets the contrast used in the effect.
  8531. */
  8532. set contrast(value: number);
  8533. /**
  8534. * Vignette stretch size.
  8535. */
  8536. vignetteStretch: number;
  8537. /**
  8538. * Vignette centre X Offset.
  8539. */
  8540. vignetteCentreX: number;
  8541. /**
  8542. * Vignette centre Y Offset.
  8543. */
  8544. vignetteCentreY: number;
  8545. /**
  8546. * Vignette weight or intensity of the vignette effect.
  8547. */
  8548. vignetteWeight: number;
  8549. /**
  8550. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8551. * if vignetteEnabled is set to true.
  8552. */
  8553. vignetteColor: Color4;
  8554. /**
  8555. * Camera field of view used by the Vignette effect.
  8556. */
  8557. vignetteCameraFov: number;
  8558. private _vignetteBlendMode;
  8559. /**
  8560. * Gets the vignette blend mode allowing different kind of effect.
  8561. */
  8562. get vignetteBlendMode(): number;
  8563. /**
  8564. * Sets the vignette blend mode allowing different kind of effect.
  8565. */
  8566. set vignetteBlendMode(value: number);
  8567. private _vignetteEnabled;
  8568. /**
  8569. * Gets wether the vignette effect is enabled.
  8570. */
  8571. get vignetteEnabled(): boolean;
  8572. /**
  8573. * Sets wether the vignette effect is enabled.
  8574. */
  8575. set vignetteEnabled(value: boolean);
  8576. private _applyByPostProcess;
  8577. /**
  8578. * Gets wether the image processing is applied through a post process or not.
  8579. */
  8580. get applyByPostProcess(): boolean;
  8581. /**
  8582. * Sets wether the image processing is applied through a post process or not.
  8583. */
  8584. set applyByPostProcess(value: boolean);
  8585. private _isEnabled;
  8586. /**
  8587. * Gets wether the image processing is enabled or not.
  8588. */
  8589. get isEnabled(): boolean;
  8590. /**
  8591. * Sets wether the image processing is enabled or not.
  8592. */
  8593. set isEnabled(value: boolean);
  8594. /**
  8595. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8596. */
  8597. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8598. /**
  8599. * Method called each time the image processing information changes requires to recompile the effect.
  8600. */
  8601. protected _updateParameters(): void;
  8602. /**
  8603. * Gets the current class name.
  8604. * @return "ImageProcessingConfiguration"
  8605. */
  8606. getClassName(): string;
  8607. /**
  8608. * Prepare the list of uniforms associated with the Image Processing effects.
  8609. * @param uniforms The list of uniforms used in the effect
  8610. * @param defines the list of defines currently in use
  8611. */
  8612. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8613. /**
  8614. * Prepare the list of samplers associated with the Image Processing effects.
  8615. * @param samplersList The list of uniforms used in the effect
  8616. * @param defines the list of defines currently in use
  8617. */
  8618. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8619. /**
  8620. * Prepare the list of defines associated to the shader.
  8621. * @param defines the list of defines to complete
  8622. * @param forPostProcess Define if we are currently in post process mode or not
  8623. */
  8624. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8625. /**
  8626. * Returns true if all the image processing information are ready.
  8627. * @returns True if ready, otherwise, false
  8628. */
  8629. isReady(): boolean;
  8630. /**
  8631. * Binds the image processing to the shader.
  8632. * @param effect The effect to bind to
  8633. * @param overrideAspectRatio Override the aspect ratio of the effect
  8634. */
  8635. bind(effect: Effect, overrideAspectRatio?: number): void;
  8636. /**
  8637. * Clones the current image processing instance.
  8638. * @return The cloned image processing
  8639. */
  8640. clone(): ImageProcessingConfiguration;
  8641. /**
  8642. * Serializes the current image processing instance to a json representation.
  8643. * @return a JSON representation
  8644. */
  8645. serialize(): any;
  8646. /**
  8647. * Parses the image processing from a json representation.
  8648. * @param source the JSON source to parse
  8649. * @return The parsed image processing
  8650. */
  8651. static Parse(source: any): ImageProcessingConfiguration;
  8652. private static _VIGNETTEMODE_MULTIPLY;
  8653. private static _VIGNETTEMODE_OPAQUE;
  8654. /**
  8655. * Used to apply the vignette as a mix with the pixel color.
  8656. */
  8657. static get VIGNETTEMODE_MULTIPLY(): number;
  8658. /**
  8659. * Used to apply the vignette as a replacement of the pixel color.
  8660. */
  8661. static get VIGNETTEMODE_OPAQUE(): number;
  8662. }
  8663. }
  8664. declare module "babylonjs/Shaders/postprocess.vertex" {
  8665. /** @hidden */
  8666. export var postprocessVertexShader: {
  8667. name: string;
  8668. shader: string;
  8669. };
  8670. }
  8671. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8672. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8673. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8674. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8675. module "babylonjs/Engines/thinEngine" {
  8676. interface ThinEngine {
  8677. /**
  8678. * Creates a new render target texture
  8679. * @param size defines the size of the texture
  8680. * @param options defines the options used to create the texture
  8681. * @returns a new render target texture stored in an InternalTexture
  8682. */
  8683. createRenderTargetTexture(size: number | {
  8684. width: number;
  8685. height: number;
  8686. layers?: number;
  8687. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8688. /**
  8689. * Creates a depth stencil texture.
  8690. * This is only available in WebGL 2 or with the depth texture extension available.
  8691. * @param size The size of face edge in the texture.
  8692. * @param options The options defining the texture.
  8693. * @returns The texture
  8694. */
  8695. createDepthStencilTexture(size: number | {
  8696. width: number;
  8697. height: number;
  8698. layers?: number;
  8699. }, options: DepthTextureCreationOptions): InternalTexture;
  8700. /** @hidden */
  8701. _createDepthStencilTexture(size: number | {
  8702. width: number;
  8703. height: number;
  8704. layers?: number;
  8705. }, options: DepthTextureCreationOptions): InternalTexture;
  8706. }
  8707. }
  8708. }
  8709. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8710. /**
  8711. * Defines the kind of connection point for node based material
  8712. */
  8713. export enum NodeMaterialBlockConnectionPointTypes {
  8714. /** Float */
  8715. Float = 1,
  8716. /** Int */
  8717. Int = 2,
  8718. /** Vector2 */
  8719. Vector2 = 4,
  8720. /** Vector3 */
  8721. Vector3 = 8,
  8722. /** Vector4 */
  8723. Vector4 = 16,
  8724. /** Color3 */
  8725. Color3 = 32,
  8726. /** Color4 */
  8727. Color4 = 64,
  8728. /** Matrix */
  8729. Matrix = 128,
  8730. /** Custom object */
  8731. Object = 256,
  8732. /** Detect type based on connection */
  8733. AutoDetect = 1024,
  8734. /** Output type that will be defined by input type */
  8735. BasedOnInput = 2048
  8736. }
  8737. }
  8738. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8739. /**
  8740. * Enum used to define the target of a block
  8741. */
  8742. export enum NodeMaterialBlockTargets {
  8743. /** Vertex shader */
  8744. Vertex = 1,
  8745. /** Fragment shader */
  8746. Fragment = 2,
  8747. /** Neutral */
  8748. Neutral = 4,
  8749. /** Vertex and Fragment */
  8750. VertexAndFragment = 3
  8751. }
  8752. }
  8753. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8754. /**
  8755. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8756. */
  8757. export enum NodeMaterialBlockConnectionPointMode {
  8758. /** Value is an uniform */
  8759. Uniform = 0,
  8760. /** Value is a mesh attribute */
  8761. Attribute = 1,
  8762. /** Value is a varying between vertex and fragment shaders */
  8763. Varying = 2,
  8764. /** Mode is undefined */
  8765. Undefined = 3
  8766. }
  8767. }
  8768. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8769. /**
  8770. * Enum used to define system values e.g. values automatically provided by the system
  8771. */
  8772. export enum NodeMaterialSystemValues {
  8773. /** World */
  8774. World = 1,
  8775. /** View */
  8776. View = 2,
  8777. /** Projection */
  8778. Projection = 3,
  8779. /** ViewProjection */
  8780. ViewProjection = 4,
  8781. /** WorldView */
  8782. WorldView = 5,
  8783. /** WorldViewProjection */
  8784. WorldViewProjection = 6,
  8785. /** CameraPosition */
  8786. CameraPosition = 7,
  8787. /** Fog Color */
  8788. FogColor = 8,
  8789. /** Delta time */
  8790. DeltaTime = 9
  8791. }
  8792. }
  8793. declare module "babylonjs/Maths/math.axis" {
  8794. import { Vector3 } from "babylonjs/Maths/math.vector";
  8795. /** Defines supported spaces */
  8796. export enum Space {
  8797. /** Local (object) space */
  8798. LOCAL = 0,
  8799. /** World space */
  8800. WORLD = 1,
  8801. /** Bone space */
  8802. BONE = 2
  8803. }
  8804. /** Defines the 3 main axes */
  8805. export class Axis {
  8806. /** X axis */
  8807. static X: Vector3;
  8808. /** Y axis */
  8809. static Y: Vector3;
  8810. /** Z axis */
  8811. static Z: Vector3;
  8812. }
  8813. }
  8814. declare module "babylonjs/Maths/math.frustum" {
  8815. import { Matrix } from "babylonjs/Maths/math.vector";
  8816. import { DeepImmutable } from "babylonjs/types";
  8817. import { Plane } from "babylonjs/Maths/math.plane";
  8818. /**
  8819. * Represents a camera frustum
  8820. */
  8821. export class Frustum {
  8822. /**
  8823. * Gets the planes representing the frustum
  8824. * @param transform matrix to be applied to the returned planes
  8825. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8826. */
  8827. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8828. /**
  8829. * Gets the near frustum plane transformed by the transform matrix
  8830. * @param transform transformation matrix to be applied to the resulting frustum plane
  8831. * @param frustumPlane the resuling frustum plane
  8832. */
  8833. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8834. /**
  8835. * Gets the far frustum plane transformed by the transform matrix
  8836. * @param transform transformation matrix to be applied to the resulting frustum plane
  8837. * @param frustumPlane the resuling frustum plane
  8838. */
  8839. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8840. /**
  8841. * Gets the left frustum plane transformed by the transform matrix
  8842. * @param transform transformation matrix to be applied to the resulting frustum plane
  8843. * @param frustumPlane the resuling frustum plane
  8844. */
  8845. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8846. /**
  8847. * Gets the right frustum plane transformed by the transform matrix
  8848. * @param transform transformation matrix to be applied to the resulting frustum plane
  8849. * @param frustumPlane the resuling frustum plane
  8850. */
  8851. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8852. /**
  8853. * Gets the top frustum plane transformed by the transform matrix
  8854. * @param transform transformation matrix to be applied to the resulting frustum plane
  8855. * @param frustumPlane the resuling frustum plane
  8856. */
  8857. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8858. /**
  8859. * Gets the bottom frustum plane transformed by the transform matrix
  8860. * @param transform transformation matrix to be applied to the resulting frustum plane
  8861. * @param frustumPlane the resuling frustum plane
  8862. */
  8863. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8864. /**
  8865. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8866. * @param transform transformation matrix to be applied to the resulting frustum planes
  8867. * @param frustumPlanes the resuling frustum planes
  8868. */
  8869. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8870. }
  8871. }
  8872. declare module "babylonjs/Maths/math.size" {
  8873. /**
  8874. * Interface for the size containing width and height
  8875. */
  8876. export interface ISize {
  8877. /**
  8878. * Width
  8879. */
  8880. width: number;
  8881. /**
  8882. * Heighht
  8883. */
  8884. height: number;
  8885. }
  8886. /**
  8887. * Size containing widht and height
  8888. */
  8889. export class Size implements ISize {
  8890. /**
  8891. * Width
  8892. */
  8893. width: number;
  8894. /**
  8895. * Height
  8896. */
  8897. height: number;
  8898. /**
  8899. * Creates a Size object from the given width and height (floats).
  8900. * @param width width of the new size
  8901. * @param height height of the new size
  8902. */
  8903. constructor(width: number, height: number);
  8904. /**
  8905. * Returns a string with the Size width and height
  8906. * @returns a string with the Size width and height
  8907. */
  8908. toString(): string;
  8909. /**
  8910. * "Size"
  8911. * @returns the string "Size"
  8912. */
  8913. getClassName(): string;
  8914. /**
  8915. * Returns the Size hash code.
  8916. * @returns a hash code for a unique width and height
  8917. */
  8918. getHashCode(): number;
  8919. /**
  8920. * Updates the current size from the given one.
  8921. * @param src the given size
  8922. */
  8923. copyFrom(src: Size): void;
  8924. /**
  8925. * Updates in place the current Size from the given floats.
  8926. * @param width width of the new size
  8927. * @param height height of the new size
  8928. * @returns the updated Size.
  8929. */
  8930. copyFromFloats(width: number, height: number): Size;
  8931. /**
  8932. * Updates in place the current Size from the given floats.
  8933. * @param width width to set
  8934. * @param height height to set
  8935. * @returns the updated Size.
  8936. */
  8937. set(width: number, height: number): Size;
  8938. /**
  8939. * Multiplies the width and height by numbers
  8940. * @param w factor to multiple the width by
  8941. * @param h factor to multiple the height by
  8942. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8943. */
  8944. multiplyByFloats(w: number, h: number): Size;
  8945. /**
  8946. * Clones the size
  8947. * @returns a new Size copied from the given one.
  8948. */
  8949. clone(): Size;
  8950. /**
  8951. * True if the current Size and the given one width and height are strictly equal.
  8952. * @param other the other size to compare against
  8953. * @returns True if the current Size and the given one width and height are strictly equal.
  8954. */
  8955. equals(other: Size): boolean;
  8956. /**
  8957. * The surface of the Size : width * height (float).
  8958. */
  8959. get surface(): number;
  8960. /**
  8961. * Create a new size of zero
  8962. * @returns a new Size set to (0.0, 0.0)
  8963. */
  8964. static Zero(): Size;
  8965. /**
  8966. * Sums the width and height of two sizes
  8967. * @param otherSize size to add to this size
  8968. * @returns a new Size set as the addition result of the current Size and the given one.
  8969. */
  8970. add(otherSize: Size): Size;
  8971. /**
  8972. * Subtracts the width and height of two
  8973. * @param otherSize size to subtract to this size
  8974. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8975. */
  8976. subtract(otherSize: Size): Size;
  8977. /**
  8978. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8979. * @param start starting size to lerp between
  8980. * @param end end size to lerp between
  8981. * @param amount amount to lerp between the start and end values
  8982. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8983. */
  8984. static Lerp(start: Size, end: Size, amount: number): Size;
  8985. }
  8986. }
  8987. declare module "babylonjs/Maths/math.vertexFormat" {
  8988. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8989. /**
  8990. * Contains position and normal vectors for a vertex
  8991. */
  8992. export class PositionNormalVertex {
  8993. /** the position of the vertex (defaut: 0,0,0) */
  8994. position: Vector3;
  8995. /** the normal of the vertex (defaut: 0,1,0) */
  8996. normal: Vector3;
  8997. /**
  8998. * Creates a PositionNormalVertex
  8999. * @param position the position of the vertex (defaut: 0,0,0)
  9000. * @param normal the normal of the vertex (defaut: 0,1,0)
  9001. */
  9002. constructor(
  9003. /** the position of the vertex (defaut: 0,0,0) */
  9004. position?: Vector3,
  9005. /** the normal of the vertex (defaut: 0,1,0) */
  9006. normal?: Vector3);
  9007. /**
  9008. * Clones the PositionNormalVertex
  9009. * @returns the cloned PositionNormalVertex
  9010. */
  9011. clone(): PositionNormalVertex;
  9012. }
  9013. /**
  9014. * Contains position, normal and uv vectors for a vertex
  9015. */
  9016. export class PositionNormalTextureVertex {
  9017. /** the position of the vertex (defaut: 0,0,0) */
  9018. position: Vector3;
  9019. /** the normal of the vertex (defaut: 0,1,0) */
  9020. normal: Vector3;
  9021. /** the uv of the vertex (default: 0,0) */
  9022. uv: Vector2;
  9023. /**
  9024. * Creates a PositionNormalTextureVertex
  9025. * @param position the position of the vertex (defaut: 0,0,0)
  9026. * @param normal the normal of the vertex (defaut: 0,1,0)
  9027. * @param uv the uv of the vertex (default: 0,0)
  9028. */
  9029. constructor(
  9030. /** the position of the vertex (defaut: 0,0,0) */
  9031. position?: Vector3,
  9032. /** the normal of the vertex (defaut: 0,1,0) */
  9033. normal?: Vector3,
  9034. /** the uv of the vertex (default: 0,0) */
  9035. uv?: Vector2);
  9036. /**
  9037. * Clones the PositionNormalTextureVertex
  9038. * @returns the cloned PositionNormalTextureVertex
  9039. */
  9040. clone(): PositionNormalTextureVertex;
  9041. }
  9042. }
  9043. declare module "babylonjs/Maths/math" {
  9044. export * from "babylonjs/Maths/math.axis";
  9045. export * from "babylonjs/Maths/math.color";
  9046. export * from "babylonjs/Maths/math.constants";
  9047. export * from "babylonjs/Maths/math.frustum";
  9048. export * from "babylonjs/Maths/math.path";
  9049. export * from "babylonjs/Maths/math.plane";
  9050. export * from "babylonjs/Maths/math.size";
  9051. export * from "babylonjs/Maths/math.vector";
  9052. export * from "babylonjs/Maths/math.vertexFormat";
  9053. export * from "babylonjs/Maths/math.viewport";
  9054. }
  9055. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9056. /**
  9057. * Enum defining the type of animations supported by InputBlock
  9058. */
  9059. export enum AnimatedInputBlockTypes {
  9060. /** No animation */
  9061. None = 0,
  9062. /** Time based animation. Will only work for floats */
  9063. Time = 1
  9064. }
  9065. }
  9066. declare module "babylonjs/Lights/shadowLight" {
  9067. import { Camera } from "babylonjs/Cameras/camera";
  9068. import { Scene } from "babylonjs/scene";
  9069. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9071. import { Light } from "babylonjs/Lights/light";
  9072. /**
  9073. * Interface describing all the common properties and methods a shadow light needs to implement.
  9074. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9075. * as well as binding the different shadow properties to the effects.
  9076. */
  9077. export interface IShadowLight extends Light {
  9078. /**
  9079. * The light id in the scene (used in scene.findLighById for instance)
  9080. */
  9081. id: string;
  9082. /**
  9083. * The position the shdow will be casted from.
  9084. */
  9085. position: Vector3;
  9086. /**
  9087. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9088. */
  9089. direction: Vector3;
  9090. /**
  9091. * The transformed position. Position of the light in world space taking parenting in account.
  9092. */
  9093. transformedPosition: Vector3;
  9094. /**
  9095. * The transformed direction. Direction of the light in world space taking parenting in account.
  9096. */
  9097. transformedDirection: Vector3;
  9098. /**
  9099. * The friendly name of the light in the scene.
  9100. */
  9101. name: string;
  9102. /**
  9103. * Defines the shadow projection clipping minimum z value.
  9104. */
  9105. shadowMinZ: number;
  9106. /**
  9107. * Defines the shadow projection clipping maximum z value.
  9108. */
  9109. shadowMaxZ: number;
  9110. /**
  9111. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9112. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9113. */
  9114. computeTransformedInformation(): boolean;
  9115. /**
  9116. * Gets the scene the light belongs to.
  9117. * @returns The scene
  9118. */
  9119. getScene(): Scene;
  9120. /**
  9121. * Callback defining a custom Projection Matrix Builder.
  9122. * This can be used to override the default projection matrix computation.
  9123. */
  9124. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9125. /**
  9126. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9127. * @param matrix The materix to updated with the projection information
  9128. * @param viewMatrix The transform matrix of the light
  9129. * @param renderList The list of mesh to render in the map
  9130. * @returns The current light
  9131. */
  9132. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9133. /**
  9134. * Gets the current depth scale used in ESM.
  9135. * @returns The scale
  9136. */
  9137. getDepthScale(): number;
  9138. /**
  9139. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9140. * @returns true if a cube texture needs to be use
  9141. */
  9142. needCube(): boolean;
  9143. /**
  9144. * Detects if the projection matrix requires to be recomputed this frame.
  9145. * @returns true if it requires to be recomputed otherwise, false.
  9146. */
  9147. needProjectionMatrixCompute(): boolean;
  9148. /**
  9149. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9150. */
  9151. forceProjectionMatrixCompute(): void;
  9152. /**
  9153. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9154. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9155. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9156. */
  9157. getShadowDirection(faceIndex?: number): Vector3;
  9158. /**
  9159. * Gets the minZ used for shadow according to both the scene and the light.
  9160. * @param activeCamera The camera we are returning the min for
  9161. * @returns the depth min z
  9162. */
  9163. getDepthMinZ(activeCamera: Camera): number;
  9164. /**
  9165. * Gets the maxZ used for shadow according to both the scene and the light.
  9166. * @param activeCamera The camera we are returning the max for
  9167. * @returns the depth max z
  9168. */
  9169. getDepthMaxZ(activeCamera: Camera): number;
  9170. }
  9171. /**
  9172. * Base implementation IShadowLight
  9173. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9174. */
  9175. export abstract class ShadowLight extends Light implements IShadowLight {
  9176. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9177. protected _position: Vector3;
  9178. protected _setPosition(value: Vector3): void;
  9179. /**
  9180. * Sets the position the shadow will be casted from. Also use as the light position for both
  9181. * point and spot lights.
  9182. */
  9183. get position(): Vector3;
  9184. /**
  9185. * Sets the position the shadow will be casted from. Also use as the light position for both
  9186. * point and spot lights.
  9187. */
  9188. set position(value: Vector3);
  9189. protected _direction: Vector3;
  9190. protected _setDirection(value: Vector3): void;
  9191. /**
  9192. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9193. * Also use as the light direction on spot and directional lights.
  9194. */
  9195. get direction(): Vector3;
  9196. /**
  9197. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9198. * Also use as the light direction on spot and directional lights.
  9199. */
  9200. set direction(value: Vector3);
  9201. protected _shadowMinZ: number;
  9202. /**
  9203. * Gets the shadow projection clipping minimum z value.
  9204. */
  9205. get shadowMinZ(): number;
  9206. /**
  9207. * Sets the shadow projection clipping minimum z value.
  9208. */
  9209. set shadowMinZ(value: number);
  9210. protected _shadowMaxZ: number;
  9211. /**
  9212. * Sets the shadow projection clipping maximum z value.
  9213. */
  9214. get shadowMaxZ(): number;
  9215. /**
  9216. * Gets the shadow projection clipping maximum z value.
  9217. */
  9218. set shadowMaxZ(value: number);
  9219. /**
  9220. * Callback defining a custom Projection Matrix Builder.
  9221. * This can be used to override the default projection matrix computation.
  9222. */
  9223. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9224. /**
  9225. * The transformed position. Position of the light in world space taking parenting in account.
  9226. */
  9227. transformedPosition: Vector3;
  9228. /**
  9229. * The transformed direction. Direction of the light in world space taking parenting in account.
  9230. */
  9231. transformedDirection: Vector3;
  9232. private _needProjectionMatrixCompute;
  9233. /**
  9234. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9235. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9236. */
  9237. computeTransformedInformation(): boolean;
  9238. /**
  9239. * Return the depth scale used for the shadow map.
  9240. * @returns the depth scale.
  9241. */
  9242. getDepthScale(): number;
  9243. /**
  9244. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9245. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9246. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9247. */
  9248. getShadowDirection(faceIndex?: number): Vector3;
  9249. /**
  9250. * Returns the ShadowLight absolute position in the World.
  9251. * @returns the position vector in world space
  9252. */
  9253. getAbsolutePosition(): Vector3;
  9254. /**
  9255. * Sets the ShadowLight direction toward the passed target.
  9256. * @param target The point to target in local space
  9257. * @returns the updated ShadowLight direction
  9258. */
  9259. setDirectionToTarget(target: Vector3): Vector3;
  9260. /**
  9261. * Returns the light rotation in euler definition.
  9262. * @returns the x y z rotation in local space.
  9263. */
  9264. getRotation(): Vector3;
  9265. /**
  9266. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9267. * @returns true if a cube texture needs to be use
  9268. */
  9269. needCube(): boolean;
  9270. /**
  9271. * Detects if the projection matrix requires to be recomputed this frame.
  9272. * @returns true if it requires to be recomputed otherwise, false.
  9273. */
  9274. needProjectionMatrixCompute(): boolean;
  9275. /**
  9276. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9277. */
  9278. forceProjectionMatrixCompute(): void;
  9279. /** @hidden */
  9280. _initCache(): void;
  9281. /** @hidden */
  9282. _isSynchronized(): boolean;
  9283. /**
  9284. * Computes the world matrix of the node
  9285. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9286. * @returns the world matrix
  9287. */
  9288. computeWorldMatrix(force?: boolean): Matrix;
  9289. /**
  9290. * Gets the minZ used for shadow according to both the scene and the light.
  9291. * @param activeCamera The camera we are returning the min for
  9292. * @returns the depth min z
  9293. */
  9294. getDepthMinZ(activeCamera: Camera): number;
  9295. /**
  9296. * Gets the maxZ used for shadow according to both the scene and the light.
  9297. * @param activeCamera The camera we are returning the max for
  9298. * @returns the depth max z
  9299. */
  9300. getDepthMaxZ(activeCamera: Camera): number;
  9301. /**
  9302. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9303. * @param matrix The materix to updated with the projection information
  9304. * @param viewMatrix The transform matrix of the light
  9305. * @param renderList The list of mesh to render in the map
  9306. * @returns The current light
  9307. */
  9308. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9309. }
  9310. }
  9311. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9312. /** @hidden */
  9313. export var packingFunctions: {
  9314. name: string;
  9315. shader: string;
  9316. };
  9317. }
  9318. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9319. /** @hidden */
  9320. export var bayerDitherFunctions: {
  9321. name: string;
  9322. shader: string;
  9323. };
  9324. }
  9325. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9326. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9327. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9328. /** @hidden */
  9329. export var shadowMapFragmentDeclaration: {
  9330. name: string;
  9331. shader: string;
  9332. };
  9333. }
  9334. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9335. /** @hidden */
  9336. export var clipPlaneFragmentDeclaration: {
  9337. name: string;
  9338. shader: string;
  9339. };
  9340. }
  9341. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9342. /** @hidden */
  9343. export var clipPlaneFragment: {
  9344. name: string;
  9345. shader: string;
  9346. };
  9347. }
  9348. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9349. /** @hidden */
  9350. export var shadowMapFragment: {
  9351. name: string;
  9352. shader: string;
  9353. };
  9354. }
  9355. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9356. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9357. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9358. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9359. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9360. /** @hidden */
  9361. export var shadowMapPixelShader: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9367. /** @hidden */
  9368. export var bonesDeclaration: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9374. /** @hidden */
  9375. export var morphTargetsVertexGlobalDeclaration: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9381. /** @hidden */
  9382. export var morphTargetsVertexDeclaration: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9388. /** @hidden */
  9389. export var instancesDeclaration: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9395. /** @hidden */
  9396. export var helperFunctions: {
  9397. name: string;
  9398. shader: string;
  9399. };
  9400. }
  9401. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9402. /** @hidden */
  9403. export var shadowMapVertexDeclaration: {
  9404. name: string;
  9405. shader: string;
  9406. };
  9407. }
  9408. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9409. /** @hidden */
  9410. export var clipPlaneVertexDeclaration: {
  9411. name: string;
  9412. shader: string;
  9413. };
  9414. }
  9415. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9416. /** @hidden */
  9417. export var morphTargetsVertex: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9423. /** @hidden */
  9424. export var instancesVertex: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9430. /** @hidden */
  9431. export var bonesVertex: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9437. /** @hidden */
  9438. export var shadowMapVertexNormalBias: {
  9439. name: string;
  9440. shader: string;
  9441. };
  9442. }
  9443. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9444. /** @hidden */
  9445. export var shadowMapVertexMetric: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9451. /** @hidden */
  9452. export var clipPlaneVertex: {
  9453. name: string;
  9454. shader: string;
  9455. };
  9456. }
  9457. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9458. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9459. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9460. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9461. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9462. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9463. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9464. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9465. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9466. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9467. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9468. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9469. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9470. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9471. /** @hidden */
  9472. export var shadowMapVertexShader: {
  9473. name: string;
  9474. shader: string;
  9475. };
  9476. }
  9477. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9478. /** @hidden */
  9479. export var depthBoxBlurPixelShader: {
  9480. name: string;
  9481. shader: string;
  9482. };
  9483. }
  9484. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9485. /** @hidden */
  9486. export var shadowMapFragmentSoftTransparentShadow: {
  9487. name: string;
  9488. shader: string;
  9489. };
  9490. }
  9491. declare module "babylonjs/Materials/effectFallbacks" {
  9492. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9493. import { Effect } from "babylonjs/Materials/effect";
  9494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9495. /**
  9496. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9497. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9498. */
  9499. export class EffectFallbacks implements IEffectFallbacks {
  9500. private _defines;
  9501. private _currentRank;
  9502. private _maxRank;
  9503. private _mesh;
  9504. /**
  9505. * Removes the fallback from the bound mesh.
  9506. */
  9507. unBindMesh(): void;
  9508. /**
  9509. * Adds a fallback on the specified property.
  9510. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9511. * @param define The name of the define in the shader
  9512. */
  9513. addFallback(rank: number, define: string): void;
  9514. /**
  9515. * Sets the mesh to use CPU skinning when needing to fallback.
  9516. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9517. * @param mesh The mesh to use the fallbacks.
  9518. */
  9519. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9520. /**
  9521. * Checks to see if more fallbacks are still availible.
  9522. */
  9523. get hasMoreFallbacks(): boolean;
  9524. /**
  9525. * Removes the defines that should be removed when falling back.
  9526. * @param currentDefines defines the current define statements for the shader.
  9527. * @param effect defines the current effect we try to compile
  9528. * @returns The resulting defines with defines of the current rank removed.
  9529. */
  9530. reduce(currentDefines: string, effect: Effect): string;
  9531. }
  9532. }
  9533. declare module "babylonjs/Actions/action" {
  9534. import { Observable } from "babylonjs/Misc/observable";
  9535. import { Condition } from "babylonjs/Actions/condition";
  9536. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9537. import { Nullable } from "babylonjs/types";
  9538. import { Scene } from "babylonjs/scene";
  9539. import { ActionManager } from "babylonjs/Actions/actionManager";
  9540. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9541. import { Node } from "babylonjs/node";
  9542. /**
  9543. * Interface used to define Action
  9544. */
  9545. export interface IAction {
  9546. /**
  9547. * Trigger for the action
  9548. */
  9549. trigger: number;
  9550. /** Options of the trigger */
  9551. triggerOptions: any;
  9552. /**
  9553. * Gets the trigger parameters
  9554. * @returns the trigger parameters
  9555. */
  9556. getTriggerParameter(): any;
  9557. /**
  9558. * Internal only - executes current action event
  9559. * @hidden
  9560. */
  9561. _executeCurrent(evt?: ActionEvent): void;
  9562. /**
  9563. * Serialize placeholder for child classes
  9564. * @param parent of child
  9565. * @returns the serialized object
  9566. */
  9567. serialize(parent: any): any;
  9568. /**
  9569. * Internal only
  9570. * @hidden
  9571. */
  9572. _prepare(): void;
  9573. /**
  9574. * Internal only - manager for action
  9575. * @hidden
  9576. */
  9577. _actionManager: Nullable<AbstractActionManager>;
  9578. /**
  9579. * Adds action to chain of actions, may be a DoNothingAction
  9580. * @param action defines the next action to execute
  9581. * @returns The action passed in
  9582. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9583. */
  9584. then(action: IAction): IAction;
  9585. }
  9586. /**
  9587. * The action to be carried out following a trigger
  9588. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9589. */
  9590. export class Action implements IAction {
  9591. /** the trigger, with or without parameters, for the action */
  9592. triggerOptions: any;
  9593. /**
  9594. * Trigger for the action
  9595. */
  9596. trigger: number;
  9597. /**
  9598. * Internal only - manager for action
  9599. * @hidden
  9600. */
  9601. _actionManager: ActionManager;
  9602. private _nextActiveAction;
  9603. private _child;
  9604. private _condition?;
  9605. private _triggerParameter;
  9606. /**
  9607. * An event triggered prior to action being executed.
  9608. */
  9609. onBeforeExecuteObservable: Observable<Action>;
  9610. /**
  9611. * Creates a new Action
  9612. * @param triggerOptions the trigger, with or without parameters, for the action
  9613. * @param condition an optional determinant of action
  9614. */
  9615. constructor(
  9616. /** the trigger, with or without parameters, for the action */
  9617. triggerOptions: any, condition?: Condition);
  9618. /**
  9619. * Internal only
  9620. * @hidden
  9621. */
  9622. _prepare(): void;
  9623. /**
  9624. * Gets the trigger parameters
  9625. * @returns the trigger parameters
  9626. */
  9627. getTriggerParameter(): any;
  9628. /**
  9629. * Internal only - executes current action event
  9630. * @hidden
  9631. */
  9632. _executeCurrent(evt?: ActionEvent): void;
  9633. /**
  9634. * Execute placeholder for child classes
  9635. * @param evt optional action event
  9636. */
  9637. execute(evt?: ActionEvent): void;
  9638. /**
  9639. * Skips to next active action
  9640. */
  9641. skipToNextActiveAction(): void;
  9642. /**
  9643. * Adds action to chain of actions, may be a DoNothingAction
  9644. * @param action defines the next action to execute
  9645. * @returns The action passed in
  9646. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9647. */
  9648. then(action: Action): Action;
  9649. /**
  9650. * Internal only
  9651. * @hidden
  9652. */
  9653. _getProperty(propertyPath: string): string;
  9654. /**
  9655. * Internal only
  9656. * @hidden
  9657. */
  9658. _getEffectiveTarget(target: any, propertyPath: string): any;
  9659. /**
  9660. * Serialize placeholder for child classes
  9661. * @param parent of child
  9662. * @returns the serialized object
  9663. */
  9664. serialize(parent: any): any;
  9665. /**
  9666. * Internal only called by serialize
  9667. * @hidden
  9668. */
  9669. protected _serialize(serializedAction: any, parent?: any): any;
  9670. /**
  9671. * Internal only
  9672. * @hidden
  9673. */
  9674. static _SerializeValueAsString: (value: any) => string;
  9675. /**
  9676. * Internal only
  9677. * @hidden
  9678. */
  9679. static _GetTargetProperty: (target: Scene | Node) => {
  9680. name: string;
  9681. targetType: string;
  9682. value: string;
  9683. };
  9684. }
  9685. }
  9686. declare module "babylonjs/Actions/condition" {
  9687. import { ActionManager } from "babylonjs/Actions/actionManager";
  9688. /**
  9689. * A Condition applied to an Action
  9690. */
  9691. export class Condition {
  9692. /**
  9693. * Internal only - manager for action
  9694. * @hidden
  9695. */
  9696. _actionManager: ActionManager;
  9697. /**
  9698. * Internal only
  9699. * @hidden
  9700. */
  9701. _evaluationId: number;
  9702. /**
  9703. * Internal only
  9704. * @hidden
  9705. */
  9706. _currentResult: boolean;
  9707. /**
  9708. * Creates a new Condition
  9709. * @param actionManager the manager of the action the condition is applied to
  9710. */
  9711. constructor(actionManager: ActionManager);
  9712. /**
  9713. * Check if the current condition is valid
  9714. * @returns a boolean
  9715. */
  9716. isValid(): boolean;
  9717. /**
  9718. * Internal only
  9719. * @hidden
  9720. */
  9721. _getProperty(propertyPath: string): string;
  9722. /**
  9723. * Internal only
  9724. * @hidden
  9725. */
  9726. _getEffectiveTarget(target: any, propertyPath: string): any;
  9727. /**
  9728. * Serialize placeholder for child classes
  9729. * @returns the serialized object
  9730. */
  9731. serialize(): any;
  9732. /**
  9733. * Internal only
  9734. * @hidden
  9735. */
  9736. protected _serialize(serializedCondition: any): any;
  9737. }
  9738. /**
  9739. * Defines specific conditional operators as extensions of Condition
  9740. */
  9741. export class ValueCondition extends Condition {
  9742. /** path to specify the property of the target the conditional operator uses */
  9743. propertyPath: string;
  9744. /** the value compared by the conditional operator against the current value of the property */
  9745. value: any;
  9746. /** the conditional operator, default ValueCondition.IsEqual */
  9747. operator: number;
  9748. /**
  9749. * Internal only
  9750. * @hidden
  9751. */
  9752. private static _IsEqual;
  9753. /**
  9754. * Internal only
  9755. * @hidden
  9756. */
  9757. private static _IsDifferent;
  9758. /**
  9759. * Internal only
  9760. * @hidden
  9761. */
  9762. private static _IsGreater;
  9763. /**
  9764. * Internal only
  9765. * @hidden
  9766. */
  9767. private static _IsLesser;
  9768. /**
  9769. * returns the number for IsEqual
  9770. */
  9771. static get IsEqual(): number;
  9772. /**
  9773. * Returns the number for IsDifferent
  9774. */
  9775. static get IsDifferent(): number;
  9776. /**
  9777. * Returns the number for IsGreater
  9778. */
  9779. static get IsGreater(): number;
  9780. /**
  9781. * Returns the number for IsLesser
  9782. */
  9783. static get IsLesser(): number;
  9784. /**
  9785. * Internal only The action manager for the condition
  9786. * @hidden
  9787. */
  9788. _actionManager: ActionManager;
  9789. /**
  9790. * Internal only
  9791. * @hidden
  9792. */
  9793. private _target;
  9794. /**
  9795. * Internal only
  9796. * @hidden
  9797. */
  9798. private _effectiveTarget;
  9799. /**
  9800. * Internal only
  9801. * @hidden
  9802. */
  9803. private _property;
  9804. /**
  9805. * Creates a new ValueCondition
  9806. * @param actionManager manager for the action the condition applies to
  9807. * @param target for the action
  9808. * @param propertyPath path to specify the property of the target the conditional operator uses
  9809. * @param value the value compared by the conditional operator against the current value of the property
  9810. * @param operator the conditional operator, default ValueCondition.IsEqual
  9811. */
  9812. constructor(actionManager: ActionManager, target: any,
  9813. /** path to specify the property of the target the conditional operator uses */
  9814. propertyPath: string,
  9815. /** the value compared by the conditional operator against the current value of the property */
  9816. value: any,
  9817. /** the conditional operator, default ValueCondition.IsEqual */
  9818. operator?: number);
  9819. /**
  9820. * Compares the given value with the property value for the specified conditional operator
  9821. * @returns the result of the comparison
  9822. */
  9823. isValid(): boolean;
  9824. /**
  9825. * Serialize the ValueCondition into a JSON compatible object
  9826. * @returns serialization object
  9827. */
  9828. serialize(): any;
  9829. /**
  9830. * Gets the name of the conditional operator for the ValueCondition
  9831. * @param operator the conditional operator
  9832. * @returns the name
  9833. */
  9834. static GetOperatorName(operator: number): string;
  9835. }
  9836. /**
  9837. * Defines a predicate condition as an extension of Condition
  9838. */
  9839. export class PredicateCondition extends Condition {
  9840. /** defines the predicate function used to validate the condition */
  9841. predicate: () => boolean;
  9842. /**
  9843. * Internal only - manager for action
  9844. * @hidden
  9845. */
  9846. _actionManager: ActionManager;
  9847. /**
  9848. * Creates a new PredicateCondition
  9849. * @param actionManager manager for the action the condition applies to
  9850. * @param predicate defines the predicate function used to validate the condition
  9851. */
  9852. constructor(actionManager: ActionManager,
  9853. /** defines the predicate function used to validate the condition */
  9854. predicate: () => boolean);
  9855. /**
  9856. * @returns the validity of the predicate condition
  9857. */
  9858. isValid(): boolean;
  9859. }
  9860. /**
  9861. * Defines a state condition as an extension of Condition
  9862. */
  9863. export class StateCondition extends Condition {
  9864. /** Value to compare with target state */
  9865. value: string;
  9866. /**
  9867. * Internal only - manager for action
  9868. * @hidden
  9869. */
  9870. _actionManager: ActionManager;
  9871. /**
  9872. * Internal only
  9873. * @hidden
  9874. */
  9875. private _target;
  9876. /**
  9877. * Creates a new StateCondition
  9878. * @param actionManager manager for the action the condition applies to
  9879. * @param target of the condition
  9880. * @param value to compare with target state
  9881. */
  9882. constructor(actionManager: ActionManager, target: any,
  9883. /** Value to compare with target state */
  9884. value: string);
  9885. /**
  9886. * Gets a boolean indicating if the current condition is met
  9887. * @returns the validity of the state
  9888. */
  9889. isValid(): boolean;
  9890. /**
  9891. * Serialize the StateCondition into a JSON compatible object
  9892. * @returns serialization object
  9893. */
  9894. serialize(): any;
  9895. }
  9896. }
  9897. declare module "babylonjs/Actions/directActions" {
  9898. import { Action } from "babylonjs/Actions/action";
  9899. import { Condition } from "babylonjs/Actions/condition";
  9900. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9901. /**
  9902. * This defines an action responsible to toggle a boolean once triggered.
  9903. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9904. */
  9905. export class SwitchBooleanAction extends Action {
  9906. /**
  9907. * The path to the boolean property in the target object
  9908. */
  9909. propertyPath: string;
  9910. private _target;
  9911. private _effectiveTarget;
  9912. private _property;
  9913. /**
  9914. * Instantiate the action
  9915. * @param triggerOptions defines the trigger options
  9916. * @param target defines the object containing the boolean
  9917. * @param propertyPath defines the path to the boolean property in the target object
  9918. * @param condition defines the trigger related conditions
  9919. */
  9920. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9921. /** @hidden */
  9922. _prepare(): void;
  9923. /**
  9924. * Execute the action toggle the boolean value.
  9925. */
  9926. execute(): void;
  9927. /**
  9928. * Serializes the actions and its related information.
  9929. * @param parent defines the object to serialize in
  9930. * @returns the serialized object
  9931. */
  9932. serialize(parent: any): any;
  9933. }
  9934. /**
  9935. * This defines an action responsible to set a the state field of the target
  9936. * to a desired value once triggered.
  9937. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9938. */
  9939. export class SetStateAction extends Action {
  9940. /**
  9941. * The value to store in the state field.
  9942. */
  9943. value: string;
  9944. private _target;
  9945. /**
  9946. * Instantiate the action
  9947. * @param triggerOptions defines the trigger options
  9948. * @param target defines the object containing the state property
  9949. * @param value defines the value to store in the state field
  9950. * @param condition defines the trigger related conditions
  9951. */
  9952. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9953. /**
  9954. * Execute the action and store the value on the target state property.
  9955. */
  9956. execute(): void;
  9957. /**
  9958. * Serializes the actions and its related information.
  9959. * @param parent defines the object to serialize in
  9960. * @returns the serialized object
  9961. */
  9962. serialize(parent: any): any;
  9963. }
  9964. /**
  9965. * This defines an action responsible to set a property of the target
  9966. * to a desired value once triggered.
  9967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9968. */
  9969. export class SetValueAction extends Action {
  9970. /**
  9971. * The path of the property to set in the target.
  9972. */
  9973. propertyPath: string;
  9974. /**
  9975. * The value to set in the property
  9976. */
  9977. value: any;
  9978. private _target;
  9979. private _effectiveTarget;
  9980. private _property;
  9981. /**
  9982. * Instantiate the action
  9983. * @param triggerOptions defines the trigger options
  9984. * @param target defines the object containing the property
  9985. * @param propertyPath defines the path of the property to set in the target
  9986. * @param value defines the value to set in the property
  9987. * @param condition defines the trigger related conditions
  9988. */
  9989. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9990. /** @hidden */
  9991. _prepare(): void;
  9992. /**
  9993. * Execute the action and set the targetted property to the desired value.
  9994. */
  9995. execute(): void;
  9996. /**
  9997. * Serializes the actions and its related information.
  9998. * @param parent defines the object to serialize in
  9999. * @returns the serialized object
  10000. */
  10001. serialize(parent: any): any;
  10002. }
  10003. /**
  10004. * This defines an action responsible to increment the target value
  10005. * to a desired value once triggered.
  10006. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10007. */
  10008. export class IncrementValueAction extends Action {
  10009. /**
  10010. * The path of the property to increment in the target.
  10011. */
  10012. propertyPath: string;
  10013. /**
  10014. * The value we should increment the property by.
  10015. */
  10016. value: any;
  10017. private _target;
  10018. private _effectiveTarget;
  10019. private _property;
  10020. /**
  10021. * Instantiate the action
  10022. * @param triggerOptions defines the trigger options
  10023. * @param target defines the object containing the property
  10024. * @param propertyPath defines the path of the property to increment in the target
  10025. * @param value defines the value value we should increment the property by
  10026. * @param condition defines the trigger related conditions
  10027. */
  10028. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10029. /** @hidden */
  10030. _prepare(): void;
  10031. /**
  10032. * Execute the action and increment the target of the value amount.
  10033. */
  10034. execute(): void;
  10035. /**
  10036. * Serializes the actions and its related information.
  10037. * @param parent defines the object to serialize in
  10038. * @returns the serialized object
  10039. */
  10040. serialize(parent: any): any;
  10041. }
  10042. /**
  10043. * This defines an action responsible to start an animation once triggered.
  10044. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10045. */
  10046. export class PlayAnimationAction extends Action {
  10047. /**
  10048. * Where the animation should start (animation frame)
  10049. */
  10050. from: number;
  10051. /**
  10052. * Where the animation should stop (animation frame)
  10053. */
  10054. to: number;
  10055. /**
  10056. * Define if the animation should loop or stop after the first play.
  10057. */
  10058. loop?: boolean;
  10059. private _target;
  10060. /**
  10061. * Instantiate the action
  10062. * @param triggerOptions defines the trigger options
  10063. * @param target defines the target animation or animation name
  10064. * @param from defines from where the animation should start (animation frame)
  10065. * @param end defines where the animation should stop (animation frame)
  10066. * @param loop defines if the animation should loop or stop after the first play
  10067. * @param condition defines the trigger related conditions
  10068. */
  10069. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10070. /** @hidden */
  10071. _prepare(): void;
  10072. /**
  10073. * Execute the action and play the animation.
  10074. */
  10075. execute(): void;
  10076. /**
  10077. * Serializes the actions and its related information.
  10078. * @param parent defines the object to serialize in
  10079. * @returns the serialized object
  10080. */
  10081. serialize(parent: any): any;
  10082. }
  10083. /**
  10084. * This defines an action responsible to stop an animation once triggered.
  10085. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10086. */
  10087. export class StopAnimationAction extends Action {
  10088. private _target;
  10089. /**
  10090. * Instantiate the action
  10091. * @param triggerOptions defines the trigger options
  10092. * @param target defines the target animation or animation name
  10093. * @param condition defines the trigger related conditions
  10094. */
  10095. constructor(triggerOptions: any, target: any, condition?: Condition);
  10096. /** @hidden */
  10097. _prepare(): void;
  10098. /**
  10099. * Execute the action and stop the animation.
  10100. */
  10101. execute(): void;
  10102. /**
  10103. * Serializes the actions and its related information.
  10104. * @param parent defines the object to serialize in
  10105. * @returns the serialized object
  10106. */
  10107. serialize(parent: any): any;
  10108. }
  10109. /**
  10110. * This defines an action responsible that does nothing once triggered.
  10111. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10112. */
  10113. export class DoNothingAction extends Action {
  10114. /**
  10115. * Instantiate the action
  10116. * @param triggerOptions defines the trigger options
  10117. * @param condition defines the trigger related conditions
  10118. */
  10119. constructor(triggerOptions?: any, condition?: Condition);
  10120. /**
  10121. * Execute the action and do nothing.
  10122. */
  10123. execute(): void;
  10124. /**
  10125. * Serializes the actions and its related information.
  10126. * @param parent defines the object to serialize in
  10127. * @returns the serialized object
  10128. */
  10129. serialize(parent: any): any;
  10130. }
  10131. /**
  10132. * This defines an action responsible to trigger several actions once triggered.
  10133. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10134. */
  10135. export class CombineAction extends Action {
  10136. /**
  10137. * The list of aggregated animations to run.
  10138. */
  10139. children: Action[];
  10140. /**
  10141. * Instantiate the action
  10142. * @param triggerOptions defines the trigger options
  10143. * @param children defines the list of aggregated animations to run
  10144. * @param condition defines the trigger related conditions
  10145. */
  10146. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10147. /** @hidden */
  10148. _prepare(): void;
  10149. /**
  10150. * Execute the action and executes all the aggregated actions.
  10151. */
  10152. execute(evt: ActionEvent): void;
  10153. /**
  10154. * Serializes the actions and its related information.
  10155. * @param parent defines the object to serialize in
  10156. * @returns the serialized object
  10157. */
  10158. serialize(parent: any): any;
  10159. }
  10160. /**
  10161. * This defines an action responsible to run code (external event) once triggered.
  10162. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10163. */
  10164. export class ExecuteCodeAction extends Action {
  10165. /**
  10166. * The callback function to run.
  10167. */
  10168. func: (evt: ActionEvent) => void;
  10169. /**
  10170. * Instantiate the action
  10171. * @param triggerOptions defines the trigger options
  10172. * @param func defines the callback function to run
  10173. * @param condition defines the trigger related conditions
  10174. */
  10175. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10176. /**
  10177. * Execute the action and run the attached code.
  10178. */
  10179. execute(evt: ActionEvent): void;
  10180. }
  10181. /**
  10182. * This defines an action responsible to set the parent property of the target once triggered.
  10183. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10184. */
  10185. export class SetParentAction extends Action {
  10186. private _parent;
  10187. private _target;
  10188. /**
  10189. * Instantiate the action
  10190. * @param triggerOptions defines the trigger options
  10191. * @param target defines the target containing the parent property
  10192. * @param parent defines from where the animation should start (animation frame)
  10193. * @param condition defines the trigger related conditions
  10194. */
  10195. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10196. /** @hidden */
  10197. _prepare(): void;
  10198. /**
  10199. * Execute the action and set the parent property.
  10200. */
  10201. execute(): void;
  10202. /**
  10203. * Serializes the actions and its related information.
  10204. * @param parent defines the object to serialize in
  10205. * @returns the serialized object
  10206. */
  10207. serialize(parent: any): any;
  10208. }
  10209. }
  10210. declare module "babylonjs/Actions/actionManager" {
  10211. import { Nullable } from "babylonjs/types";
  10212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10213. import { Scene } from "babylonjs/scene";
  10214. import { IAction } from "babylonjs/Actions/action";
  10215. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10216. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10217. /**
  10218. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10219. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10220. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10221. */
  10222. export class ActionManager extends AbstractActionManager {
  10223. /**
  10224. * Nothing
  10225. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10226. */
  10227. static readonly NothingTrigger: number;
  10228. /**
  10229. * On pick
  10230. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10231. */
  10232. static readonly OnPickTrigger: number;
  10233. /**
  10234. * On left pick
  10235. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10236. */
  10237. static readonly OnLeftPickTrigger: number;
  10238. /**
  10239. * On right pick
  10240. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10241. */
  10242. static readonly OnRightPickTrigger: number;
  10243. /**
  10244. * On center pick
  10245. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10246. */
  10247. static readonly OnCenterPickTrigger: number;
  10248. /**
  10249. * On pick down
  10250. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10251. */
  10252. static readonly OnPickDownTrigger: number;
  10253. /**
  10254. * On double pick
  10255. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10256. */
  10257. static readonly OnDoublePickTrigger: number;
  10258. /**
  10259. * On pick up
  10260. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10261. */
  10262. static readonly OnPickUpTrigger: number;
  10263. /**
  10264. * On pick out.
  10265. * This trigger will only be raised if you also declared a OnPickDown
  10266. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10267. */
  10268. static readonly OnPickOutTrigger: number;
  10269. /**
  10270. * On long press
  10271. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10272. */
  10273. static readonly OnLongPressTrigger: number;
  10274. /**
  10275. * On pointer over
  10276. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10277. */
  10278. static readonly OnPointerOverTrigger: number;
  10279. /**
  10280. * On pointer out
  10281. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10282. */
  10283. static readonly OnPointerOutTrigger: number;
  10284. /**
  10285. * On every frame
  10286. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10287. */
  10288. static readonly OnEveryFrameTrigger: number;
  10289. /**
  10290. * On intersection enter
  10291. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10292. */
  10293. static readonly OnIntersectionEnterTrigger: number;
  10294. /**
  10295. * On intersection exit
  10296. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10297. */
  10298. static readonly OnIntersectionExitTrigger: number;
  10299. /**
  10300. * On key down
  10301. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10302. */
  10303. static readonly OnKeyDownTrigger: number;
  10304. /**
  10305. * On key up
  10306. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10307. */
  10308. static readonly OnKeyUpTrigger: number;
  10309. private _scene;
  10310. /**
  10311. * Creates a new action manager
  10312. * @param scene defines the hosting scene
  10313. */
  10314. constructor(scene: Scene);
  10315. /**
  10316. * Releases all associated resources
  10317. */
  10318. dispose(): void;
  10319. /**
  10320. * Gets hosting scene
  10321. * @returns the hosting scene
  10322. */
  10323. getScene(): Scene;
  10324. /**
  10325. * Does this action manager handles actions of any of the given triggers
  10326. * @param triggers defines the triggers to be tested
  10327. * @return a boolean indicating whether one (or more) of the triggers is handled
  10328. */
  10329. hasSpecificTriggers(triggers: number[]): boolean;
  10330. /**
  10331. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10332. * speed.
  10333. * @param triggerA defines the trigger to be tested
  10334. * @param triggerB defines the trigger to be tested
  10335. * @return a boolean indicating whether one (or more) of the triggers is handled
  10336. */
  10337. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10338. /**
  10339. * Does this action manager handles actions of a given trigger
  10340. * @param trigger defines the trigger to be tested
  10341. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10342. * @return whether the trigger is handled
  10343. */
  10344. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10345. /**
  10346. * Does this action manager has pointer triggers
  10347. */
  10348. get hasPointerTriggers(): boolean;
  10349. /**
  10350. * Does this action manager has pick triggers
  10351. */
  10352. get hasPickTriggers(): boolean;
  10353. /**
  10354. * Registers an action to this action manager
  10355. * @param action defines the action to be registered
  10356. * @return the action amended (prepared) after registration
  10357. */
  10358. registerAction(action: IAction): Nullable<IAction>;
  10359. /**
  10360. * Unregisters an action to this action manager
  10361. * @param action defines the action to be unregistered
  10362. * @return a boolean indicating whether the action has been unregistered
  10363. */
  10364. unregisterAction(action: IAction): Boolean;
  10365. /**
  10366. * Process a specific trigger
  10367. * @param trigger defines the trigger to process
  10368. * @param evt defines the event details to be processed
  10369. */
  10370. processTrigger(trigger: number, evt?: IActionEvent): void;
  10371. /** @hidden */
  10372. _getEffectiveTarget(target: any, propertyPath: string): any;
  10373. /** @hidden */
  10374. _getProperty(propertyPath: string): string;
  10375. /**
  10376. * Serialize this manager to a JSON object
  10377. * @param name defines the property name to store this manager
  10378. * @returns a JSON representation of this manager
  10379. */
  10380. serialize(name: string): any;
  10381. /**
  10382. * Creates a new ActionManager from a JSON data
  10383. * @param parsedActions defines the JSON data to read from
  10384. * @param object defines the hosting mesh
  10385. * @param scene defines the hosting scene
  10386. */
  10387. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10388. /**
  10389. * Get a trigger name by index
  10390. * @param trigger defines the trigger index
  10391. * @returns a trigger name
  10392. */
  10393. static GetTriggerName(trigger: number): string;
  10394. }
  10395. }
  10396. declare module "babylonjs/Sprites/sprite" {
  10397. import { Vector3 } from "babylonjs/Maths/math.vector";
  10398. import { Nullable } from "babylonjs/types";
  10399. import { ActionManager } from "babylonjs/Actions/actionManager";
  10400. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10401. import { Color4 } from "babylonjs/Maths/math.color";
  10402. import { Observable } from "babylonjs/Misc/observable";
  10403. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10404. import { Animation } from "babylonjs/Animations/animation";
  10405. /**
  10406. * Class used to represent a sprite
  10407. * @see https://doc.babylonjs.com/babylon101/sprites
  10408. */
  10409. export class Sprite implements IAnimatable {
  10410. /** defines the name */
  10411. name: string;
  10412. /** Gets or sets the current world position */
  10413. position: Vector3;
  10414. /** Gets or sets the main color */
  10415. color: Color4;
  10416. /** Gets or sets the width */
  10417. width: number;
  10418. /** Gets or sets the height */
  10419. height: number;
  10420. /** Gets or sets rotation angle */
  10421. angle: number;
  10422. /** Gets or sets the cell index in the sprite sheet */
  10423. cellIndex: number;
  10424. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10425. cellRef: string;
  10426. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10427. invertU: boolean;
  10428. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10429. invertV: boolean;
  10430. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10431. disposeWhenFinishedAnimating: boolean;
  10432. /** Gets the list of attached animations */
  10433. animations: Nullable<Array<Animation>>;
  10434. /** Gets or sets a boolean indicating if the sprite can be picked */
  10435. isPickable: boolean;
  10436. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10437. useAlphaForPicking: boolean;
  10438. /** @hidden */
  10439. _xOffset: number;
  10440. /** @hidden */
  10441. _yOffset: number;
  10442. /** @hidden */
  10443. _xSize: number;
  10444. /** @hidden */
  10445. _ySize: number;
  10446. /**
  10447. * Gets or sets the associated action manager
  10448. */
  10449. actionManager: Nullable<ActionManager>;
  10450. /**
  10451. * An event triggered when the control has been disposed
  10452. */
  10453. onDisposeObservable: Observable<Sprite>;
  10454. private _animationStarted;
  10455. private _loopAnimation;
  10456. private _fromIndex;
  10457. private _toIndex;
  10458. private _delay;
  10459. private _direction;
  10460. private _manager;
  10461. private _time;
  10462. private _onAnimationEnd;
  10463. /**
  10464. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10465. */
  10466. isVisible: boolean;
  10467. /**
  10468. * Gets or sets the sprite size
  10469. */
  10470. get size(): number;
  10471. set size(value: number);
  10472. /**
  10473. * Returns a boolean indicating if the animation is started
  10474. */
  10475. get animationStarted(): boolean;
  10476. /**
  10477. * Gets or sets the unique id of the sprite
  10478. */
  10479. uniqueId: number;
  10480. /**
  10481. * Gets the manager of this sprite
  10482. */
  10483. get manager(): ISpriteManager;
  10484. /**
  10485. * Creates a new Sprite
  10486. * @param name defines the name
  10487. * @param manager defines the manager
  10488. */
  10489. constructor(
  10490. /** defines the name */
  10491. name: string, manager: ISpriteManager);
  10492. /**
  10493. * Returns the string "Sprite"
  10494. * @returns "Sprite"
  10495. */
  10496. getClassName(): string;
  10497. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10498. get fromIndex(): number;
  10499. set fromIndex(value: number);
  10500. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10501. get toIndex(): number;
  10502. set toIndex(value: number);
  10503. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10504. get loopAnimation(): boolean;
  10505. set loopAnimation(value: boolean);
  10506. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10507. get delay(): number;
  10508. set delay(value: number);
  10509. /**
  10510. * Starts an animation
  10511. * @param from defines the initial key
  10512. * @param to defines the end key
  10513. * @param loop defines if the animation must loop
  10514. * @param delay defines the start delay (in ms)
  10515. * @param onAnimationEnd defines a callback to call when animation ends
  10516. */
  10517. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10518. /** Stops current animation (if any) */
  10519. stopAnimation(): void;
  10520. /** @hidden */
  10521. _animate(deltaTime: number): void;
  10522. /** Release associated resources */
  10523. dispose(): void;
  10524. /**
  10525. * Serializes the sprite to a JSON object
  10526. * @returns the JSON object
  10527. */
  10528. serialize(): any;
  10529. /**
  10530. * Parses a JSON object to create a new sprite
  10531. * @param parsedSprite The JSON object to parse
  10532. * @param manager defines the hosting manager
  10533. * @returns the new sprite
  10534. */
  10535. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10536. }
  10537. }
  10538. declare module "babylonjs/Collisions/pickingInfo" {
  10539. import { Nullable } from "babylonjs/types";
  10540. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10541. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10542. import { Sprite } from "babylonjs/Sprites/sprite";
  10543. import { Ray } from "babylonjs/Culling/ray";
  10544. /**
  10545. * Information about the result of picking within a scene
  10546. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10547. */
  10548. export class PickingInfo {
  10549. /** @hidden */
  10550. _pickingUnavailable: boolean;
  10551. /**
  10552. * If the pick collided with an object
  10553. */
  10554. hit: boolean;
  10555. /**
  10556. * Distance away where the pick collided
  10557. */
  10558. distance: number;
  10559. /**
  10560. * The location of pick collision
  10561. */
  10562. pickedPoint: Nullable<Vector3>;
  10563. /**
  10564. * The mesh corresponding the the pick collision
  10565. */
  10566. pickedMesh: Nullable<AbstractMesh>;
  10567. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10568. bu: number;
  10569. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10570. bv: number;
  10571. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10572. faceId: number;
  10573. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10574. subMeshFaceId: number;
  10575. /** Id of the the submesh that was picked */
  10576. subMeshId: number;
  10577. /** If a sprite was picked, this will be the sprite the pick collided with */
  10578. pickedSprite: Nullable<Sprite>;
  10579. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10580. thinInstanceIndex: number;
  10581. /**
  10582. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10583. */
  10584. originMesh: Nullable<AbstractMesh>;
  10585. /**
  10586. * The ray that was used to perform the picking.
  10587. */
  10588. ray: Nullable<Ray>;
  10589. /**
  10590. * Gets the normal correspodning to the face the pick collided with
  10591. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10592. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10593. * @returns The normal correspodning to the face the pick collided with
  10594. */
  10595. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10596. /**
  10597. * Gets the texture coordinates of where the pick occured
  10598. * @returns the vector containing the coordnates of the texture
  10599. */
  10600. getTextureCoordinates(): Nullable<Vector2>;
  10601. }
  10602. }
  10603. declare module "babylonjs/Culling/ray" {
  10604. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10605. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10606. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10607. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10608. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10609. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10610. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10611. import { Plane } from "babylonjs/Maths/math.plane";
  10612. /**
  10613. * Class representing a ray with position and direction
  10614. */
  10615. export class Ray {
  10616. /** origin point */
  10617. origin: Vector3;
  10618. /** direction */
  10619. direction: Vector3;
  10620. /** length of the ray */
  10621. length: number;
  10622. private static readonly _TmpVector3;
  10623. private _tmpRay;
  10624. /**
  10625. * Creates a new ray
  10626. * @param origin origin point
  10627. * @param direction direction
  10628. * @param length length of the ray
  10629. */
  10630. constructor(
  10631. /** origin point */
  10632. origin: Vector3,
  10633. /** direction */
  10634. direction: Vector3,
  10635. /** length of the ray */
  10636. length?: number);
  10637. /**
  10638. * Checks if the ray intersects a box
  10639. * This does not account for the ray lenght by design to improve perfs.
  10640. * @param minimum bound of the box
  10641. * @param maximum bound of the box
  10642. * @param intersectionTreshold extra extend to be added to the box in all direction
  10643. * @returns if the box was hit
  10644. */
  10645. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10646. /**
  10647. * Checks if the ray intersects a box
  10648. * This does not account for the ray lenght by design to improve perfs.
  10649. * @param box the bounding box to check
  10650. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10651. * @returns if the box was hit
  10652. */
  10653. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10654. /**
  10655. * If the ray hits a sphere
  10656. * @param sphere the bounding sphere to check
  10657. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10658. * @returns true if it hits the sphere
  10659. */
  10660. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10661. /**
  10662. * If the ray hits a triange
  10663. * @param vertex0 triangle vertex
  10664. * @param vertex1 triangle vertex
  10665. * @param vertex2 triangle vertex
  10666. * @returns intersection information if hit
  10667. */
  10668. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10669. /**
  10670. * Checks if ray intersects a plane
  10671. * @param plane the plane to check
  10672. * @returns the distance away it was hit
  10673. */
  10674. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10675. /**
  10676. * Calculate the intercept of a ray on a given axis
  10677. * @param axis to check 'x' | 'y' | 'z'
  10678. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10679. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10680. */
  10681. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10682. /**
  10683. * Checks if ray intersects a mesh
  10684. * @param mesh the mesh to check
  10685. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10686. * @returns picking info of the intersecton
  10687. */
  10688. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10689. /**
  10690. * Checks if ray intersects a mesh
  10691. * @param meshes the meshes to check
  10692. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10693. * @param results array to store result in
  10694. * @returns Array of picking infos
  10695. */
  10696. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10697. private _comparePickingInfo;
  10698. private static smallnum;
  10699. private static rayl;
  10700. /**
  10701. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10702. * @param sega the first point of the segment to test the intersection against
  10703. * @param segb the second point of the segment to test the intersection against
  10704. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10705. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10706. */
  10707. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10708. /**
  10709. * Update the ray from viewport position
  10710. * @param x position
  10711. * @param y y position
  10712. * @param viewportWidth viewport width
  10713. * @param viewportHeight viewport height
  10714. * @param world world matrix
  10715. * @param view view matrix
  10716. * @param projection projection matrix
  10717. * @returns this ray updated
  10718. */
  10719. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10720. /**
  10721. * Creates a ray with origin and direction of 0,0,0
  10722. * @returns the new ray
  10723. */
  10724. static Zero(): Ray;
  10725. /**
  10726. * Creates a new ray from screen space and viewport
  10727. * @param x position
  10728. * @param y y position
  10729. * @param viewportWidth viewport width
  10730. * @param viewportHeight viewport height
  10731. * @param world world matrix
  10732. * @param view view matrix
  10733. * @param projection projection matrix
  10734. * @returns new ray
  10735. */
  10736. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10737. /**
  10738. * 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
  10739. * transformed to the given world matrix.
  10740. * @param origin The origin point
  10741. * @param end The end point
  10742. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10743. * @returns the new ray
  10744. */
  10745. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10746. /**
  10747. * Transforms a ray by a matrix
  10748. * @param ray ray to transform
  10749. * @param matrix matrix to apply
  10750. * @returns the resulting new ray
  10751. */
  10752. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10753. /**
  10754. * Transforms a ray by a matrix
  10755. * @param ray ray to transform
  10756. * @param matrix matrix to apply
  10757. * @param result ray to store result in
  10758. */
  10759. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10760. /**
  10761. * Unproject a ray from screen space to object space
  10762. * @param sourceX defines the screen space x coordinate to use
  10763. * @param sourceY defines the screen space y coordinate to use
  10764. * @param viewportWidth defines the current width of the viewport
  10765. * @param viewportHeight defines the current height of the viewport
  10766. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10767. * @param view defines the view matrix to use
  10768. * @param projection defines the projection matrix to use
  10769. */
  10770. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10771. }
  10772. /**
  10773. * Type used to define predicate used to select faces when a mesh intersection is detected
  10774. */
  10775. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10776. module "babylonjs/scene" {
  10777. interface Scene {
  10778. /** @hidden */
  10779. _tempPickingRay: Nullable<Ray>;
  10780. /** @hidden */
  10781. _cachedRayForTransform: Ray;
  10782. /** @hidden */
  10783. _pickWithRayInverseMatrix: Matrix;
  10784. /** @hidden */
  10785. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10786. /** @hidden */
  10787. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10788. /** @hidden */
  10789. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10790. }
  10791. }
  10792. }
  10793. declare module "babylonjs/sceneComponent" {
  10794. import { Scene } from "babylonjs/scene";
  10795. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10796. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10797. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10798. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10799. import { Nullable } from "babylonjs/types";
  10800. import { Camera } from "babylonjs/Cameras/camera";
  10801. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10802. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10803. import { AbstractScene } from "babylonjs/abstractScene";
  10804. import { Mesh } from "babylonjs/Meshes/mesh";
  10805. /**
  10806. * Groups all the scene component constants in one place to ease maintenance.
  10807. * @hidden
  10808. */
  10809. export class SceneComponentConstants {
  10810. static readonly NAME_EFFECTLAYER: string;
  10811. static readonly NAME_LAYER: string;
  10812. static readonly NAME_LENSFLARESYSTEM: string;
  10813. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10814. static readonly NAME_PARTICLESYSTEM: string;
  10815. static readonly NAME_GAMEPAD: string;
  10816. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10817. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10818. static readonly NAME_PREPASSRENDERER: string;
  10819. static readonly NAME_DEPTHRENDERER: string;
  10820. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10821. static readonly NAME_SPRITE: string;
  10822. static readonly NAME_OUTLINERENDERER: string;
  10823. static readonly NAME_PROCEDURALTEXTURE: string;
  10824. static readonly NAME_SHADOWGENERATOR: string;
  10825. static readonly NAME_OCTREE: string;
  10826. static readonly NAME_PHYSICSENGINE: string;
  10827. static readonly NAME_AUDIO: string;
  10828. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10829. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10830. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10831. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10832. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10833. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10834. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10835. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10836. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10837. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10838. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10839. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10840. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10841. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10842. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10843. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10844. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10845. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10846. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10847. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10848. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10849. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10850. static readonly STEP_AFTERRENDER_AUDIO: number;
  10851. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10852. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10853. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10854. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10855. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10856. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10857. static readonly STEP_POINTERMOVE_SPRITE: number;
  10858. static readonly STEP_POINTERDOWN_SPRITE: number;
  10859. static readonly STEP_POINTERUP_SPRITE: number;
  10860. }
  10861. /**
  10862. * This represents a scene component.
  10863. *
  10864. * This is used to decouple the dependency the scene is having on the different workloads like
  10865. * layers, post processes...
  10866. */
  10867. export interface ISceneComponent {
  10868. /**
  10869. * The name of the component. Each component must have a unique name.
  10870. */
  10871. name: string;
  10872. /**
  10873. * The scene the component belongs to.
  10874. */
  10875. scene: Scene;
  10876. /**
  10877. * Register the component to one instance of a scene.
  10878. */
  10879. register(): void;
  10880. /**
  10881. * Rebuilds the elements related to this component in case of
  10882. * context lost for instance.
  10883. */
  10884. rebuild(): void;
  10885. /**
  10886. * Disposes the component and the associated ressources.
  10887. */
  10888. dispose(): void;
  10889. }
  10890. /**
  10891. * This represents a SERIALIZABLE scene component.
  10892. *
  10893. * This extends Scene Component to add Serialization methods on top.
  10894. */
  10895. export interface ISceneSerializableComponent extends ISceneComponent {
  10896. /**
  10897. * Adds all the elements from the container to the scene
  10898. * @param container the container holding the elements
  10899. */
  10900. addFromContainer(container: AbstractScene): void;
  10901. /**
  10902. * Removes all the elements in the container from the scene
  10903. * @param container contains the elements to remove
  10904. * @param dispose if the removed element should be disposed (default: false)
  10905. */
  10906. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10907. /**
  10908. * Serializes the component data to the specified json object
  10909. * @param serializationObject The object to serialize to
  10910. */
  10911. serialize(serializationObject: any): void;
  10912. }
  10913. /**
  10914. * Strong typing of a Mesh related stage step action
  10915. */
  10916. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10917. /**
  10918. * Strong typing of a Evaluate Sub Mesh related stage step action
  10919. */
  10920. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10921. /**
  10922. * Strong typing of a Active Mesh related stage step action
  10923. */
  10924. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10925. /**
  10926. * Strong typing of a Camera related stage step action
  10927. */
  10928. export type CameraStageAction = (camera: Camera) => void;
  10929. /**
  10930. * Strong typing of a Camera Frame buffer related stage step action
  10931. */
  10932. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10933. /**
  10934. * Strong typing of a Render Target related stage step action
  10935. */
  10936. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10937. /**
  10938. * Strong typing of a RenderingGroup related stage step action
  10939. */
  10940. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10941. /**
  10942. * Strong typing of a Mesh Render related stage step action
  10943. */
  10944. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10945. /**
  10946. * Strong typing of a simple stage step action
  10947. */
  10948. export type SimpleStageAction = () => void;
  10949. /**
  10950. * Strong typing of a render target action.
  10951. */
  10952. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10953. /**
  10954. * Strong typing of a pointer move action.
  10955. */
  10956. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10957. /**
  10958. * Strong typing of a pointer up/down action.
  10959. */
  10960. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10961. /**
  10962. * Representation of a stage in the scene (Basically a list of ordered steps)
  10963. * @hidden
  10964. */
  10965. export class Stage<T extends Function> extends Array<{
  10966. index: number;
  10967. component: ISceneComponent;
  10968. action: T;
  10969. }> {
  10970. /**
  10971. * Hide ctor from the rest of the world.
  10972. * @param items The items to add.
  10973. */
  10974. private constructor();
  10975. /**
  10976. * Creates a new Stage.
  10977. * @returns A new instance of a Stage
  10978. */
  10979. static Create<T extends Function>(): Stage<T>;
  10980. /**
  10981. * Registers a step in an ordered way in the targeted stage.
  10982. * @param index Defines the position to register the step in
  10983. * @param component Defines the component attached to the step
  10984. * @param action Defines the action to launch during the step
  10985. */
  10986. registerStep(index: number, component: ISceneComponent, action: T): void;
  10987. /**
  10988. * Clears all the steps from the stage.
  10989. */
  10990. clear(): void;
  10991. }
  10992. }
  10993. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10994. import { Nullable } from "babylonjs/types";
  10995. import { Observable } from "babylonjs/Misc/observable";
  10996. import { Scene } from "babylonjs/scene";
  10997. import { Sprite } from "babylonjs/Sprites/sprite";
  10998. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10999. import { Ray } from "babylonjs/Culling/ray";
  11000. import { Camera } from "babylonjs/Cameras/camera";
  11001. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11002. import { ISceneComponent } from "babylonjs/sceneComponent";
  11003. module "babylonjs/scene" {
  11004. interface Scene {
  11005. /** @hidden */
  11006. _pointerOverSprite: Nullable<Sprite>;
  11007. /** @hidden */
  11008. _pickedDownSprite: Nullable<Sprite>;
  11009. /** @hidden */
  11010. _tempSpritePickingRay: Nullable<Ray>;
  11011. /**
  11012. * All of the sprite managers added to this scene
  11013. * @see https://doc.babylonjs.com/babylon101/sprites
  11014. */
  11015. spriteManagers: Array<ISpriteManager>;
  11016. /**
  11017. * An event triggered when sprites rendering is about to start
  11018. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11019. */
  11020. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11021. /**
  11022. * An event triggered when sprites rendering is done
  11023. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11024. */
  11025. onAfterSpritesRenderingObservable: Observable<Scene>;
  11026. /** @hidden */
  11027. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11028. /** Launch a ray to try to pick a sprite in the scene
  11029. * @param x position on screen
  11030. * @param y position on screen
  11031. * @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
  11032. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11033. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11034. * @returns a PickingInfo
  11035. */
  11036. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11037. /** Use the given ray to pick a sprite in the scene
  11038. * @param ray The ray (in world space) to use to pick meshes
  11039. * @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
  11040. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11041. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11042. * @returns a PickingInfo
  11043. */
  11044. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11045. /** @hidden */
  11046. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11047. /** Launch a ray to try to pick sprites in the scene
  11048. * @param x position on screen
  11049. * @param y position on screen
  11050. * @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
  11051. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11052. * @returns a PickingInfo array
  11053. */
  11054. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11055. /** Use the given ray to pick sprites in the scene
  11056. * @param ray The ray (in world space) to use to pick meshes
  11057. * @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
  11058. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11059. * @returns a PickingInfo array
  11060. */
  11061. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11062. /**
  11063. * Force the sprite under the pointer
  11064. * @param sprite defines the sprite to use
  11065. */
  11066. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11067. /**
  11068. * Gets the sprite under the pointer
  11069. * @returns a Sprite or null if no sprite is under the pointer
  11070. */
  11071. getPointerOverSprite(): Nullable<Sprite>;
  11072. }
  11073. }
  11074. /**
  11075. * Defines the sprite scene component responsible to manage sprites
  11076. * in a given scene.
  11077. */
  11078. export class SpriteSceneComponent implements ISceneComponent {
  11079. /**
  11080. * The component name helpfull to identify the component in the list of scene components.
  11081. */
  11082. readonly name: string;
  11083. /**
  11084. * The scene the component belongs to.
  11085. */
  11086. scene: Scene;
  11087. /** @hidden */
  11088. private _spritePredicate;
  11089. /**
  11090. * Creates a new instance of the component for the given scene
  11091. * @param scene Defines the scene to register the component in
  11092. */
  11093. constructor(scene: Scene);
  11094. /**
  11095. * Registers the component in a given scene
  11096. */
  11097. register(): void;
  11098. /**
  11099. * Rebuilds the elements related to this component in case of
  11100. * context lost for instance.
  11101. */
  11102. rebuild(): void;
  11103. /**
  11104. * Disposes the component and the associated ressources.
  11105. */
  11106. dispose(): void;
  11107. private _pickSpriteButKeepRay;
  11108. private _pointerMove;
  11109. private _pointerDown;
  11110. private _pointerUp;
  11111. }
  11112. }
  11113. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11114. /** @hidden */
  11115. export var fogFragmentDeclaration: {
  11116. name: string;
  11117. shader: string;
  11118. };
  11119. }
  11120. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11121. /** @hidden */
  11122. export var fogFragment: {
  11123. name: string;
  11124. shader: string;
  11125. };
  11126. }
  11127. declare module "babylonjs/Shaders/sprites.fragment" {
  11128. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11129. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11130. /** @hidden */
  11131. export var spritesPixelShader: {
  11132. name: string;
  11133. shader: string;
  11134. };
  11135. }
  11136. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11137. /** @hidden */
  11138. export var fogVertexDeclaration: {
  11139. name: string;
  11140. shader: string;
  11141. };
  11142. }
  11143. declare module "babylonjs/Shaders/sprites.vertex" {
  11144. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11145. /** @hidden */
  11146. export var spritesVertexShader: {
  11147. name: string;
  11148. shader: string;
  11149. };
  11150. }
  11151. declare module "babylonjs/Sprites/spriteManager" {
  11152. import { IDisposable, Scene } from "babylonjs/scene";
  11153. import { Nullable } from "babylonjs/types";
  11154. import { Observable } from "babylonjs/Misc/observable";
  11155. import { Sprite } from "babylonjs/Sprites/sprite";
  11156. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11157. import { Camera } from "babylonjs/Cameras/camera";
  11158. import { Texture } from "babylonjs/Materials/Textures/texture";
  11159. import "babylonjs/Shaders/sprites.fragment";
  11160. import "babylonjs/Shaders/sprites.vertex";
  11161. import { Ray } from "babylonjs/Culling/ray";
  11162. /**
  11163. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11164. */
  11165. export interface ISpriteManager extends IDisposable {
  11166. /**
  11167. * Gets manager's name
  11168. */
  11169. name: string;
  11170. /**
  11171. * Restricts the camera to viewing objects with the same layerMask.
  11172. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11173. */
  11174. layerMask: number;
  11175. /**
  11176. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11177. */
  11178. isPickable: boolean;
  11179. /**
  11180. * Gets the hosting scene
  11181. */
  11182. scene: Scene;
  11183. /**
  11184. * Specifies the rendering group id for this mesh (0 by default)
  11185. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11186. */
  11187. renderingGroupId: number;
  11188. /**
  11189. * Defines the list of sprites managed by the manager.
  11190. */
  11191. sprites: Array<Sprite>;
  11192. /**
  11193. * Gets or sets the spritesheet texture
  11194. */
  11195. texture: Texture;
  11196. /** Defines the default width of a cell in the spritesheet */
  11197. cellWidth: number;
  11198. /** Defines the default height of a cell in the spritesheet */
  11199. cellHeight: number;
  11200. /**
  11201. * Tests the intersection of a sprite with a specific ray.
  11202. * @param ray The ray we are sending to test the collision
  11203. * @param camera The camera space we are sending rays in
  11204. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11205. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11206. * @returns picking info or null.
  11207. */
  11208. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11209. /**
  11210. * Intersects the sprites with a ray
  11211. * @param ray defines the ray to intersect with
  11212. * @param camera defines the current active camera
  11213. * @param predicate defines a predicate used to select candidate sprites
  11214. * @returns null if no hit or a PickingInfo array
  11215. */
  11216. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11217. /**
  11218. * Renders the list of sprites on screen.
  11219. */
  11220. render(): void;
  11221. }
  11222. /**
  11223. * Class used to manage multiple sprites on the same spritesheet
  11224. * @see https://doc.babylonjs.com/babylon101/sprites
  11225. */
  11226. export class SpriteManager implements ISpriteManager {
  11227. /** defines the manager's name */
  11228. name: string;
  11229. /** Define the Url to load snippets */
  11230. static SnippetUrl: string;
  11231. /** Snippet ID if the manager was created from the snippet server */
  11232. snippetId: string;
  11233. /** Gets the list of sprites */
  11234. sprites: Sprite[];
  11235. /** Gets or sets the rendering group id (0 by default) */
  11236. renderingGroupId: number;
  11237. /** Gets or sets camera layer mask */
  11238. layerMask: number;
  11239. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11240. fogEnabled: boolean;
  11241. /** Gets or sets a boolean indicating if the sprites are pickable */
  11242. isPickable: boolean;
  11243. /** Defines the default width of a cell in the spritesheet */
  11244. cellWidth: number;
  11245. /** Defines the default height of a cell in the spritesheet */
  11246. cellHeight: number;
  11247. /** Associative array from JSON sprite data file */
  11248. private _cellData;
  11249. /** Array of sprite names from JSON sprite data file */
  11250. private _spriteMap;
  11251. /** True when packed cell data from JSON file is ready*/
  11252. private _packedAndReady;
  11253. private _textureContent;
  11254. private _useInstancing;
  11255. /**
  11256. * An event triggered when the manager is disposed.
  11257. */
  11258. onDisposeObservable: Observable<SpriteManager>;
  11259. private _onDisposeObserver;
  11260. /**
  11261. * Callback called when the manager is disposed
  11262. */
  11263. set onDispose(callback: () => void);
  11264. private _capacity;
  11265. private _fromPacked;
  11266. private _spriteTexture;
  11267. private _epsilon;
  11268. private _scene;
  11269. private _vertexData;
  11270. private _buffer;
  11271. private _vertexBuffers;
  11272. private _spriteBuffer;
  11273. private _indexBuffer;
  11274. private _effectBase;
  11275. private _effectFog;
  11276. private _vertexBufferSize;
  11277. /**
  11278. * Gets or sets the unique id of the sprite
  11279. */
  11280. uniqueId: number;
  11281. /**
  11282. * Gets the array of sprites
  11283. */
  11284. get children(): Sprite[];
  11285. /**
  11286. * Gets the hosting scene
  11287. */
  11288. get scene(): Scene;
  11289. /**
  11290. * Gets the capacity of the manager
  11291. */
  11292. get capacity(): number;
  11293. /**
  11294. * Gets or sets the spritesheet texture
  11295. */
  11296. get texture(): Texture;
  11297. set texture(value: Texture);
  11298. private _blendMode;
  11299. /**
  11300. * Blend mode use to render the particle, it can be any of
  11301. * the static Constants.ALPHA_x properties provided in this class.
  11302. * Default value is Constants.ALPHA_COMBINE
  11303. */
  11304. get blendMode(): number;
  11305. set blendMode(blendMode: number);
  11306. /** Disables writing to the depth buffer when rendering the sprites.
  11307. * It can be handy to disable depth writing when using textures without alpha channel
  11308. * and setting some specific blend modes.
  11309. */
  11310. disableDepthWrite: boolean;
  11311. /**
  11312. * Creates a new sprite manager
  11313. * @param name defines the manager's name
  11314. * @param imgUrl defines the sprite sheet url
  11315. * @param capacity defines the maximum allowed number of sprites
  11316. * @param cellSize defines the size of a sprite cell
  11317. * @param scene defines the hosting scene
  11318. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11319. * @param samplingMode defines the smapling mode to use with spritesheet
  11320. * @param fromPacked set to false; do not alter
  11321. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11322. */
  11323. constructor(
  11324. /** defines the manager's name */
  11325. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11326. /**
  11327. * Returns the string "SpriteManager"
  11328. * @returns "SpriteManager"
  11329. */
  11330. getClassName(): string;
  11331. private _makePacked;
  11332. private _appendSpriteVertex;
  11333. private _checkTextureAlpha;
  11334. /**
  11335. * Intersects the sprites with a ray
  11336. * @param ray defines the ray to intersect with
  11337. * @param camera defines the current active camera
  11338. * @param predicate defines a predicate used to select candidate sprites
  11339. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11340. * @returns null if no hit or a PickingInfo
  11341. */
  11342. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11343. /**
  11344. * Intersects the sprites with a ray
  11345. * @param ray defines the ray to intersect with
  11346. * @param camera defines the current active camera
  11347. * @param predicate defines a predicate used to select candidate sprites
  11348. * @returns null if no hit or a PickingInfo array
  11349. */
  11350. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11351. /**
  11352. * Render all child sprites
  11353. */
  11354. render(): void;
  11355. /**
  11356. * Release associated resources
  11357. */
  11358. dispose(): void;
  11359. /**
  11360. * Serializes the sprite manager to a JSON object
  11361. * @param serializeTexture defines if the texture must be serialized as well
  11362. * @returns the JSON object
  11363. */
  11364. serialize(serializeTexture?: boolean): any;
  11365. /**
  11366. * Parses a JSON object to create a new sprite manager.
  11367. * @param parsedManager The JSON object to parse
  11368. * @param scene The scene to create the sprite managerin
  11369. * @param rootUrl The root url to use to load external dependencies like texture
  11370. * @returns the new sprite manager
  11371. */
  11372. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11373. /**
  11374. * Creates a sprite manager from a snippet saved in a remote file
  11375. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11376. * @param url defines the url to load from
  11377. * @param scene defines the hosting scene
  11378. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11379. * @returns a promise that will resolve to the new sprite manager
  11380. */
  11381. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11382. /**
  11383. * Creates a sprite manager from a snippet saved by the sprite editor
  11384. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11385. * @param scene defines the hosting scene
  11386. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11387. * @returns a promise that will resolve to the new sprite manager
  11388. */
  11389. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11390. }
  11391. }
  11392. declare module "babylonjs/Misc/gradients" {
  11393. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11394. /** Interface used by value gradients (color, factor, ...) */
  11395. export interface IValueGradient {
  11396. /**
  11397. * Gets or sets the gradient value (between 0 and 1)
  11398. */
  11399. gradient: number;
  11400. }
  11401. /** Class used to store color4 gradient */
  11402. export class ColorGradient implements IValueGradient {
  11403. /**
  11404. * Gets or sets the gradient value (between 0 and 1)
  11405. */
  11406. gradient: number;
  11407. /**
  11408. * Gets or sets first associated color
  11409. */
  11410. color1: Color4;
  11411. /**
  11412. * Gets or sets second associated color
  11413. */
  11414. color2?: Color4 | undefined;
  11415. /**
  11416. * Creates a new color4 gradient
  11417. * @param gradient gets or sets the gradient value (between 0 and 1)
  11418. * @param color1 gets or sets first associated color
  11419. * @param color2 gets or sets first second color
  11420. */
  11421. constructor(
  11422. /**
  11423. * Gets or sets the gradient value (between 0 and 1)
  11424. */
  11425. gradient: number,
  11426. /**
  11427. * Gets or sets first associated color
  11428. */
  11429. color1: Color4,
  11430. /**
  11431. * Gets or sets second associated color
  11432. */
  11433. color2?: Color4 | undefined);
  11434. /**
  11435. * Will get a color picked randomly between color1 and color2.
  11436. * If color2 is undefined then color1 will be used
  11437. * @param result defines the target Color4 to store the result in
  11438. */
  11439. getColorToRef(result: Color4): void;
  11440. }
  11441. /** Class used to store color 3 gradient */
  11442. export class Color3Gradient implements IValueGradient {
  11443. /**
  11444. * Gets or sets the gradient value (between 0 and 1)
  11445. */
  11446. gradient: number;
  11447. /**
  11448. * Gets or sets the associated color
  11449. */
  11450. color: Color3;
  11451. /**
  11452. * Creates a new color3 gradient
  11453. * @param gradient gets or sets the gradient value (between 0 and 1)
  11454. * @param color gets or sets associated color
  11455. */
  11456. constructor(
  11457. /**
  11458. * Gets or sets the gradient value (between 0 and 1)
  11459. */
  11460. gradient: number,
  11461. /**
  11462. * Gets or sets the associated color
  11463. */
  11464. color: Color3);
  11465. }
  11466. /** Class used to store factor gradient */
  11467. export class FactorGradient implements IValueGradient {
  11468. /**
  11469. * Gets or sets the gradient value (between 0 and 1)
  11470. */
  11471. gradient: number;
  11472. /**
  11473. * Gets or sets first associated factor
  11474. */
  11475. factor1: number;
  11476. /**
  11477. * Gets or sets second associated factor
  11478. */
  11479. factor2?: number | undefined;
  11480. /**
  11481. * Creates a new factor gradient
  11482. * @param gradient gets or sets the gradient value (between 0 and 1)
  11483. * @param factor1 gets or sets first associated factor
  11484. * @param factor2 gets or sets second associated factor
  11485. */
  11486. constructor(
  11487. /**
  11488. * Gets or sets the gradient value (between 0 and 1)
  11489. */
  11490. gradient: number,
  11491. /**
  11492. * Gets or sets first associated factor
  11493. */
  11494. factor1: number,
  11495. /**
  11496. * Gets or sets second associated factor
  11497. */
  11498. factor2?: number | undefined);
  11499. /**
  11500. * Will get a number picked randomly between factor1 and factor2.
  11501. * If factor2 is undefined then factor1 will be used
  11502. * @returns the picked number
  11503. */
  11504. getFactor(): number;
  11505. }
  11506. /**
  11507. * Helper used to simplify some generic gradient tasks
  11508. */
  11509. export class GradientHelper {
  11510. /**
  11511. * Gets the current gradient from an array of IValueGradient
  11512. * @param ratio defines the current ratio to get
  11513. * @param gradients defines the array of IValueGradient
  11514. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11515. */
  11516. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11517. }
  11518. }
  11519. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11520. import { Nullable } from "babylonjs/types";
  11521. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11522. import { Scene } from "babylonjs/scene";
  11523. module "babylonjs/Engines/thinEngine" {
  11524. interface ThinEngine {
  11525. /**
  11526. * Creates a raw texture
  11527. * @param data defines the data to store in the texture
  11528. * @param width defines the width of the texture
  11529. * @param height defines the height of the texture
  11530. * @param format defines the format of the data
  11531. * @param generateMipMaps defines if the engine should generate the mip levels
  11532. * @param invertY defines if data must be stored with Y axis inverted
  11533. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11534. * @param compression defines the compression used (null by default)
  11535. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11536. * @returns the raw texture inside an InternalTexture
  11537. */
  11538. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11539. /**
  11540. * Update a raw texture
  11541. * @param texture defines the texture to update
  11542. * @param data defines the data to store in the texture
  11543. * @param format defines the format of the data
  11544. * @param invertY defines if data must be stored with Y axis inverted
  11545. */
  11546. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11547. /**
  11548. * Update a raw texture
  11549. * @param texture defines the texture to update
  11550. * @param data defines the data to store in the texture
  11551. * @param format defines the format of the data
  11552. * @param invertY defines if data must be stored with Y axis inverted
  11553. * @param compression defines the compression used (null by default)
  11554. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11555. */
  11556. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11557. /**
  11558. * Creates a new raw cube texture
  11559. * @param data defines the array of data to use to create each face
  11560. * @param size defines the size of the textures
  11561. * @param format defines the format of the data
  11562. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11563. * @param generateMipMaps defines if the engine should generate the mip levels
  11564. * @param invertY defines if data must be stored with Y axis inverted
  11565. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11566. * @param compression defines the compression used (null by default)
  11567. * @returns the cube texture as an InternalTexture
  11568. */
  11569. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11570. /**
  11571. * Update a raw cube texture
  11572. * @param texture defines the texture to udpdate
  11573. * @param data defines the data to store
  11574. * @param format defines the data format
  11575. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11576. * @param invertY defines if data must be stored with Y axis inverted
  11577. */
  11578. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11579. /**
  11580. * Update a raw cube texture
  11581. * @param texture defines the texture to udpdate
  11582. * @param data defines the data to store
  11583. * @param format defines the data format
  11584. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11585. * @param invertY defines if data must be stored with Y axis inverted
  11586. * @param compression defines the compression used (null by default)
  11587. */
  11588. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11589. /**
  11590. * Update a raw cube texture
  11591. * @param texture defines the texture to udpdate
  11592. * @param data defines the data to store
  11593. * @param format defines the data format
  11594. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11595. * @param invertY defines if data must be stored with Y axis inverted
  11596. * @param compression defines the compression used (null by default)
  11597. * @param level defines which level of the texture to update
  11598. */
  11599. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11600. /**
  11601. * Creates a new raw cube texture from a specified url
  11602. * @param url defines the url where the data is located
  11603. * @param scene defines the current scene
  11604. * @param size defines the size of the textures
  11605. * @param format defines the format of the data
  11606. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11607. * @param noMipmap defines if the engine should avoid generating the mip levels
  11608. * @param callback defines a callback used to extract texture data from loaded data
  11609. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11610. * @param onLoad defines a callback called when texture is loaded
  11611. * @param onError defines a callback called if there is an error
  11612. * @returns the cube texture as an InternalTexture
  11613. */
  11614. 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;
  11615. /**
  11616. * Creates a new raw cube texture from a specified url
  11617. * @param url defines the url where the data is located
  11618. * @param scene defines the current scene
  11619. * @param size defines the size of the textures
  11620. * @param format defines the format of the data
  11621. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11622. * @param noMipmap defines if the engine should avoid generating the mip levels
  11623. * @param callback defines a callback used to extract texture data from loaded data
  11624. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11625. * @param onLoad defines a callback called when texture is loaded
  11626. * @param onError defines a callback called if there is an error
  11627. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11628. * @param invertY defines if data must be stored with Y axis inverted
  11629. * @returns the cube texture as an InternalTexture
  11630. */
  11631. 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;
  11632. /**
  11633. * Creates a new raw 3D texture
  11634. * @param data defines the data used to create the texture
  11635. * @param width defines the width of the texture
  11636. * @param height defines the height of the texture
  11637. * @param depth defines the depth of the texture
  11638. * @param format defines the format of the texture
  11639. * @param generateMipMaps defines if the engine must generate mip levels
  11640. * @param invertY defines if data must be stored with Y axis inverted
  11641. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11642. * @param compression defines the compressed used (can be null)
  11643. * @param textureType defines the compressed used (can be null)
  11644. * @returns a new raw 3D texture (stored in an InternalTexture)
  11645. */
  11646. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11647. /**
  11648. * Update a raw 3D texture
  11649. * @param texture defines the texture to update
  11650. * @param data defines the data to store
  11651. * @param format defines the data format
  11652. * @param invertY defines if data must be stored with Y axis inverted
  11653. */
  11654. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11655. /**
  11656. * Update a raw 3D texture
  11657. * @param texture defines the texture to update
  11658. * @param data defines the data to store
  11659. * @param format defines the data format
  11660. * @param invertY defines if data must be stored with Y axis inverted
  11661. * @param compression defines the used compression (can be null)
  11662. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11663. */
  11664. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11665. /**
  11666. * Creates a new raw 2D array texture
  11667. * @param data defines the data used to create the texture
  11668. * @param width defines the width of the texture
  11669. * @param height defines the height of the texture
  11670. * @param depth defines the number of layers of the texture
  11671. * @param format defines the format of the texture
  11672. * @param generateMipMaps defines if the engine must generate mip levels
  11673. * @param invertY defines if data must be stored with Y axis inverted
  11674. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11675. * @param compression defines the compressed used (can be null)
  11676. * @param textureType defines the compressed used (can be null)
  11677. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11678. */
  11679. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11680. /**
  11681. * Update a raw 2D array texture
  11682. * @param texture defines the texture to update
  11683. * @param data defines the data to store
  11684. * @param format defines the data format
  11685. * @param invertY defines if data must be stored with Y axis inverted
  11686. */
  11687. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11688. /**
  11689. * Update a raw 2D array texture
  11690. * @param texture defines the texture to update
  11691. * @param data defines the data to store
  11692. * @param format defines the data format
  11693. * @param invertY defines if data must be stored with Y axis inverted
  11694. * @param compression defines the used compression (can be null)
  11695. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11696. */
  11697. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11698. }
  11699. }
  11700. }
  11701. declare module "babylonjs/Materials/Textures/rawTexture" {
  11702. import { Texture } from "babylonjs/Materials/Textures/texture";
  11703. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11704. import { Nullable } from "babylonjs/types";
  11705. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11706. import { Scene } from "babylonjs/scene";
  11707. /**
  11708. * Raw texture can help creating a texture directly from an array of data.
  11709. * This can be super useful if you either get the data from an uncompressed source or
  11710. * if you wish to create your texture pixel by pixel.
  11711. */
  11712. export class RawTexture extends Texture {
  11713. /**
  11714. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11715. */
  11716. format: number;
  11717. /**
  11718. * Instantiates a new RawTexture.
  11719. * Raw texture can help creating a texture directly from an array of data.
  11720. * This can be super useful if you either get the data from an uncompressed source or
  11721. * if you wish to create your texture pixel by pixel.
  11722. * @param data define the array of data to use to create the texture
  11723. * @param width define the width of the texture
  11724. * @param height define the height of the texture
  11725. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11726. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11727. * @param generateMipMaps define whether mip maps should be generated or not
  11728. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11729. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11730. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11731. */
  11732. constructor(data: ArrayBufferView, width: number, height: number,
  11733. /**
  11734. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11735. */
  11736. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11737. /**
  11738. * Updates the texture underlying data.
  11739. * @param data Define the new data of the texture
  11740. */
  11741. update(data: ArrayBufferView): void;
  11742. /**
  11743. * Creates a luminance texture from some data.
  11744. * @param data Define the texture data
  11745. * @param width Define the width of the texture
  11746. * @param height Define the height of the texture
  11747. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11748. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11749. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11750. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11751. * @returns the luminance texture
  11752. */
  11753. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11754. /**
  11755. * Creates a luminance alpha texture from some data.
  11756. * @param data Define the texture data
  11757. * @param width Define the width of the texture
  11758. * @param height Define the height of the texture
  11759. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11760. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11761. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11762. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11763. * @returns the luminance alpha texture
  11764. */
  11765. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11766. /**
  11767. * Creates an alpha texture from some data.
  11768. * @param data Define the texture data
  11769. * @param width Define the width of the texture
  11770. * @param height Define the height of the texture
  11771. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11772. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11773. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11774. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11775. * @returns the alpha texture
  11776. */
  11777. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11778. /**
  11779. * Creates a RGB texture from some data.
  11780. * @param data Define the texture data
  11781. * @param width Define the width of the texture
  11782. * @param height Define the height of the texture
  11783. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11784. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11785. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11786. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11787. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11788. * @returns the RGB alpha texture
  11789. */
  11790. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11791. /**
  11792. * Creates a RGBA texture from some data.
  11793. * @param data Define the texture data
  11794. * @param width Define the width of the texture
  11795. * @param height Define the height of the texture
  11796. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11797. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11798. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11799. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11800. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11801. * @returns the RGBA texture
  11802. */
  11803. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11804. /**
  11805. * Creates a R texture from some data.
  11806. * @param data Define the texture data
  11807. * @param width Define the width of the texture
  11808. * @param height Define the height of the texture
  11809. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11810. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11811. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11812. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11813. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11814. * @returns the R texture
  11815. */
  11816. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11817. }
  11818. }
  11819. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  11820. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  11821. import { IndicesArray, DataArray } from "babylonjs/types";
  11822. module "babylonjs/Engines/thinEngine" {
  11823. interface ThinEngine {
  11824. /**
  11825. * Update a dynamic index buffer
  11826. * @param indexBuffer defines the target index buffer
  11827. * @param indices defines the data to update
  11828. * @param offset defines the offset in the target index buffer where update should start
  11829. */
  11830. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11831. /**
  11832. * Updates a dynamic vertex buffer.
  11833. * @param vertexBuffer the vertex buffer to update
  11834. * @param data the data used to update the vertex buffer
  11835. * @param byteOffset the byte offset of the data
  11836. * @param byteLength the byte length of the data
  11837. */
  11838. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11839. }
  11840. }
  11841. }
  11842. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11843. import { Scene } from "babylonjs/scene";
  11844. import { ISceneComponent } from "babylonjs/sceneComponent";
  11845. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11846. module "babylonjs/abstractScene" {
  11847. interface AbstractScene {
  11848. /**
  11849. * The list of procedural textures added to the scene
  11850. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11851. */
  11852. proceduralTextures: Array<ProceduralTexture>;
  11853. }
  11854. }
  11855. /**
  11856. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11857. * in a given scene.
  11858. */
  11859. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11860. /**
  11861. * The component name helpfull to identify the component in the list of scene components.
  11862. */
  11863. readonly name: string;
  11864. /**
  11865. * The scene the component belongs to.
  11866. */
  11867. scene: Scene;
  11868. /**
  11869. * Creates a new instance of the component for the given scene
  11870. * @param scene Defines the scene to register the component in
  11871. */
  11872. constructor(scene: Scene);
  11873. /**
  11874. * Registers the component in a given scene
  11875. */
  11876. register(): void;
  11877. /**
  11878. * Rebuilds the elements related to this component in case of
  11879. * context lost for instance.
  11880. */
  11881. rebuild(): void;
  11882. /**
  11883. * Disposes the component and the associated ressources.
  11884. */
  11885. dispose(): void;
  11886. private _beforeClear;
  11887. }
  11888. }
  11889. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11890. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11891. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11892. module "babylonjs/Engines/thinEngine" {
  11893. interface ThinEngine {
  11894. /**
  11895. * Creates a new render target cube texture
  11896. * @param size defines the size of the texture
  11897. * @param options defines the options used to create the texture
  11898. * @returns a new render target cube texture stored in an InternalTexture
  11899. */
  11900. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11901. }
  11902. }
  11903. }
  11904. declare module "babylonjs/Shaders/procedural.vertex" {
  11905. /** @hidden */
  11906. export var proceduralVertexShader: {
  11907. name: string;
  11908. shader: string;
  11909. };
  11910. }
  11911. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11912. import { Observable } from "babylonjs/Misc/observable";
  11913. import { Nullable } from "babylonjs/types";
  11914. import { Scene } from "babylonjs/scene";
  11915. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11916. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11917. import { Effect } from "babylonjs/Materials/effect";
  11918. import { Texture } from "babylonjs/Materials/Textures/texture";
  11919. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11920. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11921. import "babylonjs/Shaders/procedural.vertex";
  11922. /**
  11923. * 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.
  11924. * This is the base class of any Procedural texture and contains most of the shareable code.
  11925. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11926. */
  11927. export class ProceduralTexture extends Texture {
  11928. /**
  11929. * Define if the texture is enabled or not (disabled texture will not render)
  11930. */
  11931. isEnabled: boolean;
  11932. /**
  11933. * Define if the texture must be cleared before rendering (default is true)
  11934. */
  11935. autoClear: boolean;
  11936. /**
  11937. * Callback called when the texture is generated
  11938. */
  11939. onGenerated: () => void;
  11940. /**
  11941. * Event raised when the texture is generated
  11942. */
  11943. onGeneratedObservable: Observable<ProceduralTexture>;
  11944. /** @hidden */
  11945. _generateMipMaps: boolean;
  11946. /** @hidden **/
  11947. _effect: Effect;
  11948. /** @hidden */
  11949. _textures: {
  11950. [key: string]: Texture;
  11951. };
  11952. /** @hidden */
  11953. protected _fallbackTexture: Nullable<Texture>;
  11954. private _size;
  11955. private _currentRefreshId;
  11956. private _frameId;
  11957. private _refreshRate;
  11958. private _vertexBuffers;
  11959. private _indexBuffer;
  11960. private _uniforms;
  11961. private _samplers;
  11962. private _fragment;
  11963. private _floats;
  11964. private _ints;
  11965. private _floatsArrays;
  11966. private _colors3;
  11967. private _colors4;
  11968. private _vectors2;
  11969. private _vectors3;
  11970. private _matrices;
  11971. private _fallbackTextureUsed;
  11972. private _fullEngine;
  11973. private _cachedDefines;
  11974. private _contentUpdateId;
  11975. private _contentData;
  11976. /**
  11977. * Instantiates a new procedural texture.
  11978. * 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.
  11979. * This is the base class of any Procedural texture and contains most of the shareable code.
  11980. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11981. * @param name Define the name of the texture
  11982. * @param size Define the size of the texture to create
  11983. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11984. * @param scene Define the scene the texture belongs to
  11985. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11986. * @param generateMipMaps Define if the texture should creates mip maps or not
  11987. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11988. */
  11989. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11990. /**
  11991. * The effect that is created when initializing the post process.
  11992. * @returns The created effect corresponding the the postprocess.
  11993. */
  11994. getEffect(): Effect;
  11995. /**
  11996. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11997. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11998. */
  11999. getContent(): Nullable<ArrayBufferView>;
  12000. private _createIndexBuffer;
  12001. /** @hidden */
  12002. _rebuild(): void;
  12003. /**
  12004. * Resets the texture in order to recreate its associated resources.
  12005. * This can be called in case of context loss
  12006. */
  12007. reset(): void;
  12008. protected _getDefines(): string;
  12009. /**
  12010. * Is the texture ready to be used ? (rendered at least once)
  12011. * @returns true if ready, otherwise, false.
  12012. */
  12013. isReady(): boolean;
  12014. /**
  12015. * Resets the refresh counter of the texture and start bak from scratch.
  12016. * Could be useful to regenerate the texture if it is setup to render only once.
  12017. */
  12018. resetRefreshCounter(): void;
  12019. /**
  12020. * Set the fragment shader to use in order to render the texture.
  12021. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12022. */
  12023. setFragment(fragment: any): void;
  12024. /**
  12025. * Define the refresh rate of the texture or the rendering frequency.
  12026. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12027. */
  12028. get refreshRate(): number;
  12029. set refreshRate(value: number);
  12030. /** @hidden */
  12031. _shouldRender(): boolean;
  12032. /**
  12033. * Get the size the texture is rendering at.
  12034. * @returns the size (texture is always squared)
  12035. */
  12036. getRenderSize(): number;
  12037. /**
  12038. * Resize the texture to new value.
  12039. * @param size Define the new size the texture should have
  12040. * @param generateMipMaps Define whether the new texture should create mip maps
  12041. */
  12042. resize(size: number, generateMipMaps: boolean): void;
  12043. private _checkUniform;
  12044. /**
  12045. * Set a texture in the shader program used to render.
  12046. * @param name Define the name of the uniform samplers as defined in the shader
  12047. * @param texture Define the texture to bind to this sampler
  12048. * @return the texture itself allowing "fluent" like uniform updates
  12049. */
  12050. setTexture(name: string, texture: Texture): ProceduralTexture;
  12051. /**
  12052. * Set a float in the shader.
  12053. * @param name Define the name of the uniform as defined in the shader
  12054. * @param value Define the value to give to the uniform
  12055. * @return the texture itself allowing "fluent" like uniform updates
  12056. */
  12057. setFloat(name: string, value: number): ProceduralTexture;
  12058. /**
  12059. * Set a int in the shader.
  12060. * @param name Define the name of the uniform as defined in the shader
  12061. * @param value Define the value to give to the uniform
  12062. * @return the texture itself allowing "fluent" like uniform updates
  12063. */
  12064. setInt(name: string, value: number): ProceduralTexture;
  12065. /**
  12066. * Set an array of floats in the shader.
  12067. * @param name Define the name of the uniform as defined in the shader
  12068. * @param value Define the value to give to the uniform
  12069. * @return the texture itself allowing "fluent" like uniform updates
  12070. */
  12071. setFloats(name: string, value: number[]): ProceduralTexture;
  12072. /**
  12073. * Set a vec3 in the shader from a Color3.
  12074. * @param name Define the name of the uniform as defined in the shader
  12075. * @param value Define the value to give to the uniform
  12076. * @return the texture itself allowing "fluent" like uniform updates
  12077. */
  12078. setColor3(name: string, value: Color3): ProceduralTexture;
  12079. /**
  12080. * Set a vec4 in the shader from a Color4.
  12081. * @param name Define the name of the uniform as defined in the shader
  12082. * @param value Define the value to give to the uniform
  12083. * @return the texture itself allowing "fluent" like uniform updates
  12084. */
  12085. setColor4(name: string, value: Color4): ProceduralTexture;
  12086. /**
  12087. * Set a vec2 in the shader from a Vector2.
  12088. * @param name Define the name of the uniform as defined in the shader
  12089. * @param value Define the value to give to the uniform
  12090. * @return the texture itself allowing "fluent" like uniform updates
  12091. */
  12092. setVector2(name: string, value: Vector2): ProceduralTexture;
  12093. /**
  12094. * Set a vec3 in the shader from a Vector3.
  12095. * @param name Define the name of the uniform as defined in the shader
  12096. * @param value Define the value to give to the uniform
  12097. * @return the texture itself allowing "fluent" like uniform updates
  12098. */
  12099. setVector3(name: string, value: Vector3): ProceduralTexture;
  12100. /**
  12101. * Set a mat4 in the shader from a MAtrix.
  12102. * @param name Define the name of the uniform as defined in the shader
  12103. * @param value Define the value to give to the uniform
  12104. * @return the texture itself allowing "fluent" like uniform updates
  12105. */
  12106. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12107. /**
  12108. * Render the texture to its associated render target.
  12109. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12110. */
  12111. render(useCameraPostProcess?: boolean): void;
  12112. /**
  12113. * Clone the texture.
  12114. * @returns the cloned texture
  12115. */
  12116. clone(): ProceduralTexture;
  12117. /**
  12118. * Dispose the texture and release its asoociated resources.
  12119. */
  12120. dispose(): void;
  12121. }
  12122. }
  12123. declare module "babylonjs/Particles/baseParticleSystem" {
  12124. import { Nullable } from "babylonjs/types";
  12125. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12127. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12128. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12129. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12130. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12131. import { Color4 } from "babylonjs/Maths/math.color";
  12132. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12133. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  12134. import { Animation } from "babylonjs/Animations/animation";
  12135. import { Scene } from "babylonjs/scene";
  12136. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12137. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12138. /**
  12139. * This represents the base class for particle system in Babylon.
  12140. * 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.
  12141. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12142. * @example https://doc.babylonjs.com/babylon101/particles
  12143. */
  12144. export class BaseParticleSystem {
  12145. /**
  12146. * Source color is added to the destination color without alpha affecting the result
  12147. */
  12148. static BLENDMODE_ONEONE: number;
  12149. /**
  12150. * Blend current color and particle color using particle’s alpha
  12151. */
  12152. static BLENDMODE_STANDARD: number;
  12153. /**
  12154. * Add current color and particle color multiplied by particle’s alpha
  12155. */
  12156. static BLENDMODE_ADD: number;
  12157. /**
  12158. * Multiply current color with particle color
  12159. */
  12160. static BLENDMODE_MULTIPLY: number;
  12161. /**
  12162. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12163. */
  12164. static BLENDMODE_MULTIPLYADD: number;
  12165. /**
  12166. * List of animations used by the particle system.
  12167. */
  12168. animations: Animation[];
  12169. /**
  12170. * Gets or sets the unique id of the particle system
  12171. */
  12172. uniqueId: number;
  12173. /**
  12174. * The id of the Particle system.
  12175. */
  12176. id: string;
  12177. /**
  12178. * The friendly name of the Particle system.
  12179. */
  12180. name: string;
  12181. /**
  12182. * Snippet ID if the particle system was created from the snippet server
  12183. */
  12184. snippetId: string;
  12185. /**
  12186. * The rendering group used by the Particle system to chose when to render.
  12187. */
  12188. renderingGroupId: number;
  12189. /**
  12190. * The emitter represents the Mesh or position we are attaching the particle system to.
  12191. */
  12192. emitter: Nullable<AbstractMesh | Vector3>;
  12193. /**
  12194. * The maximum number of particles to emit per frame
  12195. */
  12196. emitRate: number;
  12197. /**
  12198. * If you want to launch only a few particles at once, that can be done, as well.
  12199. */
  12200. manualEmitCount: number;
  12201. /**
  12202. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12203. */
  12204. updateSpeed: number;
  12205. /**
  12206. * The amount of time the particle system is running (depends of the overall update speed).
  12207. */
  12208. targetStopDuration: number;
  12209. /**
  12210. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12211. */
  12212. disposeOnStop: boolean;
  12213. /**
  12214. * Minimum power of emitting particles.
  12215. */
  12216. minEmitPower: number;
  12217. /**
  12218. * Maximum power of emitting particles.
  12219. */
  12220. maxEmitPower: number;
  12221. /**
  12222. * Minimum life time of emitting particles.
  12223. */
  12224. minLifeTime: number;
  12225. /**
  12226. * Maximum life time of emitting particles.
  12227. */
  12228. maxLifeTime: number;
  12229. /**
  12230. * Minimum Size of emitting particles.
  12231. */
  12232. minSize: number;
  12233. /**
  12234. * Maximum Size of emitting particles.
  12235. */
  12236. maxSize: number;
  12237. /**
  12238. * Minimum scale of emitting particles on X axis.
  12239. */
  12240. minScaleX: number;
  12241. /**
  12242. * Maximum scale of emitting particles on X axis.
  12243. */
  12244. maxScaleX: number;
  12245. /**
  12246. * Minimum scale of emitting particles on Y axis.
  12247. */
  12248. minScaleY: number;
  12249. /**
  12250. * Maximum scale of emitting particles on Y axis.
  12251. */
  12252. maxScaleY: number;
  12253. /**
  12254. * Gets or sets the minimal initial rotation in radians.
  12255. */
  12256. minInitialRotation: number;
  12257. /**
  12258. * Gets or sets the maximal initial rotation in radians.
  12259. */
  12260. maxInitialRotation: number;
  12261. /**
  12262. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12263. */
  12264. minAngularSpeed: number;
  12265. /**
  12266. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12267. */
  12268. maxAngularSpeed: number;
  12269. /**
  12270. * The texture used to render each particle. (this can be a spritesheet)
  12271. */
  12272. particleTexture: Nullable<BaseTexture>;
  12273. /**
  12274. * The layer mask we are rendering the particles through.
  12275. */
  12276. layerMask: number;
  12277. /**
  12278. * This can help using your own shader to render the particle system.
  12279. * The according effect will be created
  12280. */
  12281. customShader: any;
  12282. /**
  12283. * By default particle system starts as soon as they are created. This prevents the
  12284. * automatic start to happen and let you decide when to start emitting particles.
  12285. */
  12286. preventAutoStart: boolean;
  12287. private _noiseTexture;
  12288. /**
  12289. * Gets or sets a texture used to add random noise to particle positions
  12290. */
  12291. get noiseTexture(): Nullable<ProceduralTexture>;
  12292. set noiseTexture(value: Nullable<ProceduralTexture>);
  12293. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12294. noiseStrength: Vector3;
  12295. /**
  12296. * Callback triggered when the particle animation is ending.
  12297. */
  12298. onAnimationEnd: Nullable<() => void>;
  12299. /**
  12300. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12301. */
  12302. blendMode: number;
  12303. /**
  12304. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12305. * to override the particles.
  12306. */
  12307. forceDepthWrite: boolean;
  12308. /** 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 */
  12309. preWarmCycles: number;
  12310. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12311. preWarmStepOffset: number;
  12312. /**
  12313. * 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)
  12314. */
  12315. spriteCellChangeSpeed: number;
  12316. /**
  12317. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12318. */
  12319. startSpriteCellID: number;
  12320. /**
  12321. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12322. */
  12323. endSpriteCellID: number;
  12324. /**
  12325. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12326. */
  12327. spriteCellWidth: number;
  12328. /**
  12329. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12330. */
  12331. spriteCellHeight: number;
  12332. /**
  12333. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12334. */
  12335. spriteRandomStartCell: boolean;
  12336. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12337. translationPivot: Vector2;
  12338. /** @hidden */
  12339. protected _isAnimationSheetEnabled: boolean;
  12340. /**
  12341. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12342. */
  12343. beginAnimationOnStart: boolean;
  12344. /**
  12345. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12346. */
  12347. beginAnimationFrom: number;
  12348. /**
  12349. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12350. */
  12351. beginAnimationTo: number;
  12352. /**
  12353. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12354. */
  12355. beginAnimationLoop: boolean;
  12356. /**
  12357. * Gets or sets a world offset applied to all particles
  12358. */
  12359. worldOffset: Vector3;
  12360. /**
  12361. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12362. */
  12363. get isAnimationSheetEnabled(): boolean;
  12364. set isAnimationSheetEnabled(value: boolean);
  12365. /**
  12366. * Get hosting scene
  12367. * @returns the scene
  12368. */
  12369. getScene(): Nullable<Scene>;
  12370. /**
  12371. * You can use gravity if you want to give an orientation to your particles.
  12372. */
  12373. gravity: Vector3;
  12374. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12375. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12376. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12377. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12378. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12379. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12380. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12381. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12382. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12383. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12384. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12385. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12386. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12387. /**
  12388. * Defines the delay in milliseconds before starting the system (0 by default)
  12389. */
  12390. startDelay: number;
  12391. /**
  12392. * Gets the current list of drag gradients.
  12393. * You must use addDragGradient and removeDragGradient to udpate this list
  12394. * @returns the list of drag gradients
  12395. */
  12396. getDragGradients(): Nullable<Array<FactorGradient>>;
  12397. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12398. limitVelocityDamping: number;
  12399. /**
  12400. * Gets the current list of limit velocity gradients.
  12401. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12402. * @returns the list of limit velocity gradients
  12403. */
  12404. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12405. /**
  12406. * Gets the current list of color gradients.
  12407. * You must use addColorGradient and removeColorGradient to udpate this list
  12408. * @returns the list of color gradients
  12409. */
  12410. getColorGradients(): Nullable<Array<ColorGradient>>;
  12411. /**
  12412. * Gets the current list of size gradients.
  12413. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12414. * @returns the list of size gradients
  12415. */
  12416. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12417. /**
  12418. * Gets the current list of color remap gradients.
  12419. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12420. * @returns the list of color remap gradients
  12421. */
  12422. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12423. /**
  12424. * Gets the current list of alpha remap gradients.
  12425. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12426. * @returns the list of alpha remap gradients
  12427. */
  12428. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12429. /**
  12430. * Gets the current list of life time gradients.
  12431. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12432. * @returns the list of life time gradients
  12433. */
  12434. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12435. /**
  12436. * Gets the current list of angular speed gradients.
  12437. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12438. * @returns the list of angular speed gradients
  12439. */
  12440. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12441. /**
  12442. * Gets the current list of velocity gradients.
  12443. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12444. * @returns the list of velocity gradients
  12445. */
  12446. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12447. /**
  12448. * Gets the current list of start size gradients.
  12449. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12450. * @returns the list of start size gradients
  12451. */
  12452. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12453. /**
  12454. * Gets the current list of emit rate gradients.
  12455. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12456. * @returns the list of emit rate gradients
  12457. */
  12458. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12459. /**
  12460. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12461. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12462. */
  12463. get direction1(): Vector3;
  12464. set direction1(value: Vector3);
  12465. /**
  12466. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12467. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12468. */
  12469. get direction2(): Vector3;
  12470. set direction2(value: Vector3);
  12471. /**
  12472. * 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.
  12473. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12474. */
  12475. get minEmitBox(): Vector3;
  12476. set minEmitBox(value: Vector3);
  12477. /**
  12478. * 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.
  12479. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12480. */
  12481. get maxEmitBox(): Vector3;
  12482. set maxEmitBox(value: Vector3);
  12483. /**
  12484. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12485. */
  12486. color1: Color4;
  12487. /**
  12488. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12489. */
  12490. color2: Color4;
  12491. /**
  12492. * Color the particle will have at the end of its lifetime
  12493. */
  12494. colorDead: Color4;
  12495. /**
  12496. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12497. */
  12498. textureMask: Color4;
  12499. /**
  12500. * The particle emitter type defines the emitter used by the particle system.
  12501. * It can be for example box, sphere, or cone...
  12502. */
  12503. particleEmitterType: IParticleEmitterType;
  12504. /** @hidden */
  12505. _isSubEmitter: boolean;
  12506. /**
  12507. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12508. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12509. */
  12510. billboardMode: number;
  12511. protected _isBillboardBased: boolean;
  12512. /**
  12513. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12514. */
  12515. get isBillboardBased(): boolean;
  12516. set isBillboardBased(value: boolean);
  12517. /**
  12518. * The scene the particle system belongs to.
  12519. */
  12520. protected _scene: Nullable<Scene>;
  12521. /**
  12522. * The engine the particle system belongs to.
  12523. */
  12524. protected _engine: ThinEngine;
  12525. /**
  12526. * Local cache of defines for image processing.
  12527. */
  12528. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12529. /**
  12530. * Default configuration related to image processing available in the standard Material.
  12531. */
  12532. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12533. /**
  12534. * Gets the image processing configuration used either in this material.
  12535. */
  12536. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12537. /**
  12538. * Sets the Default image processing configuration used either in the this material.
  12539. *
  12540. * If sets to null, the scene one is in use.
  12541. */
  12542. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12543. /**
  12544. * Attaches a new image processing configuration to the Standard Material.
  12545. * @param configuration
  12546. */
  12547. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12548. /** @hidden */
  12549. protected _reset(): void;
  12550. /** @hidden */
  12551. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12552. /**
  12553. * Instantiates a particle system.
  12554. * 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.
  12555. * @param name The name of the particle system
  12556. */
  12557. constructor(name: string);
  12558. /**
  12559. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12560. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12561. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12562. * @returns the emitter
  12563. */
  12564. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12565. /**
  12566. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12567. * @param radius The radius of the hemisphere to emit from
  12568. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12569. * @returns the emitter
  12570. */
  12571. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12572. /**
  12573. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12574. * @param radius The radius of the sphere to emit from
  12575. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12576. * @returns the emitter
  12577. */
  12578. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12579. /**
  12580. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12581. * @param radius The radius of the sphere to emit from
  12582. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12583. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12584. * @returns the emitter
  12585. */
  12586. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12587. /**
  12588. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12589. * @param radius The radius of the emission cylinder
  12590. * @param height The height of the emission cylinder
  12591. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12592. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12593. * @returns the emitter
  12594. */
  12595. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12596. /**
  12597. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12598. * @param radius The radius of the cylinder to emit from
  12599. * @param height The height of the emission cylinder
  12600. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12601. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12602. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12603. * @returns the emitter
  12604. */
  12605. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12606. /**
  12607. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12608. * @param radius The radius of the cone to emit from
  12609. * @param angle The base angle of the cone
  12610. * @returns the emitter
  12611. */
  12612. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12613. /**
  12614. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12615. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12616. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12617. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12618. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12619. * @returns the emitter
  12620. */
  12621. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12622. }
  12623. }
  12624. declare module "babylonjs/Particles/subEmitter" {
  12625. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12626. import { Scene } from "babylonjs/scene";
  12627. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12628. /**
  12629. * Type of sub emitter
  12630. */
  12631. export enum SubEmitterType {
  12632. /**
  12633. * Attached to the particle over it's lifetime
  12634. */
  12635. ATTACHED = 0,
  12636. /**
  12637. * Created when the particle dies
  12638. */
  12639. END = 1
  12640. }
  12641. /**
  12642. * Sub emitter class used to emit particles from an existing particle
  12643. */
  12644. export class SubEmitter {
  12645. /**
  12646. * the particle system to be used by the sub emitter
  12647. */
  12648. particleSystem: ParticleSystem;
  12649. /**
  12650. * Type of the submitter (Default: END)
  12651. */
  12652. type: SubEmitterType;
  12653. /**
  12654. * 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)
  12655. * Note: This only is supported when using an emitter of type Mesh
  12656. */
  12657. inheritDirection: boolean;
  12658. /**
  12659. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12660. */
  12661. inheritedVelocityAmount: number;
  12662. /**
  12663. * Creates a sub emitter
  12664. * @param particleSystem the particle system to be used by the sub emitter
  12665. */
  12666. constructor(
  12667. /**
  12668. * the particle system to be used by the sub emitter
  12669. */
  12670. particleSystem: ParticleSystem);
  12671. /**
  12672. * Clones the sub emitter
  12673. * @returns the cloned sub emitter
  12674. */
  12675. clone(): SubEmitter;
  12676. /**
  12677. * Serialize current object to a JSON object
  12678. * @returns the serialized object
  12679. */
  12680. serialize(): any;
  12681. /** @hidden */
  12682. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12683. /**
  12684. * Creates a new SubEmitter from a serialized JSON version
  12685. * @param serializationObject defines the JSON object to read from
  12686. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12687. * @param rootUrl defines the rootUrl for data loading
  12688. * @returns a new SubEmitter
  12689. */
  12690. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12691. /** Release associated resources */
  12692. dispose(): void;
  12693. }
  12694. }
  12695. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12696. /** @hidden */
  12697. export var imageProcessingDeclaration: {
  12698. name: string;
  12699. shader: string;
  12700. };
  12701. }
  12702. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12703. /** @hidden */
  12704. export var imageProcessingFunctions: {
  12705. name: string;
  12706. shader: string;
  12707. };
  12708. }
  12709. declare module "babylonjs/Shaders/particles.fragment" {
  12710. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12711. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12712. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12713. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12714. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12715. /** @hidden */
  12716. export var particlesPixelShader: {
  12717. name: string;
  12718. shader: string;
  12719. };
  12720. }
  12721. declare module "babylonjs/Shaders/particles.vertex" {
  12722. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12723. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12724. /** @hidden */
  12725. export var particlesVertexShader: {
  12726. name: string;
  12727. shader: string;
  12728. };
  12729. }
  12730. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12731. import { Nullable } from "babylonjs/types";
  12732. import { Plane } from "babylonjs/Maths/math";
  12733. /**
  12734. * Interface used to define entities containing multiple clip planes
  12735. */
  12736. export interface IClipPlanesHolder {
  12737. /**
  12738. * Gets or sets the active clipplane 1
  12739. */
  12740. clipPlane: Nullable<Plane>;
  12741. /**
  12742. * Gets or sets the active clipplane 2
  12743. */
  12744. clipPlane2: Nullable<Plane>;
  12745. /**
  12746. * Gets or sets the active clipplane 3
  12747. */
  12748. clipPlane3: Nullable<Plane>;
  12749. /**
  12750. * Gets or sets the active clipplane 4
  12751. */
  12752. clipPlane4: Nullable<Plane>;
  12753. /**
  12754. * Gets or sets the active clipplane 5
  12755. */
  12756. clipPlane5: Nullable<Plane>;
  12757. /**
  12758. * Gets or sets the active clipplane 6
  12759. */
  12760. clipPlane6: Nullable<Plane>;
  12761. }
  12762. }
  12763. declare module "babylonjs/Materials/thinMaterialHelper" {
  12764. import { Effect } from "babylonjs/Materials/effect";
  12765. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12766. /**
  12767. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12768. *
  12769. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12770. *
  12771. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12772. */
  12773. export class ThinMaterialHelper {
  12774. /**
  12775. * Binds the clip plane information from the holder to the effect.
  12776. * @param effect The effect we are binding the data to
  12777. * @param holder The entity containing the clip plane information
  12778. */
  12779. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12780. }
  12781. }
  12782. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  12783. module "babylonjs/Engines/thinEngine" {
  12784. interface ThinEngine {
  12785. /**
  12786. * Sets alpha constants used by some alpha blending modes
  12787. * @param r defines the red component
  12788. * @param g defines the green component
  12789. * @param b defines the blue component
  12790. * @param a defines the alpha component
  12791. */
  12792. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12793. /**
  12794. * Sets the current alpha mode
  12795. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12796. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12797. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12798. */
  12799. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12800. /**
  12801. * Gets the current alpha mode
  12802. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12803. * @returns the current alpha mode
  12804. */
  12805. getAlphaMode(): number;
  12806. /**
  12807. * Sets the current alpha equation
  12808. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12809. */
  12810. setAlphaEquation(equation: number): void;
  12811. /**
  12812. * Gets the current alpha equation.
  12813. * @returns the current alpha equation
  12814. */
  12815. getAlphaEquation(): number;
  12816. }
  12817. }
  12818. }
  12819. declare module "babylonjs/Particles/particleSystem" {
  12820. import { Nullable } from "babylonjs/types";
  12821. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12822. import { Observable } from "babylonjs/Misc/observable";
  12823. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12824. import { Effect } from "babylonjs/Materials/effect";
  12825. import { IDisposable } from "babylonjs/scene";
  12826. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12827. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12828. import { Particle } from "babylonjs/Particles/particle";
  12829. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12830. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12831. import "babylonjs/Shaders/particles.fragment";
  12832. import "babylonjs/Shaders/particles.vertex";
  12833. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12834. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12835. import "babylonjs/Engines/Extensions/engine.alpha";
  12836. import { Scene } from "babylonjs/scene";
  12837. /**
  12838. * This represents a particle system in Babylon.
  12839. * 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.
  12840. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12841. * @example https://doc.babylonjs.com/babylon101/particles
  12842. */
  12843. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12844. /**
  12845. * Billboard mode will only apply to Y axis
  12846. */
  12847. static readonly BILLBOARDMODE_Y: number;
  12848. /**
  12849. * Billboard mode will apply to all axes
  12850. */
  12851. static readonly BILLBOARDMODE_ALL: number;
  12852. /**
  12853. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12854. */
  12855. static readonly BILLBOARDMODE_STRETCHED: number;
  12856. /**
  12857. * This function can be defined to provide custom update for active particles.
  12858. * This function will be called instead of regular update (age, position, color, etc.).
  12859. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12860. */
  12861. updateFunction: (particles: Particle[]) => void;
  12862. private _emitterWorldMatrix;
  12863. /**
  12864. * This function can be defined to specify initial direction for every new particle.
  12865. * It by default use the emitterType defined function
  12866. */
  12867. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12868. /**
  12869. * This function can be defined to specify initial position for every new particle.
  12870. * It by default use the emitterType defined function
  12871. */
  12872. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12873. /**
  12874. * @hidden
  12875. */
  12876. _inheritedVelocityOffset: Vector3;
  12877. /**
  12878. * An event triggered when the system is disposed
  12879. */
  12880. onDisposeObservable: Observable<IParticleSystem>;
  12881. private _onDisposeObserver;
  12882. /**
  12883. * Sets a callback that will be triggered when the system is disposed
  12884. */
  12885. set onDispose(callback: () => void);
  12886. private _particles;
  12887. private _epsilon;
  12888. private _capacity;
  12889. private _stockParticles;
  12890. private _newPartsExcess;
  12891. private _vertexData;
  12892. private _vertexBuffer;
  12893. private _vertexBuffers;
  12894. private _spriteBuffer;
  12895. private _indexBuffer;
  12896. private _effect;
  12897. private _customEffect;
  12898. private _cachedDefines;
  12899. private _scaledColorStep;
  12900. private _colorDiff;
  12901. private _scaledDirection;
  12902. private _scaledGravity;
  12903. private _currentRenderId;
  12904. private _alive;
  12905. private _useInstancing;
  12906. private _started;
  12907. private _stopped;
  12908. private _actualFrame;
  12909. private _scaledUpdateSpeed;
  12910. private _vertexBufferSize;
  12911. /** @hidden */
  12912. _currentEmitRateGradient: Nullable<FactorGradient>;
  12913. /** @hidden */
  12914. _currentEmitRate1: number;
  12915. /** @hidden */
  12916. _currentEmitRate2: number;
  12917. /** @hidden */
  12918. _currentStartSizeGradient: Nullable<FactorGradient>;
  12919. /** @hidden */
  12920. _currentStartSize1: number;
  12921. /** @hidden */
  12922. _currentStartSize2: number;
  12923. private readonly _rawTextureWidth;
  12924. private _rampGradientsTexture;
  12925. private _useRampGradients;
  12926. /** Gets or sets a matrix to use to compute projection */
  12927. defaultProjectionMatrix: Matrix;
  12928. /** Gets or sets a matrix to use to compute view */
  12929. defaultViewMatrix: Matrix;
  12930. /** Gets or sets a boolean indicating that ramp gradients must be used
  12931. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12932. */
  12933. get useRampGradients(): boolean;
  12934. set useRampGradients(value: boolean);
  12935. /**
  12936. * 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.
  12937. * 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: [])
  12938. */
  12939. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12940. private _subEmitters;
  12941. /**
  12942. * @hidden
  12943. * If the particle systems emitter should be disposed when the particle system is disposed
  12944. */
  12945. _disposeEmitterOnDispose: boolean;
  12946. /**
  12947. * The current active Sub-systems, this property is used by the root particle system only.
  12948. */
  12949. activeSubSystems: Array<ParticleSystem>;
  12950. /**
  12951. * Specifies if the particles are updated in emitter local space or world space
  12952. */
  12953. isLocal: boolean;
  12954. private _rootParticleSystem;
  12955. /**
  12956. * Gets the current list of active particles
  12957. */
  12958. get particles(): Particle[];
  12959. /**
  12960. * Gets the number of particles active at the same time.
  12961. * @returns The number of active particles.
  12962. */
  12963. getActiveCount(): number;
  12964. /**
  12965. * Returns the string "ParticleSystem"
  12966. * @returns a string containing the class name
  12967. */
  12968. getClassName(): string;
  12969. /**
  12970. * Gets a boolean indicating that the system is stopping
  12971. * @returns true if the system is currently stopping
  12972. */
  12973. isStopping(): boolean;
  12974. /**
  12975. * Gets the custom effect used to render the particles
  12976. * @param blendMode Blend mode for which the effect should be retrieved
  12977. * @returns The effect
  12978. */
  12979. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12980. /**
  12981. * Sets the custom effect used to render the particles
  12982. * @param effect The effect to set
  12983. * @param blendMode Blend mode for which the effect should be set
  12984. */
  12985. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12986. /** @hidden */
  12987. private _onBeforeDrawParticlesObservable;
  12988. /**
  12989. * Observable that will be called just before the particles are drawn
  12990. */
  12991. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12992. /**
  12993. * Gets the name of the particle vertex shader
  12994. */
  12995. get vertexShaderName(): string;
  12996. /**
  12997. * Instantiates a particle system.
  12998. * 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.
  12999. * @param name The name of the particle system
  13000. * @param capacity The max number of particles alive at the same time
  13001. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  13002. * @param customEffect a custom effect used to change the way particles are rendered by default
  13003. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13004. * @param epsilon Offset used to render the particles
  13005. */
  13006. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13007. private _addFactorGradient;
  13008. private _removeFactorGradient;
  13009. /**
  13010. * Adds a new life time gradient
  13011. * @param gradient defines the gradient to use (between 0 and 1)
  13012. * @param factor defines the life time factor to affect to the specified gradient
  13013. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13014. * @returns the current particle system
  13015. */
  13016. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13017. /**
  13018. * Remove a specific life time gradient
  13019. * @param gradient defines the gradient to remove
  13020. * @returns the current particle system
  13021. */
  13022. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13023. /**
  13024. * Adds a new size gradient
  13025. * @param gradient defines the gradient to use (between 0 and 1)
  13026. * @param factor defines the size factor to affect to the specified gradient
  13027. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13028. * @returns the current particle system
  13029. */
  13030. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13031. /**
  13032. * Remove a specific size gradient
  13033. * @param gradient defines the gradient to remove
  13034. * @returns the current particle system
  13035. */
  13036. removeSizeGradient(gradient: number): IParticleSystem;
  13037. /**
  13038. * Adds a new color remap gradient
  13039. * @param gradient defines the gradient to use (between 0 and 1)
  13040. * @param min defines the color remap minimal range
  13041. * @param max defines the color remap maximal range
  13042. * @returns the current particle system
  13043. */
  13044. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13045. /**
  13046. * Remove a specific color remap gradient
  13047. * @param gradient defines the gradient to remove
  13048. * @returns the current particle system
  13049. */
  13050. removeColorRemapGradient(gradient: number): IParticleSystem;
  13051. /**
  13052. * Adds a new alpha remap gradient
  13053. * @param gradient defines the gradient to use (between 0 and 1)
  13054. * @param min defines the alpha remap minimal range
  13055. * @param max defines the alpha remap maximal range
  13056. * @returns the current particle system
  13057. */
  13058. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13059. /**
  13060. * Remove a specific alpha remap gradient
  13061. * @param gradient defines the gradient to remove
  13062. * @returns the current particle system
  13063. */
  13064. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13065. /**
  13066. * Adds a new angular speed gradient
  13067. * @param gradient defines the gradient to use (between 0 and 1)
  13068. * @param factor defines the angular speed to affect to the specified gradient
  13069. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13070. * @returns the current particle system
  13071. */
  13072. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13073. /**
  13074. * Remove a specific angular speed gradient
  13075. * @param gradient defines the gradient to remove
  13076. * @returns the current particle system
  13077. */
  13078. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13079. /**
  13080. * Adds a new velocity gradient
  13081. * @param gradient defines the gradient to use (between 0 and 1)
  13082. * @param factor defines the velocity to affect to the specified gradient
  13083. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13084. * @returns the current particle system
  13085. */
  13086. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13087. /**
  13088. * Remove a specific velocity gradient
  13089. * @param gradient defines the gradient to remove
  13090. * @returns the current particle system
  13091. */
  13092. removeVelocityGradient(gradient: number): IParticleSystem;
  13093. /**
  13094. * Adds a new limit velocity gradient
  13095. * @param gradient defines the gradient to use (between 0 and 1)
  13096. * @param factor defines the limit velocity value to affect to the specified gradient
  13097. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13098. * @returns the current particle system
  13099. */
  13100. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13101. /**
  13102. * Remove a specific limit velocity gradient
  13103. * @param gradient defines the gradient to remove
  13104. * @returns the current particle system
  13105. */
  13106. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13107. /**
  13108. * Adds a new drag gradient
  13109. * @param gradient defines the gradient to use (between 0 and 1)
  13110. * @param factor defines the drag value to affect to the specified gradient
  13111. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13112. * @returns the current particle system
  13113. */
  13114. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13115. /**
  13116. * Remove a specific drag gradient
  13117. * @param gradient defines the gradient to remove
  13118. * @returns the current particle system
  13119. */
  13120. removeDragGradient(gradient: number): IParticleSystem;
  13121. /**
  13122. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13123. * @param gradient defines the gradient to use (between 0 and 1)
  13124. * @param factor defines the emit rate value to affect to the specified gradient
  13125. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13126. * @returns the current particle system
  13127. */
  13128. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13129. /**
  13130. * Remove a specific emit rate gradient
  13131. * @param gradient defines the gradient to remove
  13132. * @returns the current particle system
  13133. */
  13134. removeEmitRateGradient(gradient: number): IParticleSystem;
  13135. /**
  13136. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13137. * @param gradient defines the gradient to use (between 0 and 1)
  13138. * @param factor defines the start size value to affect to the specified gradient
  13139. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13140. * @returns the current particle system
  13141. */
  13142. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13143. /**
  13144. * Remove a specific start size gradient
  13145. * @param gradient defines the gradient to remove
  13146. * @returns the current particle system
  13147. */
  13148. removeStartSizeGradient(gradient: number): IParticleSystem;
  13149. private _createRampGradientTexture;
  13150. /**
  13151. * Gets the current list of ramp gradients.
  13152. * You must use addRampGradient and removeRampGradient to udpate this list
  13153. * @returns the list of ramp gradients
  13154. */
  13155. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13156. /** Force the system to rebuild all gradients that need to be resync */
  13157. forceRefreshGradients(): void;
  13158. private _syncRampGradientTexture;
  13159. /**
  13160. * Adds a new ramp gradient used to remap particle colors
  13161. * @param gradient defines the gradient to use (between 0 and 1)
  13162. * @param color defines the color to affect to the specified gradient
  13163. * @returns the current particle system
  13164. */
  13165. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13166. /**
  13167. * Remove a specific ramp gradient
  13168. * @param gradient defines the gradient to remove
  13169. * @returns the current particle system
  13170. */
  13171. removeRampGradient(gradient: number): ParticleSystem;
  13172. /**
  13173. * Adds a new color gradient
  13174. * @param gradient defines the gradient to use (between 0 and 1)
  13175. * @param color1 defines the color to affect to the specified gradient
  13176. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13177. * @returns this particle system
  13178. */
  13179. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13180. /**
  13181. * Remove a specific color gradient
  13182. * @param gradient defines the gradient to remove
  13183. * @returns this particle system
  13184. */
  13185. removeColorGradient(gradient: number): IParticleSystem;
  13186. private _fetchR;
  13187. protected _reset(): void;
  13188. private _resetEffect;
  13189. private _createVertexBuffers;
  13190. private _createIndexBuffer;
  13191. /**
  13192. * Gets the maximum number of particles active at the same time.
  13193. * @returns The max number of active particles.
  13194. */
  13195. getCapacity(): number;
  13196. /**
  13197. * Gets whether there are still active particles in the system.
  13198. * @returns True if it is alive, otherwise false.
  13199. */
  13200. isAlive(): boolean;
  13201. /**
  13202. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13203. * @returns True if it has been started, otherwise false.
  13204. */
  13205. isStarted(): boolean;
  13206. private _prepareSubEmitterInternalArray;
  13207. /**
  13208. * Starts the particle system and begins to emit
  13209. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13210. */
  13211. start(delay?: number): void;
  13212. /**
  13213. * Stops the particle system.
  13214. * @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.
  13215. */
  13216. stop(stopSubEmitters?: boolean): void;
  13217. /**
  13218. * Remove all active particles
  13219. */
  13220. reset(): void;
  13221. /**
  13222. * @hidden (for internal use only)
  13223. */
  13224. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13225. /**
  13226. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13227. * Its lifetime will start back at 0.
  13228. */
  13229. recycleParticle: (particle: Particle) => void;
  13230. private _stopSubEmitters;
  13231. private _createParticle;
  13232. private _removeFromRoot;
  13233. private _emitFromParticle;
  13234. private _update;
  13235. /** @hidden */
  13236. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13237. /** @hidden */
  13238. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13239. /**
  13240. * Fill the defines array according to the current settings of the particle system
  13241. * @param defines Array to be updated
  13242. * @param blendMode blend mode to take into account when updating the array
  13243. */
  13244. fillDefines(defines: Array<string>, blendMode: number): void;
  13245. /**
  13246. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13247. * @param uniforms Uniforms array to fill
  13248. * @param attributes Attributes array to fill
  13249. * @param samplers Samplers array to fill
  13250. */
  13251. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13252. /** @hidden */
  13253. private _getEffect;
  13254. /**
  13255. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13256. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13257. */
  13258. animate(preWarmOnly?: boolean): void;
  13259. private _appendParticleVertices;
  13260. /**
  13261. * Rebuilds the particle system.
  13262. */
  13263. rebuild(): void;
  13264. /**
  13265. * Is this system ready to be used/rendered
  13266. * @return true if the system is ready
  13267. */
  13268. isReady(): boolean;
  13269. private _render;
  13270. /**
  13271. * Renders the particle system in its current state.
  13272. * @returns the current number of particles
  13273. */
  13274. render(): number;
  13275. /**
  13276. * Disposes the particle system and free the associated resources
  13277. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13278. */
  13279. dispose(disposeTexture?: boolean): void;
  13280. /**
  13281. * Clones the particle system.
  13282. * @param name The name of the cloned object
  13283. * @param newEmitter The new emitter to use
  13284. * @returns the cloned particle system
  13285. */
  13286. clone(name: string, newEmitter: any): ParticleSystem;
  13287. /**
  13288. * Serializes the particle system to a JSON object
  13289. * @param serializeTexture defines if the texture must be serialized as well
  13290. * @returns the JSON object
  13291. */
  13292. serialize(serializeTexture?: boolean): any;
  13293. /** @hidden */
  13294. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13295. /** @hidden */
  13296. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13297. /**
  13298. * Parses a JSON object to create a particle system.
  13299. * @param parsedParticleSystem The JSON object to parse
  13300. * @param sceneOrEngine The scene or the engine to create the particle system in
  13301. * @param rootUrl The root url to use to load external dependencies like texture
  13302. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13303. * @returns the Parsed particle system
  13304. */
  13305. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13306. }
  13307. }
  13308. declare module "babylonjs/Particles/particle" {
  13309. import { Nullable } from "babylonjs/types";
  13310. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13311. import { Color4 } from "babylonjs/Maths/math.color";
  13312. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13313. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13314. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13315. /**
  13316. * A particle represents one of the element emitted by a particle system.
  13317. * This is mainly define by its coordinates, direction, velocity and age.
  13318. */
  13319. export class Particle {
  13320. /**
  13321. * The particle system the particle belongs to.
  13322. */
  13323. particleSystem: ParticleSystem;
  13324. private static _Count;
  13325. /**
  13326. * Unique ID of the particle
  13327. */
  13328. id: number;
  13329. /**
  13330. * The world position of the particle in the scene.
  13331. */
  13332. position: Vector3;
  13333. /**
  13334. * The world direction of the particle in the scene.
  13335. */
  13336. direction: Vector3;
  13337. /**
  13338. * The color of the particle.
  13339. */
  13340. color: Color4;
  13341. /**
  13342. * The color change of the particle per step.
  13343. */
  13344. colorStep: Color4;
  13345. /**
  13346. * Defines how long will the life of the particle be.
  13347. */
  13348. lifeTime: number;
  13349. /**
  13350. * The current age of the particle.
  13351. */
  13352. age: number;
  13353. /**
  13354. * The current size of the particle.
  13355. */
  13356. size: number;
  13357. /**
  13358. * The current scale of the particle.
  13359. */
  13360. scale: Vector2;
  13361. /**
  13362. * The current angle of the particle.
  13363. */
  13364. angle: number;
  13365. /**
  13366. * Defines how fast is the angle changing.
  13367. */
  13368. angularSpeed: number;
  13369. /**
  13370. * Defines the cell index used by the particle to be rendered from a sprite.
  13371. */
  13372. cellIndex: number;
  13373. /**
  13374. * The information required to support color remapping
  13375. */
  13376. remapData: Vector4;
  13377. /** @hidden */
  13378. _randomCellOffset?: number;
  13379. /** @hidden */
  13380. _initialDirection: Nullable<Vector3>;
  13381. /** @hidden */
  13382. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13383. /** @hidden */
  13384. _initialStartSpriteCellID: number;
  13385. /** @hidden */
  13386. _initialEndSpriteCellID: number;
  13387. /** @hidden */
  13388. _currentColorGradient: Nullable<ColorGradient>;
  13389. /** @hidden */
  13390. _currentColor1: Color4;
  13391. /** @hidden */
  13392. _currentColor2: Color4;
  13393. /** @hidden */
  13394. _currentSizeGradient: Nullable<FactorGradient>;
  13395. /** @hidden */
  13396. _currentSize1: number;
  13397. /** @hidden */
  13398. _currentSize2: number;
  13399. /** @hidden */
  13400. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13401. /** @hidden */
  13402. _currentAngularSpeed1: number;
  13403. /** @hidden */
  13404. _currentAngularSpeed2: number;
  13405. /** @hidden */
  13406. _currentVelocityGradient: Nullable<FactorGradient>;
  13407. /** @hidden */
  13408. _currentVelocity1: number;
  13409. /** @hidden */
  13410. _currentVelocity2: number;
  13411. /** @hidden */
  13412. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13413. /** @hidden */
  13414. _currentLimitVelocity1: number;
  13415. /** @hidden */
  13416. _currentLimitVelocity2: number;
  13417. /** @hidden */
  13418. _currentDragGradient: Nullable<FactorGradient>;
  13419. /** @hidden */
  13420. _currentDrag1: number;
  13421. /** @hidden */
  13422. _currentDrag2: number;
  13423. /** @hidden */
  13424. _randomNoiseCoordinates1: Vector3;
  13425. /** @hidden */
  13426. _randomNoiseCoordinates2: Vector3;
  13427. /** @hidden */
  13428. _localPosition?: Vector3;
  13429. /**
  13430. * Creates a new instance Particle
  13431. * @param particleSystem the particle system the particle belongs to
  13432. */
  13433. constructor(
  13434. /**
  13435. * The particle system the particle belongs to.
  13436. */
  13437. particleSystem: ParticleSystem);
  13438. private updateCellInfoFromSystem;
  13439. /**
  13440. * Defines how the sprite cell index is updated for the particle
  13441. */
  13442. updateCellIndex(): void;
  13443. /** @hidden */
  13444. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13445. /** @hidden */
  13446. _inheritParticleInfoToSubEmitters(): void;
  13447. /** @hidden */
  13448. _reset(): void;
  13449. /**
  13450. * Copy the properties of particle to another one.
  13451. * @param other the particle to copy the information to.
  13452. */
  13453. copyTo(other: Particle): void;
  13454. }
  13455. }
  13456. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13457. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13458. import { Effect } from "babylonjs/Materials/effect";
  13459. import { Particle } from "babylonjs/Particles/particle";
  13460. import { Nullable } from "babylonjs/types";
  13461. import { Scene } from "babylonjs/scene";
  13462. /**
  13463. * Particle emitter represents a volume emitting particles.
  13464. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13465. */
  13466. export interface IParticleEmitterType {
  13467. /**
  13468. * Called by the particle System when the direction is computed for the created particle.
  13469. * @param worldMatrix is the world matrix of the particle system
  13470. * @param directionToUpdate is the direction vector to update with the result
  13471. * @param particle is the particle we are computed the direction for
  13472. * @param isLocal defines if the direction should be set in local space
  13473. */
  13474. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13475. /**
  13476. * Called by the particle System when the position is computed for the created particle.
  13477. * @param worldMatrix is the world matrix of the particle system
  13478. * @param positionToUpdate is the position vector to update with the result
  13479. * @param particle is the particle we are computed the position for
  13480. * @param isLocal defines if the position should be set in local space
  13481. */
  13482. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13483. /**
  13484. * Clones the current emitter and returns a copy of it
  13485. * @returns the new emitter
  13486. */
  13487. clone(): IParticleEmitterType;
  13488. /**
  13489. * Called by the GPUParticleSystem to setup the update shader
  13490. * @param effect defines the update shader
  13491. */
  13492. applyToShader(effect: Effect): void;
  13493. /**
  13494. * Returns a string to use to update the GPU particles update shader
  13495. * @returns the effect defines string
  13496. */
  13497. getEffectDefines(): string;
  13498. /**
  13499. * Returns a string representing the class name
  13500. * @returns a string containing the class name
  13501. */
  13502. getClassName(): string;
  13503. /**
  13504. * Serializes the particle system to a JSON object.
  13505. * @returns the JSON object
  13506. */
  13507. serialize(): any;
  13508. /**
  13509. * Parse properties from a JSON object
  13510. * @param serializationObject defines the JSON object
  13511. * @param scene defines the hosting scene
  13512. */
  13513. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13514. }
  13515. }
  13516. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13517. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13518. import { Effect } from "babylonjs/Materials/effect";
  13519. import { Particle } from "babylonjs/Particles/particle";
  13520. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13521. /**
  13522. * Particle emitter emitting particles from the inside of a box.
  13523. * It emits the particles randomly between 2 given directions.
  13524. */
  13525. export class BoxParticleEmitter implements IParticleEmitterType {
  13526. /**
  13527. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13528. */
  13529. direction1: Vector3;
  13530. /**
  13531. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13532. */
  13533. direction2: Vector3;
  13534. /**
  13535. * 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.
  13536. */
  13537. minEmitBox: Vector3;
  13538. /**
  13539. * 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.
  13540. */
  13541. maxEmitBox: Vector3;
  13542. /**
  13543. * Creates a new instance BoxParticleEmitter
  13544. */
  13545. constructor();
  13546. /**
  13547. * Called by the particle System when the direction is computed for the created particle.
  13548. * @param worldMatrix is the world matrix of the particle system
  13549. * @param directionToUpdate is the direction vector to update with the result
  13550. * @param particle is the particle we are computed the direction for
  13551. * @param isLocal defines if the direction should be set in local space
  13552. */
  13553. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13554. /**
  13555. * Called by the particle System when the position is computed for the created particle.
  13556. * @param worldMatrix is the world matrix of the particle system
  13557. * @param positionToUpdate is the position vector to update with the result
  13558. * @param particle is the particle we are computed the position for
  13559. * @param isLocal defines if the position should be set in local space
  13560. */
  13561. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13562. /**
  13563. * Clones the current emitter and returns a copy of it
  13564. * @returns the new emitter
  13565. */
  13566. clone(): BoxParticleEmitter;
  13567. /**
  13568. * Called by the GPUParticleSystem to setup the update shader
  13569. * @param effect defines the update shader
  13570. */
  13571. applyToShader(effect: Effect): void;
  13572. /**
  13573. * Returns a string to use to update the GPU particles update shader
  13574. * @returns a string containng the defines string
  13575. */
  13576. getEffectDefines(): string;
  13577. /**
  13578. * Returns the string "BoxParticleEmitter"
  13579. * @returns a string containing the class name
  13580. */
  13581. getClassName(): string;
  13582. /**
  13583. * Serializes the particle system to a JSON object.
  13584. * @returns the JSON object
  13585. */
  13586. serialize(): any;
  13587. /**
  13588. * Parse properties from a JSON object
  13589. * @param serializationObject defines the JSON object
  13590. */
  13591. parse(serializationObject: any): void;
  13592. }
  13593. }
  13594. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13595. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13596. import { Effect } from "babylonjs/Materials/effect";
  13597. import { Particle } from "babylonjs/Particles/particle";
  13598. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13599. /**
  13600. * Particle emitter emitting particles from the inside of a cone.
  13601. * It emits the particles alongside the cone volume from the base to the particle.
  13602. * The emission direction might be randomized.
  13603. */
  13604. export class ConeParticleEmitter implements IParticleEmitterType {
  13605. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13606. directionRandomizer: number;
  13607. private _radius;
  13608. private _angle;
  13609. private _height;
  13610. /**
  13611. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13612. */
  13613. radiusRange: number;
  13614. /**
  13615. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13616. */
  13617. heightRange: number;
  13618. /**
  13619. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13620. */
  13621. emitFromSpawnPointOnly: boolean;
  13622. /**
  13623. * Gets or sets the radius of the emission cone
  13624. */
  13625. get radius(): number;
  13626. set radius(value: number);
  13627. /**
  13628. * Gets or sets the angle of the emission cone
  13629. */
  13630. get angle(): number;
  13631. set angle(value: number);
  13632. private _buildHeight;
  13633. /**
  13634. * Creates a new instance ConeParticleEmitter
  13635. * @param radius the radius of the emission cone (1 by default)
  13636. * @param angle the cone base angle (PI by default)
  13637. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13638. */
  13639. constructor(radius?: number, angle?: number,
  13640. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13641. directionRandomizer?: number);
  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(): ConeParticleEmitter;
  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 "ConeParticleEmitter"
  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/cylinderParticleEmitter" {
  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 cylinder.
  13697. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13698. */
  13699. export class CylinderParticleEmitter implements IParticleEmitterType {
  13700. /**
  13701. * The radius of the emission cylinder.
  13702. */
  13703. radius: number;
  13704. /**
  13705. * The height of the emission cylinder.
  13706. */
  13707. height: number;
  13708. /**
  13709. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13710. */
  13711. radiusRange: number;
  13712. /**
  13713. * How much to randomize the particle direction [0-1].
  13714. */
  13715. directionRandomizer: number;
  13716. /**
  13717. * Creates a new instance CylinderParticleEmitter
  13718. * @param radius the radius of the emission cylinder (1 by default)
  13719. * @param height the height of the emission cylinder (1 by default)
  13720. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13721. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13722. */
  13723. constructor(
  13724. /**
  13725. * The radius of the emission cylinder.
  13726. */
  13727. radius?: number,
  13728. /**
  13729. * The height of the emission cylinder.
  13730. */
  13731. height?: number,
  13732. /**
  13733. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13734. */
  13735. radiusRange?: number,
  13736. /**
  13737. * How much to randomize the particle direction [0-1].
  13738. */
  13739. directionRandomizer?: number);
  13740. /**
  13741. * Called by the particle System when the direction is computed for the created particle.
  13742. * @param worldMatrix is the world matrix of the particle system
  13743. * @param directionToUpdate is the direction vector to update with the result
  13744. * @param particle is the particle we are computed the direction for
  13745. * @param isLocal defines if the direction should be set in local space
  13746. */
  13747. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13748. /**
  13749. * Called by the particle System when the position is computed for the created particle.
  13750. * @param worldMatrix is the world matrix of the particle system
  13751. * @param positionToUpdate is the position vector to update with the result
  13752. * @param particle is the particle we are computed the position for
  13753. * @param isLocal defines if the position should be set in local space
  13754. */
  13755. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13756. /**
  13757. * Clones the current emitter and returns a copy of it
  13758. * @returns the new emitter
  13759. */
  13760. clone(): CylinderParticleEmitter;
  13761. /**
  13762. * Called by the GPUParticleSystem to setup the update shader
  13763. * @param effect defines the update shader
  13764. */
  13765. applyToShader(effect: Effect): void;
  13766. /**
  13767. * Returns a string to use to update the GPU particles update shader
  13768. * @returns a string containng the defines string
  13769. */
  13770. getEffectDefines(): string;
  13771. /**
  13772. * Returns the string "CylinderParticleEmitter"
  13773. * @returns a string containing the class name
  13774. */
  13775. getClassName(): string;
  13776. /**
  13777. * Serializes the particle system to a JSON object.
  13778. * @returns the JSON object
  13779. */
  13780. serialize(): any;
  13781. /**
  13782. * Parse properties from a JSON object
  13783. * @param serializationObject defines the JSON object
  13784. */
  13785. parse(serializationObject: any): void;
  13786. }
  13787. /**
  13788. * Particle emitter emitting particles from the inside of a cylinder.
  13789. * It emits the particles randomly between two vectors.
  13790. */
  13791. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13792. /**
  13793. * The min limit of the emission direction.
  13794. */
  13795. direction1: Vector3;
  13796. /**
  13797. * The max limit of the emission direction.
  13798. */
  13799. direction2: Vector3;
  13800. /**
  13801. * Creates a new instance CylinderDirectedParticleEmitter
  13802. * @param radius the radius of the emission cylinder (1 by default)
  13803. * @param height the height of the emission cylinder (1 by default)
  13804. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13805. * @param direction1 the min limit of the emission direction (up vector by default)
  13806. * @param direction2 the max limit of the emission direction (up vector by default)
  13807. */
  13808. constructor(radius?: number, height?: number, radiusRange?: number,
  13809. /**
  13810. * The min limit of the emission direction.
  13811. */
  13812. direction1?: Vector3,
  13813. /**
  13814. * The max limit of the emission direction.
  13815. */
  13816. direction2?: Vector3);
  13817. /**
  13818. * Called by the particle System when the direction is computed for the created particle.
  13819. * @param worldMatrix is the world matrix of the particle system
  13820. * @param directionToUpdate is the direction vector to update with the result
  13821. * @param particle is the particle we are computed the direction for
  13822. */
  13823. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13824. /**
  13825. * Clones the current emitter and returns a copy of it
  13826. * @returns the new emitter
  13827. */
  13828. clone(): CylinderDirectedParticleEmitter;
  13829. /**
  13830. * Called by the GPUParticleSystem to setup the update shader
  13831. * @param effect defines the update shader
  13832. */
  13833. applyToShader(effect: Effect): void;
  13834. /**
  13835. * Returns a string to use to update the GPU particles update shader
  13836. * @returns a string containng the defines string
  13837. */
  13838. getEffectDefines(): string;
  13839. /**
  13840. * Returns the string "CylinderDirectedParticleEmitter"
  13841. * @returns a string containing the class name
  13842. */
  13843. getClassName(): string;
  13844. /**
  13845. * Serializes the particle system to a JSON object.
  13846. * @returns the JSON object
  13847. */
  13848. serialize(): any;
  13849. /**
  13850. * Parse properties from a JSON object
  13851. * @param serializationObject defines the JSON object
  13852. */
  13853. parse(serializationObject: any): void;
  13854. }
  13855. }
  13856. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13857. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13858. import { Effect } from "babylonjs/Materials/effect";
  13859. import { Particle } from "babylonjs/Particles/particle";
  13860. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13861. /**
  13862. * Particle emitter emitting particles from the inside of a hemisphere.
  13863. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13864. */
  13865. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13866. /**
  13867. * The radius of the emission hemisphere.
  13868. */
  13869. radius: number;
  13870. /**
  13871. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13872. */
  13873. radiusRange: number;
  13874. /**
  13875. * How much to randomize the particle direction [0-1].
  13876. */
  13877. directionRandomizer: number;
  13878. /**
  13879. * Creates a new instance HemisphericParticleEmitter
  13880. * @param radius the radius of the emission hemisphere (1 by default)
  13881. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13882. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13883. */
  13884. constructor(
  13885. /**
  13886. * The radius of the emission hemisphere.
  13887. */
  13888. radius?: number,
  13889. /**
  13890. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13891. */
  13892. radiusRange?: number,
  13893. /**
  13894. * How much to randomize the particle direction [0-1].
  13895. */
  13896. directionRandomizer?: number);
  13897. /**
  13898. * Called by the particle System when the direction is computed for the created particle.
  13899. * @param worldMatrix is the world matrix of the particle system
  13900. * @param directionToUpdate is the direction vector to update with the result
  13901. * @param particle is the particle we are computed the direction for
  13902. * @param isLocal defines if the direction should be set in local space
  13903. */
  13904. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13905. /**
  13906. * Called by the particle System when the position is computed for the created particle.
  13907. * @param worldMatrix is the world matrix of the particle system
  13908. * @param positionToUpdate is the position vector to update with the result
  13909. * @param particle is the particle we are computed the position for
  13910. * @param isLocal defines if the position should be set in local space
  13911. */
  13912. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13913. /**
  13914. * Clones the current emitter and returns a copy of it
  13915. * @returns the new emitter
  13916. */
  13917. clone(): HemisphericParticleEmitter;
  13918. /**
  13919. * Called by the GPUParticleSystem to setup the update shader
  13920. * @param effect defines the update shader
  13921. */
  13922. applyToShader(effect: Effect): void;
  13923. /**
  13924. * Returns a string to use to update the GPU particles update shader
  13925. * @returns a string containng the defines string
  13926. */
  13927. getEffectDefines(): string;
  13928. /**
  13929. * Returns the string "HemisphericParticleEmitter"
  13930. * @returns a string containing the class name
  13931. */
  13932. getClassName(): string;
  13933. /**
  13934. * Serializes the particle system to a JSON object.
  13935. * @returns the JSON object
  13936. */
  13937. serialize(): any;
  13938. /**
  13939. * Parse properties from a JSON object
  13940. * @param serializationObject defines the JSON object
  13941. */
  13942. parse(serializationObject: any): void;
  13943. }
  13944. }
  13945. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13946. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13947. import { Effect } from "babylonjs/Materials/effect";
  13948. import { Particle } from "babylonjs/Particles/particle";
  13949. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13950. /**
  13951. * Particle emitter emitting particles from a point.
  13952. * It emits the particles randomly between 2 given directions.
  13953. */
  13954. export class PointParticleEmitter implements IParticleEmitterType {
  13955. /**
  13956. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13957. */
  13958. direction1: Vector3;
  13959. /**
  13960. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13961. */
  13962. direction2: Vector3;
  13963. /**
  13964. * Creates a new instance PointParticleEmitter
  13965. */
  13966. constructor();
  13967. /**
  13968. * Called by the particle System when the direction is computed for the created particle.
  13969. * @param worldMatrix is the world matrix of the particle system
  13970. * @param directionToUpdate is the direction vector to update with the result
  13971. * @param particle is the particle we are computed the direction for
  13972. * @param isLocal defines if the direction should be set in local space
  13973. */
  13974. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13975. /**
  13976. * Called by the particle System when the position is computed for the created particle.
  13977. * @param worldMatrix is the world matrix of the particle system
  13978. * @param positionToUpdate is the position vector to update with the result
  13979. * @param particle is the particle we are computed the position for
  13980. * @param isLocal defines if the position should be set in local space
  13981. */
  13982. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13983. /**
  13984. * Clones the current emitter and returns a copy of it
  13985. * @returns the new emitter
  13986. */
  13987. clone(): PointParticleEmitter;
  13988. /**
  13989. * Called by the GPUParticleSystem to setup the update shader
  13990. * @param effect defines the update shader
  13991. */
  13992. applyToShader(effect: Effect): void;
  13993. /**
  13994. * Returns a string to use to update the GPU particles update shader
  13995. * @returns a string containng the defines string
  13996. */
  13997. getEffectDefines(): string;
  13998. /**
  13999. * Returns the string "PointParticleEmitter"
  14000. * @returns a string containing the class name
  14001. */
  14002. getClassName(): string;
  14003. /**
  14004. * Serializes the particle system to a JSON object.
  14005. * @returns the JSON object
  14006. */
  14007. serialize(): any;
  14008. /**
  14009. * Parse properties from a JSON object
  14010. * @param serializationObject defines the JSON object
  14011. */
  14012. parse(serializationObject: any): void;
  14013. }
  14014. }
  14015. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  14016. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14017. import { Effect } from "babylonjs/Materials/effect";
  14018. import { Particle } from "babylonjs/Particles/particle";
  14019. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14020. /**
  14021. * Particle emitter emitting particles from the inside of a sphere.
  14022. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14023. */
  14024. export class SphereParticleEmitter implements IParticleEmitterType {
  14025. /**
  14026. * The radius of the emission sphere.
  14027. */
  14028. radius: number;
  14029. /**
  14030. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14031. */
  14032. radiusRange: number;
  14033. /**
  14034. * How much to randomize the particle direction [0-1].
  14035. */
  14036. directionRandomizer: number;
  14037. /**
  14038. * Creates a new instance SphereParticleEmitter
  14039. * @param radius the radius of the emission sphere (1 by default)
  14040. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14041. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14042. */
  14043. constructor(
  14044. /**
  14045. * The radius of the emission sphere.
  14046. */
  14047. radius?: number,
  14048. /**
  14049. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14050. */
  14051. radiusRange?: number,
  14052. /**
  14053. * How much to randomize the particle direction [0-1].
  14054. */
  14055. directionRandomizer?: number);
  14056. /**
  14057. * Called by the particle System when the direction is computed for the created particle.
  14058. * @param worldMatrix is the world matrix of the particle system
  14059. * @param directionToUpdate is the direction vector to update with the result
  14060. * @param particle is the particle we are computed the direction for
  14061. * @param isLocal defines if the direction should be set in local space
  14062. */
  14063. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14064. /**
  14065. * Called by the particle System when the position is computed for the created particle.
  14066. * @param worldMatrix is the world matrix of the particle system
  14067. * @param positionToUpdate is the position vector to update with the result
  14068. * @param particle is the particle we are computed the position for
  14069. * @param isLocal defines if the position should be set in local space
  14070. */
  14071. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14072. /**
  14073. * Clones the current emitter and returns a copy of it
  14074. * @returns the new emitter
  14075. */
  14076. clone(): SphereParticleEmitter;
  14077. /**
  14078. * Called by the GPUParticleSystem to setup the update shader
  14079. * @param effect defines the update shader
  14080. */
  14081. applyToShader(effect: Effect): void;
  14082. /**
  14083. * Returns a string to use to update the GPU particles update shader
  14084. * @returns a string containng the defines string
  14085. */
  14086. getEffectDefines(): string;
  14087. /**
  14088. * Returns the string "SphereParticleEmitter"
  14089. * @returns a string containing the class name
  14090. */
  14091. getClassName(): string;
  14092. /**
  14093. * Serializes the particle system to a JSON object.
  14094. * @returns the JSON object
  14095. */
  14096. serialize(): any;
  14097. /**
  14098. * Parse properties from a JSON object
  14099. * @param serializationObject defines the JSON object
  14100. */
  14101. parse(serializationObject: any): void;
  14102. }
  14103. /**
  14104. * Particle emitter emitting particles from the inside of a sphere.
  14105. * It emits the particles randomly between two vectors.
  14106. */
  14107. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14108. /**
  14109. * The min limit of the emission direction.
  14110. */
  14111. direction1: Vector3;
  14112. /**
  14113. * The max limit of the emission direction.
  14114. */
  14115. direction2: Vector3;
  14116. /**
  14117. * Creates a new instance SphereDirectedParticleEmitter
  14118. * @param radius the radius of the emission sphere (1 by default)
  14119. * @param direction1 the min limit of the emission direction (up vector by default)
  14120. * @param direction2 the max limit of the emission direction (up vector by default)
  14121. */
  14122. constructor(radius?: number,
  14123. /**
  14124. * The min limit of the emission direction.
  14125. */
  14126. direction1?: Vector3,
  14127. /**
  14128. * The max limit of the emission direction.
  14129. */
  14130. direction2?: Vector3);
  14131. /**
  14132. * Called by the particle System when the direction is computed for the created particle.
  14133. * @param worldMatrix is the world matrix of the particle system
  14134. * @param directionToUpdate is the direction vector to update with the result
  14135. * @param particle is the particle we are computed the direction for
  14136. */
  14137. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14138. /**
  14139. * Clones the current emitter and returns a copy of it
  14140. * @returns the new emitter
  14141. */
  14142. clone(): SphereDirectedParticleEmitter;
  14143. /**
  14144. * Called by the GPUParticleSystem to setup the update shader
  14145. * @param effect defines the update shader
  14146. */
  14147. applyToShader(effect: Effect): void;
  14148. /**
  14149. * Returns a string to use to update the GPU particles update shader
  14150. * @returns a string containng the defines string
  14151. */
  14152. getEffectDefines(): string;
  14153. /**
  14154. * Returns the string "SphereDirectedParticleEmitter"
  14155. * @returns a string containing the class name
  14156. */
  14157. getClassName(): string;
  14158. /**
  14159. * Serializes the particle system to a JSON object.
  14160. * @returns the JSON object
  14161. */
  14162. serialize(): any;
  14163. /**
  14164. * Parse properties from a JSON object
  14165. * @param serializationObject defines the JSON object
  14166. */
  14167. parse(serializationObject: any): void;
  14168. }
  14169. }
  14170. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14171. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14172. import { Effect } from "babylonjs/Materials/effect";
  14173. import { Particle } from "babylonjs/Particles/particle";
  14174. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14175. import { Nullable } from "babylonjs/types";
  14176. /**
  14177. * Particle emitter emitting particles from a custom list of positions.
  14178. */
  14179. export class CustomParticleEmitter implements IParticleEmitterType {
  14180. /**
  14181. * Gets or sets the position generator that will create the inital position of each particle.
  14182. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14183. */
  14184. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14185. /**
  14186. * Gets or sets the destination generator that will create the final destination of each particle.
  14187. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14188. */
  14189. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14190. /**
  14191. * Creates a new instance CustomParticleEmitter
  14192. */
  14193. constructor();
  14194. /**
  14195. * Called by the particle System when the direction is computed for the created particle.
  14196. * @param worldMatrix is the world matrix of the particle system
  14197. * @param directionToUpdate is the direction vector to update with the result
  14198. * @param particle is the particle we are computed the direction for
  14199. * @param isLocal defines if the direction should be set in local space
  14200. */
  14201. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14202. /**
  14203. * Called by the particle System when the position is computed for the created particle.
  14204. * @param worldMatrix is the world matrix of the particle system
  14205. * @param positionToUpdate is the position vector to update with the result
  14206. * @param particle is the particle we are computed the position for
  14207. * @param isLocal defines if the position should be set in local space
  14208. */
  14209. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14210. /**
  14211. * Clones the current emitter and returns a copy of it
  14212. * @returns the new emitter
  14213. */
  14214. clone(): CustomParticleEmitter;
  14215. /**
  14216. * Called by the GPUParticleSystem to setup the update shader
  14217. * @param effect defines the update shader
  14218. */
  14219. applyToShader(effect: Effect): void;
  14220. /**
  14221. * Returns a string to use to update the GPU particles update shader
  14222. * @returns a string containng the defines string
  14223. */
  14224. getEffectDefines(): string;
  14225. /**
  14226. * Returns the string "PointParticleEmitter"
  14227. * @returns a string containing the class name
  14228. */
  14229. getClassName(): string;
  14230. /**
  14231. * Serializes the particle system to a JSON object.
  14232. * @returns the JSON object
  14233. */
  14234. serialize(): any;
  14235. /**
  14236. * Parse properties from a JSON object
  14237. * @param serializationObject defines the JSON object
  14238. */
  14239. parse(serializationObject: any): void;
  14240. }
  14241. }
  14242. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14243. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14244. import { Effect } from "babylonjs/Materials/effect";
  14245. import { Particle } from "babylonjs/Particles/particle";
  14246. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14247. import { Nullable } from "babylonjs/types";
  14248. import { Scene } from "babylonjs/scene";
  14249. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14250. /**
  14251. * Particle emitter emitting particles from the inside of a box.
  14252. * It emits the particles randomly between 2 given directions.
  14253. */
  14254. export class MeshParticleEmitter implements IParticleEmitterType {
  14255. private _indices;
  14256. private _positions;
  14257. private _normals;
  14258. private _storedNormal;
  14259. private _mesh;
  14260. /**
  14261. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14262. */
  14263. direction1: Vector3;
  14264. /**
  14265. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14266. */
  14267. direction2: Vector3;
  14268. /**
  14269. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14270. */
  14271. useMeshNormalsForDirection: boolean;
  14272. /** Defines the mesh to use as source */
  14273. get mesh(): Nullable<AbstractMesh>;
  14274. set mesh(value: Nullable<AbstractMesh>);
  14275. /**
  14276. * Creates a new instance MeshParticleEmitter
  14277. * @param mesh defines the mesh to use as source
  14278. */
  14279. constructor(mesh?: Nullable<AbstractMesh>);
  14280. /**
  14281. * Called by the particle System when the direction is computed for the created particle.
  14282. * @param worldMatrix is the world matrix of the particle system
  14283. * @param directionToUpdate is the direction vector to update with the result
  14284. * @param particle is the particle we are computed the direction for
  14285. * @param isLocal defines if the direction should be set in local space
  14286. */
  14287. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14288. /**
  14289. * Called by the particle System when the position is computed for the created particle.
  14290. * @param worldMatrix is the world matrix of the particle system
  14291. * @param positionToUpdate is the position vector to update with the result
  14292. * @param particle is the particle we are computed the position for
  14293. * @param isLocal defines if the position should be set in local space
  14294. */
  14295. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14296. /**
  14297. * Clones the current emitter and returns a copy of it
  14298. * @returns the new emitter
  14299. */
  14300. clone(): MeshParticleEmitter;
  14301. /**
  14302. * Called by the GPUParticleSystem to setup the update shader
  14303. * @param effect defines the update shader
  14304. */
  14305. applyToShader(effect: Effect): void;
  14306. /**
  14307. * Returns a string to use to update the GPU particles update shader
  14308. * @returns a string containng the defines string
  14309. */
  14310. getEffectDefines(): string;
  14311. /**
  14312. * Returns the string "BoxParticleEmitter"
  14313. * @returns a string containing the class name
  14314. */
  14315. getClassName(): string;
  14316. /**
  14317. * Serializes the particle system to a JSON object.
  14318. * @returns the JSON object
  14319. */
  14320. serialize(): any;
  14321. /**
  14322. * Parse properties from a JSON object
  14323. * @param serializationObject defines the JSON object
  14324. * @param scene defines the hosting scene
  14325. */
  14326. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14327. }
  14328. }
  14329. declare module "babylonjs/Particles/EmitterTypes/index" {
  14330. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14331. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14332. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14333. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14334. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14335. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14336. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14337. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14338. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14339. }
  14340. declare module "babylonjs/Particles/IParticleSystem" {
  14341. import { Nullable } from "babylonjs/types";
  14342. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14343. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14344. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14345. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14346. import { Scene } from "babylonjs/scene";
  14347. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14348. import { Effect } from "babylonjs/Materials/effect";
  14349. import { Observable } from "babylonjs/Misc/observable";
  14350. import { Animation } from "babylonjs/Animations/animation";
  14351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14352. /**
  14353. * Interface representing a particle system in Babylon.js.
  14354. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14355. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14356. */
  14357. export interface IParticleSystem {
  14358. /**
  14359. * List of animations used by the particle system.
  14360. */
  14361. animations: Animation[];
  14362. /**
  14363. * The id of the Particle system.
  14364. */
  14365. id: string;
  14366. /**
  14367. * The name of the Particle system.
  14368. */
  14369. name: string;
  14370. /**
  14371. * The emitter represents the Mesh or position we are attaching the particle system to.
  14372. */
  14373. emitter: Nullable<AbstractMesh | Vector3>;
  14374. /**
  14375. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14376. */
  14377. isBillboardBased: boolean;
  14378. /**
  14379. * The rendering group used by the Particle system to chose when to render.
  14380. */
  14381. renderingGroupId: number;
  14382. /**
  14383. * The layer mask we are rendering the particles through.
  14384. */
  14385. layerMask: number;
  14386. /**
  14387. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14388. */
  14389. updateSpeed: number;
  14390. /**
  14391. * The amount of time the particle system is running (depends of the overall update speed).
  14392. */
  14393. targetStopDuration: number;
  14394. /**
  14395. * The texture used to render each particle. (this can be a spritesheet)
  14396. */
  14397. particleTexture: Nullable<BaseTexture>;
  14398. /**
  14399. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14400. */
  14401. blendMode: number;
  14402. /**
  14403. * Minimum life time of emitting particles.
  14404. */
  14405. minLifeTime: number;
  14406. /**
  14407. * Maximum life time of emitting particles.
  14408. */
  14409. maxLifeTime: number;
  14410. /**
  14411. * Minimum Size of emitting particles.
  14412. */
  14413. minSize: number;
  14414. /**
  14415. * Maximum Size of emitting particles.
  14416. */
  14417. maxSize: number;
  14418. /**
  14419. * Minimum scale of emitting particles on X axis.
  14420. */
  14421. minScaleX: number;
  14422. /**
  14423. * Maximum scale of emitting particles on X axis.
  14424. */
  14425. maxScaleX: number;
  14426. /**
  14427. * Minimum scale of emitting particles on Y axis.
  14428. */
  14429. minScaleY: number;
  14430. /**
  14431. * Maximum scale of emitting particles on Y axis.
  14432. */
  14433. maxScaleY: number;
  14434. /**
  14435. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14436. */
  14437. color1: Color4;
  14438. /**
  14439. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14440. */
  14441. color2: Color4;
  14442. /**
  14443. * Color the particle will have at the end of its lifetime.
  14444. */
  14445. colorDead: Color4;
  14446. /**
  14447. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14448. */
  14449. emitRate: number;
  14450. /**
  14451. * You can use gravity if you want to give an orientation to your particles.
  14452. */
  14453. gravity: Vector3;
  14454. /**
  14455. * Minimum power of emitting particles.
  14456. */
  14457. minEmitPower: number;
  14458. /**
  14459. * Maximum power of emitting particles.
  14460. */
  14461. maxEmitPower: number;
  14462. /**
  14463. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14464. */
  14465. minAngularSpeed: number;
  14466. /**
  14467. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14468. */
  14469. maxAngularSpeed: number;
  14470. /**
  14471. * Gets or sets the minimal initial rotation in radians.
  14472. */
  14473. minInitialRotation: number;
  14474. /**
  14475. * Gets or sets the maximal initial rotation in radians.
  14476. */
  14477. maxInitialRotation: number;
  14478. /**
  14479. * The particle emitter type defines the emitter used by the particle system.
  14480. * It can be for example box, sphere, or cone...
  14481. */
  14482. particleEmitterType: Nullable<IParticleEmitterType>;
  14483. /**
  14484. * Defines the delay in milliseconds before starting the system (0 by default)
  14485. */
  14486. startDelay: number;
  14487. /**
  14488. * 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
  14489. */
  14490. preWarmCycles: number;
  14491. /**
  14492. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14493. */
  14494. preWarmStepOffset: number;
  14495. /**
  14496. * 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)
  14497. */
  14498. spriteCellChangeSpeed: number;
  14499. /**
  14500. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14501. */
  14502. startSpriteCellID: number;
  14503. /**
  14504. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14505. */
  14506. endSpriteCellID: number;
  14507. /**
  14508. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14509. */
  14510. spriteCellWidth: number;
  14511. /**
  14512. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14513. */
  14514. spriteCellHeight: number;
  14515. /**
  14516. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14517. */
  14518. spriteRandomStartCell: boolean;
  14519. /**
  14520. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14521. */
  14522. isAnimationSheetEnabled: boolean;
  14523. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14524. translationPivot: Vector2;
  14525. /**
  14526. * Gets or sets a texture used to add random noise to particle positions
  14527. */
  14528. noiseTexture: Nullable<BaseTexture>;
  14529. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14530. noiseStrength: Vector3;
  14531. /**
  14532. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14533. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14534. */
  14535. billboardMode: number;
  14536. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14537. limitVelocityDamping: number;
  14538. /**
  14539. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14540. */
  14541. beginAnimationOnStart: boolean;
  14542. /**
  14543. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14544. */
  14545. beginAnimationFrom: number;
  14546. /**
  14547. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14548. */
  14549. beginAnimationTo: number;
  14550. /**
  14551. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14552. */
  14553. beginAnimationLoop: boolean;
  14554. /**
  14555. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14556. */
  14557. disposeOnStop: boolean;
  14558. /**
  14559. * Specifies if the particles are updated in emitter local space or world space
  14560. */
  14561. isLocal: boolean;
  14562. /** Snippet ID if the particle system was created from the snippet server */
  14563. snippetId: string;
  14564. /** Gets or sets a matrix to use to compute projection */
  14565. defaultProjectionMatrix: Matrix;
  14566. /**
  14567. * Gets the maximum number of particles active at the same time.
  14568. * @returns The max number of active particles.
  14569. */
  14570. getCapacity(): number;
  14571. /**
  14572. * Gets the number of particles active at the same time.
  14573. * @returns The number of active particles.
  14574. */
  14575. getActiveCount(): number;
  14576. /**
  14577. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14578. * @returns True if it has been started, otherwise false.
  14579. */
  14580. isStarted(): boolean;
  14581. /**
  14582. * Animates the particle system for this frame.
  14583. */
  14584. animate(): void;
  14585. /**
  14586. * Renders the particle system in its current state.
  14587. * @returns the current number of particles
  14588. */
  14589. render(): number;
  14590. /**
  14591. * Dispose the particle system and frees its associated resources.
  14592. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14593. */
  14594. dispose(disposeTexture?: boolean): void;
  14595. /**
  14596. * An event triggered when the system is disposed
  14597. */
  14598. onDisposeObservable: Observable<IParticleSystem>;
  14599. /**
  14600. * Clones the particle system.
  14601. * @param name The name of the cloned object
  14602. * @param newEmitter The new emitter to use
  14603. * @returns the cloned particle system
  14604. */
  14605. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14606. /**
  14607. * Serializes the particle system to a JSON object
  14608. * @param serializeTexture defines if the texture must be serialized as well
  14609. * @returns the JSON object
  14610. */
  14611. serialize(serializeTexture: boolean): any;
  14612. /**
  14613. * Rebuild the particle system
  14614. */
  14615. rebuild(): void;
  14616. /** Force the system to rebuild all gradients that need to be resync */
  14617. forceRefreshGradients(): void;
  14618. /**
  14619. * Starts the particle system and begins to emit
  14620. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14621. */
  14622. start(delay?: number): void;
  14623. /**
  14624. * Stops the particle system.
  14625. */
  14626. stop(): void;
  14627. /**
  14628. * Remove all active particles
  14629. */
  14630. reset(): void;
  14631. /**
  14632. * Gets a boolean indicating that the system is stopping
  14633. * @returns true if the system is currently stopping
  14634. */
  14635. isStopping(): boolean;
  14636. /**
  14637. * Is this system ready to be used/rendered
  14638. * @return true if the system is ready
  14639. */
  14640. isReady(): boolean;
  14641. /**
  14642. * Returns the string "ParticleSystem"
  14643. * @returns a string containing the class name
  14644. */
  14645. getClassName(): string;
  14646. /**
  14647. * Gets the custom effect used to render the particles
  14648. * @param blendMode Blend mode for which the effect should be retrieved
  14649. * @returns The effect
  14650. */
  14651. getCustomEffect(blendMode: number): Nullable<Effect>;
  14652. /**
  14653. * Sets the custom effect used to render the particles
  14654. * @param effect The effect to set
  14655. * @param blendMode Blend mode for which the effect should be set
  14656. */
  14657. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14658. /**
  14659. * Fill the defines array according to the current settings of the particle system
  14660. * @param defines Array to be updated
  14661. * @param blendMode blend mode to take into account when updating the array
  14662. */
  14663. fillDefines(defines: Array<string>, blendMode: number): void;
  14664. /**
  14665. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14666. * @param uniforms Uniforms array to fill
  14667. * @param attributes Attributes array to fill
  14668. * @param samplers Samplers array to fill
  14669. */
  14670. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14671. /**
  14672. * Observable that will be called just before the particles are drawn
  14673. */
  14674. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14675. /**
  14676. * Gets the name of the particle vertex shader
  14677. */
  14678. vertexShaderName: string;
  14679. /**
  14680. * Adds a new color gradient
  14681. * @param gradient defines the gradient to use (between 0 and 1)
  14682. * @param color1 defines the color to affect to the specified gradient
  14683. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14684. * @returns the current particle system
  14685. */
  14686. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14687. /**
  14688. * Remove a specific color gradient
  14689. * @param gradient defines the gradient to remove
  14690. * @returns the current particle system
  14691. */
  14692. removeColorGradient(gradient: number): IParticleSystem;
  14693. /**
  14694. * Adds a new size gradient
  14695. * @param gradient defines the gradient to use (between 0 and 1)
  14696. * @param factor defines the size factor to affect to the specified gradient
  14697. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14698. * @returns the current particle system
  14699. */
  14700. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14701. /**
  14702. * Remove a specific size gradient
  14703. * @param gradient defines the gradient to remove
  14704. * @returns the current particle system
  14705. */
  14706. removeSizeGradient(gradient: number): IParticleSystem;
  14707. /**
  14708. * Gets the current list of color gradients.
  14709. * You must use addColorGradient and removeColorGradient to udpate this list
  14710. * @returns the list of color gradients
  14711. */
  14712. getColorGradients(): Nullable<Array<ColorGradient>>;
  14713. /**
  14714. * Gets the current list of size gradients.
  14715. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14716. * @returns the list of size gradients
  14717. */
  14718. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14719. /**
  14720. * Gets the current list of angular speed gradients.
  14721. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14722. * @returns the list of angular speed gradients
  14723. */
  14724. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14725. /**
  14726. * Adds a new angular speed gradient
  14727. * @param gradient defines the gradient to use (between 0 and 1)
  14728. * @param factor defines the angular speed to affect to the specified gradient
  14729. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14730. * @returns the current particle system
  14731. */
  14732. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14733. /**
  14734. * Remove a specific angular speed gradient
  14735. * @param gradient defines the gradient to remove
  14736. * @returns the current particle system
  14737. */
  14738. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14739. /**
  14740. * Gets the current list of velocity gradients.
  14741. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14742. * @returns the list of velocity gradients
  14743. */
  14744. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14745. /**
  14746. * Adds a new velocity gradient
  14747. * @param gradient defines the gradient to use (between 0 and 1)
  14748. * @param factor defines the velocity to affect to the specified gradient
  14749. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14750. * @returns the current particle system
  14751. */
  14752. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14753. /**
  14754. * Remove a specific velocity gradient
  14755. * @param gradient defines the gradient to remove
  14756. * @returns the current particle system
  14757. */
  14758. removeVelocityGradient(gradient: number): IParticleSystem;
  14759. /**
  14760. * Gets the current list of limit velocity gradients.
  14761. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14762. * @returns the list of limit velocity gradients
  14763. */
  14764. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14765. /**
  14766. * Adds a new limit velocity gradient
  14767. * @param gradient defines the gradient to use (between 0 and 1)
  14768. * @param factor defines the limit velocity to affect to the specified gradient
  14769. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14770. * @returns the current particle system
  14771. */
  14772. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14773. /**
  14774. * Remove a specific limit velocity gradient
  14775. * @param gradient defines the gradient to remove
  14776. * @returns the current particle system
  14777. */
  14778. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14779. /**
  14780. * Adds a new drag gradient
  14781. * @param gradient defines the gradient to use (between 0 and 1)
  14782. * @param factor defines the drag to affect to the specified gradient
  14783. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14784. * @returns the current particle system
  14785. */
  14786. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14787. /**
  14788. * Remove a specific drag gradient
  14789. * @param gradient defines the gradient to remove
  14790. * @returns the current particle system
  14791. */
  14792. removeDragGradient(gradient: number): IParticleSystem;
  14793. /**
  14794. * Gets the current list of drag gradients.
  14795. * You must use addDragGradient and removeDragGradient to udpate this list
  14796. * @returns the list of drag gradients
  14797. */
  14798. getDragGradients(): Nullable<Array<FactorGradient>>;
  14799. /**
  14800. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14801. * @param gradient defines the gradient to use (between 0 and 1)
  14802. * @param factor defines the emit rate to affect to the specified gradient
  14803. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14804. * @returns the current particle system
  14805. */
  14806. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14807. /**
  14808. * Remove a specific emit rate gradient
  14809. * @param gradient defines the gradient to remove
  14810. * @returns the current particle system
  14811. */
  14812. removeEmitRateGradient(gradient: number): IParticleSystem;
  14813. /**
  14814. * Gets the current list of emit rate gradients.
  14815. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14816. * @returns the list of emit rate gradients
  14817. */
  14818. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14819. /**
  14820. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14821. * @param gradient defines the gradient to use (between 0 and 1)
  14822. * @param factor defines the start size to affect to the specified gradient
  14823. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14824. * @returns the current particle system
  14825. */
  14826. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14827. /**
  14828. * Remove a specific start size gradient
  14829. * @param gradient defines the gradient to remove
  14830. * @returns the current particle system
  14831. */
  14832. removeStartSizeGradient(gradient: number): IParticleSystem;
  14833. /**
  14834. * Gets the current list of start size gradients.
  14835. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14836. * @returns the list of start size gradients
  14837. */
  14838. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14839. /**
  14840. * Adds a new life time gradient
  14841. * @param gradient defines the gradient to use (between 0 and 1)
  14842. * @param factor defines the life time factor to affect to the specified gradient
  14843. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14844. * @returns the current particle system
  14845. */
  14846. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14847. /**
  14848. * Remove a specific life time gradient
  14849. * @param gradient defines the gradient to remove
  14850. * @returns the current particle system
  14851. */
  14852. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14853. /**
  14854. * Gets the current list of life time gradients.
  14855. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14856. * @returns the list of life time gradients
  14857. */
  14858. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14859. /**
  14860. * Gets the current list of color gradients.
  14861. * You must use addColorGradient and removeColorGradient to udpate this list
  14862. * @returns the list of color gradients
  14863. */
  14864. getColorGradients(): Nullable<Array<ColorGradient>>;
  14865. /**
  14866. * Adds a new ramp gradient used to remap particle colors
  14867. * @param gradient defines the gradient to use (between 0 and 1)
  14868. * @param color defines the color to affect to the specified gradient
  14869. * @returns the current particle system
  14870. */
  14871. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14872. /**
  14873. * Gets the current list of ramp gradients.
  14874. * You must use addRampGradient and removeRampGradient to udpate this list
  14875. * @returns the list of ramp gradients
  14876. */
  14877. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14878. /** Gets or sets a boolean indicating that ramp gradients must be used
  14879. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14880. */
  14881. useRampGradients: boolean;
  14882. /**
  14883. * Adds a new color remap gradient
  14884. * @param gradient defines the gradient to use (between 0 and 1)
  14885. * @param min defines the color remap minimal range
  14886. * @param max defines the color remap maximal range
  14887. * @returns the current particle system
  14888. */
  14889. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14890. /**
  14891. * Gets the current list of color remap gradients.
  14892. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14893. * @returns the list of color remap gradients
  14894. */
  14895. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14896. /**
  14897. * Adds a new alpha remap gradient
  14898. * @param gradient defines the gradient to use (between 0 and 1)
  14899. * @param min defines the alpha remap minimal range
  14900. * @param max defines the alpha remap maximal range
  14901. * @returns the current particle system
  14902. */
  14903. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14904. /**
  14905. * Gets the current list of alpha remap gradients.
  14906. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14907. * @returns the list of alpha remap gradients
  14908. */
  14909. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14910. /**
  14911. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14912. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14913. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14914. * @returns the emitter
  14915. */
  14916. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14917. /**
  14918. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14919. * @param radius The radius of the hemisphere to emit from
  14920. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14921. * @returns the emitter
  14922. */
  14923. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14924. /**
  14925. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14926. * @param radius The radius of the sphere to emit from
  14927. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14928. * @returns the emitter
  14929. */
  14930. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14931. /**
  14932. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14933. * @param radius The radius of the sphere to emit from
  14934. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14935. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14936. * @returns the emitter
  14937. */
  14938. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14939. /**
  14940. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14941. * @param radius The radius of the emission cylinder
  14942. * @param height The height of the emission cylinder
  14943. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14944. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14945. * @returns the emitter
  14946. */
  14947. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14948. /**
  14949. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14950. * @param radius The radius of the cylinder to emit from
  14951. * @param height The height of the emission cylinder
  14952. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14953. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14954. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14955. * @returns the emitter
  14956. */
  14957. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14958. /**
  14959. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14960. * @param radius The radius of the cone to emit from
  14961. * @param angle The base angle of the cone
  14962. * @returns the emitter
  14963. */
  14964. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14965. /**
  14966. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14967. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14968. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14969. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14970. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14971. * @returns the emitter
  14972. */
  14973. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14974. /**
  14975. * Get hosting scene
  14976. * @returns the scene
  14977. */
  14978. getScene(): Nullable<Scene>;
  14979. }
  14980. }
  14981. declare module "babylonjs/Meshes/transformNode" {
  14982. import { DeepImmutable } from "babylonjs/types";
  14983. import { Observable } from "babylonjs/Misc/observable";
  14984. import { Nullable } from "babylonjs/types";
  14985. import { Camera } from "babylonjs/Cameras/camera";
  14986. import { Scene } from "babylonjs/scene";
  14987. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14988. import { Node } from "babylonjs/node";
  14989. import { Bone } from "babylonjs/Bones/bone";
  14990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14991. import { Space } from "babylonjs/Maths/math.axis";
  14992. /**
  14993. * 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.
  14994. * @see https://doc.babylonjs.com/how_to/transformnode
  14995. */
  14996. export class TransformNode extends Node {
  14997. /**
  14998. * Object will not rotate to face the camera
  14999. */
  15000. static BILLBOARDMODE_NONE: number;
  15001. /**
  15002. * Object will rotate to face the camera but only on the x axis
  15003. */
  15004. static BILLBOARDMODE_X: number;
  15005. /**
  15006. * Object will rotate to face the camera but only on the y axis
  15007. */
  15008. static BILLBOARDMODE_Y: number;
  15009. /**
  15010. * Object will rotate to face the camera but only on the z axis
  15011. */
  15012. static BILLBOARDMODE_Z: number;
  15013. /**
  15014. * Object will rotate to face the camera
  15015. */
  15016. static BILLBOARDMODE_ALL: number;
  15017. /**
  15018. * Object will rotate to face the camera's position instead of orientation
  15019. */
  15020. static BILLBOARDMODE_USE_POSITION: number;
  15021. private static _TmpRotation;
  15022. private static _TmpScaling;
  15023. private static _TmpTranslation;
  15024. private _forward;
  15025. private _forwardInverted;
  15026. private _up;
  15027. private _right;
  15028. private _rightInverted;
  15029. private _position;
  15030. private _rotation;
  15031. private _rotationQuaternion;
  15032. protected _scaling: Vector3;
  15033. protected _isDirty: boolean;
  15034. private _transformToBoneReferal;
  15035. private _isAbsoluteSynced;
  15036. private _billboardMode;
  15037. /**
  15038. * Gets or sets the billboard mode. Default is 0.
  15039. *
  15040. * | Value | Type | Description |
  15041. * | --- | --- | --- |
  15042. * | 0 | BILLBOARDMODE_NONE | |
  15043. * | 1 | BILLBOARDMODE_X | |
  15044. * | 2 | BILLBOARDMODE_Y | |
  15045. * | 4 | BILLBOARDMODE_Z | |
  15046. * | 7 | BILLBOARDMODE_ALL | |
  15047. *
  15048. */
  15049. get billboardMode(): number;
  15050. set billboardMode(value: number);
  15051. private _preserveParentRotationForBillboard;
  15052. /**
  15053. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  15054. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  15055. */
  15056. get preserveParentRotationForBillboard(): boolean;
  15057. set preserveParentRotationForBillboard(value: boolean);
  15058. /**
  15059. * 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
  15060. */
  15061. scalingDeterminant: number;
  15062. private _infiniteDistance;
  15063. /**
  15064. * Gets or sets the distance of the object to max, often used by skybox
  15065. */
  15066. get infiniteDistance(): boolean;
  15067. set infiniteDistance(value: boolean);
  15068. /**
  15069. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15070. * By default the system will update normals to compensate
  15071. */
  15072. ignoreNonUniformScaling: boolean;
  15073. /**
  15074. * 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
  15075. */
  15076. reIntegrateRotationIntoRotationQuaternion: boolean;
  15077. /** @hidden */
  15078. _poseMatrix: Nullable<Matrix>;
  15079. /** @hidden */
  15080. _localMatrix: Matrix;
  15081. private _usePivotMatrix;
  15082. private _absolutePosition;
  15083. private _absoluteScaling;
  15084. private _absoluteRotationQuaternion;
  15085. private _pivotMatrix;
  15086. private _pivotMatrixInverse;
  15087. /** @hidden */
  15088. _postMultiplyPivotMatrix: boolean;
  15089. protected _isWorldMatrixFrozen: boolean;
  15090. /** @hidden */
  15091. _indexInSceneTransformNodesArray: number;
  15092. /**
  15093. * An event triggered after the world matrix is updated
  15094. */
  15095. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15096. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15097. /**
  15098. * Gets a string identifying the name of the class
  15099. * @returns "TransformNode" string
  15100. */
  15101. getClassName(): string;
  15102. /**
  15103. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15104. */
  15105. get position(): Vector3;
  15106. set position(newPosition: Vector3);
  15107. /**
  15108. * 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)).
  15109. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15110. */
  15111. get rotation(): Vector3;
  15112. set rotation(newRotation: Vector3);
  15113. /**
  15114. * 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)).
  15115. */
  15116. get scaling(): Vector3;
  15117. set scaling(newScaling: Vector3);
  15118. /**
  15119. * 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).
  15120. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15121. */
  15122. get rotationQuaternion(): Nullable<Quaternion>;
  15123. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15124. /**
  15125. * The forward direction of that transform in world space.
  15126. */
  15127. get forward(): Vector3;
  15128. /**
  15129. * The up direction of that transform in world space.
  15130. */
  15131. get up(): Vector3;
  15132. /**
  15133. * The right direction of that transform in world space.
  15134. */
  15135. get right(): Vector3;
  15136. /**
  15137. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15138. * @param matrix the matrix to copy the pose from
  15139. * @returns this TransformNode.
  15140. */
  15141. updatePoseMatrix(matrix: Matrix): TransformNode;
  15142. /**
  15143. * Returns the mesh Pose matrix.
  15144. * @returns the pose matrix
  15145. */
  15146. getPoseMatrix(): Matrix;
  15147. /** @hidden */
  15148. _isSynchronized(): boolean;
  15149. /** @hidden */
  15150. _initCache(): void;
  15151. /**
  15152. * Flag the transform node as dirty (Forcing it to update everything)
  15153. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15154. * @returns this transform node
  15155. */
  15156. markAsDirty(property: string): TransformNode;
  15157. /**
  15158. * Returns the current mesh absolute position.
  15159. * Returns a Vector3.
  15160. */
  15161. get absolutePosition(): Vector3;
  15162. /**
  15163. * Returns the current mesh absolute scaling.
  15164. * Returns a Vector3.
  15165. */
  15166. get absoluteScaling(): Vector3;
  15167. /**
  15168. * Returns the current mesh absolute rotation.
  15169. * Returns a Quaternion.
  15170. */
  15171. get absoluteRotationQuaternion(): Quaternion;
  15172. /**
  15173. * Sets a new matrix to apply before all other transformation
  15174. * @param matrix defines the transform matrix
  15175. * @returns the current TransformNode
  15176. */
  15177. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15178. /**
  15179. * Sets a new pivot matrix to the current node
  15180. * @param matrix defines the new pivot matrix to use
  15181. * @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
  15182. * @returns the current TransformNode
  15183. */
  15184. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15185. /**
  15186. * Returns the mesh pivot matrix.
  15187. * Default : Identity.
  15188. * @returns the matrix
  15189. */
  15190. getPivotMatrix(): Matrix;
  15191. /**
  15192. * Instantiate (when possible) or clone that node with its hierarchy
  15193. * @param newParent defines the new parent to use for the instance (or clone)
  15194. * @param options defines options to configure how copy is done
  15195. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15196. * @returns an instance (or a clone) of the current node with its hiearchy
  15197. */
  15198. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15199. doNotInstantiate: boolean;
  15200. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15201. /**
  15202. * Prevents the World matrix to be computed any longer
  15203. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15204. * @returns the TransformNode.
  15205. */
  15206. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15207. /**
  15208. * Allows back the World matrix computation.
  15209. * @returns the TransformNode.
  15210. */
  15211. unfreezeWorldMatrix(): this;
  15212. /**
  15213. * True if the World matrix has been frozen.
  15214. */
  15215. get isWorldMatrixFrozen(): boolean;
  15216. /**
  15217. * Retuns the mesh absolute position in the World.
  15218. * @returns a Vector3.
  15219. */
  15220. getAbsolutePosition(): Vector3;
  15221. /**
  15222. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15223. * @param absolutePosition the absolute position to set
  15224. * @returns the TransformNode.
  15225. */
  15226. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15227. /**
  15228. * Sets the mesh position in its local space.
  15229. * @param vector3 the position to set in localspace
  15230. * @returns the TransformNode.
  15231. */
  15232. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15233. /**
  15234. * Returns the mesh position in the local space from the current World matrix values.
  15235. * @returns a new Vector3.
  15236. */
  15237. getPositionExpressedInLocalSpace(): Vector3;
  15238. /**
  15239. * Translates the mesh along the passed Vector3 in its local space.
  15240. * @param vector3 the distance to translate in localspace
  15241. * @returns the TransformNode.
  15242. */
  15243. locallyTranslate(vector3: Vector3): TransformNode;
  15244. private static _lookAtVectorCache;
  15245. /**
  15246. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15247. * @param targetPoint the position (must be in same space as current mesh) to look at
  15248. * @param yawCor optional yaw (y-axis) correction in radians
  15249. * @param pitchCor optional pitch (x-axis) correction in radians
  15250. * @param rollCor optional roll (z-axis) correction in radians
  15251. * @param space the choosen space of the target
  15252. * @returns the TransformNode.
  15253. */
  15254. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15255. /**
  15256. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15257. * This Vector3 is expressed in the World space.
  15258. * @param localAxis axis to rotate
  15259. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15260. */
  15261. getDirection(localAxis: Vector3): Vector3;
  15262. /**
  15263. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15264. * localAxis is expressed in the mesh local space.
  15265. * result is computed in the Wordl space from the mesh World matrix.
  15266. * @param localAxis axis to rotate
  15267. * @param result the resulting transformnode
  15268. * @returns this TransformNode.
  15269. */
  15270. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15271. /**
  15272. * Sets this transform node rotation to the given local axis.
  15273. * @param localAxis the axis in local space
  15274. * @param yawCor optional yaw (y-axis) correction in radians
  15275. * @param pitchCor optional pitch (x-axis) correction in radians
  15276. * @param rollCor optional roll (z-axis) correction in radians
  15277. * @returns this TransformNode
  15278. */
  15279. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15280. /**
  15281. * Sets a new pivot point to the current node
  15282. * @param point defines the new pivot point to use
  15283. * @param space defines if the point is in world or local space (local by default)
  15284. * @returns the current TransformNode
  15285. */
  15286. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15287. /**
  15288. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15289. * @returns the pivot point
  15290. */
  15291. getPivotPoint(): Vector3;
  15292. /**
  15293. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15294. * @param result the vector3 to store the result
  15295. * @returns this TransformNode.
  15296. */
  15297. getPivotPointToRef(result: Vector3): TransformNode;
  15298. /**
  15299. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15300. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15301. */
  15302. getAbsolutePivotPoint(): Vector3;
  15303. /**
  15304. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15305. * @param result vector3 to store the result
  15306. * @returns this TransformNode.
  15307. */
  15308. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15309. /**
  15310. * Defines the passed node as the parent of the current node.
  15311. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15312. * @see https://doc.babylonjs.com/how_to/parenting
  15313. * @param node the node ot set as the parent
  15314. * @returns this TransformNode.
  15315. */
  15316. setParent(node: Nullable<Node>): TransformNode;
  15317. private _nonUniformScaling;
  15318. /**
  15319. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15320. */
  15321. get nonUniformScaling(): boolean;
  15322. /** @hidden */
  15323. _updateNonUniformScalingState(value: boolean): boolean;
  15324. /**
  15325. * Attach the current TransformNode to another TransformNode associated with a bone
  15326. * @param bone Bone affecting the TransformNode
  15327. * @param affectedTransformNode TransformNode associated with the bone
  15328. * @returns this object
  15329. */
  15330. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15331. /**
  15332. * Detach the transform node if its associated with a bone
  15333. * @returns this object
  15334. */
  15335. detachFromBone(): TransformNode;
  15336. private static _rotationAxisCache;
  15337. /**
  15338. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15339. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15340. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15341. * The passed axis is also normalized.
  15342. * @param axis the axis to rotate around
  15343. * @param amount the amount to rotate in radians
  15344. * @param space Space to rotate in (Default: local)
  15345. * @returns the TransformNode.
  15346. */
  15347. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15348. /**
  15349. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15350. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15351. * The passed axis is also normalized. .
  15352. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15353. * @param point the point to rotate around
  15354. * @param axis the axis to rotate around
  15355. * @param amount the amount to rotate in radians
  15356. * @returns the TransformNode
  15357. */
  15358. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15359. /**
  15360. * Translates the mesh along the axis vector for the passed distance in the given space.
  15361. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15362. * @param axis the axis to translate in
  15363. * @param distance the distance to translate
  15364. * @param space Space to rotate in (Default: local)
  15365. * @returns the TransformNode.
  15366. */
  15367. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15368. /**
  15369. * Adds a rotation step to the mesh current rotation.
  15370. * x, y, z are Euler angles expressed in radians.
  15371. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15372. * This means this rotation is made in the mesh local space only.
  15373. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15374. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15375. * ```javascript
  15376. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15377. * ```
  15378. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15379. * 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.
  15380. * @param x Rotation to add
  15381. * @param y Rotation to add
  15382. * @param z Rotation to add
  15383. * @returns the TransformNode.
  15384. */
  15385. addRotation(x: number, y: number, z: number): TransformNode;
  15386. /**
  15387. * @hidden
  15388. */
  15389. protected _getEffectiveParent(): Nullable<Node>;
  15390. /**
  15391. * Computes the world matrix of the node
  15392. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15393. * @returns the world matrix
  15394. */
  15395. computeWorldMatrix(force?: boolean): Matrix;
  15396. /**
  15397. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15398. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15399. */
  15400. resetLocalMatrix(independentOfChildren?: boolean): void;
  15401. protected _afterComputeWorldMatrix(): void;
  15402. /**
  15403. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15404. * @param func callback function to add
  15405. *
  15406. * @returns the TransformNode.
  15407. */
  15408. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15409. /**
  15410. * Removes a registered callback function.
  15411. * @param func callback function to remove
  15412. * @returns the TransformNode.
  15413. */
  15414. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15415. /**
  15416. * Gets the position of the current mesh in camera space
  15417. * @param camera defines the camera to use
  15418. * @returns a position
  15419. */
  15420. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15421. /**
  15422. * Returns the distance from the mesh to the active camera
  15423. * @param camera defines the camera to use
  15424. * @returns the distance
  15425. */
  15426. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15427. /**
  15428. * Clone the current transform node
  15429. * @param name Name of the new clone
  15430. * @param newParent New parent for the clone
  15431. * @param doNotCloneChildren Do not clone children hierarchy
  15432. * @returns the new transform node
  15433. */
  15434. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15435. /**
  15436. * Serializes the objects information.
  15437. * @param currentSerializationObject defines the object to serialize in
  15438. * @returns the serialized object
  15439. */
  15440. serialize(currentSerializationObject?: any): any;
  15441. /**
  15442. * Returns a new TransformNode object parsed from the source provided.
  15443. * @param parsedTransformNode is the source.
  15444. * @param scene the scne the object belongs to
  15445. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15446. * @returns a new TransformNode object parsed from the source provided.
  15447. */
  15448. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15449. /**
  15450. * Get all child-transformNodes of this node
  15451. * @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
  15452. * @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
  15453. * @returns an array of TransformNode
  15454. */
  15455. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15456. /**
  15457. * Releases resources associated with this transform node.
  15458. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15459. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15460. */
  15461. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15462. /**
  15463. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15464. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15465. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15466. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15467. * @returns the current mesh
  15468. */
  15469. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15470. private _syncAbsoluteScalingAndRotation;
  15471. }
  15472. }
  15473. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15474. /**
  15475. * Class used to override all child animations of a given target
  15476. */
  15477. export class AnimationPropertiesOverride {
  15478. /**
  15479. * Gets or sets a value indicating if animation blending must be used
  15480. */
  15481. enableBlending: boolean;
  15482. /**
  15483. * Gets or sets the blending speed to use when enableBlending is true
  15484. */
  15485. blendingSpeed: number;
  15486. /**
  15487. * Gets or sets the default loop mode to use
  15488. */
  15489. loopMode: number;
  15490. }
  15491. }
  15492. declare module "babylonjs/Bones/bone" {
  15493. import { Skeleton } from "babylonjs/Bones/skeleton";
  15494. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15495. import { Nullable } from "babylonjs/types";
  15496. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15497. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15498. import { Node } from "babylonjs/node";
  15499. import { Space } from "babylonjs/Maths/math.axis";
  15500. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15501. /**
  15502. * Class used to store bone information
  15503. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15504. */
  15505. export class Bone extends Node {
  15506. /**
  15507. * defines the bone name
  15508. */
  15509. name: string;
  15510. private static _tmpVecs;
  15511. private static _tmpQuat;
  15512. private static _tmpMats;
  15513. /**
  15514. * Gets the list of child bones
  15515. */
  15516. children: Bone[];
  15517. /** Gets the animations associated with this bone */
  15518. animations: import("babylonjs/Animations/animation").Animation[];
  15519. /**
  15520. * Gets or sets bone length
  15521. */
  15522. length: number;
  15523. /**
  15524. * @hidden Internal only
  15525. * Set this value to map this bone to a different index in the transform matrices
  15526. * Set this value to -1 to exclude the bone from the transform matrices
  15527. */
  15528. _index: Nullable<number>;
  15529. private _skeleton;
  15530. private _localMatrix;
  15531. private _restPose;
  15532. private _bindPose;
  15533. private _baseMatrix;
  15534. private _absoluteTransform;
  15535. private _invertedAbsoluteTransform;
  15536. private _parent;
  15537. private _scalingDeterminant;
  15538. private _worldTransform;
  15539. private _localScaling;
  15540. private _localRotation;
  15541. private _localPosition;
  15542. private _needToDecompose;
  15543. private _needToCompose;
  15544. /** @hidden */
  15545. _linkedTransformNode: Nullable<TransformNode>;
  15546. /** @hidden */
  15547. _waitingTransformNodeId: Nullable<string>;
  15548. /** @hidden */
  15549. get _matrix(): Matrix;
  15550. /** @hidden */
  15551. set _matrix(value: Matrix);
  15552. /**
  15553. * Create a new bone
  15554. * @param name defines the bone name
  15555. * @param skeleton defines the parent skeleton
  15556. * @param parentBone defines the parent (can be null if the bone is the root)
  15557. * @param localMatrix defines the local matrix
  15558. * @param restPose defines the rest pose matrix
  15559. * @param baseMatrix defines the base matrix
  15560. * @param index defines index of the bone in the hiearchy
  15561. */
  15562. constructor(
  15563. /**
  15564. * defines the bone name
  15565. */
  15566. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15567. /**
  15568. * Gets the current object class name.
  15569. * @return the class name
  15570. */
  15571. getClassName(): string;
  15572. /**
  15573. * Gets the parent skeleton
  15574. * @returns a skeleton
  15575. */
  15576. getSkeleton(): Skeleton;
  15577. /**
  15578. * Gets parent bone
  15579. * @returns a bone or null if the bone is the root of the bone hierarchy
  15580. */
  15581. getParent(): Nullable<Bone>;
  15582. /**
  15583. * Returns an array containing the root bones
  15584. * @returns an array containing the root bones
  15585. */
  15586. getChildren(): Array<Bone>;
  15587. /**
  15588. * Gets the node index in matrix array generated for rendering
  15589. * @returns the node index
  15590. */
  15591. getIndex(): number;
  15592. /**
  15593. * Sets the parent bone
  15594. * @param parent defines the parent (can be null if the bone is the root)
  15595. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15596. */
  15597. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15598. /**
  15599. * Gets the local matrix
  15600. * @returns a matrix
  15601. */
  15602. getLocalMatrix(): Matrix;
  15603. /**
  15604. * Gets the base matrix (initial matrix which remains unchanged)
  15605. * @returns a matrix
  15606. */
  15607. getBaseMatrix(): Matrix;
  15608. /**
  15609. * Gets the rest pose matrix
  15610. * @returns a matrix
  15611. */
  15612. getRestPose(): Matrix;
  15613. /**
  15614. * Sets the rest pose matrix
  15615. * @param matrix the local-space rest pose to set for this bone
  15616. */
  15617. setRestPose(matrix: Matrix): void;
  15618. /**
  15619. * Gets the bind pose matrix
  15620. * @returns the bind pose matrix
  15621. */
  15622. getBindPose(): Matrix;
  15623. /**
  15624. * Sets the bind pose matrix
  15625. * @param matrix the local-space bind pose to set for this bone
  15626. */
  15627. setBindPose(matrix: Matrix): void;
  15628. /**
  15629. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15630. */
  15631. getWorldMatrix(): Matrix;
  15632. /**
  15633. * Sets the local matrix to rest pose matrix
  15634. */
  15635. returnToRest(): void;
  15636. /**
  15637. * Gets the inverse of the absolute transform matrix.
  15638. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15639. * @returns a matrix
  15640. */
  15641. getInvertedAbsoluteTransform(): Matrix;
  15642. /**
  15643. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15644. * @returns a matrix
  15645. */
  15646. getAbsoluteTransform(): Matrix;
  15647. /**
  15648. * Links with the given transform node.
  15649. * The local matrix of this bone is copied from the transform node every frame.
  15650. * @param transformNode defines the transform node to link to
  15651. */
  15652. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15653. /**
  15654. * Gets the node used to drive the bone's transformation
  15655. * @returns a transform node or null
  15656. */
  15657. getTransformNode(): Nullable<TransformNode>;
  15658. /** Gets or sets current position (in local space) */
  15659. get position(): Vector3;
  15660. set position(newPosition: Vector3);
  15661. /** Gets or sets current rotation (in local space) */
  15662. get rotation(): Vector3;
  15663. set rotation(newRotation: Vector3);
  15664. /** Gets or sets current rotation quaternion (in local space) */
  15665. get rotationQuaternion(): Quaternion;
  15666. set rotationQuaternion(newRotation: Quaternion);
  15667. /** Gets or sets current scaling (in local space) */
  15668. get scaling(): Vector3;
  15669. set scaling(newScaling: Vector3);
  15670. /**
  15671. * Gets the animation properties override
  15672. */
  15673. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15674. private _decompose;
  15675. private _compose;
  15676. /**
  15677. * Update the base and local matrices
  15678. * @param matrix defines the new base or local matrix
  15679. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15680. * @param updateLocalMatrix defines if the local matrix should be updated
  15681. */
  15682. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15683. /** @hidden */
  15684. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15685. /**
  15686. * Flag the bone as dirty (Forcing it to update everything)
  15687. */
  15688. markAsDirty(): void;
  15689. /** @hidden */
  15690. _markAsDirtyAndCompose(): void;
  15691. private _markAsDirtyAndDecompose;
  15692. /**
  15693. * Translate the bone in local or world space
  15694. * @param vec The amount to translate the bone
  15695. * @param space The space that the translation is in
  15696. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15697. */
  15698. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15699. /**
  15700. * Set the postion of the bone in local or world space
  15701. * @param position The position to set the bone
  15702. * @param space The space that the position is in
  15703. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15704. */
  15705. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15706. /**
  15707. * Set the absolute position of the bone (world space)
  15708. * @param position The position to set the bone
  15709. * @param mesh The mesh that this bone is attached to
  15710. */
  15711. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15712. /**
  15713. * Scale the bone on the x, y and z axes (in local space)
  15714. * @param x The amount to scale the bone on the x axis
  15715. * @param y The amount to scale the bone on the y axis
  15716. * @param z The amount to scale the bone on the z axis
  15717. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15718. */
  15719. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15720. /**
  15721. * Set the bone scaling in local space
  15722. * @param scale defines the scaling vector
  15723. */
  15724. setScale(scale: Vector3): void;
  15725. /**
  15726. * Gets the current scaling in local space
  15727. * @returns the current scaling vector
  15728. */
  15729. getScale(): Vector3;
  15730. /**
  15731. * Gets the current scaling in local space and stores it in a target vector
  15732. * @param result defines the target vector
  15733. */
  15734. getScaleToRef(result: Vector3): void;
  15735. /**
  15736. * Set the yaw, pitch, and roll of the bone in local or world space
  15737. * @param yaw The rotation of the bone on the y axis
  15738. * @param pitch The rotation of the bone on the x axis
  15739. * @param roll The rotation of the bone on the z axis
  15740. * @param space The space that the axes of rotation are in
  15741. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15742. */
  15743. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15744. /**
  15745. * Add a rotation to the bone on an axis in local or world space
  15746. * @param axis The axis to rotate the bone on
  15747. * @param amount The amount to rotate the bone
  15748. * @param space The space that the axis is in
  15749. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15750. */
  15751. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15752. /**
  15753. * Set the rotation of the bone to a particular axis angle in local or world space
  15754. * @param axis The axis to rotate the bone on
  15755. * @param angle The angle that the bone should be rotated to
  15756. * @param space The space that the axis is in
  15757. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15758. */
  15759. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15760. /**
  15761. * Set the euler rotation of the bone in local of world space
  15762. * @param rotation The euler rotation that the bone should be set to
  15763. * @param space The space that the rotation is in
  15764. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15765. */
  15766. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15767. /**
  15768. * Set the quaternion rotation of the bone in local of world space
  15769. * @param quat The quaternion rotation that the bone should be set to
  15770. * @param space The space that the rotation is in
  15771. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15772. */
  15773. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15774. /**
  15775. * Set the rotation matrix of the bone in local of world space
  15776. * @param rotMat The rotation matrix that the bone should be set to
  15777. * @param space The space that the rotation is in
  15778. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15779. */
  15780. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15781. private _rotateWithMatrix;
  15782. private _getNegativeRotationToRef;
  15783. /**
  15784. * Get the position of the bone in local or world space
  15785. * @param space The space that the returned position is in
  15786. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15787. * @returns The position of the bone
  15788. */
  15789. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15790. /**
  15791. * Copy the position of the bone to a vector3 in local or world space
  15792. * @param space The space that the returned position is in
  15793. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15794. * @param result The vector3 to copy the position to
  15795. */
  15796. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15797. /**
  15798. * Get the absolute position of the bone (world space)
  15799. * @param mesh The mesh that this bone is attached to
  15800. * @returns The absolute position of the bone
  15801. */
  15802. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15803. /**
  15804. * Copy the absolute position of the bone (world space) to the result param
  15805. * @param mesh The mesh that this bone is attached to
  15806. * @param result The vector3 to copy the absolute position to
  15807. */
  15808. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15809. /**
  15810. * Compute the absolute transforms of this bone and its children
  15811. */
  15812. computeAbsoluteTransforms(): void;
  15813. /**
  15814. * Get the world direction from an axis that is in the local space of the bone
  15815. * @param localAxis The local direction that is used to compute the world direction
  15816. * @param mesh The mesh that this bone is attached to
  15817. * @returns The world direction
  15818. */
  15819. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15820. /**
  15821. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15822. * @param localAxis The local direction that is used to compute the world direction
  15823. * @param mesh The mesh that this bone is attached to
  15824. * @param result The vector3 that the world direction will be copied to
  15825. */
  15826. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15827. /**
  15828. * Get the euler rotation of the bone in local or world space
  15829. * @param space The space that the rotation should be in
  15830. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15831. * @returns The euler rotation
  15832. */
  15833. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15834. /**
  15835. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15836. * @param space The space that the rotation should be in
  15837. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15838. * @param result The vector3 that the rotation should be copied to
  15839. */
  15840. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15841. /**
  15842. * Get the quaternion rotation of the bone in either local or world space
  15843. * @param space The space that the rotation should be in
  15844. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15845. * @returns The quaternion rotation
  15846. */
  15847. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15848. /**
  15849. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15850. * @param space The space that the rotation should be in
  15851. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15852. * @param result The quaternion that the rotation should be copied to
  15853. */
  15854. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15855. /**
  15856. * Get the rotation matrix of the bone in local or world space
  15857. * @param space The space that the rotation should be in
  15858. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15859. * @returns The rotation matrix
  15860. */
  15861. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15862. /**
  15863. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15864. * @param space The space that the rotation should be in
  15865. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15866. * @param result The quaternion that the rotation should be copied to
  15867. */
  15868. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15869. /**
  15870. * Get the world position of a point that is in the local space of the bone
  15871. * @param position The local position
  15872. * @param mesh The mesh that this bone is attached to
  15873. * @returns The world position
  15874. */
  15875. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15876. /**
  15877. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15878. * @param position The local position
  15879. * @param mesh The mesh that this bone is attached to
  15880. * @param result The vector3 that the world position should be copied to
  15881. */
  15882. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15883. /**
  15884. * Get the local position of a point that is in world space
  15885. * @param position The world position
  15886. * @param mesh The mesh that this bone is attached to
  15887. * @returns The local position
  15888. */
  15889. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15890. /**
  15891. * Get the local position of a point that is in world space and copy it to the result param
  15892. * @param position The world position
  15893. * @param mesh The mesh that this bone is attached to
  15894. * @param result The vector3 that the local position should be copied to
  15895. */
  15896. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15897. }
  15898. }
  15899. declare module "babylonjs/Animations/runtimeAnimation" {
  15900. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15901. import { Animatable } from "babylonjs/Animations/animatable";
  15902. import { Scene } from "babylonjs/scene";
  15903. /**
  15904. * Defines a runtime animation
  15905. */
  15906. export class RuntimeAnimation {
  15907. private _events;
  15908. /**
  15909. * The current frame of the runtime animation
  15910. */
  15911. private _currentFrame;
  15912. /**
  15913. * The animation used by the runtime animation
  15914. */
  15915. private _animation;
  15916. /**
  15917. * The target of the runtime animation
  15918. */
  15919. private _target;
  15920. /**
  15921. * The initiating animatable
  15922. */
  15923. private _host;
  15924. /**
  15925. * The original value of the runtime animation
  15926. */
  15927. private _originalValue;
  15928. /**
  15929. * The original blend value of the runtime animation
  15930. */
  15931. private _originalBlendValue;
  15932. /**
  15933. * The offsets cache of the runtime animation
  15934. */
  15935. private _offsetsCache;
  15936. /**
  15937. * The high limits cache of the runtime animation
  15938. */
  15939. private _highLimitsCache;
  15940. /**
  15941. * Specifies if the runtime animation has been stopped
  15942. */
  15943. private _stopped;
  15944. /**
  15945. * The blending factor of the runtime animation
  15946. */
  15947. private _blendingFactor;
  15948. /**
  15949. * The BabylonJS scene
  15950. */
  15951. private _scene;
  15952. /**
  15953. * The current value of the runtime animation
  15954. */
  15955. private _currentValue;
  15956. /** @hidden */
  15957. _animationState: _IAnimationState;
  15958. /**
  15959. * The active target of the runtime animation
  15960. */
  15961. private _activeTargets;
  15962. private _currentActiveTarget;
  15963. private _directTarget;
  15964. /**
  15965. * The target path of the runtime animation
  15966. */
  15967. private _targetPath;
  15968. /**
  15969. * The weight of the runtime animation
  15970. */
  15971. private _weight;
  15972. /**
  15973. * The ratio offset of the runtime animation
  15974. */
  15975. private _ratioOffset;
  15976. /**
  15977. * The previous delay of the runtime animation
  15978. */
  15979. private _previousDelay;
  15980. /**
  15981. * The previous ratio of the runtime animation
  15982. */
  15983. private _previousRatio;
  15984. private _enableBlending;
  15985. private _keys;
  15986. private _minFrame;
  15987. private _maxFrame;
  15988. private _minValue;
  15989. private _maxValue;
  15990. private _targetIsArray;
  15991. /**
  15992. * Gets the current frame of the runtime animation
  15993. */
  15994. get currentFrame(): number;
  15995. /**
  15996. * Gets the weight of the runtime animation
  15997. */
  15998. get weight(): number;
  15999. /**
  16000. * Gets the current value of the runtime animation
  16001. */
  16002. get currentValue(): any;
  16003. /**
  16004. * Gets the target path of the runtime animation
  16005. */
  16006. get targetPath(): string;
  16007. /**
  16008. * Gets the actual target of the runtime animation
  16009. */
  16010. get target(): any;
  16011. /**
  16012. * Gets the additive state of the runtime animation
  16013. */
  16014. get isAdditive(): boolean;
  16015. /** @hidden */
  16016. _onLoop: () => void;
  16017. /**
  16018. * Create a new RuntimeAnimation object
  16019. * @param target defines the target of the animation
  16020. * @param animation defines the source animation object
  16021. * @param scene defines the hosting scene
  16022. * @param host defines the initiating Animatable
  16023. */
  16024. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  16025. private _preparePath;
  16026. /**
  16027. * Gets the animation from the runtime animation
  16028. */
  16029. get animation(): Animation;
  16030. /**
  16031. * Resets the runtime animation to the beginning
  16032. * @param restoreOriginal defines whether to restore the target property to the original value
  16033. */
  16034. reset(restoreOriginal?: boolean): void;
  16035. /**
  16036. * Specifies if the runtime animation is stopped
  16037. * @returns Boolean specifying if the runtime animation is stopped
  16038. */
  16039. isStopped(): boolean;
  16040. /**
  16041. * Disposes of the runtime animation
  16042. */
  16043. dispose(): void;
  16044. /**
  16045. * Apply the interpolated value to the target
  16046. * @param currentValue defines the value computed by the animation
  16047. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  16048. */
  16049. setValue(currentValue: any, weight: number): void;
  16050. private _getOriginalValues;
  16051. private _setValue;
  16052. /**
  16053. * Gets the loop pmode of the runtime animation
  16054. * @returns Loop Mode
  16055. */
  16056. private _getCorrectLoopMode;
  16057. /**
  16058. * Move the current animation to a given frame
  16059. * @param frame defines the frame to move to
  16060. */
  16061. goToFrame(frame: number): void;
  16062. /**
  16063. * @hidden Internal use only
  16064. */
  16065. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16066. /**
  16067. * Execute the current animation
  16068. * @param delay defines the delay to add to the current frame
  16069. * @param from defines the lower bound of the animation range
  16070. * @param to defines the upper bound of the animation range
  16071. * @param loop defines if the current animation must loop
  16072. * @param speedRatio defines the current speed ratio
  16073. * @param weight defines the weight of the animation (default is -1 so no weight)
  16074. * @param onLoop optional callback called when animation loops
  16075. * @returns a boolean indicating if the animation is running
  16076. */
  16077. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16078. }
  16079. }
  16080. declare module "babylonjs/Animations/animatable" {
  16081. import { Animation } from "babylonjs/Animations/animation";
  16082. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16083. import { Nullable } from "babylonjs/types";
  16084. import { Observable } from "babylonjs/Misc/observable";
  16085. import { Scene } from "babylonjs/scene";
  16086. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16087. import { Node } from "babylonjs/node";
  16088. /**
  16089. * Class used to store an actual running animation
  16090. */
  16091. export class Animatable {
  16092. /** defines the target object */
  16093. target: any;
  16094. /** defines the starting frame number (default is 0) */
  16095. fromFrame: number;
  16096. /** defines the ending frame number (default is 100) */
  16097. toFrame: number;
  16098. /** defines if the animation must loop (default is false) */
  16099. loopAnimation: boolean;
  16100. /** defines a callback to call when animation ends if it is not looping */
  16101. onAnimationEnd?: (() => void) | null | undefined;
  16102. /** defines a callback to call when animation loops */
  16103. onAnimationLoop?: (() => void) | null | undefined;
  16104. /** defines whether the animation should be evaluated additively */
  16105. isAdditive: boolean;
  16106. private _localDelayOffset;
  16107. private _pausedDelay;
  16108. private _runtimeAnimations;
  16109. private _paused;
  16110. private _scene;
  16111. private _speedRatio;
  16112. private _weight;
  16113. private _syncRoot;
  16114. /**
  16115. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16116. * This will only apply for non looping animation (default is true)
  16117. */
  16118. disposeOnEnd: boolean;
  16119. /**
  16120. * Gets a boolean indicating if the animation has started
  16121. */
  16122. animationStarted: boolean;
  16123. /**
  16124. * Observer raised when the animation ends
  16125. */
  16126. onAnimationEndObservable: Observable<Animatable>;
  16127. /**
  16128. * Observer raised when the animation loops
  16129. */
  16130. onAnimationLoopObservable: Observable<Animatable>;
  16131. /**
  16132. * Gets the root Animatable used to synchronize and normalize animations
  16133. */
  16134. get syncRoot(): Nullable<Animatable>;
  16135. /**
  16136. * Gets the current frame of the first RuntimeAnimation
  16137. * Used to synchronize Animatables
  16138. */
  16139. get masterFrame(): number;
  16140. /**
  16141. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16142. */
  16143. get weight(): number;
  16144. set weight(value: number);
  16145. /**
  16146. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16147. */
  16148. get speedRatio(): number;
  16149. set speedRatio(value: number);
  16150. /**
  16151. * Creates a new Animatable
  16152. * @param scene defines the hosting scene
  16153. * @param target defines the target object
  16154. * @param fromFrame defines the starting frame number (default is 0)
  16155. * @param toFrame defines the ending frame number (default is 100)
  16156. * @param loopAnimation defines if the animation must loop (default is false)
  16157. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16158. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16159. * @param animations defines a group of animation to add to the new Animatable
  16160. * @param onAnimationLoop defines a callback to call when animation loops
  16161. * @param isAdditive defines whether the animation should be evaluated additively
  16162. */
  16163. constructor(scene: Scene,
  16164. /** defines the target object */
  16165. target: any,
  16166. /** defines the starting frame number (default is 0) */
  16167. fromFrame?: number,
  16168. /** defines the ending frame number (default is 100) */
  16169. toFrame?: number,
  16170. /** defines if the animation must loop (default is false) */
  16171. loopAnimation?: boolean, speedRatio?: number,
  16172. /** defines a callback to call when animation ends if it is not looping */
  16173. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16174. /** defines a callback to call when animation loops */
  16175. onAnimationLoop?: (() => void) | null | undefined,
  16176. /** defines whether the animation should be evaluated additively */
  16177. isAdditive?: boolean);
  16178. /**
  16179. * Synchronize and normalize current Animatable with a source Animatable
  16180. * This is useful when using animation weights and when animations are not of the same length
  16181. * @param root defines the root Animatable to synchronize with
  16182. * @returns the current Animatable
  16183. */
  16184. syncWith(root: Animatable): Animatable;
  16185. /**
  16186. * Gets the list of runtime animations
  16187. * @returns an array of RuntimeAnimation
  16188. */
  16189. getAnimations(): RuntimeAnimation[];
  16190. /**
  16191. * Adds more animations to the current animatable
  16192. * @param target defines the target of the animations
  16193. * @param animations defines the new animations to add
  16194. */
  16195. appendAnimations(target: any, animations: Animation[]): void;
  16196. /**
  16197. * Gets the source animation for a specific property
  16198. * @param property defines the propertyu to look for
  16199. * @returns null or the source animation for the given property
  16200. */
  16201. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16202. /**
  16203. * Gets the runtime animation for a specific property
  16204. * @param property defines the propertyu to look for
  16205. * @returns null or the runtime animation for the given property
  16206. */
  16207. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16208. /**
  16209. * Resets the animatable to its original state
  16210. */
  16211. reset(): void;
  16212. /**
  16213. * Allows the animatable to blend with current running animations
  16214. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16215. * @param blendingSpeed defines the blending speed to use
  16216. */
  16217. enableBlending(blendingSpeed: number): void;
  16218. /**
  16219. * Disable animation blending
  16220. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16221. */
  16222. disableBlending(): void;
  16223. /**
  16224. * Jump directly to a given frame
  16225. * @param frame defines the frame to jump to
  16226. */
  16227. goToFrame(frame: number): void;
  16228. /**
  16229. * Pause the animation
  16230. */
  16231. pause(): void;
  16232. /**
  16233. * Restart the animation
  16234. */
  16235. restart(): void;
  16236. private _raiseOnAnimationEnd;
  16237. /**
  16238. * Stop and delete the current animation
  16239. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16240. * @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)
  16241. */
  16242. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16243. /**
  16244. * Wait asynchronously for the animation to end
  16245. * @returns a promise which will be fullfilled when the animation ends
  16246. */
  16247. waitAsync(): Promise<Animatable>;
  16248. /** @hidden */
  16249. _animate(delay: number): boolean;
  16250. }
  16251. module "babylonjs/scene" {
  16252. interface Scene {
  16253. /** @hidden */
  16254. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16255. /** @hidden */
  16256. _processLateAnimationBindingsForMatrices(holder: {
  16257. totalWeight: number;
  16258. totalAdditiveWeight: number;
  16259. animations: RuntimeAnimation[];
  16260. additiveAnimations: RuntimeAnimation[];
  16261. originalValue: Matrix;
  16262. }): any;
  16263. /** @hidden */
  16264. _processLateAnimationBindingsForQuaternions(holder: {
  16265. totalWeight: number;
  16266. totalAdditiveWeight: number;
  16267. animations: RuntimeAnimation[];
  16268. additiveAnimations: RuntimeAnimation[];
  16269. originalValue: Quaternion;
  16270. }, refQuaternion: Quaternion): Quaternion;
  16271. /** @hidden */
  16272. _processLateAnimationBindings(): void;
  16273. /**
  16274. * Will start the animation sequence of a given target
  16275. * @param target defines the target
  16276. * @param from defines from which frame should animation start
  16277. * @param to defines until which frame should animation run.
  16278. * @param weight defines the weight to apply to the animation (1.0 by default)
  16279. * @param loop defines if the animation loops
  16280. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16281. * @param onAnimationEnd defines the function to be executed when the animation ends
  16282. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16283. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16284. * @param onAnimationLoop defines the callback to call when an animation loops
  16285. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16286. * @returns the animatable object created for this animation
  16287. */
  16288. 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;
  16289. /**
  16290. * Will start the animation sequence of a given target
  16291. * @param target defines the target
  16292. * @param from defines from which frame should animation start
  16293. * @param to defines until which frame should animation run.
  16294. * @param loop defines if the animation loops
  16295. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16296. * @param onAnimationEnd defines the function to be executed when the animation ends
  16297. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16298. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16299. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16300. * @param onAnimationLoop defines the callback to call when an animation loops
  16301. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16302. * @returns the animatable object created for this animation
  16303. */
  16304. 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;
  16305. /**
  16306. * Will start the animation sequence of a given target and its hierarchy
  16307. * @param target defines the target
  16308. * @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.
  16309. * @param from defines from which frame should animation start
  16310. * @param to defines until which frame should animation run.
  16311. * @param loop defines if the animation loops
  16312. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16313. * @param onAnimationEnd defines the function to be executed when the animation ends
  16314. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16315. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16316. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16317. * @param onAnimationLoop defines the callback to call when an animation loops
  16318. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16319. * @returns the list of created animatables
  16320. */
  16321. 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[];
  16322. /**
  16323. * Begin a new animation on a given node
  16324. * @param target defines the target where the animation will take place
  16325. * @param animations defines the list of animations to start
  16326. * @param from defines the initial value
  16327. * @param to defines the final value
  16328. * @param loop defines if you want animation to loop (off by default)
  16329. * @param speedRatio defines the speed ratio to apply to all animations
  16330. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16331. * @param onAnimationLoop defines the callback to call when an animation loops
  16332. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16333. * @returns the list of created animatables
  16334. */
  16335. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16336. /**
  16337. * Begin a new animation on a given node and its hierarchy
  16338. * @param target defines the root node where the animation will take place
  16339. * @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.
  16340. * @param animations defines the list of animations to start
  16341. * @param from defines the initial value
  16342. * @param to defines the final value
  16343. * @param loop defines if you want animation to loop (off by default)
  16344. * @param speedRatio defines the speed ratio to apply to all animations
  16345. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16346. * @param onAnimationLoop defines the callback to call when an animation loops
  16347. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16348. * @returns the list of animatables created for all nodes
  16349. */
  16350. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16351. /**
  16352. * Gets the animatable associated with a specific target
  16353. * @param target defines the target of the animatable
  16354. * @returns the required animatable if found
  16355. */
  16356. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16357. /**
  16358. * Gets all animatables associated with a given target
  16359. * @param target defines the target to look animatables for
  16360. * @returns an array of Animatables
  16361. */
  16362. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16363. /**
  16364. * Stops and removes all animations that have been applied to the scene
  16365. */
  16366. stopAllAnimations(): void;
  16367. /**
  16368. * Gets the current delta time used by animation engine
  16369. */
  16370. deltaTime: number;
  16371. }
  16372. }
  16373. module "babylonjs/Bones/bone" {
  16374. interface Bone {
  16375. /**
  16376. * Copy an animation range from another bone
  16377. * @param source defines the source bone
  16378. * @param rangeName defines the range name to copy
  16379. * @param frameOffset defines the frame offset
  16380. * @param rescaleAsRequired defines if rescaling must be applied if required
  16381. * @param skelDimensionsRatio defines the scaling ratio
  16382. * @returns true if operation was successful
  16383. */
  16384. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16385. }
  16386. }
  16387. }
  16388. declare module "babylonjs/Bones/skeleton" {
  16389. import { Bone } from "babylonjs/Bones/bone";
  16390. import { Observable } from "babylonjs/Misc/observable";
  16391. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16392. import { Scene } from "babylonjs/scene";
  16393. import { Nullable } from "babylonjs/types";
  16394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16395. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16396. import { Animatable } from "babylonjs/Animations/animatable";
  16397. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16398. import { Animation } from "babylonjs/Animations/animation";
  16399. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16400. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16401. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16402. /**
  16403. * Class used to handle skinning animations
  16404. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16405. */
  16406. export class Skeleton implements IAnimatable {
  16407. /** defines the skeleton name */
  16408. name: string;
  16409. /** defines the skeleton Id */
  16410. id: string;
  16411. /**
  16412. * Defines the list of child bones
  16413. */
  16414. bones: Bone[];
  16415. /**
  16416. * Defines an estimate of the dimension of the skeleton at rest
  16417. */
  16418. dimensionsAtRest: Vector3;
  16419. /**
  16420. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16421. */
  16422. needInitialSkinMatrix: boolean;
  16423. /**
  16424. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16425. */
  16426. overrideMesh: Nullable<AbstractMesh>;
  16427. /**
  16428. * Gets the list of animations attached to this skeleton
  16429. */
  16430. animations: Array<Animation>;
  16431. private _scene;
  16432. private _isDirty;
  16433. private _transformMatrices;
  16434. private _transformMatrixTexture;
  16435. private _meshesWithPoseMatrix;
  16436. private _animatables;
  16437. private _identity;
  16438. private _synchronizedWithMesh;
  16439. private _ranges;
  16440. private _lastAbsoluteTransformsUpdateId;
  16441. private _canUseTextureForBones;
  16442. private _uniqueId;
  16443. /** @hidden */
  16444. _numBonesWithLinkedTransformNode: number;
  16445. /** @hidden */
  16446. _hasWaitingData: Nullable<boolean>;
  16447. /** @hidden */
  16448. _waitingOverrideMeshId: Nullable<string>;
  16449. /**
  16450. * Specifies if the skeleton should be serialized
  16451. */
  16452. doNotSerialize: boolean;
  16453. private _useTextureToStoreBoneMatrices;
  16454. /**
  16455. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16456. * Please note that this option is not available if the hardware does not support it
  16457. */
  16458. get useTextureToStoreBoneMatrices(): boolean;
  16459. set useTextureToStoreBoneMatrices(value: boolean);
  16460. private _animationPropertiesOverride;
  16461. /**
  16462. * Gets or sets the animation properties override
  16463. */
  16464. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16465. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16466. /**
  16467. * List of inspectable custom properties (used by the Inspector)
  16468. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16469. */
  16470. inspectableCustomProperties: IInspectable[];
  16471. /**
  16472. * An observable triggered before computing the skeleton's matrices
  16473. */
  16474. onBeforeComputeObservable: Observable<Skeleton>;
  16475. /**
  16476. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16477. */
  16478. get isUsingTextureForMatrices(): boolean;
  16479. /**
  16480. * Gets the unique ID of this skeleton
  16481. */
  16482. get uniqueId(): number;
  16483. /**
  16484. * Creates a new skeleton
  16485. * @param name defines the skeleton name
  16486. * @param id defines the skeleton Id
  16487. * @param scene defines the hosting scene
  16488. */
  16489. constructor(
  16490. /** defines the skeleton name */
  16491. name: string,
  16492. /** defines the skeleton Id */
  16493. id: string, scene: Scene);
  16494. /**
  16495. * Gets the current object class name.
  16496. * @return the class name
  16497. */
  16498. getClassName(): string;
  16499. /**
  16500. * Returns an array containing the root bones
  16501. * @returns an array containing the root bones
  16502. */
  16503. getChildren(): Array<Bone>;
  16504. /**
  16505. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16506. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16507. * @returns a Float32Array containing matrices data
  16508. */
  16509. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16510. /**
  16511. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16512. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16513. * @returns a raw texture containing the data
  16514. */
  16515. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16516. /**
  16517. * Gets the current hosting scene
  16518. * @returns a scene object
  16519. */
  16520. getScene(): Scene;
  16521. /**
  16522. * Gets a string representing the current skeleton data
  16523. * @param fullDetails defines a boolean indicating if we want a verbose version
  16524. * @returns a string representing the current skeleton data
  16525. */
  16526. toString(fullDetails?: boolean): string;
  16527. /**
  16528. * Get bone's index searching by name
  16529. * @param name defines bone's name to search for
  16530. * @return the indice of the bone. Returns -1 if not found
  16531. */
  16532. getBoneIndexByName(name: string): number;
  16533. /**
  16534. * Creater a new animation range
  16535. * @param name defines the name of the range
  16536. * @param from defines the start key
  16537. * @param to defines the end key
  16538. */
  16539. createAnimationRange(name: string, from: number, to: number): void;
  16540. /**
  16541. * Delete a specific animation range
  16542. * @param name defines the name of the range
  16543. * @param deleteFrames defines if frames must be removed as well
  16544. */
  16545. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16546. /**
  16547. * Gets a specific animation range
  16548. * @param name defines the name of the range to look for
  16549. * @returns the requested animation range or null if not found
  16550. */
  16551. getAnimationRange(name: string): Nullable<AnimationRange>;
  16552. /**
  16553. * Gets the list of all animation ranges defined on this skeleton
  16554. * @returns an array
  16555. */
  16556. getAnimationRanges(): Nullable<AnimationRange>[];
  16557. /**
  16558. * Copy animation range from a source skeleton.
  16559. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16560. * @param source defines the source skeleton
  16561. * @param name defines the name of the range to copy
  16562. * @param rescaleAsRequired defines if rescaling must be applied if required
  16563. * @returns true if operation was successful
  16564. */
  16565. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16566. /**
  16567. * Forces the skeleton to go to rest pose
  16568. */
  16569. returnToRest(): void;
  16570. private _getHighestAnimationFrame;
  16571. /**
  16572. * Begin a specific animation range
  16573. * @param name defines the name of the range to start
  16574. * @param loop defines if looping must be turned on (false by default)
  16575. * @param speedRatio defines the speed ratio to apply (1 by default)
  16576. * @param onAnimationEnd defines a callback which will be called when animation will end
  16577. * @returns a new animatable
  16578. */
  16579. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16580. /**
  16581. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16582. * @param skeleton defines the Skeleton containing the animation range to convert
  16583. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16584. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16585. * @returns the original skeleton
  16586. */
  16587. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16588. /** @hidden */
  16589. _markAsDirty(): void;
  16590. /** @hidden */
  16591. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16592. /** @hidden */
  16593. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16594. private _computeTransformMatrices;
  16595. /**
  16596. * Build all resources required to render a skeleton
  16597. */
  16598. prepare(): void;
  16599. /**
  16600. * Gets the list of animatables currently running for this skeleton
  16601. * @returns an array of animatables
  16602. */
  16603. getAnimatables(): IAnimatable[];
  16604. /**
  16605. * Clone the current skeleton
  16606. * @param name defines the name of the new skeleton
  16607. * @param id defines the id of the new skeleton
  16608. * @returns the new skeleton
  16609. */
  16610. clone(name: string, id?: string): Skeleton;
  16611. /**
  16612. * Enable animation blending for this skeleton
  16613. * @param blendingSpeed defines the blending speed to apply
  16614. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16615. */
  16616. enableBlending(blendingSpeed?: number): void;
  16617. /**
  16618. * Releases all resources associated with the current skeleton
  16619. */
  16620. dispose(): void;
  16621. /**
  16622. * Serialize the skeleton in a JSON object
  16623. * @returns a JSON object
  16624. */
  16625. serialize(): any;
  16626. /**
  16627. * Creates a new skeleton from serialized data
  16628. * @param parsedSkeleton defines the serialized data
  16629. * @param scene defines the hosting scene
  16630. * @returns a new skeleton
  16631. */
  16632. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16633. /**
  16634. * Compute all node absolute transforms
  16635. * @param forceUpdate defines if computation must be done even if cache is up to date
  16636. */
  16637. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16638. /**
  16639. * Gets the root pose matrix
  16640. * @returns a matrix
  16641. */
  16642. getPoseMatrix(): Nullable<Matrix>;
  16643. /**
  16644. * Sorts bones per internal index
  16645. */
  16646. sortBones(): void;
  16647. private _sortBones;
  16648. }
  16649. }
  16650. declare module "babylonjs/Meshes/instancedMesh" {
  16651. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16652. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16653. import { Camera } from "babylonjs/Cameras/camera";
  16654. import { Node } from "babylonjs/node";
  16655. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16656. import { Mesh } from "babylonjs/Meshes/mesh";
  16657. import { Material } from "babylonjs/Materials/material";
  16658. import { Skeleton } from "babylonjs/Bones/skeleton";
  16659. import { Light } from "babylonjs/Lights/light";
  16660. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16661. /**
  16662. * Creates an instance based on a source mesh.
  16663. */
  16664. export class InstancedMesh extends AbstractMesh {
  16665. private _sourceMesh;
  16666. private _currentLOD;
  16667. /** @hidden */
  16668. _indexInSourceMeshInstanceArray: number;
  16669. constructor(name: string, source: Mesh);
  16670. /**
  16671. * Returns the string "InstancedMesh".
  16672. */
  16673. getClassName(): string;
  16674. /** Gets the list of lights affecting that mesh */
  16675. get lightSources(): Light[];
  16676. _resyncLightSources(): void;
  16677. _resyncLightSource(light: Light): void;
  16678. _removeLightSource(light: Light, dispose: boolean): void;
  16679. /**
  16680. * If the source mesh receives shadows
  16681. */
  16682. get receiveShadows(): boolean;
  16683. /**
  16684. * The material of the source mesh
  16685. */
  16686. get material(): Nullable<Material>;
  16687. /**
  16688. * Visibility of the source mesh
  16689. */
  16690. get visibility(): number;
  16691. /**
  16692. * Skeleton of the source mesh
  16693. */
  16694. get skeleton(): Nullable<Skeleton>;
  16695. /**
  16696. * Rendering ground id of the source mesh
  16697. */
  16698. get renderingGroupId(): number;
  16699. set renderingGroupId(value: number);
  16700. /**
  16701. * Returns the total number of vertices (integer).
  16702. */
  16703. getTotalVertices(): number;
  16704. /**
  16705. * Returns a positive integer : the total number of indices in this mesh geometry.
  16706. * @returns the numner of indices or zero if the mesh has no geometry.
  16707. */
  16708. getTotalIndices(): number;
  16709. /**
  16710. * The source mesh of the instance
  16711. */
  16712. get sourceMesh(): Mesh;
  16713. /**
  16714. * Creates a new InstancedMesh object from the mesh model.
  16715. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16716. * @param name defines the name of the new instance
  16717. * @returns a new InstancedMesh
  16718. */
  16719. createInstance(name: string): InstancedMesh;
  16720. /**
  16721. * Is this node ready to be used/rendered
  16722. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16723. * @return {boolean} is it ready
  16724. */
  16725. isReady(completeCheck?: boolean): boolean;
  16726. /**
  16727. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16728. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16729. * @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.
  16730. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16731. */
  16732. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16733. /**
  16734. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16735. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16736. * The `data` are either a numeric array either a Float32Array.
  16737. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16738. * 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).
  16739. * Note that a new underlying VertexBuffer object is created each call.
  16740. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16741. *
  16742. * Possible `kind` values :
  16743. * - VertexBuffer.PositionKind
  16744. * - VertexBuffer.UVKind
  16745. * - VertexBuffer.UV2Kind
  16746. * - VertexBuffer.UV3Kind
  16747. * - VertexBuffer.UV4Kind
  16748. * - VertexBuffer.UV5Kind
  16749. * - VertexBuffer.UV6Kind
  16750. * - VertexBuffer.ColorKind
  16751. * - VertexBuffer.MatricesIndicesKind
  16752. * - VertexBuffer.MatricesIndicesExtraKind
  16753. * - VertexBuffer.MatricesWeightsKind
  16754. * - VertexBuffer.MatricesWeightsExtraKind
  16755. *
  16756. * Returns the Mesh.
  16757. */
  16758. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16759. /**
  16760. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16761. * If the mesh has no geometry, it is simply returned as it is.
  16762. * The `data` are either a numeric array either a Float32Array.
  16763. * No new underlying VertexBuffer object is created.
  16764. * 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.
  16765. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16766. *
  16767. * Possible `kind` values :
  16768. * - VertexBuffer.PositionKind
  16769. * - VertexBuffer.UVKind
  16770. * - VertexBuffer.UV2Kind
  16771. * - VertexBuffer.UV3Kind
  16772. * - VertexBuffer.UV4Kind
  16773. * - VertexBuffer.UV5Kind
  16774. * - VertexBuffer.UV6Kind
  16775. * - VertexBuffer.ColorKind
  16776. * - VertexBuffer.MatricesIndicesKind
  16777. * - VertexBuffer.MatricesIndicesExtraKind
  16778. * - VertexBuffer.MatricesWeightsKind
  16779. * - VertexBuffer.MatricesWeightsExtraKind
  16780. *
  16781. * Returns the Mesh.
  16782. */
  16783. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16784. /**
  16785. * Sets the mesh indices.
  16786. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16787. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16788. * This method creates a new index buffer each call.
  16789. * Returns the Mesh.
  16790. */
  16791. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16792. /**
  16793. * Boolean : True if the mesh owns the requested kind of data.
  16794. */
  16795. isVerticesDataPresent(kind: string): boolean;
  16796. /**
  16797. * Returns an array of indices (IndicesArray).
  16798. */
  16799. getIndices(): Nullable<IndicesArray>;
  16800. get _positions(): Nullable<Vector3[]>;
  16801. /**
  16802. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16803. * This means the mesh underlying bounding box and sphere are recomputed.
  16804. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16805. * @returns the current mesh
  16806. */
  16807. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16808. /** @hidden */
  16809. _preActivate(): InstancedMesh;
  16810. /** @hidden */
  16811. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16812. /** @hidden */
  16813. _postActivate(): void;
  16814. getWorldMatrix(): Matrix;
  16815. get isAnInstance(): boolean;
  16816. /**
  16817. * Returns the current associated LOD AbstractMesh.
  16818. */
  16819. getLOD(camera: Camera): AbstractMesh;
  16820. /** @hidden */
  16821. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16822. /** @hidden */
  16823. _syncSubMeshes(): InstancedMesh;
  16824. /** @hidden */
  16825. _generatePointsArray(): boolean;
  16826. /** @hidden */
  16827. _updateBoundingInfo(): AbstractMesh;
  16828. /**
  16829. * Creates a new InstancedMesh from the current mesh.
  16830. * - name (string) : the cloned mesh name
  16831. * - newParent (optional Node) : the optional Node to parent the clone to.
  16832. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16833. *
  16834. * Returns the clone.
  16835. */
  16836. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16837. /**
  16838. * Disposes the InstancedMesh.
  16839. * Returns nothing.
  16840. */
  16841. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16842. }
  16843. module "babylonjs/Meshes/mesh" {
  16844. interface Mesh {
  16845. /**
  16846. * Register a custom buffer that will be instanced
  16847. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16848. * @param kind defines the buffer kind
  16849. * @param stride defines the stride in floats
  16850. */
  16851. registerInstancedBuffer(kind: string, stride: number): void;
  16852. /**
  16853. * true to use the edge renderer for all instances of this mesh
  16854. */
  16855. edgesShareWithInstances: boolean;
  16856. /** @hidden */
  16857. _userInstancedBuffersStorage: {
  16858. data: {
  16859. [key: string]: Float32Array;
  16860. };
  16861. sizes: {
  16862. [key: string]: number;
  16863. };
  16864. vertexBuffers: {
  16865. [key: string]: Nullable<VertexBuffer>;
  16866. };
  16867. strides: {
  16868. [key: string]: number;
  16869. };
  16870. };
  16871. }
  16872. }
  16873. module "babylonjs/Meshes/abstractMesh" {
  16874. interface AbstractMesh {
  16875. /**
  16876. * Object used to store instanced buffers defined by user
  16877. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16878. */
  16879. instancedBuffers: {
  16880. [key: string]: any;
  16881. };
  16882. }
  16883. }
  16884. }
  16885. declare module "babylonjs/Materials/shaderMaterial" {
  16886. import { Nullable } from "babylonjs/types";
  16887. import { Scene } from "babylonjs/scene";
  16888. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16890. import { Mesh } from "babylonjs/Meshes/mesh";
  16891. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16892. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16893. import { Effect } from "babylonjs/Materials/effect";
  16894. import { Material } from "babylonjs/Materials/material";
  16895. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16896. /**
  16897. * Defines the options associated with the creation of a shader material.
  16898. */
  16899. export interface IShaderMaterialOptions {
  16900. /**
  16901. * Does the material work in alpha blend mode
  16902. */
  16903. needAlphaBlending: boolean;
  16904. /**
  16905. * Does the material work in alpha test mode
  16906. */
  16907. needAlphaTesting: boolean;
  16908. /**
  16909. * The list of attribute names used in the shader
  16910. */
  16911. attributes: string[];
  16912. /**
  16913. * The list of unifrom names used in the shader
  16914. */
  16915. uniforms: string[];
  16916. /**
  16917. * The list of UBO names used in the shader
  16918. */
  16919. uniformBuffers: string[];
  16920. /**
  16921. * The list of sampler names used in the shader
  16922. */
  16923. samplers: string[];
  16924. /**
  16925. * The list of defines used in the shader
  16926. */
  16927. defines: string[];
  16928. }
  16929. /**
  16930. * 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.
  16931. *
  16932. * This returned material effects how the mesh will look based on the code in the shaders.
  16933. *
  16934. * @see https://doc.babylonjs.com/how_to/shader_material
  16935. */
  16936. export class ShaderMaterial extends Material {
  16937. private _shaderPath;
  16938. private _options;
  16939. private _textures;
  16940. private _textureArrays;
  16941. private _floats;
  16942. private _ints;
  16943. private _floatsArrays;
  16944. private _colors3;
  16945. private _colors3Arrays;
  16946. private _colors4;
  16947. private _colors4Arrays;
  16948. private _vectors2;
  16949. private _vectors3;
  16950. private _vectors4;
  16951. private _matrices;
  16952. private _matrixArrays;
  16953. private _matrices3x3;
  16954. private _matrices2x2;
  16955. private _vectors2Arrays;
  16956. private _vectors3Arrays;
  16957. private _vectors4Arrays;
  16958. private _cachedWorldViewMatrix;
  16959. private _cachedWorldViewProjectionMatrix;
  16960. private _renderId;
  16961. private _multiview;
  16962. private _cachedDefines;
  16963. /** Define the Url to load snippets */
  16964. static SnippetUrl: string;
  16965. /** Snippet ID if the material was created from the snippet server */
  16966. snippetId: string;
  16967. /**
  16968. * Instantiate a new shader material.
  16969. * 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.
  16970. * This returned material effects how the mesh will look based on the code in the shaders.
  16971. * @see https://doc.babylonjs.com/how_to/shader_material
  16972. * @param name Define the name of the material in the scene
  16973. * @param scene Define the scene the material belongs to
  16974. * @param shaderPath Defines the route to the shader code in one of three ways:
  16975. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16976. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16977. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16978. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16979. * @param options Define the options used to create the shader
  16980. */
  16981. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16982. /**
  16983. * Gets the shader path used to define the shader code
  16984. * It can be modified to trigger a new compilation
  16985. */
  16986. get shaderPath(): any;
  16987. /**
  16988. * Sets the shader path used to define the shader code
  16989. * It can be modified to trigger a new compilation
  16990. */
  16991. set shaderPath(shaderPath: any);
  16992. /**
  16993. * Gets the options used to compile the shader.
  16994. * They can be modified to trigger a new compilation
  16995. */
  16996. get options(): IShaderMaterialOptions;
  16997. /**
  16998. * Gets the current class name of the material e.g. "ShaderMaterial"
  16999. * Mainly use in serialization.
  17000. * @returns the class name
  17001. */
  17002. getClassName(): string;
  17003. /**
  17004. * Specifies if the material will require alpha blending
  17005. * @returns a boolean specifying if alpha blending is needed
  17006. */
  17007. needAlphaBlending(): boolean;
  17008. /**
  17009. * Specifies if this material should be rendered in alpha test mode
  17010. * @returns a boolean specifying if an alpha test is needed.
  17011. */
  17012. needAlphaTesting(): boolean;
  17013. private _checkUniform;
  17014. /**
  17015. * Set a texture in the shader.
  17016. * @param name Define the name of the uniform samplers as defined in the shader
  17017. * @param texture Define the texture to bind to this sampler
  17018. * @return the material itself allowing "fluent" like uniform updates
  17019. */
  17020. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  17021. /**
  17022. * Set a texture array in the shader.
  17023. * @param name Define the name of the uniform sampler array as defined in the shader
  17024. * @param textures Define the list of textures to bind to this sampler
  17025. * @return the material itself allowing "fluent" like uniform updates
  17026. */
  17027. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  17028. /**
  17029. * Set a float in the shader.
  17030. * @param name Define the name of the uniform as defined in the shader
  17031. * @param value Define the value to give to the uniform
  17032. * @return the material itself allowing "fluent" like uniform updates
  17033. */
  17034. setFloat(name: string, value: number): ShaderMaterial;
  17035. /**
  17036. * Set a int in the shader.
  17037. * @param name Define the name of the uniform as defined in the shader
  17038. * @param value Define the value to give to the uniform
  17039. * @return the material itself allowing "fluent" like uniform updates
  17040. */
  17041. setInt(name: string, value: number): ShaderMaterial;
  17042. /**
  17043. * Set an array of floats in the shader.
  17044. * @param name Define the name of the uniform as defined in the shader
  17045. * @param value Define the value to give to the uniform
  17046. * @return the material itself allowing "fluent" like uniform updates
  17047. */
  17048. setFloats(name: string, value: number[]): ShaderMaterial;
  17049. /**
  17050. * Set a vec3 in the shader from a Color3.
  17051. * @param name Define the name of the uniform as defined in the shader
  17052. * @param value Define the value to give to the uniform
  17053. * @return the material itself allowing "fluent" like uniform updates
  17054. */
  17055. setColor3(name: string, value: Color3): ShaderMaterial;
  17056. /**
  17057. * Set a vec3 array in the shader from a Color3 array.
  17058. * @param name Define the name of the uniform as defined in the shader
  17059. * @param value Define the value to give to the uniform
  17060. * @return the material itself allowing "fluent" like uniform updates
  17061. */
  17062. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17063. /**
  17064. * Set a vec4 in the shader from a Color4.
  17065. * @param name Define the name of the uniform as defined in the shader
  17066. * @param value Define the value to give to the uniform
  17067. * @return the material itself allowing "fluent" like uniform updates
  17068. */
  17069. setColor4(name: string, value: Color4): ShaderMaterial;
  17070. /**
  17071. * Set a vec4 array in the shader from a Color4 array.
  17072. * @param name Define the name of the uniform as defined in the shader
  17073. * @param value Define the value to give to the uniform
  17074. * @return the material itself allowing "fluent" like uniform updates
  17075. */
  17076. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17077. /**
  17078. * Set a vec2 in the shader from a Vector2.
  17079. * @param name Define the name of the uniform as defined in the shader
  17080. * @param value Define the value to give to the uniform
  17081. * @return the material itself allowing "fluent" like uniform updates
  17082. */
  17083. setVector2(name: string, value: Vector2): ShaderMaterial;
  17084. /**
  17085. * Set a vec3 in the shader from a Vector3.
  17086. * @param name Define the name of the uniform as defined in the shader
  17087. * @param value Define the value to give to the uniform
  17088. * @return the material itself allowing "fluent" like uniform updates
  17089. */
  17090. setVector3(name: string, value: Vector3): ShaderMaterial;
  17091. /**
  17092. * Set a vec4 in the shader from a Vector4.
  17093. * @param name Define the name of the uniform as defined in the shader
  17094. * @param value Define the value to give to the uniform
  17095. * @return the material itself allowing "fluent" like uniform updates
  17096. */
  17097. setVector4(name: string, value: Vector4): ShaderMaterial;
  17098. /**
  17099. * Set a mat4 in the shader from a Matrix.
  17100. * @param name Define the name of the uniform as defined in the shader
  17101. * @param value Define the value to give to the uniform
  17102. * @return the material itself allowing "fluent" like uniform updates
  17103. */
  17104. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17105. /**
  17106. * Set a float32Array in the shader from a matrix array.
  17107. * @param name Define the name of the uniform as defined in the shader
  17108. * @param value Define the value to give to the uniform
  17109. * @return the material itself allowing "fluent" like uniform updates
  17110. */
  17111. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17112. /**
  17113. * Set a mat3 in the shader from a Float32Array.
  17114. * @param name Define the name of the uniform as defined in the shader
  17115. * @param value Define the value to give to the uniform
  17116. * @return the material itself allowing "fluent" like uniform updates
  17117. */
  17118. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17119. /**
  17120. * Set a mat2 in the shader from a Float32Array.
  17121. * @param name Define the name of the uniform as defined in the shader
  17122. * @param value Define the value to give to the uniform
  17123. * @return the material itself allowing "fluent" like uniform updates
  17124. */
  17125. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17126. /**
  17127. * Set a vec2 array in the shader from a number array.
  17128. * @param name Define the name of the uniform as defined in the shader
  17129. * @param value Define the value to give to the uniform
  17130. * @return the material itself allowing "fluent" like uniform updates
  17131. */
  17132. setArray2(name: string, value: number[]): ShaderMaterial;
  17133. /**
  17134. * Set a vec3 array in the shader from a number array.
  17135. * @param name Define the name of the uniform as defined in the shader
  17136. * @param value Define the value to give to the uniform
  17137. * @return the material itself allowing "fluent" like uniform updates
  17138. */
  17139. setArray3(name: string, value: number[]): ShaderMaterial;
  17140. /**
  17141. * Set a vec4 array in the shader from a number array.
  17142. * @param name Define the name of the uniform as defined in the shader
  17143. * @param value Define the value to give to the uniform
  17144. * @return the material itself allowing "fluent" like uniform updates
  17145. */
  17146. setArray4(name: string, value: number[]): ShaderMaterial;
  17147. private _checkCache;
  17148. /**
  17149. * Specifies that the submesh is ready to be used
  17150. * @param mesh defines the mesh to check
  17151. * @param subMesh defines which submesh to check
  17152. * @param useInstances specifies that instances should be used
  17153. * @returns a boolean indicating that the submesh is ready or not
  17154. */
  17155. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17156. /**
  17157. * Checks if the material is ready to render the requested mesh
  17158. * @param mesh Define the mesh to render
  17159. * @param useInstances Define whether or not the material is used with instances
  17160. * @returns true if ready, otherwise false
  17161. */
  17162. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17163. /**
  17164. * Binds the world matrix to the material
  17165. * @param world defines the world transformation matrix
  17166. * @param effectOverride - If provided, use this effect instead of internal effect
  17167. */
  17168. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17169. /**
  17170. * Binds the submesh to this material by preparing the effect and shader to draw
  17171. * @param world defines the world transformation matrix
  17172. * @param mesh defines the mesh containing the submesh
  17173. * @param subMesh defines the submesh to bind the material to
  17174. */
  17175. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17176. /**
  17177. * Binds the material to the mesh
  17178. * @param world defines the world transformation matrix
  17179. * @param mesh defines the mesh to bind the material to
  17180. * @param effectOverride - If provided, use this effect instead of internal effect
  17181. */
  17182. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17183. protected _afterBind(mesh?: Mesh): void;
  17184. /**
  17185. * Gets the active textures from the material
  17186. * @returns an array of textures
  17187. */
  17188. getActiveTextures(): BaseTexture[];
  17189. /**
  17190. * Specifies if the material uses a texture
  17191. * @param texture defines the texture to check against the material
  17192. * @returns a boolean specifying if the material uses the texture
  17193. */
  17194. hasTexture(texture: BaseTexture): boolean;
  17195. /**
  17196. * Makes a duplicate of the material, and gives it a new name
  17197. * @param name defines the new name for the duplicated material
  17198. * @returns the cloned material
  17199. */
  17200. clone(name: string): ShaderMaterial;
  17201. /**
  17202. * Disposes the material
  17203. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17204. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17205. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17206. */
  17207. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17208. /**
  17209. * Serializes this material in a JSON representation
  17210. * @returns the serialized material object
  17211. */
  17212. serialize(): any;
  17213. /**
  17214. * Creates a shader material from parsed shader material data
  17215. * @param source defines the JSON represnetation of the material
  17216. * @param scene defines the hosting scene
  17217. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17218. * @returns a new material
  17219. */
  17220. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17221. /**
  17222. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17223. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17224. * @param url defines the url to load from
  17225. * @param scene defines the hosting scene
  17226. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17227. * @returns a promise that will resolve to the new ShaderMaterial
  17228. */
  17229. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17230. /**
  17231. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17232. * @param snippetId defines the snippet to load
  17233. * @param scene defines the hosting scene
  17234. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17235. * @returns a promise that will resolve to the new ShaderMaterial
  17236. */
  17237. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17238. }
  17239. }
  17240. declare module "babylonjs/Shaders/color.fragment" {
  17241. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17242. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17243. /** @hidden */
  17244. export var colorPixelShader: {
  17245. name: string;
  17246. shader: string;
  17247. };
  17248. }
  17249. declare module "babylonjs/Shaders/color.vertex" {
  17250. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17251. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17252. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17253. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17254. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17255. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17256. /** @hidden */
  17257. export var colorVertexShader: {
  17258. name: string;
  17259. shader: string;
  17260. };
  17261. }
  17262. declare module "babylonjs/Meshes/linesMesh" {
  17263. import { Nullable } from "babylonjs/types";
  17264. import { Scene } from "babylonjs/scene";
  17265. import { Color3 } from "babylonjs/Maths/math.color";
  17266. import { Node } from "babylonjs/node";
  17267. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17268. import { Mesh } from "babylonjs/Meshes/mesh";
  17269. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17270. import { Effect } from "babylonjs/Materials/effect";
  17271. import { Material } from "babylonjs/Materials/material";
  17272. import "babylonjs/Shaders/color.fragment";
  17273. import "babylonjs/Shaders/color.vertex";
  17274. /**
  17275. * Line mesh
  17276. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17277. */
  17278. export class LinesMesh extends Mesh {
  17279. /**
  17280. * If vertex color should be applied to the mesh
  17281. */
  17282. readonly useVertexColor?: boolean | undefined;
  17283. /**
  17284. * If vertex alpha should be applied to the mesh
  17285. */
  17286. readonly useVertexAlpha?: boolean | undefined;
  17287. /**
  17288. * Color of the line (Default: White)
  17289. */
  17290. color: Color3;
  17291. /**
  17292. * Alpha of the line (Default: 1)
  17293. */
  17294. alpha: number;
  17295. /**
  17296. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17297. * This margin is expressed in world space coordinates, so its value may vary.
  17298. * Default value is 0.1
  17299. */
  17300. intersectionThreshold: number;
  17301. private _colorShader;
  17302. private color4;
  17303. /**
  17304. * Creates a new LinesMesh
  17305. * @param name defines the name
  17306. * @param scene defines the hosting scene
  17307. * @param parent defines the parent mesh if any
  17308. * @param source defines the optional source LinesMesh used to clone data from
  17309. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17310. * When false, achieved by calling a clone(), also passing False.
  17311. * This will make creation of children, recursive.
  17312. * @param useVertexColor defines if this LinesMesh supports vertex color
  17313. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17314. */
  17315. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17316. /**
  17317. * If vertex color should be applied to the mesh
  17318. */
  17319. useVertexColor?: boolean | undefined,
  17320. /**
  17321. * If vertex alpha should be applied to the mesh
  17322. */
  17323. useVertexAlpha?: boolean | undefined);
  17324. private _addClipPlaneDefine;
  17325. private _removeClipPlaneDefine;
  17326. isReady(): boolean;
  17327. /**
  17328. * Returns the string "LineMesh"
  17329. */
  17330. getClassName(): string;
  17331. /**
  17332. * @hidden
  17333. */
  17334. get material(): Material;
  17335. /**
  17336. * @hidden
  17337. */
  17338. set material(value: Material);
  17339. /**
  17340. * @hidden
  17341. */
  17342. get checkCollisions(): boolean;
  17343. /** @hidden */
  17344. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17345. /** @hidden */
  17346. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17347. /**
  17348. * Disposes of the line mesh
  17349. * @param doNotRecurse If children should be disposed
  17350. */
  17351. dispose(doNotRecurse?: boolean): void;
  17352. /**
  17353. * Returns a new LineMesh object cloned from the current one.
  17354. */
  17355. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17356. /**
  17357. * Creates a new InstancedLinesMesh object from the mesh model.
  17358. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17359. * @param name defines the name of the new instance
  17360. * @returns a new InstancedLinesMesh
  17361. */
  17362. createInstance(name: string): InstancedLinesMesh;
  17363. }
  17364. /**
  17365. * Creates an instance based on a source LinesMesh
  17366. */
  17367. export class InstancedLinesMesh extends InstancedMesh {
  17368. /**
  17369. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17370. * This margin is expressed in world space coordinates, so its value may vary.
  17371. * Initilized with the intersectionThreshold value of the source LinesMesh
  17372. */
  17373. intersectionThreshold: number;
  17374. constructor(name: string, source: LinesMesh);
  17375. /**
  17376. * Returns the string "InstancedLinesMesh".
  17377. */
  17378. getClassName(): string;
  17379. }
  17380. }
  17381. declare module "babylonjs/Shaders/line.fragment" {
  17382. /** @hidden */
  17383. export var linePixelShader: {
  17384. name: string;
  17385. shader: string;
  17386. };
  17387. }
  17388. declare module "babylonjs/Shaders/line.vertex" {
  17389. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17390. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17391. /** @hidden */
  17392. export var lineVertexShader: {
  17393. name: string;
  17394. shader: string;
  17395. };
  17396. }
  17397. declare module "babylonjs/Rendering/edgesRenderer" {
  17398. import { Nullable } from "babylonjs/types";
  17399. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17401. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17402. import { IDisposable } from "babylonjs/scene";
  17403. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17404. import "babylonjs/Shaders/line.fragment";
  17405. import "babylonjs/Shaders/line.vertex";
  17406. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17407. import { SmartArray } from "babylonjs/Misc/smartArray";
  17408. module "babylonjs/scene" {
  17409. interface Scene {
  17410. /** @hidden */
  17411. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17412. }
  17413. }
  17414. module "babylonjs/Meshes/abstractMesh" {
  17415. interface AbstractMesh {
  17416. /**
  17417. * Gets the edgesRenderer associated with the mesh
  17418. */
  17419. edgesRenderer: Nullable<EdgesRenderer>;
  17420. }
  17421. }
  17422. module "babylonjs/Meshes/linesMesh" {
  17423. interface LinesMesh {
  17424. /**
  17425. * Enables the edge rendering mode on the mesh.
  17426. * This mode makes the mesh edges visible
  17427. * @param epsilon defines the maximal distance between two angles to detect a face
  17428. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17429. * @returns the currentAbstractMesh
  17430. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17431. */
  17432. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17433. }
  17434. }
  17435. module "babylonjs/Meshes/linesMesh" {
  17436. interface InstancedLinesMesh {
  17437. /**
  17438. * Enables the edge rendering mode on the mesh.
  17439. * This mode makes the mesh edges visible
  17440. * @param epsilon defines the maximal distance between two angles to detect a face
  17441. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17442. * @returns the current InstancedLinesMesh
  17443. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17444. */
  17445. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17446. }
  17447. }
  17448. /**
  17449. * Defines the minimum contract an Edges renderer should follow.
  17450. */
  17451. export interface IEdgesRenderer extends IDisposable {
  17452. /**
  17453. * Gets or sets a boolean indicating if the edgesRenderer is active
  17454. */
  17455. isEnabled: boolean;
  17456. /**
  17457. * Renders the edges of the attached mesh,
  17458. */
  17459. render(): void;
  17460. /**
  17461. * Checks wether or not the edges renderer is ready to render.
  17462. * @return true if ready, otherwise false.
  17463. */
  17464. isReady(): boolean;
  17465. /**
  17466. * List of instances to render in case the source mesh has instances
  17467. */
  17468. customInstances: SmartArray<Matrix>;
  17469. }
  17470. /**
  17471. * Defines the additional options of the edges renderer
  17472. */
  17473. export interface IEdgesRendererOptions {
  17474. /**
  17475. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17476. * If not defined, the default value is true
  17477. */
  17478. useAlternateEdgeFinder?: boolean;
  17479. /**
  17480. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17481. * If not defined, the default value is true.
  17482. * 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)
  17483. * This option is used only if useAlternateEdgeFinder = true
  17484. */
  17485. useFastVertexMerger?: boolean;
  17486. /**
  17487. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17488. * The default value is 1e-6
  17489. * This option is used only if useAlternateEdgeFinder = true
  17490. */
  17491. epsilonVertexMerge?: number;
  17492. /**
  17493. * 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
  17494. * 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.
  17495. * This option is used only if useAlternateEdgeFinder = true
  17496. */
  17497. applyTessellation?: boolean;
  17498. /**
  17499. * 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
  17500. * The default value is 1e-6
  17501. * This option is used only if useAlternateEdgeFinder = true
  17502. */
  17503. epsilonVertexAligned?: number;
  17504. }
  17505. /**
  17506. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17507. */
  17508. export class EdgesRenderer implements IEdgesRenderer {
  17509. /**
  17510. * Define the size of the edges with an orthographic camera
  17511. */
  17512. edgesWidthScalerForOrthographic: number;
  17513. /**
  17514. * Define the size of the edges with a perspective camera
  17515. */
  17516. edgesWidthScalerForPerspective: number;
  17517. protected _source: AbstractMesh;
  17518. protected _linesPositions: number[];
  17519. protected _linesNormals: number[];
  17520. protected _linesIndices: number[];
  17521. protected _epsilon: number;
  17522. protected _indicesCount: number;
  17523. protected _lineShader: ShaderMaterial;
  17524. protected _ib: DataBuffer;
  17525. protected _buffers: {
  17526. [key: string]: Nullable<VertexBuffer>;
  17527. };
  17528. protected _buffersForInstances: {
  17529. [key: string]: Nullable<VertexBuffer>;
  17530. };
  17531. protected _checkVerticesInsteadOfIndices: boolean;
  17532. protected _options: Nullable<IEdgesRendererOptions>;
  17533. private _meshRebuildObserver;
  17534. private _meshDisposeObserver;
  17535. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17536. isEnabled: boolean;
  17537. /**
  17538. * List of instances to render in case the source mesh has instances
  17539. */
  17540. customInstances: SmartArray<Matrix>;
  17541. private static GetShader;
  17542. /**
  17543. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17544. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17545. * @param source Mesh used to create edges
  17546. * @param epsilon sum of angles in adjacency to check for edge
  17547. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17548. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17549. * @param options The options to apply when generating the edges
  17550. */
  17551. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17552. protected _prepareRessources(): void;
  17553. /** @hidden */
  17554. _rebuild(): void;
  17555. /**
  17556. * Releases the required resources for the edges renderer
  17557. */
  17558. dispose(): void;
  17559. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17560. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17561. /**
  17562. * Checks if the pair of p0 and p1 is en edge
  17563. * @param faceIndex
  17564. * @param edge
  17565. * @param faceNormals
  17566. * @param p0
  17567. * @param p1
  17568. * @private
  17569. */
  17570. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17571. /**
  17572. * push line into the position, normal and index buffer
  17573. * @protected
  17574. */
  17575. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17576. /**
  17577. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17578. */
  17579. private _tessellateTriangle;
  17580. private _generateEdgesLinesAlternate;
  17581. /**
  17582. * Generates lines edges from adjacencjes
  17583. * @private
  17584. */
  17585. _generateEdgesLines(): void;
  17586. /**
  17587. * Checks wether or not the edges renderer is ready to render.
  17588. * @return true if ready, otherwise false.
  17589. */
  17590. isReady(): boolean;
  17591. /**
  17592. * Renders the edges of the attached mesh,
  17593. */
  17594. render(): void;
  17595. }
  17596. /**
  17597. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17598. */
  17599. export class LineEdgesRenderer extends EdgesRenderer {
  17600. /**
  17601. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17602. * @param source LineMesh used to generate edges
  17603. * @param epsilon not important (specified angle for edge detection)
  17604. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17605. */
  17606. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17607. /**
  17608. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17609. */
  17610. _generateEdgesLines(): void;
  17611. }
  17612. }
  17613. declare module "babylonjs/Rendering/renderingGroup" {
  17614. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17615. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17616. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17617. import { Nullable } from "babylonjs/types";
  17618. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17619. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17620. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17621. import { Material } from "babylonjs/Materials/material";
  17622. import { Scene } from "babylonjs/scene";
  17623. /**
  17624. * This represents the object necessary to create a rendering group.
  17625. * This is exclusively used and created by the rendering manager.
  17626. * To modify the behavior, you use the available helpers in your scene or meshes.
  17627. * @hidden
  17628. */
  17629. export class RenderingGroup {
  17630. index: number;
  17631. private static _zeroVector;
  17632. private _scene;
  17633. private _opaqueSubMeshes;
  17634. private _transparentSubMeshes;
  17635. private _alphaTestSubMeshes;
  17636. private _depthOnlySubMeshes;
  17637. private _particleSystems;
  17638. private _spriteManagers;
  17639. private _opaqueSortCompareFn;
  17640. private _alphaTestSortCompareFn;
  17641. private _transparentSortCompareFn;
  17642. private _renderOpaque;
  17643. private _renderAlphaTest;
  17644. private _renderTransparent;
  17645. /** @hidden */
  17646. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17647. onBeforeTransparentRendering: () => void;
  17648. /**
  17649. * Set the opaque sort comparison function.
  17650. * If null the sub meshes will be render in the order they were created
  17651. */
  17652. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17653. /**
  17654. * Set the alpha test sort comparison function.
  17655. * If null the sub meshes will be render in the order they were created
  17656. */
  17657. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17658. /**
  17659. * Set the transparent sort comparison function.
  17660. * If null the sub meshes will be render in the order they were created
  17661. */
  17662. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17663. /**
  17664. * Creates a new rendering group.
  17665. * @param index The rendering group index
  17666. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17667. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17668. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17669. */
  17670. 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>);
  17671. /**
  17672. * Render all the sub meshes contained in the group.
  17673. * @param customRenderFunction Used to override the default render behaviour of the group.
  17674. * @returns true if rendered some submeshes.
  17675. */
  17676. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17677. /**
  17678. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17679. * @param subMeshes The submeshes to render
  17680. */
  17681. private renderOpaqueSorted;
  17682. /**
  17683. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17684. * @param subMeshes The submeshes to render
  17685. */
  17686. private renderAlphaTestSorted;
  17687. /**
  17688. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17689. * @param subMeshes The submeshes to render
  17690. */
  17691. private renderTransparentSorted;
  17692. /**
  17693. * Renders the submeshes in a specified order.
  17694. * @param subMeshes The submeshes to sort before render
  17695. * @param sortCompareFn The comparison function use to sort
  17696. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17697. * @param transparent Specifies to activate blending if true
  17698. */
  17699. private static renderSorted;
  17700. /**
  17701. * Renders the submeshes in the order they were dispatched (no sort applied).
  17702. * @param subMeshes The submeshes to render
  17703. */
  17704. private static renderUnsorted;
  17705. /**
  17706. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17707. * are rendered back to front if in the same alpha index.
  17708. *
  17709. * @param a The first submesh
  17710. * @param b The second submesh
  17711. * @returns The result of the comparison
  17712. */
  17713. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17714. /**
  17715. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17716. * are rendered back to front.
  17717. *
  17718. * @param a The first submesh
  17719. * @param b The second submesh
  17720. * @returns The result of the comparison
  17721. */
  17722. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17723. /**
  17724. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17725. * are rendered front to back (prevent overdraw).
  17726. *
  17727. * @param a The first submesh
  17728. * @param b The second submesh
  17729. * @returns The result of the comparison
  17730. */
  17731. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17732. /**
  17733. * Resets the different lists of submeshes to prepare a new frame.
  17734. */
  17735. prepare(): void;
  17736. dispose(): void;
  17737. /**
  17738. * Inserts the submesh in its correct queue depending on its material.
  17739. * @param subMesh The submesh to dispatch
  17740. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17741. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17742. */
  17743. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17744. dispatchSprites(spriteManager: ISpriteManager): void;
  17745. dispatchParticles(particleSystem: IParticleSystem): void;
  17746. private _renderParticles;
  17747. private _renderSprites;
  17748. }
  17749. }
  17750. declare module "babylonjs/Rendering/renderingManager" {
  17751. import { Nullable } from "babylonjs/types";
  17752. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17753. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17754. import { SmartArray } from "babylonjs/Misc/smartArray";
  17755. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17756. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17757. import { Material } from "babylonjs/Materials/material";
  17758. import { Scene } from "babylonjs/scene";
  17759. import { Camera } from "babylonjs/Cameras/camera";
  17760. /**
  17761. * Interface describing the different options available in the rendering manager
  17762. * regarding Auto Clear between groups.
  17763. */
  17764. export interface IRenderingManagerAutoClearSetup {
  17765. /**
  17766. * Defines whether or not autoclear is enable.
  17767. */
  17768. autoClear: boolean;
  17769. /**
  17770. * Defines whether or not to autoclear the depth buffer.
  17771. */
  17772. depth: boolean;
  17773. /**
  17774. * Defines whether or not to autoclear the stencil buffer.
  17775. */
  17776. stencil: boolean;
  17777. }
  17778. /**
  17779. * This class is used by the onRenderingGroupObservable
  17780. */
  17781. export class RenderingGroupInfo {
  17782. /**
  17783. * The Scene that being rendered
  17784. */
  17785. scene: Scene;
  17786. /**
  17787. * The camera currently used for the rendering pass
  17788. */
  17789. camera: Nullable<Camera>;
  17790. /**
  17791. * The ID of the renderingGroup being processed
  17792. */
  17793. renderingGroupId: number;
  17794. }
  17795. /**
  17796. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17797. * It is enable to manage the different groups as well as the different necessary sort functions.
  17798. * This should not be used directly aside of the few static configurations
  17799. */
  17800. export class RenderingManager {
  17801. /**
  17802. * The max id used for rendering groups (not included)
  17803. */
  17804. static MAX_RENDERINGGROUPS: number;
  17805. /**
  17806. * The min id used for rendering groups (included)
  17807. */
  17808. static MIN_RENDERINGGROUPS: number;
  17809. /**
  17810. * Used to globally prevent autoclearing scenes.
  17811. */
  17812. static AUTOCLEAR: boolean;
  17813. /**
  17814. * @hidden
  17815. */
  17816. _useSceneAutoClearSetup: boolean;
  17817. private _scene;
  17818. private _renderingGroups;
  17819. private _depthStencilBufferAlreadyCleaned;
  17820. private _autoClearDepthStencil;
  17821. private _customOpaqueSortCompareFn;
  17822. private _customAlphaTestSortCompareFn;
  17823. private _customTransparentSortCompareFn;
  17824. private _renderingGroupInfo;
  17825. /**
  17826. * Instantiates a new rendering group for a particular scene
  17827. * @param scene Defines the scene the groups belongs to
  17828. */
  17829. constructor(scene: Scene);
  17830. private _clearDepthStencilBuffer;
  17831. /**
  17832. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17833. * @hidden
  17834. */
  17835. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17836. /**
  17837. * Resets the different information of the group to prepare a new frame
  17838. * @hidden
  17839. */
  17840. reset(): void;
  17841. /**
  17842. * Dispose and release the group and its associated resources.
  17843. * @hidden
  17844. */
  17845. dispose(): void;
  17846. /**
  17847. * Clear the info related to rendering groups preventing retention points during dispose.
  17848. */
  17849. freeRenderingGroups(): void;
  17850. private _prepareRenderingGroup;
  17851. /**
  17852. * Add a sprite manager to the rendering manager in order to render it this frame.
  17853. * @param spriteManager Define the sprite manager to render
  17854. */
  17855. dispatchSprites(spriteManager: ISpriteManager): void;
  17856. /**
  17857. * Add a particle system to the rendering manager in order to render it this frame.
  17858. * @param particleSystem Define the particle system to render
  17859. */
  17860. dispatchParticles(particleSystem: IParticleSystem): void;
  17861. /**
  17862. * Add a submesh to the manager in order to render it this frame
  17863. * @param subMesh The submesh to dispatch
  17864. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17865. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17866. */
  17867. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17868. /**
  17869. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17870. * This allowed control for front to back rendering or reversly depending of the special needs.
  17871. *
  17872. * @param renderingGroupId The rendering group id corresponding to its index
  17873. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17874. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17875. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17876. */
  17877. 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;
  17878. /**
  17879. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17880. *
  17881. * @param renderingGroupId The rendering group id corresponding to its index
  17882. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17883. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17884. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17885. */
  17886. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17887. /**
  17888. * Gets the current auto clear configuration for one rendering group of the rendering
  17889. * manager.
  17890. * @param index the rendering group index to get the information for
  17891. * @returns The auto clear setup for the requested rendering group
  17892. */
  17893. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17894. }
  17895. }
  17896. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17897. import { SmartArray } from "babylonjs/Misc/smartArray";
  17898. import { Nullable } from "babylonjs/types";
  17899. import { Scene } from "babylonjs/scene";
  17900. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17901. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17902. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17903. import { Mesh } from "babylonjs/Meshes/mesh";
  17904. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17905. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17906. import { Effect } from "babylonjs/Materials/effect";
  17907. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17908. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17909. import "babylonjs/Shaders/shadowMap.fragment";
  17910. import "babylonjs/Shaders/shadowMap.vertex";
  17911. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17912. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17913. import { Observable } from "babylonjs/Misc/observable";
  17914. /**
  17915. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17916. */
  17917. export interface ICustomShaderOptions {
  17918. /**
  17919. * Gets or sets the custom shader name to use
  17920. */
  17921. shaderName: string;
  17922. /**
  17923. * The list of attribute names used in the shader
  17924. */
  17925. attributes?: string[];
  17926. /**
  17927. * The list of unifrom names used in the shader
  17928. */
  17929. uniforms?: string[];
  17930. /**
  17931. * The list of sampler names used in the shader
  17932. */
  17933. samplers?: string[];
  17934. /**
  17935. * The list of defines used in the shader
  17936. */
  17937. defines?: string[];
  17938. }
  17939. /**
  17940. * Interface to implement to create a shadow generator compatible with BJS.
  17941. */
  17942. export interface IShadowGenerator {
  17943. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17944. id: string;
  17945. /**
  17946. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17947. * @returns The render target texture if present otherwise, null
  17948. */
  17949. getShadowMap(): Nullable<RenderTargetTexture>;
  17950. /**
  17951. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17952. * @param subMesh The submesh we want to render in the shadow map
  17953. * @param useInstances Defines wether will draw in the map using instances
  17954. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17955. * @returns true if ready otherwise, false
  17956. */
  17957. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17958. /**
  17959. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17960. * @param defines Defines of the material we want to update
  17961. * @param lightIndex Index of the light in the enabled light list of the material
  17962. */
  17963. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17964. /**
  17965. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17966. * defined in the generator but impacting the effect).
  17967. * It implies the unifroms available on the materials are the standard BJS ones.
  17968. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17969. * @param effect The effect we are binfing the information for
  17970. */
  17971. bindShadowLight(lightIndex: string, effect: Effect): void;
  17972. /**
  17973. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17974. * (eq to shadow prjection matrix * light transform matrix)
  17975. * @returns The transform matrix used to create the shadow map
  17976. */
  17977. getTransformMatrix(): Matrix;
  17978. /**
  17979. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17980. * Cube and 2D textures for instance.
  17981. */
  17982. recreateShadowMap(): void;
  17983. /**
  17984. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17985. * @param onCompiled Callback triggered at the and of the effects compilation
  17986. * @param options Sets of optional options forcing the compilation with different modes
  17987. */
  17988. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17989. useInstances: boolean;
  17990. }>): void;
  17991. /**
  17992. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17993. * @param options Sets of optional options forcing the compilation with different modes
  17994. * @returns A promise that resolves when the compilation completes
  17995. */
  17996. forceCompilationAsync(options?: Partial<{
  17997. useInstances: boolean;
  17998. }>): Promise<void>;
  17999. /**
  18000. * Serializes the shadow generator setup to a json object.
  18001. * @returns The serialized JSON object
  18002. */
  18003. serialize(): any;
  18004. /**
  18005. * Disposes the Shadow map and related Textures and effects.
  18006. */
  18007. dispose(): void;
  18008. }
  18009. /**
  18010. * Default implementation IShadowGenerator.
  18011. * This is the main object responsible of generating shadows in the framework.
  18012. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  18013. */
  18014. export class ShadowGenerator implements IShadowGenerator {
  18015. /**
  18016. * Name of the shadow generator class
  18017. */
  18018. static CLASSNAME: string;
  18019. /**
  18020. * Shadow generator mode None: no filtering applied.
  18021. */
  18022. static readonly FILTER_NONE: number;
  18023. /**
  18024. * Shadow generator mode ESM: Exponential Shadow Mapping.
  18025. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18026. */
  18027. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  18028. /**
  18029. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  18030. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  18031. */
  18032. static readonly FILTER_POISSONSAMPLING: number;
  18033. /**
  18034. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  18035. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18036. */
  18037. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  18038. /**
  18039. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  18040. * edge artifacts on steep falloff.
  18041. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18042. */
  18043. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  18044. /**
  18045. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  18046. * edge artifacts on steep falloff.
  18047. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18048. */
  18049. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  18050. /**
  18051. * Shadow generator mode PCF: Percentage Closer Filtering
  18052. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18053. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  18054. */
  18055. static readonly FILTER_PCF: number;
  18056. /**
  18057. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  18058. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18059. * Contact Hardening
  18060. */
  18061. static readonly FILTER_PCSS: number;
  18062. /**
  18063. * Reserved for PCF and PCSS
  18064. * Highest Quality.
  18065. *
  18066. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18067. *
  18068. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18069. */
  18070. static readonly QUALITY_HIGH: number;
  18071. /**
  18072. * Reserved for PCF and PCSS
  18073. * Good tradeoff for quality/perf cross devices
  18074. *
  18075. * Execute PCF on a 3*3 kernel.
  18076. *
  18077. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18078. */
  18079. static readonly QUALITY_MEDIUM: number;
  18080. /**
  18081. * Reserved for PCF and PCSS
  18082. * The lowest quality but the fastest.
  18083. *
  18084. * Execute PCF on a 1*1 kernel.
  18085. *
  18086. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18087. */
  18088. static readonly QUALITY_LOW: number;
  18089. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18090. id: string;
  18091. /** Gets or sets the custom shader name to use */
  18092. customShaderOptions: ICustomShaderOptions;
  18093. /**
  18094. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18095. */
  18096. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18097. /**
  18098. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18099. */
  18100. onAfterShadowMapRenderObservable: Observable<Effect>;
  18101. /**
  18102. * Observable triggered before a mesh is rendered in the shadow map.
  18103. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18104. */
  18105. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18106. /**
  18107. * Observable triggered after a mesh is rendered in the shadow map.
  18108. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18109. */
  18110. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18111. protected _bias: number;
  18112. /**
  18113. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18114. */
  18115. get bias(): number;
  18116. /**
  18117. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18118. */
  18119. set bias(bias: number);
  18120. protected _normalBias: number;
  18121. /**
  18122. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18123. */
  18124. get normalBias(): number;
  18125. /**
  18126. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18127. */
  18128. set normalBias(normalBias: number);
  18129. protected _blurBoxOffset: number;
  18130. /**
  18131. * Gets the blur box offset: offset applied during the blur pass.
  18132. * Only useful if useKernelBlur = false
  18133. */
  18134. get blurBoxOffset(): number;
  18135. /**
  18136. * Sets the blur box offset: offset applied during the blur pass.
  18137. * Only useful if useKernelBlur = false
  18138. */
  18139. set blurBoxOffset(value: number);
  18140. protected _blurScale: number;
  18141. /**
  18142. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18143. * 2 means half of the size.
  18144. */
  18145. get blurScale(): number;
  18146. /**
  18147. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18148. * 2 means half of the size.
  18149. */
  18150. set blurScale(value: number);
  18151. protected _blurKernel: number;
  18152. /**
  18153. * Gets the blur kernel: kernel size of the blur pass.
  18154. * Only useful if useKernelBlur = true
  18155. */
  18156. get blurKernel(): number;
  18157. /**
  18158. * Sets the blur kernel: kernel size of the blur pass.
  18159. * Only useful if useKernelBlur = true
  18160. */
  18161. set blurKernel(value: number);
  18162. protected _useKernelBlur: boolean;
  18163. /**
  18164. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18165. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18166. */
  18167. get useKernelBlur(): boolean;
  18168. /**
  18169. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18170. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18171. */
  18172. set useKernelBlur(value: boolean);
  18173. protected _depthScale: number;
  18174. /**
  18175. * Gets the depth scale used in ESM mode.
  18176. */
  18177. get depthScale(): number;
  18178. /**
  18179. * Sets the depth scale used in ESM mode.
  18180. * This can override the scale stored on the light.
  18181. */
  18182. set depthScale(value: number);
  18183. protected _validateFilter(filter: number): number;
  18184. protected _filter: number;
  18185. /**
  18186. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18187. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18188. */
  18189. get filter(): number;
  18190. /**
  18191. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18192. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18193. */
  18194. set filter(value: number);
  18195. /**
  18196. * Gets if the current filter is set to Poisson Sampling.
  18197. */
  18198. get usePoissonSampling(): boolean;
  18199. /**
  18200. * Sets the current filter to Poisson Sampling.
  18201. */
  18202. set usePoissonSampling(value: boolean);
  18203. /**
  18204. * Gets if the current filter is set to ESM.
  18205. */
  18206. get useExponentialShadowMap(): boolean;
  18207. /**
  18208. * Sets the current filter is to ESM.
  18209. */
  18210. set useExponentialShadowMap(value: boolean);
  18211. /**
  18212. * Gets if the current filter is set to filtered ESM.
  18213. */
  18214. get useBlurExponentialShadowMap(): boolean;
  18215. /**
  18216. * Gets if the current filter is set to filtered ESM.
  18217. */
  18218. set useBlurExponentialShadowMap(value: boolean);
  18219. /**
  18220. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18221. * exponential to prevent steep falloff artifacts).
  18222. */
  18223. get useCloseExponentialShadowMap(): boolean;
  18224. /**
  18225. * Sets the current filter to "close ESM" (using the inverse of the
  18226. * exponential to prevent steep falloff artifacts).
  18227. */
  18228. set useCloseExponentialShadowMap(value: boolean);
  18229. /**
  18230. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18231. * exponential to prevent steep falloff artifacts).
  18232. */
  18233. get useBlurCloseExponentialShadowMap(): boolean;
  18234. /**
  18235. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18236. * exponential to prevent steep falloff artifacts).
  18237. */
  18238. set useBlurCloseExponentialShadowMap(value: boolean);
  18239. /**
  18240. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18241. */
  18242. get usePercentageCloserFiltering(): boolean;
  18243. /**
  18244. * Sets the current filter to "PCF" (percentage closer filtering).
  18245. */
  18246. set usePercentageCloserFiltering(value: boolean);
  18247. protected _filteringQuality: number;
  18248. /**
  18249. * Gets the PCF or PCSS Quality.
  18250. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18251. */
  18252. get filteringQuality(): number;
  18253. /**
  18254. * Sets the PCF or PCSS Quality.
  18255. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18256. */
  18257. set filteringQuality(filteringQuality: number);
  18258. /**
  18259. * Gets if the current filter is set to "PCSS" (contact hardening).
  18260. */
  18261. get useContactHardeningShadow(): boolean;
  18262. /**
  18263. * Sets the current filter to "PCSS" (contact hardening).
  18264. */
  18265. set useContactHardeningShadow(value: boolean);
  18266. protected _contactHardeningLightSizeUVRatio: number;
  18267. /**
  18268. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18269. * Using a ratio helps keeping shape stability independently of the map size.
  18270. *
  18271. * It does not account for the light projection as it was having too much
  18272. * instability during the light setup or during light position changes.
  18273. *
  18274. * Only valid if useContactHardeningShadow is true.
  18275. */
  18276. get contactHardeningLightSizeUVRatio(): number;
  18277. /**
  18278. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18279. * Using a ratio helps keeping shape stability independently of the map size.
  18280. *
  18281. * It does not account for the light projection as it was having too much
  18282. * instability during the light setup or during light position changes.
  18283. *
  18284. * Only valid if useContactHardeningShadow is true.
  18285. */
  18286. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18287. protected _darkness: number;
  18288. /** Gets or sets the actual darkness of a shadow */
  18289. get darkness(): number;
  18290. set darkness(value: number);
  18291. /**
  18292. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18293. * 0 means strongest and 1 would means no shadow.
  18294. * @returns the darkness.
  18295. */
  18296. getDarkness(): number;
  18297. /**
  18298. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18299. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18300. * @returns the shadow generator allowing fluent coding.
  18301. */
  18302. setDarkness(darkness: number): ShadowGenerator;
  18303. protected _transparencyShadow: boolean;
  18304. /** Gets or sets the ability to have transparent shadow */
  18305. get transparencyShadow(): boolean;
  18306. set transparencyShadow(value: boolean);
  18307. /**
  18308. * Sets the ability to have transparent shadow (boolean).
  18309. * @param transparent True if transparent else False
  18310. * @returns the shadow generator allowing fluent coding
  18311. */
  18312. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18313. /**
  18314. * Enables or disables shadows with varying strength based on the transparency
  18315. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18316. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18317. * mesh.visibility * alphaTexture.a
  18318. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18319. */
  18320. enableSoftTransparentShadow: boolean;
  18321. protected _shadowMap: Nullable<RenderTargetTexture>;
  18322. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18323. /**
  18324. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18325. * @returns The render target texture if present otherwise, null
  18326. */
  18327. getShadowMap(): Nullable<RenderTargetTexture>;
  18328. /**
  18329. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18330. * @returns The render target texture if the shadow map is present otherwise, null
  18331. */
  18332. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18333. /**
  18334. * Gets the class name of that object
  18335. * @returns "ShadowGenerator"
  18336. */
  18337. getClassName(): string;
  18338. /**
  18339. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18340. * @param mesh Mesh to add
  18341. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18342. * @returns the Shadow Generator itself
  18343. */
  18344. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18345. /**
  18346. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18347. * @param mesh Mesh to remove
  18348. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18349. * @returns the Shadow Generator itself
  18350. */
  18351. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18352. /**
  18353. * Controls the extent to which the shadows fade out at the edge of the frustum
  18354. */
  18355. frustumEdgeFalloff: number;
  18356. protected _light: IShadowLight;
  18357. /**
  18358. * Returns the associated light object.
  18359. * @returns the light generating the shadow
  18360. */
  18361. getLight(): IShadowLight;
  18362. /**
  18363. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18364. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18365. * It might on the other hand introduce peter panning.
  18366. */
  18367. forceBackFacesOnly: boolean;
  18368. protected _scene: Scene;
  18369. protected _lightDirection: Vector3;
  18370. protected _effect: Effect;
  18371. protected _viewMatrix: Matrix;
  18372. protected _projectionMatrix: Matrix;
  18373. protected _transformMatrix: Matrix;
  18374. protected _cachedPosition: Vector3;
  18375. protected _cachedDirection: Vector3;
  18376. protected _cachedDefines: string;
  18377. protected _currentRenderID: number;
  18378. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18379. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18380. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18381. protected _blurPostProcesses: PostProcess[];
  18382. protected _mapSize: number;
  18383. protected _currentFaceIndex: number;
  18384. protected _currentFaceIndexCache: number;
  18385. protected _textureType: number;
  18386. protected _defaultTextureMatrix: Matrix;
  18387. protected _storedUniqueId: Nullable<number>;
  18388. /** @hidden */
  18389. static _SceneComponentInitialization: (scene: Scene) => void;
  18390. /**
  18391. * Creates a ShadowGenerator object.
  18392. * A ShadowGenerator is the required tool to use the shadows.
  18393. * Each light casting shadows needs to use its own ShadowGenerator.
  18394. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18395. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18396. * @param light The light object generating the shadows.
  18397. * @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.
  18398. */
  18399. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18400. protected _initializeGenerator(): void;
  18401. protected _createTargetRenderTexture(): void;
  18402. protected _initializeShadowMap(): void;
  18403. protected _initializeBlurRTTAndPostProcesses(): void;
  18404. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18405. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18406. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18407. protected _applyFilterValues(): void;
  18408. /**
  18409. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18410. * @param onCompiled Callback triggered at the and of the effects compilation
  18411. * @param options Sets of optional options forcing the compilation with different modes
  18412. */
  18413. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18414. useInstances: boolean;
  18415. }>): void;
  18416. /**
  18417. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18418. * @param options Sets of optional options forcing the compilation with different modes
  18419. * @returns A promise that resolves when the compilation completes
  18420. */
  18421. forceCompilationAsync(options?: Partial<{
  18422. useInstances: boolean;
  18423. }>): Promise<void>;
  18424. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18425. private _prepareShadowDefines;
  18426. /**
  18427. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18428. * @param subMesh The submesh we want to render in the shadow map
  18429. * @param useInstances Defines wether will draw in the map using instances
  18430. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18431. * @returns true if ready otherwise, false
  18432. */
  18433. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18434. /**
  18435. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18436. * @param defines Defines of the material we want to update
  18437. * @param lightIndex Index of the light in the enabled light list of the material
  18438. */
  18439. prepareDefines(defines: any, lightIndex: number): void;
  18440. /**
  18441. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18442. * defined in the generator but impacting the effect).
  18443. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18444. * @param effect The effect we are binfing the information for
  18445. */
  18446. bindShadowLight(lightIndex: string, effect: Effect): void;
  18447. /**
  18448. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18449. * (eq to shadow prjection matrix * light transform matrix)
  18450. * @returns The transform matrix used to create the shadow map
  18451. */
  18452. getTransformMatrix(): Matrix;
  18453. /**
  18454. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18455. * Cube and 2D textures for instance.
  18456. */
  18457. recreateShadowMap(): void;
  18458. protected _disposeBlurPostProcesses(): void;
  18459. protected _disposeRTTandPostProcesses(): void;
  18460. /**
  18461. * Disposes the ShadowGenerator.
  18462. * Returns nothing.
  18463. */
  18464. dispose(): void;
  18465. /**
  18466. * Serializes the shadow generator setup to a json object.
  18467. * @returns The serialized JSON object
  18468. */
  18469. serialize(): any;
  18470. /**
  18471. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18472. * @param parsedShadowGenerator The JSON object to parse
  18473. * @param scene The scene to create the shadow map for
  18474. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18475. * @returns The parsed shadow generator
  18476. */
  18477. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18478. }
  18479. }
  18480. declare module "babylonjs/Lights/light" {
  18481. import { Nullable } from "babylonjs/types";
  18482. import { Scene } from "babylonjs/scene";
  18483. import { Vector3 } from "babylonjs/Maths/math.vector";
  18484. import { Color3 } from "babylonjs/Maths/math.color";
  18485. import { Node } from "babylonjs/node";
  18486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18487. import { Effect } from "babylonjs/Materials/effect";
  18488. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18489. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18490. /**
  18491. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18492. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18493. * 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.
  18494. */
  18495. export abstract class Light extends Node {
  18496. /**
  18497. * Falloff Default: light is falling off following the material specification:
  18498. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18499. */
  18500. static readonly FALLOFF_DEFAULT: number;
  18501. /**
  18502. * Falloff Physical: light is falling off following the inverse squared distance law.
  18503. */
  18504. static readonly FALLOFF_PHYSICAL: number;
  18505. /**
  18506. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18507. * to enhance interoperability with other engines.
  18508. */
  18509. static readonly FALLOFF_GLTF: number;
  18510. /**
  18511. * Falloff Standard: light is falling off like in the standard material
  18512. * to enhance interoperability with other materials.
  18513. */
  18514. static readonly FALLOFF_STANDARD: number;
  18515. /**
  18516. * If every light affecting the material is in this lightmapMode,
  18517. * material.lightmapTexture adds or multiplies
  18518. * (depends on material.useLightmapAsShadowmap)
  18519. * after every other light calculations.
  18520. */
  18521. static readonly LIGHTMAP_DEFAULT: number;
  18522. /**
  18523. * material.lightmapTexture as only diffuse lighting from this light
  18524. * adds only specular lighting from this light
  18525. * adds dynamic shadows
  18526. */
  18527. static readonly LIGHTMAP_SPECULAR: number;
  18528. /**
  18529. * material.lightmapTexture as only lighting
  18530. * no light calculation from this light
  18531. * only adds dynamic shadows from this light
  18532. */
  18533. static readonly LIGHTMAP_SHADOWSONLY: number;
  18534. /**
  18535. * Each light type uses the default quantity according to its type:
  18536. * point/spot lights use luminous intensity
  18537. * directional lights use illuminance
  18538. */
  18539. static readonly INTENSITYMODE_AUTOMATIC: number;
  18540. /**
  18541. * lumen (lm)
  18542. */
  18543. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18544. /**
  18545. * candela (lm/sr)
  18546. */
  18547. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18548. /**
  18549. * lux (lm/m^2)
  18550. */
  18551. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18552. /**
  18553. * nit (cd/m^2)
  18554. */
  18555. static readonly INTENSITYMODE_LUMINANCE: number;
  18556. /**
  18557. * Light type const id of the point light.
  18558. */
  18559. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18560. /**
  18561. * Light type const id of the directional light.
  18562. */
  18563. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18564. /**
  18565. * Light type const id of the spot light.
  18566. */
  18567. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18568. /**
  18569. * Light type const id of the hemispheric light.
  18570. */
  18571. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18572. /**
  18573. * Diffuse gives the basic color to an object.
  18574. */
  18575. diffuse: Color3;
  18576. /**
  18577. * Specular produces a highlight color on an object.
  18578. * Note: This is note affecting PBR materials.
  18579. */
  18580. specular: Color3;
  18581. /**
  18582. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18583. * falling off base on range or angle.
  18584. * This can be set to any values in Light.FALLOFF_x.
  18585. *
  18586. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18587. * other types of materials.
  18588. */
  18589. falloffType: number;
  18590. /**
  18591. * Strength of the light.
  18592. * Note: By default it is define in the framework own unit.
  18593. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18594. */
  18595. intensity: number;
  18596. private _range;
  18597. protected _inverseSquaredRange: number;
  18598. /**
  18599. * Defines how far from the source the light is impacting in scene units.
  18600. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18601. */
  18602. get range(): number;
  18603. /**
  18604. * Defines how far from the source the light is impacting in scene units.
  18605. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18606. */
  18607. set range(value: number);
  18608. /**
  18609. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18610. * of light.
  18611. */
  18612. private _photometricScale;
  18613. private _intensityMode;
  18614. /**
  18615. * Gets the photometric scale used to interpret the intensity.
  18616. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18617. */
  18618. get intensityMode(): number;
  18619. /**
  18620. * Sets the photometric scale used to interpret the intensity.
  18621. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18622. */
  18623. set intensityMode(value: number);
  18624. private _radius;
  18625. /**
  18626. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18627. */
  18628. get radius(): number;
  18629. /**
  18630. * sets the light radius used by PBR Materials to simulate soft area lights.
  18631. */
  18632. set radius(value: number);
  18633. private _renderPriority;
  18634. /**
  18635. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18636. * exceeding the number allowed of the materials.
  18637. */
  18638. renderPriority: number;
  18639. private _shadowEnabled;
  18640. /**
  18641. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18642. * the current shadow generator.
  18643. */
  18644. get shadowEnabled(): boolean;
  18645. /**
  18646. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18647. * the current shadow generator.
  18648. */
  18649. set shadowEnabled(value: boolean);
  18650. private _includedOnlyMeshes;
  18651. /**
  18652. * Gets the only meshes impacted by this light.
  18653. */
  18654. get includedOnlyMeshes(): AbstractMesh[];
  18655. /**
  18656. * Sets the only meshes impacted by this light.
  18657. */
  18658. set includedOnlyMeshes(value: AbstractMesh[]);
  18659. private _excludedMeshes;
  18660. /**
  18661. * Gets the meshes not impacted by this light.
  18662. */
  18663. get excludedMeshes(): AbstractMesh[];
  18664. /**
  18665. * Sets the meshes not impacted by this light.
  18666. */
  18667. set excludedMeshes(value: AbstractMesh[]);
  18668. private _excludeWithLayerMask;
  18669. /**
  18670. * Gets the layer id use to find what meshes are not impacted by the light.
  18671. * Inactive if 0
  18672. */
  18673. get excludeWithLayerMask(): number;
  18674. /**
  18675. * Sets the layer id use to find what meshes are not impacted by the light.
  18676. * Inactive if 0
  18677. */
  18678. set excludeWithLayerMask(value: number);
  18679. private _includeOnlyWithLayerMask;
  18680. /**
  18681. * Gets the layer id use to find what meshes are impacted by the light.
  18682. * Inactive if 0
  18683. */
  18684. get includeOnlyWithLayerMask(): number;
  18685. /**
  18686. * Sets the layer id use to find what meshes are impacted by the light.
  18687. * Inactive if 0
  18688. */
  18689. set includeOnlyWithLayerMask(value: number);
  18690. private _lightmapMode;
  18691. /**
  18692. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18693. */
  18694. get lightmapMode(): number;
  18695. /**
  18696. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18697. */
  18698. set lightmapMode(value: number);
  18699. /**
  18700. * Shadow generator associted to the light.
  18701. * @hidden Internal use only.
  18702. */
  18703. _shadowGenerator: Nullable<IShadowGenerator>;
  18704. /**
  18705. * @hidden Internal use only.
  18706. */
  18707. _excludedMeshesIds: string[];
  18708. /**
  18709. * @hidden Internal use only.
  18710. */
  18711. _includedOnlyMeshesIds: string[];
  18712. /**
  18713. * The current light unifom buffer.
  18714. * @hidden Internal use only.
  18715. */
  18716. _uniformBuffer: UniformBuffer;
  18717. /** @hidden */
  18718. _renderId: number;
  18719. /**
  18720. * Creates a Light object in the scene.
  18721. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18722. * @param name The firendly name of the light
  18723. * @param scene The scene the light belongs too
  18724. */
  18725. constructor(name: string, scene: Scene);
  18726. protected abstract _buildUniformLayout(): void;
  18727. /**
  18728. * Sets the passed Effect "effect" with the Light information.
  18729. * @param effect The effect to update
  18730. * @param lightIndex The index of the light in the effect to update
  18731. * @returns The light
  18732. */
  18733. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18734. /**
  18735. * Sets the passed Effect "effect" with the Light textures.
  18736. * @param effect The effect to update
  18737. * @param lightIndex The index of the light in the effect to update
  18738. * @returns The light
  18739. */
  18740. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18741. /**
  18742. * Binds the lights information from the scene to the effect for the given mesh.
  18743. * @param lightIndex Light index
  18744. * @param scene The scene where the light belongs to
  18745. * @param effect The effect we are binding the data to
  18746. * @param useSpecular Defines if specular is supported
  18747. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18748. */
  18749. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18750. /**
  18751. * Sets the passed Effect "effect" with the Light information.
  18752. * @param effect The effect to update
  18753. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18754. * @returns The light
  18755. */
  18756. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18757. /**
  18758. * Returns the string "Light".
  18759. * @returns the class name
  18760. */
  18761. getClassName(): string;
  18762. /** @hidden */
  18763. readonly _isLight: boolean;
  18764. /**
  18765. * Converts the light information to a readable string for debug purpose.
  18766. * @param fullDetails Supports for multiple levels of logging within scene loading
  18767. * @returns the human readable light info
  18768. */
  18769. toString(fullDetails?: boolean): string;
  18770. /** @hidden */
  18771. protected _syncParentEnabledState(): void;
  18772. /**
  18773. * Set the enabled state of this node.
  18774. * @param value - the new enabled state
  18775. */
  18776. setEnabled(value: boolean): void;
  18777. /**
  18778. * Returns the Light associated shadow generator if any.
  18779. * @return the associated shadow generator.
  18780. */
  18781. getShadowGenerator(): Nullable<IShadowGenerator>;
  18782. /**
  18783. * Returns a Vector3, the absolute light position in the World.
  18784. * @returns the world space position of the light
  18785. */
  18786. getAbsolutePosition(): Vector3;
  18787. /**
  18788. * Specifies if the light will affect the passed mesh.
  18789. * @param mesh The mesh to test against the light
  18790. * @return true the mesh is affected otherwise, false.
  18791. */
  18792. canAffectMesh(mesh: AbstractMesh): boolean;
  18793. /**
  18794. * Sort function to order lights for rendering.
  18795. * @param a First Light object to compare to second.
  18796. * @param b Second Light object to compare first.
  18797. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18798. */
  18799. static CompareLightsPriority(a: Light, b: Light): number;
  18800. /**
  18801. * Releases resources associated with this node.
  18802. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18803. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18804. */
  18805. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18806. /**
  18807. * Returns the light type ID (integer).
  18808. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18809. */
  18810. getTypeID(): number;
  18811. /**
  18812. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18813. * @returns the scaled intensity in intensity mode unit
  18814. */
  18815. getScaledIntensity(): number;
  18816. /**
  18817. * Returns a new Light object, named "name", from the current one.
  18818. * @param name The name of the cloned light
  18819. * @param newParent The parent of this light, if it has one
  18820. * @returns the new created light
  18821. */
  18822. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18823. /**
  18824. * Serializes the current light into a Serialization object.
  18825. * @returns the serialized object.
  18826. */
  18827. serialize(): any;
  18828. /**
  18829. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18830. * This new light is named "name" and added to the passed scene.
  18831. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18832. * @param name The friendly name of the light
  18833. * @param scene The scene the new light will belong to
  18834. * @returns the constructor function
  18835. */
  18836. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18837. /**
  18838. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18839. * @param parsedLight The JSON representation of the light
  18840. * @param scene The scene to create the parsed light in
  18841. * @returns the created light after parsing
  18842. */
  18843. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18844. private _hookArrayForExcluded;
  18845. private _hookArrayForIncludedOnly;
  18846. private _resyncMeshes;
  18847. /**
  18848. * Forces the meshes to update their light related information in their rendering used effects
  18849. * @hidden Internal Use Only
  18850. */
  18851. _markMeshesAsLightDirty(): void;
  18852. /**
  18853. * Recomputes the cached photometric scale if needed.
  18854. */
  18855. private _computePhotometricScale;
  18856. /**
  18857. * Returns the Photometric Scale according to the light type and intensity mode.
  18858. */
  18859. private _getPhotometricScale;
  18860. /**
  18861. * Reorder the light in the scene according to their defined priority.
  18862. * @hidden Internal Use Only
  18863. */
  18864. _reorderLightsInScene(): void;
  18865. /**
  18866. * Prepares the list of defines specific to the light type.
  18867. * @param defines the list of defines
  18868. * @param lightIndex defines the index of the light for the effect
  18869. */
  18870. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18871. }
  18872. }
  18873. declare module "babylonjs/Cameras/targetCamera" {
  18874. import { Nullable } from "babylonjs/types";
  18875. import { Camera } from "babylonjs/Cameras/camera";
  18876. import { Scene } from "babylonjs/scene";
  18877. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18878. /**
  18879. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18880. * This is the base of the follow, arc rotate cameras and Free camera
  18881. * @see https://doc.babylonjs.com/features/cameras
  18882. */
  18883. export class TargetCamera extends Camera {
  18884. private static _RigCamTransformMatrix;
  18885. private static _TargetTransformMatrix;
  18886. private static _TargetFocalPoint;
  18887. private _tmpUpVector;
  18888. private _tmpTargetVector;
  18889. /**
  18890. * Define the current direction the camera is moving to
  18891. */
  18892. cameraDirection: Vector3;
  18893. /**
  18894. * Define the current rotation the camera is rotating to
  18895. */
  18896. cameraRotation: Vector2;
  18897. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18898. ignoreParentScaling: boolean;
  18899. /**
  18900. * When set, the up vector of the camera will be updated by the rotation of the camera
  18901. */
  18902. updateUpVectorFromRotation: boolean;
  18903. private _tmpQuaternion;
  18904. /**
  18905. * Define the current rotation of the camera
  18906. */
  18907. rotation: Vector3;
  18908. /**
  18909. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18910. */
  18911. rotationQuaternion: Quaternion;
  18912. /**
  18913. * Define the current speed of the camera
  18914. */
  18915. speed: number;
  18916. /**
  18917. * Add constraint to the camera to prevent it to move freely in all directions and
  18918. * around all axis.
  18919. */
  18920. noRotationConstraint: boolean;
  18921. /**
  18922. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18923. * panning
  18924. */
  18925. invertRotation: boolean;
  18926. /**
  18927. * Speed multiplier for inverse camera panning
  18928. */
  18929. inverseRotationSpeed: number;
  18930. /**
  18931. * Define the current target of the camera as an object or a position.
  18932. */
  18933. lockedTarget: any;
  18934. /** @hidden */
  18935. _currentTarget: Vector3;
  18936. /** @hidden */
  18937. _initialFocalDistance: number;
  18938. /** @hidden */
  18939. _viewMatrix: Matrix;
  18940. /** @hidden */
  18941. _camMatrix: Matrix;
  18942. /** @hidden */
  18943. _cameraTransformMatrix: Matrix;
  18944. /** @hidden */
  18945. _cameraRotationMatrix: Matrix;
  18946. /** @hidden */
  18947. _referencePoint: Vector3;
  18948. /** @hidden */
  18949. _transformedReferencePoint: Vector3;
  18950. /** @hidden */
  18951. _reset: () => void;
  18952. private _defaultUp;
  18953. /**
  18954. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18955. * This is the base of the follow, arc rotate cameras and Free camera
  18956. * @see https://doc.babylonjs.com/features/cameras
  18957. * @param name Defines the name of the camera in the scene
  18958. * @param position Defines the start position of the camera in the scene
  18959. * @param scene Defines the scene the camera belongs to
  18960. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18961. */
  18962. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18963. /**
  18964. * Gets the position in front of the camera at a given distance.
  18965. * @param distance The distance from the camera we want the position to be
  18966. * @returns the position
  18967. */
  18968. getFrontPosition(distance: number): Vector3;
  18969. /** @hidden */
  18970. _getLockedTargetPosition(): Nullable<Vector3>;
  18971. private _storedPosition;
  18972. private _storedRotation;
  18973. private _storedRotationQuaternion;
  18974. /**
  18975. * Store current camera state of the camera (fov, position, rotation, etc..)
  18976. * @returns the camera
  18977. */
  18978. storeState(): Camera;
  18979. /**
  18980. * Restored camera state. You must call storeState() first
  18981. * @returns whether it was successful or not
  18982. * @hidden
  18983. */
  18984. _restoreStateValues(): boolean;
  18985. /** @hidden */
  18986. _initCache(): void;
  18987. /** @hidden */
  18988. _updateCache(ignoreParentClass?: boolean): void;
  18989. /** @hidden */
  18990. _isSynchronizedViewMatrix(): boolean;
  18991. /** @hidden */
  18992. _computeLocalCameraSpeed(): number;
  18993. /**
  18994. * Defines the target the camera should look at.
  18995. * @param target Defines the new target as a Vector or a mesh
  18996. */
  18997. setTarget(target: Vector3): void;
  18998. /**
  18999. * Defines the target point of the camera.
  19000. * The camera looks towards it form the radius distance.
  19001. */
  19002. get target(): Vector3;
  19003. set target(value: Vector3);
  19004. /**
  19005. * Return the current target position of the camera. This value is expressed in local space.
  19006. * @returns the target position
  19007. */
  19008. getTarget(): Vector3;
  19009. /** @hidden */
  19010. _decideIfNeedsToMove(): boolean;
  19011. /** @hidden */
  19012. _updatePosition(): void;
  19013. /** @hidden */
  19014. _checkInputs(): void;
  19015. protected _updateCameraRotationMatrix(): void;
  19016. /**
  19017. * 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)
  19018. * @returns the current camera
  19019. */
  19020. private _rotateUpVectorWithCameraRotationMatrix;
  19021. private _cachedRotationZ;
  19022. private _cachedQuaternionRotationZ;
  19023. /** @hidden */
  19024. _getViewMatrix(): Matrix;
  19025. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19026. /**
  19027. * @hidden
  19028. */
  19029. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19030. /**
  19031. * @hidden
  19032. */
  19033. _updateRigCameras(): void;
  19034. private _getRigCamPositionAndTarget;
  19035. /**
  19036. * Gets the current object class name.
  19037. * @return the class name
  19038. */
  19039. getClassName(): string;
  19040. }
  19041. }
  19042. declare module "babylonjs/Events/keyboardEvents" {
  19043. /**
  19044. * Gather the list of keyboard event types as constants.
  19045. */
  19046. export class KeyboardEventTypes {
  19047. /**
  19048. * The keydown event is fired when a key becomes active (pressed).
  19049. */
  19050. static readonly KEYDOWN: number;
  19051. /**
  19052. * The keyup event is fired when a key has been released.
  19053. */
  19054. static readonly KEYUP: number;
  19055. }
  19056. /**
  19057. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19058. */
  19059. export class KeyboardInfo {
  19060. /**
  19061. * Defines the type of event (KeyboardEventTypes)
  19062. */
  19063. type: number;
  19064. /**
  19065. * Defines the related dom event
  19066. */
  19067. event: KeyboardEvent;
  19068. /**
  19069. * Instantiates a new keyboard info.
  19070. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19071. * @param type Defines the type of event (KeyboardEventTypes)
  19072. * @param event Defines the related dom event
  19073. */
  19074. constructor(
  19075. /**
  19076. * Defines the type of event (KeyboardEventTypes)
  19077. */
  19078. type: number,
  19079. /**
  19080. * Defines the related dom event
  19081. */
  19082. event: KeyboardEvent);
  19083. }
  19084. /**
  19085. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19086. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19087. */
  19088. export class KeyboardInfoPre extends KeyboardInfo {
  19089. /**
  19090. * Defines the type of event (KeyboardEventTypes)
  19091. */
  19092. type: number;
  19093. /**
  19094. * Defines the related dom event
  19095. */
  19096. event: KeyboardEvent;
  19097. /**
  19098. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19099. */
  19100. skipOnPointerObservable: boolean;
  19101. /**
  19102. * Instantiates a new keyboard pre info.
  19103. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19104. * @param type Defines the type of event (KeyboardEventTypes)
  19105. * @param event Defines the related dom event
  19106. */
  19107. constructor(
  19108. /**
  19109. * Defines the type of event (KeyboardEventTypes)
  19110. */
  19111. type: number,
  19112. /**
  19113. * Defines the related dom event
  19114. */
  19115. event: KeyboardEvent);
  19116. }
  19117. }
  19118. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19119. import { Nullable } from "babylonjs/types";
  19120. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19121. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19122. /**
  19123. * Manage the keyboard inputs to control the movement of a free camera.
  19124. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19125. */
  19126. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19127. /**
  19128. * Defines the camera the input is attached to.
  19129. */
  19130. camera: FreeCamera;
  19131. /**
  19132. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19133. */
  19134. keysUp: number[];
  19135. /**
  19136. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19137. */
  19138. keysUpward: number[];
  19139. /**
  19140. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19141. */
  19142. keysDown: number[];
  19143. /**
  19144. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19145. */
  19146. keysDownward: number[];
  19147. /**
  19148. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19149. */
  19150. keysLeft: number[];
  19151. /**
  19152. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19153. */
  19154. keysRight: number[];
  19155. private _keys;
  19156. private _onCanvasBlurObserver;
  19157. private _onKeyboardObserver;
  19158. private _engine;
  19159. private _scene;
  19160. /**
  19161. * Attach the input controls to a specific dom element to get the input from.
  19162. * @param element Defines the element the controls should be listened from
  19163. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19164. */
  19165. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19166. /**
  19167. * Detach the current controls from the specified dom element.
  19168. * @param element Defines the element to stop listening the inputs from
  19169. */
  19170. detachControl(element: Nullable<HTMLElement>): void;
  19171. /**
  19172. * Update the current camera state depending on the inputs that have been used this frame.
  19173. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19174. */
  19175. checkInputs(): void;
  19176. /**
  19177. * Gets the class name of the current intput.
  19178. * @returns the class name
  19179. */
  19180. getClassName(): string;
  19181. /** @hidden */
  19182. _onLostFocus(): void;
  19183. /**
  19184. * Get the friendly name associated with the input class.
  19185. * @returns the input friendly name
  19186. */
  19187. getSimpleName(): string;
  19188. }
  19189. }
  19190. declare module "babylonjs/Events/pointerEvents" {
  19191. import { Nullable } from "babylonjs/types";
  19192. import { Vector2 } from "babylonjs/Maths/math.vector";
  19193. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19194. import { Ray } from "babylonjs/Culling/ray";
  19195. /**
  19196. * Gather the list of pointer event types as constants.
  19197. */
  19198. export class PointerEventTypes {
  19199. /**
  19200. * 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.
  19201. */
  19202. static readonly POINTERDOWN: number;
  19203. /**
  19204. * The pointerup event is fired when a pointer is no longer active.
  19205. */
  19206. static readonly POINTERUP: number;
  19207. /**
  19208. * The pointermove event is fired when a pointer changes coordinates.
  19209. */
  19210. static readonly POINTERMOVE: number;
  19211. /**
  19212. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19213. */
  19214. static readonly POINTERWHEEL: number;
  19215. /**
  19216. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19217. */
  19218. static readonly POINTERPICK: number;
  19219. /**
  19220. * The pointertap event is fired when a the object has been touched and released without drag.
  19221. */
  19222. static readonly POINTERTAP: number;
  19223. /**
  19224. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19225. */
  19226. static readonly POINTERDOUBLETAP: number;
  19227. }
  19228. /**
  19229. * Base class of pointer info types.
  19230. */
  19231. export class PointerInfoBase {
  19232. /**
  19233. * Defines the type of event (PointerEventTypes)
  19234. */
  19235. type: number;
  19236. /**
  19237. * Defines the related dom event
  19238. */
  19239. event: PointerEvent | MouseWheelEvent;
  19240. /**
  19241. * Instantiates the base class of pointers info.
  19242. * @param type Defines the type of event (PointerEventTypes)
  19243. * @param event Defines the related dom event
  19244. */
  19245. constructor(
  19246. /**
  19247. * Defines the type of event (PointerEventTypes)
  19248. */
  19249. type: number,
  19250. /**
  19251. * Defines the related dom event
  19252. */
  19253. event: PointerEvent | MouseWheelEvent);
  19254. }
  19255. /**
  19256. * This class is used to store pointer related info for the onPrePointerObservable event.
  19257. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19258. */
  19259. export class PointerInfoPre extends PointerInfoBase {
  19260. /**
  19261. * Ray from a pointer if availible (eg. 6dof controller)
  19262. */
  19263. ray: Nullable<Ray>;
  19264. /**
  19265. * Defines the local position of the pointer on the canvas.
  19266. */
  19267. localPosition: Vector2;
  19268. /**
  19269. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19270. */
  19271. skipOnPointerObservable: boolean;
  19272. /**
  19273. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19274. * @param type Defines the type of event (PointerEventTypes)
  19275. * @param event Defines the related dom event
  19276. * @param localX Defines the local x coordinates of the pointer when the event occured
  19277. * @param localY Defines the local y coordinates of the pointer when the event occured
  19278. */
  19279. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19280. }
  19281. /**
  19282. * This type contains all the data related to a pointer event in Babylon.js.
  19283. * 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.
  19284. */
  19285. export class PointerInfo extends PointerInfoBase {
  19286. /**
  19287. * Defines the picking info associated to the info (if any)\
  19288. */
  19289. pickInfo: Nullable<PickingInfo>;
  19290. /**
  19291. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19292. * @param type Defines the type of event (PointerEventTypes)
  19293. * @param event Defines the related dom event
  19294. * @param pickInfo Defines the picking info associated to the info (if any)\
  19295. */
  19296. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19297. /**
  19298. * Defines the picking info associated to the info (if any)\
  19299. */
  19300. pickInfo: Nullable<PickingInfo>);
  19301. }
  19302. /**
  19303. * Data relating to a touch event on the screen.
  19304. */
  19305. export interface PointerTouch {
  19306. /**
  19307. * X coordinate of touch.
  19308. */
  19309. x: number;
  19310. /**
  19311. * Y coordinate of touch.
  19312. */
  19313. y: number;
  19314. /**
  19315. * Id of touch. Unique for each finger.
  19316. */
  19317. pointerId: number;
  19318. /**
  19319. * Event type passed from DOM.
  19320. */
  19321. type: any;
  19322. }
  19323. }
  19324. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19325. import { Observable } from "babylonjs/Misc/observable";
  19326. import { Nullable } from "babylonjs/types";
  19327. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19328. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19329. /**
  19330. * Manage the mouse inputs to control the movement of a free camera.
  19331. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19332. */
  19333. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19334. /**
  19335. * Define if touch is enabled in the mouse input
  19336. */
  19337. touchEnabled: boolean;
  19338. /**
  19339. * Defines the camera the input is attached to.
  19340. */
  19341. camera: FreeCamera;
  19342. /**
  19343. * Defines the buttons associated with the input to handle camera move.
  19344. */
  19345. buttons: number[];
  19346. /**
  19347. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19348. */
  19349. angularSensibility: number;
  19350. private _pointerInput;
  19351. private _onMouseMove;
  19352. private _observer;
  19353. private previousPosition;
  19354. /**
  19355. * Observable for when a pointer move event occurs containing the move offset
  19356. */
  19357. onPointerMovedObservable: Observable<{
  19358. offsetX: number;
  19359. offsetY: number;
  19360. }>;
  19361. /**
  19362. * @hidden
  19363. * If the camera should be rotated automatically based on pointer movement
  19364. */
  19365. _allowCameraRotation: boolean;
  19366. /**
  19367. * Manage the mouse inputs to control the movement of a free camera.
  19368. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19369. * @param touchEnabled Defines if touch is enabled or not
  19370. */
  19371. constructor(
  19372. /**
  19373. * Define if touch is enabled in the mouse input
  19374. */
  19375. touchEnabled?: boolean);
  19376. /**
  19377. * Attach the input controls to a specific dom element to get the input from.
  19378. * @param element Defines the element the controls should be listened from
  19379. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19380. */
  19381. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19382. /**
  19383. * Called on JS contextmenu event.
  19384. * Override this method to provide functionality.
  19385. */
  19386. protected onContextMenu(evt: PointerEvent): void;
  19387. /**
  19388. * Detach the current controls from the specified dom element.
  19389. * @param element Defines the element to stop listening the inputs from
  19390. */
  19391. detachControl(element: Nullable<HTMLElement>): void;
  19392. /**
  19393. * Gets the class name of the current intput.
  19394. * @returns the class name
  19395. */
  19396. getClassName(): string;
  19397. /**
  19398. * Get the friendly name associated with the input class.
  19399. * @returns the input friendly name
  19400. */
  19401. getSimpleName(): string;
  19402. }
  19403. }
  19404. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19405. import { Nullable } from "babylonjs/types";
  19406. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19407. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19408. /**
  19409. * Manage the touch inputs to control the movement of a free camera.
  19410. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19411. */
  19412. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19413. /**
  19414. * Define if mouse events can be treated as touch events
  19415. */
  19416. allowMouse: boolean;
  19417. /**
  19418. * Defines the camera the input is attached to.
  19419. */
  19420. camera: FreeCamera;
  19421. /**
  19422. * Defines the touch sensibility for rotation.
  19423. * The higher the faster.
  19424. */
  19425. touchAngularSensibility: number;
  19426. /**
  19427. * Defines the touch sensibility for move.
  19428. * The higher the faster.
  19429. */
  19430. touchMoveSensibility: number;
  19431. private _offsetX;
  19432. private _offsetY;
  19433. private _pointerPressed;
  19434. private _pointerInput;
  19435. private _observer;
  19436. private _onLostFocus;
  19437. /**
  19438. * Manage the touch inputs to control the movement of a free camera.
  19439. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19440. * @param allowMouse Defines if mouse events can be treated as touch events
  19441. */
  19442. constructor(
  19443. /**
  19444. * Define if mouse events can be treated as touch events
  19445. */
  19446. allowMouse?: boolean);
  19447. /**
  19448. * Attach the input controls to a specific dom element to get the input from.
  19449. * @param element Defines the element the controls should be listened from
  19450. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19451. */
  19452. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19453. /**
  19454. * Detach the current controls from the specified dom element.
  19455. * @param element Defines the element to stop listening the inputs from
  19456. */
  19457. detachControl(element: Nullable<HTMLElement>): void;
  19458. /**
  19459. * Update the current camera state depending on the inputs that have been used this frame.
  19460. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19461. */
  19462. checkInputs(): void;
  19463. /**
  19464. * Gets the class name of the current intput.
  19465. * @returns the class name
  19466. */
  19467. getClassName(): string;
  19468. /**
  19469. * Get the friendly name associated with the input class.
  19470. * @returns the input friendly name
  19471. */
  19472. getSimpleName(): string;
  19473. }
  19474. }
  19475. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19476. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19477. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19478. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19479. import { Nullable } from "babylonjs/types";
  19480. /**
  19481. * Default Inputs manager for the FreeCamera.
  19482. * It groups all the default supported inputs for ease of use.
  19483. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19484. */
  19485. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19486. /**
  19487. * @hidden
  19488. */
  19489. _mouseInput: Nullable<FreeCameraMouseInput>;
  19490. /**
  19491. * Instantiates a new FreeCameraInputsManager.
  19492. * @param camera Defines the camera the inputs belong to
  19493. */
  19494. constructor(camera: FreeCamera);
  19495. /**
  19496. * Add keyboard input support to the input manager.
  19497. * @returns the current input manager
  19498. */
  19499. addKeyboard(): FreeCameraInputsManager;
  19500. /**
  19501. * Add mouse input support to the input manager.
  19502. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19503. * @returns the current input manager
  19504. */
  19505. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19506. /**
  19507. * Removes the mouse input support from the manager
  19508. * @returns the current input manager
  19509. */
  19510. removeMouse(): FreeCameraInputsManager;
  19511. /**
  19512. * Add touch input support to the input manager.
  19513. * @returns the current input manager
  19514. */
  19515. addTouch(): FreeCameraInputsManager;
  19516. /**
  19517. * Remove all attached input methods from a camera
  19518. */
  19519. clear(): void;
  19520. }
  19521. }
  19522. declare module "babylonjs/Cameras/freeCamera" {
  19523. import { Vector3 } from "babylonjs/Maths/math.vector";
  19524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19525. import { Scene } from "babylonjs/scene";
  19526. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19527. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19528. /**
  19529. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19530. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19531. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19532. */
  19533. export class FreeCamera extends TargetCamera {
  19534. /**
  19535. * Define the collision ellipsoid of the camera.
  19536. * This is helpful to simulate a camera body like the player body around the camera
  19537. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19538. */
  19539. ellipsoid: Vector3;
  19540. /**
  19541. * Define an offset for the position of the ellipsoid around the camera.
  19542. * This can be helpful to determine the center of the body near the gravity center of the body
  19543. * instead of its head.
  19544. */
  19545. ellipsoidOffset: Vector3;
  19546. /**
  19547. * Enable or disable collisions of the camera with the rest of the scene objects.
  19548. */
  19549. checkCollisions: boolean;
  19550. /**
  19551. * Enable or disable gravity on the camera.
  19552. */
  19553. applyGravity: boolean;
  19554. /**
  19555. * Define the input manager associated to the camera.
  19556. */
  19557. inputs: FreeCameraInputsManager;
  19558. /**
  19559. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19560. * Higher values reduce sensitivity.
  19561. */
  19562. get angularSensibility(): number;
  19563. /**
  19564. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19565. * Higher values reduce sensitivity.
  19566. */
  19567. set angularSensibility(value: number);
  19568. /**
  19569. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19570. */
  19571. get keysUp(): number[];
  19572. set keysUp(value: number[]);
  19573. /**
  19574. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19575. */
  19576. get keysUpward(): number[];
  19577. set keysUpward(value: number[]);
  19578. /**
  19579. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19580. */
  19581. get keysDown(): number[];
  19582. set keysDown(value: number[]);
  19583. /**
  19584. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19585. */
  19586. get keysDownward(): number[];
  19587. set keysDownward(value: number[]);
  19588. /**
  19589. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19590. */
  19591. get keysLeft(): number[];
  19592. set keysLeft(value: number[]);
  19593. /**
  19594. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19595. */
  19596. get keysRight(): number[];
  19597. set keysRight(value: number[]);
  19598. /**
  19599. * Event raised when the camera collide with a mesh in the scene.
  19600. */
  19601. onCollide: (collidedMesh: AbstractMesh) => void;
  19602. private _collider;
  19603. private _needMoveForGravity;
  19604. private _oldPosition;
  19605. private _diffPosition;
  19606. private _newPosition;
  19607. /** @hidden */
  19608. _localDirection: Vector3;
  19609. /** @hidden */
  19610. _transformedDirection: Vector3;
  19611. /**
  19612. * Instantiates a Free Camera.
  19613. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19614. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19615. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19616. * @param name Define the name of the camera in the scene
  19617. * @param position Define the start position of the camera in the scene
  19618. * @param scene Define the scene the camera belongs to
  19619. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19620. */
  19621. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19622. /**
  19623. * Attached controls to the current camera.
  19624. * @param element Defines the element the controls should be listened from
  19625. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19626. */
  19627. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19628. /**
  19629. * Detach the current controls from the camera.
  19630. * The camera will stop reacting to inputs.
  19631. * @param element Defines the element to stop listening the inputs from
  19632. */
  19633. detachControl(element: HTMLElement): void;
  19634. private _collisionMask;
  19635. /**
  19636. * Define a collision mask to limit the list of object the camera can collide with
  19637. */
  19638. get collisionMask(): number;
  19639. set collisionMask(mask: number);
  19640. /** @hidden */
  19641. _collideWithWorld(displacement: Vector3): void;
  19642. private _onCollisionPositionChange;
  19643. /** @hidden */
  19644. _checkInputs(): void;
  19645. /** @hidden */
  19646. _decideIfNeedsToMove(): boolean;
  19647. /** @hidden */
  19648. _updatePosition(): void;
  19649. /**
  19650. * Destroy the camera and release the current resources hold by it.
  19651. */
  19652. dispose(): void;
  19653. /**
  19654. * Gets the current object class name.
  19655. * @return the class name
  19656. */
  19657. getClassName(): string;
  19658. }
  19659. }
  19660. declare module "babylonjs/Gamepads/gamepad" {
  19661. import { Observable } from "babylonjs/Misc/observable";
  19662. /**
  19663. * Represents a gamepad control stick position
  19664. */
  19665. export class StickValues {
  19666. /**
  19667. * The x component of the control stick
  19668. */
  19669. x: number;
  19670. /**
  19671. * The y component of the control stick
  19672. */
  19673. y: number;
  19674. /**
  19675. * Initializes the gamepad x and y control stick values
  19676. * @param x The x component of the gamepad control stick value
  19677. * @param y The y component of the gamepad control stick value
  19678. */
  19679. constructor(
  19680. /**
  19681. * The x component of the control stick
  19682. */
  19683. x: number,
  19684. /**
  19685. * The y component of the control stick
  19686. */
  19687. y: number);
  19688. }
  19689. /**
  19690. * An interface which manages callbacks for gamepad button changes
  19691. */
  19692. export interface GamepadButtonChanges {
  19693. /**
  19694. * Called when a gamepad has been changed
  19695. */
  19696. changed: boolean;
  19697. /**
  19698. * Called when a gamepad press event has been triggered
  19699. */
  19700. pressChanged: boolean;
  19701. /**
  19702. * Called when a touch event has been triggered
  19703. */
  19704. touchChanged: boolean;
  19705. /**
  19706. * Called when a value has changed
  19707. */
  19708. valueChanged: boolean;
  19709. }
  19710. /**
  19711. * Represents a gamepad
  19712. */
  19713. export class Gamepad {
  19714. /**
  19715. * The id of the gamepad
  19716. */
  19717. id: string;
  19718. /**
  19719. * The index of the gamepad
  19720. */
  19721. index: number;
  19722. /**
  19723. * The browser gamepad
  19724. */
  19725. browserGamepad: any;
  19726. /**
  19727. * Specifies what type of gamepad this represents
  19728. */
  19729. type: number;
  19730. private _leftStick;
  19731. private _rightStick;
  19732. /** @hidden */
  19733. _isConnected: boolean;
  19734. private _leftStickAxisX;
  19735. private _leftStickAxisY;
  19736. private _rightStickAxisX;
  19737. private _rightStickAxisY;
  19738. /**
  19739. * Triggered when the left control stick has been changed
  19740. */
  19741. private _onleftstickchanged;
  19742. /**
  19743. * Triggered when the right control stick has been changed
  19744. */
  19745. private _onrightstickchanged;
  19746. /**
  19747. * Represents a gamepad controller
  19748. */
  19749. static GAMEPAD: number;
  19750. /**
  19751. * Represents a generic controller
  19752. */
  19753. static GENERIC: number;
  19754. /**
  19755. * Represents an XBox controller
  19756. */
  19757. static XBOX: number;
  19758. /**
  19759. * Represents a pose-enabled controller
  19760. */
  19761. static POSE_ENABLED: number;
  19762. /**
  19763. * Represents an Dual Shock controller
  19764. */
  19765. static DUALSHOCK: number;
  19766. /**
  19767. * Specifies whether the left control stick should be Y-inverted
  19768. */
  19769. protected _invertLeftStickY: boolean;
  19770. /**
  19771. * Specifies if the gamepad has been connected
  19772. */
  19773. get isConnected(): boolean;
  19774. /**
  19775. * Initializes the gamepad
  19776. * @param id The id of the gamepad
  19777. * @param index The index of the gamepad
  19778. * @param browserGamepad The browser gamepad
  19779. * @param leftStickX The x component of the left joystick
  19780. * @param leftStickY The y component of the left joystick
  19781. * @param rightStickX The x component of the right joystick
  19782. * @param rightStickY The y component of the right joystick
  19783. */
  19784. constructor(
  19785. /**
  19786. * The id of the gamepad
  19787. */
  19788. id: string,
  19789. /**
  19790. * The index of the gamepad
  19791. */
  19792. index: number,
  19793. /**
  19794. * The browser gamepad
  19795. */
  19796. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19797. /**
  19798. * Callback triggered when the left joystick has changed
  19799. * @param callback
  19800. */
  19801. onleftstickchanged(callback: (values: StickValues) => void): void;
  19802. /**
  19803. * Callback triggered when the right joystick has changed
  19804. * @param callback
  19805. */
  19806. onrightstickchanged(callback: (values: StickValues) => void): void;
  19807. /**
  19808. * Gets the left joystick
  19809. */
  19810. get leftStick(): StickValues;
  19811. /**
  19812. * Sets the left joystick values
  19813. */
  19814. set leftStick(newValues: StickValues);
  19815. /**
  19816. * Gets the right joystick
  19817. */
  19818. get rightStick(): StickValues;
  19819. /**
  19820. * Sets the right joystick value
  19821. */
  19822. set rightStick(newValues: StickValues);
  19823. /**
  19824. * Updates the gamepad joystick positions
  19825. */
  19826. update(): void;
  19827. /**
  19828. * Disposes the gamepad
  19829. */
  19830. dispose(): void;
  19831. }
  19832. /**
  19833. * Represents a generic gamepad
  19834. */
  19835. export class GenericPad extends Gamepad {
  19836. private _buttons;
  19837. private _onbuttondown;
  19838. private _onbuttonup;
  19839. /**
  19840. * Observable triggered when a button has been pressed
  19841. */
  19842. onButtonDownObservable: Observable<number>;
  19843. /**
  19844. * Observable triggered when a button has been released
  19845. */
  19846. onButtonUpObservable: Observable<number>;
  19847. /**
  19848. * Callback triggered when a button has been pressed
  19849. * @param callback Called when a button has been pressed
  19850. */
  19851. onbuttondown(callback: (buttonPressed: number) => void): void;
  19852. /**
  19853. * Callback triggered when a button has been released
  19854. * @param callback Called when a button has been released
  19855. */
  19856. onbuttonup(callback: (buttonReleased: number) => void): void;
  19857. /**
  19858. * Initializes the generic gamepad
  19859. * @param id The id of the generic gamepad
  19860. * @param index The index of the generic gamepad
  19861. * @param browserGamepad The browser gamepad
  19862. */
  19863. constructor(id: string, index: number, browserGamepad: any);
  19864. private _setButtonValue;
  19865. /**
  19866. * Updates the generic gamepad
  19867. */
  19868. update(): void;
  19869. /**
  19870. * Disposes the generic gamepad
  19871. */
  19872. dispose(): void;
  19873. }
  19874. }
  19875. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19876. import { Observable } from "babylonjs/Misc/observable";
  19877. import { Nullable } from "babylonjs/types";
  19878. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19879. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19880. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19881. import { Ray } from "babylonjs/Culling/ray";
  19882. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19883. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19884. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19885. /**
  19886. * Defines the types of pose enabled controllers that are supported
  19887. */
  19888. export enum PoseEnabledControllerType {
  19889. /**
  19890. * HTC Vive
  19891. */
  19892. VIVE = 0,
  19893. /**
  19894. * Oculus Rift
  19895. */
  19896. OCULUS = 1,
  19897. /**
  19898. * Windows mixed reality
  19899. */
  19900. WINDOWS = 2,
  19901. /**
  19902. * Samsung gear VR
  19903. */
  19904. GEAR_VR = 3,
  19905. /**
  19906. * Google Daydream
  19907. */
  19908. DAYDREAM = 4,
  19909. /**
  19910. * Generic
  19911. */
  19912. GENERIC = 5
  19913. }
  19914. /**
  19915. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19916. */
  19917. export interface MutableGamepadButton {
  19918. /**
  19919. * Value of the button/trigger
  19920. */
  19921. value: number;
  19922. /**
  19923. * If the button/trigger is currently touched
  19924. */
  19925. touched: boolean;
  19926. /**
  19927. * If the button/trigger is currently pressed
  19928. */
  19929. pressed: boolean;
  19930. }
  19931. /**
  19932. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19933. * @hidden
  19934. */
  19935. export interface ExtendedGamepadButton extends GamepadButton {
  19936. /**
  19937. * If the button/trigger is currently pressed
  19938. */
  19939. readonly pressed: boolean;
  19940. /**
  19941. * If the button/trigger is currently touched
  19942. */
  19943. readonly touched: boolean;
  19944. /**
  19945. * Value of the button/trigger
  19946. */
  19947. readonly value: number;
  19948. }
  19949. /** @hidden */
  19950. export interface _GamePadFactory {
  19951. /**
  19952. * Returns whether or not the current gamepad can be created for this type of controller.
  19953. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19954. * @returns true if it can be created, otherwise false
  19955. */
  19956. canCreate(gamepadInfo: any): boolean;
  19957. /**
  19958. * Creates a new instance of the Gamepad.
  19959. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19960. * @returns the new gamepad instance
  19961. */
  19962. create(gamepadInfo: any): Gamepad;
  19963. }
  19964. /**
  19965. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19966. */
  19967. export class PoseEnabledControllerHelper {
  19968. /** @hidden */
  19969. static _ControllerFactories: _GamePadFactory[];
  19970. /** @hidden */
  19971. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19972. /**
  19973. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19974. * @param vrGamepad the gamepad to initialized
  19975. * @returns a vr controller of the type the gamepad identified as
  19976. */
  19977. static InitiateController(vrGamepad: any): Gamepad;
  19978. }
  19979. /**
  19980. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19981. */
  19982. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19983. /**
  19984. * If the controller is used in a webXR session
  19985. */
  19986. isXR: boolean;
  19987. private _deviceRoomPosition;
  19988. private _deviceRoomRotationQuaternion;
  19989. /**
  19990. * The device position in babylon space
  19991. */
  19992. devicePosition: Vector3;
  19993. /**
  19994. * The device rotation in babylon space
  19995. */
  19996. deviceRotationQuaternion: Quaternion;
  19997. /**
  19998. * The scale factor of the device in babylon space
  19999. */
  20000. deviceScaleFactor: number;
  20001. /**
  20002. * (Likely devicePosition should be used instead) The device position in its room space
  20003. */
  20004. position: Vector3;
  20005. /**
  20006. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  20007. */
  20008. rotationQuaternion: Quaternion;
  20009. /**
  20010. * The type of controller (Eg. Windows mixed reality)
  20011. */
  20012. controllerType: PoseEnabledControllerType;
  20013. protected _calculatedPosition: Vector3;
  20014. private _calculatedRotation;
  20015. /**
  20016. * The raw pose from the device
  20017. */
  20018. rawPose: DevicePose;
  20019. private _trackPosition;
  20020. private _maxRotationDistFromHeadset;
  20021. private _draggedRoomRotation;
  20022. /**
  20023. * @hidden
  20024. */
  20025. _disableTrackPosition(fixedPosition: Vector3): void;
  20026. /**
  20027. * Internal, the mesh attached to the controller
  20028. * @hidden
  20029. */
  20030. _mesh: Nullable<AbstractMesh>;
  20031. private _poseControlledCamera;
  20032. private _leftHandSystemQuaternion;
  20033. /**
  20034. * Internal, matrix used to convert room space to babylon space
  20035. * @hidden
  20036. */
  20037. _deviceToWorld: Matrix;
  20038. /**
  20039. * Node to be used when casting a ray from the controller
  20040. * @hidden
  20041. */
  20042. _pointingPoseNode: Nullable<TransformNode>;
  20043. /**
  20044. * Name of the child mesh that can be used to cast a ray from the controller
  20045. */
  20046. static readonly POINTING_POSE: string;
  20047. /**
  20048. * Creates a new PoseEnabledController from a gamepad
  20049. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20050. */
  20051. constructor(browserGamepad: any);
  20052. private _workingMatrix;
  20053. /**
  20054. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20055. */
  20056. update(): void;
  20057. /**
  20058. * Updates only the pose device and mesh without doing any button event checking
  20059. */
  20060. protected _updatePoseAndMesh(): void;
  20061. /**
  20062. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20063. * @param poseData raw pose fromthe device
  20064. */
  20065. updateFromDevice(poseData: DevicePose): void;
  20066. /**
  20067. * @hidden
  20068. */
  20069. _meshAttachedObservable: Observable<AbstractMesh>;
  20070. /**
  20071. * Attaches a mesh to the controller
  20072. * @param mesh the mesh to be attached
  20073. */
  20074. attachToMesh(mesh: AbstractMesh): void;
  20075. /**
  20076. * Attaches the controllers mesh to a camera
  20077. * @param camera the camera the mesh should be attached to
  20078. */
  20079. attachToPoseControlledCamera(camera: TargetCamera): void;
  20080. /**
  20081. * Disposes of the controller
  20082. */
  20083. dispose(): void;
  20084. /**
  20085. * The mesh that is attached to the controller
  20086. */
  20087. get mesh(): Nullable<AbstractMesh>;
  20088. /**
  20089. * Gets the ray of the controller in the direction the controller is pointing
  20090. * @param length the length the resulting ray should be
  20091. * @returns a ray in the direction the controller is pointing
  20092. */
  20093. getForwardRay(length?: number): Ray;
  20094. }
  20095. }
  20096. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20097. import { Observable } from "babylonjs/Misc/observable";
  20098. import { Scene } from "babylonjs/scene";
  20099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20100. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20101. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20102. import { Nullable } from "babylonjs/types";
  20103. /**
  20104. * Defines the WebVRController object that represents controllers tracked in 3D space
  20105. */
  20106. export abstract class WebVRController extends PoseEnabledController {
  20107. /**
  20108. * Internal, the default controller model for the controller
  20109. */
  20110. protected _defaultModel: Nullable<AbstractMesh>;
  20111. /**
  20112. * Fired when the trigger state has changed
  20113. */
  20114. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20115. /**
  20116. * Fired when the main button state has changed
  20117. */
  20118. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20119. /**
  20120. * Fired when the secondary button state has changed
  20121. */
  20122. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20123. /**
  20124. * Fired when the pad state has changed
  20125. */
  20126. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20127. /**
  20128. * Fired when controllers stick values have changed
  20129. */
  20130. onPadValuesChangedObservable: Observable<StickValues>;
  20131. /**
  20132. * Array of button availible on the controller
  20133. */
  20134. protected _buttons: Array<MutableGamepadButton>;
  20135. private _onButtonStateChange;
  20136. /**
  20137. * Fired when a controller button's state has changed
  20138. * @param callback the callback containing the button that was modified
  20139. */
  20140. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20141. /**
  20142. * X and Y axis corresponding to the controllers joystick
  20143. */
  20144. pad: StickValues;
  20145. /**
  20146. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20147. */
  20148. hand: string;
  20149. /**
  20150. * The default controller model for the controller
  20151. */
  20152. get defaultModel(): Nullable<AbstractMesh>;
  20153. /**
  20154. * Creates a new WebVRController from a gamepad
  20155. * @param vrGamepad the gamepad that the WebVRController should be created from
  20156. */
  20157. constructor(vrGamepad: any);
  20158. /**
  20159. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20160. */
  20161. update(): void;
  20162. /**
  20163. * Function to be called when a button is modified
  20164. */
  20165. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20166. /**
  20167. * Loads a mesh and attaches it to the controller
  20168. * @param scene the scene the mesh should be added to
  20169. * @param meshLoaded callback for when the mesh has been loaded
  20170. */
  20171. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20172. private _setButtonValue;
  20173. private _changes;
  20174. private _checkChanges;
  20175. /**
  20176. * Disposes of th webVRCOntroller
  20177. */
  20178. dispose(): void;
  20179. }
  20180. }
  20181. declare module "babylonjs/Lights/hemisphericLight" {
  20182. import { Nullable } from "babylonjs/types";
  20183. import { Scene } from "babylonjs/scene";
  20184. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20185. import { Color3 } from "babylonjs/Maths/math.color";
  20186. import { Effect } from "babylonjs/Materials/effect";
  20187. import { Light } from "babylonjs/Lights/light";
  20188. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20189. /**
  20190. * The HemisphericLight simulates the ambient environment light,
  20191. * so the passed direction is the light reflection direction, not the incoming direction.
  20192. */
  20193. export class HemisphericLight extends Light {
  20194. /**
  20195. * The groundColor is the light in the opposite direction to the one specified during creation.
  20196. * 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.
  20197. */
  20198. groundColor: Color3;
  20199. /**
  20200. * The light reflection direction, not the incoming direction.
  20201. */
  20202. direction: Vector3;
  20203. /**
  20204. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20205. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20206. * The HemisphericLight can't cast shadows.
  20207. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20208. * @param name The friendly name of the light
  20209. * @param direction The direction of the light reflection
  20210. * @param scene The scene the light belongs to
  20211. */
  20212. constructor(name: string, direction: Vector3, scene: Scene);
  20213. protected _buildUniformLayout(): void;
  20214. /**
  20215. * Returns the string "HemisphericLight".
  20216. * @return The class name
  20217. */
  20218. getClassName(): string;
  20219. /**
  20220. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20221. * Returns the updated direction.
  20222. * @param target The target the direction should point to
  20223. * @return The computed direction
  20224. */
  20225. setDirectionToTarget(target: Vector3): Vector3;
  20226. /**
  20227. * Returns the shadow generator associated to the light.
  20228. * @returns Always null for hemispheric lights because it does not support shadows.
  20229. */
  20230. getShadowGenerator(): Nullable<IShadowGenerator>;
  20231. /**
  20232. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20233. * @param effect The effect to update
  20234. * @param lightIndex The index of the light in the effect to update
  20235. * @returns The hemispheric light
  20236. */
  20237. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20238. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20239. /**
  20240. * Computes the world matrix of the node
  20241. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20242. * @param useWasUpdatedFlag defines a reserved property
  20243. * @returns the world matrix
  20244. */
  20245. computeWorldMatrix(): Matrix;
  20246. /**
  20247. * Returns the integer 3.
  20248. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20249. */
  20250. getTypeID(): number;
  20251. /**
  20252. * Prepares the list of defines specific to the light type.
  20253. * @param defines the list of defines
  20254. * @param lightIndex defines the index of the light for the effect
  20255. */
  20256. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20257. }
  20258. }
  20259. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20260. /** @hidden */
  20261. export var vrMultiviewToSingleviewPixelShader: {
  20262. name: string;
  20263. shader: string;
  20264. };
  20265. }
  20266. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20267. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20268. import { Scene } from "babylonjs/scene";
  20269. /**
  20270. * Renders to multiple views with a single draw call
  20271. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20272. */
  20273. export class MultiviewRenderTarget extends RenderTargetTexture {
  20274. /**
  20275. * Creates a multiview render target
  20276. * @param scene scene used with the render target
  20277. * @param size the size of the render target (used for each view)
  20278. */
  20279. constructor(scene: Scene, size?: number | {
  20280. width: number;
  20281. height: number;
  20282. } | {
  20283. ratio: number;
  20284. });
  20285. /**
  20286. * @hidden
  20287. * @param faceIndex the face index, if its a cube texture
  20288. */
  20289. _bindFrameBuffer(faceIndex?: number): void;
  20290. /**
  20291. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20292. * @returns the view count
  20293. */
  20294. getViewCount(): number;
  20295. }
  20296. }
  20297. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20298. import { Camera } from "babylonjs/Cameras/camera";
  20299. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20300. import { Nullable } from "babylonjs/types";
  20301. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20302. import { Matrix } from "babylonjs/Maths/math.vector";
  20303. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20304. module "babylonjs/Engines/engine" {
  20305. interface Engine {
  20306. /**
  20307. * Creates a new multiview render target
  20308. * @param width defines the width of the texture
  20309. * @param height defines the height of the texture
  20310. * @returns the created multiview texture
  20311. */
  20312. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20313. /**
  20314. * Binds a multiview framebuffer to be drawn to
  20315. * @param multiviewTexture texture to bind
  20316. */
  20317. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20318. }
  20319. }
  20320. module "babylonjs/Cameras/camera" {
  20321. interface Camera {
  20322. /**
  20323. * @hidden
  20324. * 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)
  20325. */
  20326. _useMultiviewToSingleView: boolean;
  20327. /**
  20328. * @hidden
  20329. * 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)
  20330. */
  20331. _multiviewTexture: Nullable<RenderTargetTexture>;
  20332. /**
  20333. * @hidden
  20334. * ensures the multiview texture of the camera exists and has the specified width/height
  20335. * @param width height to set on the multiview texture
  20336. * @param height width to set on the multiview texture
  20337. */
  20338. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20339. }
  20340. }
  20341. module "babylonjs/scene" {
  20342. interface Scene {
  20343. /** @hidden */
  20344. _transformMatrixR: Matrix;
  20345. /** @hidden */
  20346. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20347. /** @hidden */
  20348. _createMultiviewUbo(): void;
  20349. /** @hidden */
  20350. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20351. /** @hidden */
  20352. _renderMultiviewToSingleView(camera: Camera): void;
  20353. }
  20354. }
  20355. }
  20356. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20357. import { Camera } from "babylonjs/Cameras/camera";
  20358. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20359. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20360. import "babylonjs/Engines/Extensions/engine.multiview";
  20361. /**
  20362. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20363. * This will not be used for webXR as it supports displaying texture arrays directly
  20364. */
  20365. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20366. /**
  20367. * Gets a string identifying the name of the class
  20368. * @returns "VRMultiviewToSingleviewPostProcess" string
  20369. */
  20370. getClassName(): string;
  20371. /**
  20372. * Initializes a VRMultiviewToSingleview
  20373. * @param name name of the post process
  20374. * @param camera camera to be applied to
  20375. * @param scaleFactor scaling factor to the size of the output texture
  20376. */
  20377. constructor(name: string, camera: Camera, scaleFactor: number);
  20378. }
  20379. }
  20380. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20381. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20382. import { Nullable } from "babylonjs/types";
  20383. import { Size } from "babylonjs/Maths/math.size";
  20384. import { Observable } from "babylonjs/Misc/observable";
  20385. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20386. /**
  20387. * Interface used to define additional presentation attributes
  20388. */
  20389. export interface IVRPresentationAttributes {
  20390. /**
  20391. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20392. */
  20393. highRefreshRate: boolean;
  20394. /**
  20395. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20396. */
  20397. foveationLevel: number;
  20398. }
  20399. module "babylonjs/Engines/engine" {
  20400. interface Engine {
  20401. /** @hidden */
  20402. _vrDisplay: any;
  20403. /** @hidden */
  20404. _vrSupported: boolean;
  20405. /** @hidden */
  20406. _oldSize: Size;
  20407. /** @hidden */
  20408. _oldHardwareScaleFactor: number;
  20409. /** @hidden */
  20410. _vrExclusivePointerMode: boolean;
  20411. /** @hidden */
  20412. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20413. /** @hidden */
  20414. _onVRDisplayPointerRestricted: () => void;
  20415. /** @hidden */
  20416. _onVRDisplayPointerUnrestricted: () => void;
  20417. /** @hidden */
  20418. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20419. /** @hidden */
  20420. _onVrDisplayDisconnect: Nullable<() => void>;
  20421. /** @hidden */
  20422. _onVrDisplayPresentChange: Nullable<() => void>;
  20423. /**
  20424. * Observable signaled when VR display mode changes
  20425. */
  20426. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20427. /**
  20428. * Observable signaled when VR request present is complete
  20429. */
  20430. onVRRequestPresentComplete: Observable<boolean>;
  20431. /**
  20432. * Observable signaled when VR request present starts
  20433. */
  20434. onVRRequestPresentStart: Observable<Engine>;
  20435. /**
  20436. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20437. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20438. */
  20439. isInVRExclusivePointerMode: boolean;
  20440. /**
  20441. * Gets a boolean indicating if a webVR device was detected
  20442. * @returns true if a webVR device was detected
  20443. */
  20444. isVRDevicePresent(): boolean;
  20445. /**
  20446. * Gets the current webVR device
  20447. * @returns the current webVR device (or null)
  20448. */
  20449. getVRDevice(): any;
  20450. /**
  20451. * Initializes a webVR display and starts listening to display change events
  20452. * The onVRDisplayChangedObservable will be notified upon these changes
  20453. * @returns A promise containing a VRDisplay and if vr is supported
  20454. */
  20455. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20456. /** @hidden */
  20457. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20458. /**
  20459. * Gets or sets the presentation attributes used to configure VR rendering
  20460. */
  20461. vrPresentationAttributes?: IVRPresentationAttributes;
  20462. /**
  20463. * Call this function to switch to webVR mode
  20464. * Will do nothing if webVR is not supported or if there is no webVR device
  20465. * @param options the webvr options provided to the camera. mainly used for multiview
  20466. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20467. */
  20468. enableVR(options: WebVROptions): void;
  20469. /** @hidden */
  20470. _onVRFullScreenTriggered(): void;
  20471. }
  20472. }
  20473. }
  20474. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20475. import { Nullable } from "babylonjs/types";
  20476. import { Observable } from "babylonjs/Misc/observable";
  20477. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20478. import { Scene } from "babylonjs/scene";
  20479. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20480. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20481. import { Node } from "babylonjs/node";
  20482. import { Ray } from "babylonjs/Culling/ray";
  20483. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20484. import "babylonjs/Engines/Extensions/engine.webVR";
  20485. /**
  20486. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20487. * IMPORTANT!! The data is right-hand data.
  20488. * @export
  20489. * @interface DevicePose
  20490. */
  20491. export interface DevicePose {
  20492. /**
  20493. * The position of the device, values in array are [x,y,z].
  20494. */
  20495. readonly position: Nullable<Float32Array>;
  20496. /**
  20497. * The linearVelocity of the device, values in array are [x,y,z].
  20498. */
  20499. readonly linearVelocity: Nullable<Float32Array>;
  20500. /**
  20501. * The linearAcceleration of the device, values in array are [x,y,z].
  20502. */
  20503. readonly linearAcceleration: Nullable<Float32Array>;
  20504. /**
  20505. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20506. */
  20507. readonly orientation: Nullable<Float32Array>;
  20508. /**
  20509. * The angularVelocity of the device, values in array are [x,y,z].
  20510. */
  20511. readonly angularVelocity: Nullable<Float32Array>;
  20512. /**
  20513. * The angularAcceleration of the device, values in array are [x,y,z].
  20514. */
  20515. readonly angularAcceleration: Nullable<Float32Array>;
  20516. }
  20517. /**
  20518. * Interface representing a pose controlled object in Babylon.
  20519. * A pose controlled object has both regular pose values as well as pose values
  20520. * from an external device such as a VR head mounted display
  20521. */
  20522. export interface PoseControlled {
  20523. /**
  20524. * The position of the object in babylon space.
  20525. */
  20526. position: Vector3;
  20527. /**
  20528. * The rotation quaternion of the object in babylon space.
  20529. */
  20530. rotationQuaternion: Quaternion;
  20531. /**
  20532. * The position of the device in babylon space.
  20533. */
  20534. devicePosition?: Vector3;
  20535. /**
  20536. * The rotation quaternion of the device in babylon space.
  20537. */
  20538. deviceRotationQuaternion: Quaternion;
  20539. /**
  20540. * The raw pose coming from the device.
  20541. */
  20542. rawPose: Nullable<DevicePose>;
  20543. /**
  20544. * The scale of the device to be used when translating from device space to babylon space.
  20545. */
  20546. deviceScaleFactor: number;
  20547. /**
  20548. * Updates the poseControlled values based on the input device pose.
  20549. * @param poseData the pose data to update the object with
  20550. */
  20551. updateFromDevice(poseData: DevicePose): void;
  20552. }
  20553. /**
  20554. * Set of options to customize the webVRCamera
  20555. */
  20556. export interface WebVROptions {
  20557. /**
  20558. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20559. */
  20560. trackPosition?: boolean;
  20561. /**
  20562. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20563. */
  20564. positionScale?: number;
  20565. /**
  20566. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20567. */
  20568. displayName?: string;
  20569. /**
  20570. * Should the native controller meshes be initialized. (default: true)
  20571. */
  20572. controllerMeshes?: boolean;
  20573. /**
  20574. * Creating a default HemiLight only on controllers. (default: true)
  20575. */
  20576. defaultLightingOnControllers?: boolean;
  20577. /**
  20578. * If you don't want to use the default VR button of the helper. (default: false)
  20579. */
  20580. useCustomVRButton?: boolean;
  20581. /**
  20582. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20583. */
  20584. customVRButton?: HTMLButtonElement;
  20585. /**
  20586. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20587. */
  20588. rayLength?: number;
  20589. /**
  20590. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20591. */
  20592. defaultHeight?: number;
  20593. /**
  20594. * If multiview should be used if availible (default: false)
  20595. */
  20596. useMultiview?: boolean;
  20597. }
  20598. /**
  20599. * This represents a WebVR camera.
  20600. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20601. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20602. */
  20603. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20604. private webVROptions;
  20605. /**
  20606. * @hidden
  20607. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20608. */
  20609. _vrDevice: any;
  20610. /**
  20611. * The rawPose of the vrDevice.
  20612. */
  20613. rawPose: Nullable<DevicePose>;
  20614. private _onVREnabled;
  20615. private _specsVersion;
  20616. private _attached;
  20617. private _frameData;
  20618. protected _descendants: Array<Node>;
  20619. private _deviceRoomPosition;
  20620. /** @hidden */
  20621. _deviceRoomRotationQuaternion: Quaternion;
  20622. private _standingMatrix;
  20623. /**
  20624. * Represents device position in babylon space.
  20625. */
  20626. devicePosition: Vector3;
  20627. /**
  20628. * Represents device rotation in babylon space.
  20629. */
  20630. deviceRotationQuaternion: Quaternion;
  20631. /**
  20632. * The scale of the device to be used when translating from device space to babylon space.
  20633. */
  20634. deviceScaleFactor: number;
  20635. private _deviceToWorld;
  20636. private _worldToDevice;
  20637. /**
  20638. * References to the webVR controllers for the vrDevice.
  20639. */
  20640. controllers: Array<WebVRController>;
  20641. /**
  20642. * Emits an event when a controller is attached.
  20643. */
  20644. onControllersAttachedObservable: Observable<WebVRController[]>;
  20645. /**
  20646. * Emits an event when a controller's mesh has been loaded;
  20647. */
  20648. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20649. /**
  20650. * Emits an event when the HMD's pose has been updated.
  20651. */
  20652. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20653. private _poseSet;
  20654. /**
  20655. * If the rig cameras be used as parent instead of this camera.
  20656. */
  20657. rigParenting: boolean;
  20658. private _lightOnControllers;
  20659. private _defaultHeight?;
  20660. /**
  20661. * Instantiates a WebVRFreeCamera.
  20662. * @param name The name of the WebVRFreeCamera
  20663. * @param position The starting anchor position for the camera
  20664. * @param scene The scene the camera belongs to
  20665. * @param webVROptions a set of customizable options for the webVRCamera
  20666. */
  20667. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20668. /**
  20669. * Gets the device distance from the ground in meters.
  20670. * @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.
  20671. */
  20672. deviceDistanceToRoomGround(): number;
  20673. /**
  20674. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20675. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20676. */
  20677. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20678. /**
  20679. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20680. * @returns A promise with a boolean set to if the standing matrix is supported.
  20681. */
  20682. useStandingMatrixAsync(): Promise<boolean>;
  20683. /**
  20684. * Disposes the camera
  20685. */
  20686. dispose(): void;
  20687. /**
  20688. * Gets a vrController by name.
  20689. * @param name The name of the controller to retreive
  20690. * @returns the controller matching the name specified or null if not found
  20691. */
  20692. getControllerByName(name: string): Nullable<WebVRController>;
  20693. private _leftController;
  20694. /**
  20695. * The controller corresponding to the users left hand.
  20696. */
  20697. get leftController(): Nullable<WebVRController>;
  20698. private _rightController;
  20699. /**
  20700. * The controller corresponding to the users right hand.
  20701. */
  20702. get rightController(): Nullable<WebVRController>;
  20703. /**
  20704. * Casts a ray forward from the vrCamera's gaze.
  20705. * @param length Length of the ray (default: 100)
  20706. * @returns the ray corresponding to the gaze
  20707. */
  20708. getForwardRay(length?: number): Ray;
  20709. /**
  20710. * @hidden
  20711. * Updates the camera based on device's frame data
  20712. */
  20713. _checkInputs(): void;
  20714. /**
  20715. * Updates the poseControlled values based on the input device pose.
  20716. * @param poseData Pose coming from the device
  20717. */
  20718. updateFromDevice(poseData: DevicePose): void;
  20719. private _htmlElementAttached;
  20720. private _detachIfAttached;
  20721. /**
  20722. * WebVR's attach control will start broadcasting frames to the device.
  20723. * Note that in certain browsers (chrome for example) this function must be called
  20724. * within a user-interaction callback. Example:
  20725. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20726. *
  20727. * @param element html element to attach the vrDevice to
  20728. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20729. */
  20730. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20731. /**
  20732. * Detaches the camera from the html element and disables VR
  20733. *
  20734. * @param element html element to detach from
  20735. */
  20736. detachControl(element: HTMLElement): void;
  20737. /**
  20738. * @returns the name of this class
  20739. */
  20740. getClassName(): string;
  20741. /**
  20742. * Calls resetPose on the vrDisplay
  20743. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20744. */
  20745. resetToCurrentRotation(): void;
  20746. /**
  20747. * @hidden
  20748. * Updates the rig cameras (left and right eye)
  20749. */
  20750. _updateRigCameras(): void;
  20751. private _workingVector;
  20752. private _oneVector;
  20753. private _workingMatrix;
  20754. private updateCacheCalled;
  20755. private _correctPositionIfNotTrackPosition;
  20756. /**
  20757. * @hidden
  20758. * Updates the cached values of the camera
  20759. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20760. */
  20761. _updateCache(ignoreParentClass?: boolean): void;
  20762. /**
  20763. * @hidden
  20764. * Get current device position in babylon world
  20765. */
  20766. _computeDevicePosition(): void;
  20767. /**
  20768. * Updates the current device position and rotation in the babylon world
  20769. */
  20770. update(): void;
  20771. /**
  20772. * @hidden
  20773. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20774. * @returns an identity matrix
  20775. */
  20776. _getViewMatrix(): Matrix;
  20777. private _tmpMatrix;
  20778. /**
  20779. * This function is called by the two RIG cameras.
  20780. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20781. * @hidden
  20782. */
  20783. _getWebVRViewMatrix(): Matrix;
  20784. /** @hidden */
  20785. _getWebVRProjectionMatrix(): Matrix;
  20786. private _onGamepadConnectedObserver;
  20787. private _onGamepadDisconnectedObserver;
  20788. private _updateCacheWhenTrackingDisabledObserver;
  20789. /**
  20790. * Initializes the controllers and their meshes
  20791. */
  20792. initControllers(): void;
  20793. }
  20794. }
  20795. declare module "babylonjs/Materials/materialHelper" {
  20796. import { Nullable } from "babylonjs/types";
  20797. import { Scene } from "babylonjs/scene";
  20798. import { Engine } from "babylonjs/Engines/engine";
  20799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20800. import { Light } from "babylonjs/Lights/light";
  20801. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20802. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20803. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20804. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20805. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20806. /**
  20807. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20808. *
  20809. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20810. *
  20811. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20812. */
  20813. export class MaterialHelper {
  20814. /**
  20815. * Bind the current view position to an effect.
  20816. * @param effect The effect to be bound
  20817. * @param scene The scene the eyes position is used from
  20818. * @param variableName name of the shader variable that will hold the eye position
  20819. */
  20820. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20821. /**
  20822. * Helps preparing the defines values about the UVs in used in the effect.
  20823. * UVs are shared as much as we can accross channels in the shaders.
  20824. * @param texture The texture we are preparing the UVs for
  20825. * @param defines The defines to update
  20826. * @param key The channel key "diffuse", "specular"... used in the shader
  20827. */
  20828. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20829. /**
  20830. * Binds a texture matrix value to its corrsponding uniform
  20831. * @param texture The texture to bind the matrix for
  20832. * @param uniformBuffer The uniform buffer receivin the data
  20833. * @param key The channel key "diffuse", "specular"... used in the shader
  20834. */
  20835. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20836. /**
  20837. * Gets the current status of the fog (should it be enabled?)
  20838. * @param mesh defines the mesh to evaluate for fog support
  20839. * @param scene defines the hosting scene
  20840. * @returns true if fog must be enabled
  20841. */
  20842. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20843. /**
  20844. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20845. * @param mesh defines the current mesh
  20846. * @param scene defines the current scene
  20847. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20848. * @param pointsCloud defines if point cloud rendering has to be turned on
  20849. * @param fogEnabled defines if fog has to be turned on
  20850. * @param alphaTest defines if alpha testing has to be turned on
  20851. * @param defines defines the current list of defines
  20852. */
  20853. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20854. /**
  20855. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20856. * @param scene defines the current scene
  20857. * @param engine defines the current engine
  20858. * @param defines specifies the list of active defines
  20859. * @param useInstances defines if instances have to be turned on
  20860. * @param useClipPlane defines if clip plane have to be turned on
  20861. * @param useInstances defines if instances have to be turned on
  20862. * @param useThinInstances defines if thin instances have to be turned on
  20863. */
  20864. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20865. /**
  20866. * Prepares the defines for bones
  20867. * @param mesh The mesh containing the geometry data we will draw
  20868. * @param defines The defines to update
  20869. */
  20870. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20871. /**
  20872. * Prepares the defines for morph targets
  20873. * @param mesh The mesh containing the geometry data we will draw
  20874. * @param defines The defines to update
  20875. */
  20876. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20877. /**
  20878. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20879. * @param mesh The mesh containing the geometry data we will draw
  20880. * @param defines The defines to update
  20881. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20882. * @param useBones Precise whether bones should be used or not (override mesh info)
  20883. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20884. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20885. * @returns false if defines are considered not dirty and have not been checked
  20886. */
  20887. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20888. /**
  20889. * Prepares the defines related to multiview
  20890. * @param scene The scene we are intending to draw
  20891. * @param defines The defines to update
  20892. */
  20893. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20894. /**
  20895. * Prepares the defines related to the prepass
  20896. * @param scene The scene we are intending to draw
  20897. * @param defines The defines to update
  20898. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20899. */
  20900. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20901. /**
  20902. * Prepares the defines related to the light information passed in parameter
  20903. * @param scene The scene we are intending to draw
  20904. * @param mesh The mesh the effect is compiling for
  20905. * @param light The light the effect is compiling for
  20906. * @param lightIndex The index of the light
  20907. * @param defines The defines to update
  20908. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20909. * @param state Defines the current state regarding what is needed (normals, etc...)
  20910. */
  20911. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20912. needNormals: boolean;
  20913. needRebuild: boolean;
  20914. shadowEnabled: boolean;
  20915. specularEnabled: boolean;
  20916. lightmapMode: boolean;
  20917. }): void;
  20918. /**
  20919. * Prepares the defines related to the light information passed in parameter
  20920. * @param scene The scene we are intending to draw
  20921. * @param mesh The mesh the effect is compiling for
  20922. * @param defines The defines to update
  20923. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20924. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20925. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20926. * @returns true if normals will be required for the rest of the effect
  20927. */
  20928. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20929. /**
  20930. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20931. * @param lightIndex defines the light index
  20932. * @param uniformsList The uniform list
  20933. * @param samplersList The sampler list
  20934. * @param projectedLightTexture defines if projected texture must be used
  20935. * @param uniformBuffersList defines an optional list of uniform buffers
  20936. */
  20937. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20938. /**
  20939. * Prepares the uniforms and samplers list to be used in the effect
  20940. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20941. * @param samplersList The sampler list
  20942. * @param defines The defines helping in the list generation
  20943. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20944. */
  20945. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20946. /**
  20947. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20948. * @param defines The defines to update while falling back
  20949. * @param fallbacks The authorized effect fallbacks
  20950. * @param maxSimultaneousLights The maximum number of lights allowed
  20951. * @param rank the current rank of the Effect
  20952. * @returns The newly affected rank
  20953. */
  20954. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20955. private static _TmpMorphInfluencers;
  20956. /**
  20957. * Prepares the list of attributes required for morph targets according to the effect defines.
  20958. * @param attribs The current list of supported attribs
  20959. * @param mesh The mesh to prepare the morph targets attributes for
  20960. * @param influencers The number of influencers
  20961. */
  20962. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20963. /**
  20964. * Prepares the list of attributes required for morph targets according to the effect defines.
  20965. * @param attribs The current list of supported attribs
  20966. * @param mesh The mesh to prepare the morph targets attributes for
  20967. * @param defines The current Defines of the effect
  20968. */
  20969. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20970. /**
  20971. * Prepares the list of attributes required for bones according to the effect defines.
  20972. * @param attribs The current list of supported attribs
  20973. * @param mesh The mesh to prepare the bones attributes for
  20974. * @param defines The current Defines of the effect
  20975. * @param fallbacks The current efffect fallback strategy
  20976. */
  20977. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20978. /**
  20979. * Check and prepare the list of attributes required for instances according to the effect defines.
  20980. * @param attribs The current list of supported attribs
  20981. * @param defines The current MaterialDefines of the effect
  20982. */
  20983. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20984. /**
  20985. * Add the list of attributes required for instances to the attribs array.
  20986. * @param attribs The current list of supported attribs
  20987. */
  20988. static PushAttributesForInstances(attribs: string[]): void;
  20989. /**
  20990. * Binds the light information to the effect.
  20991. * @param light The light containing the generator
  20992. * @param effect The effect we are binding the data to
  20993. * @param lightIndex The light index in the effect used to render
  20994. */
  20995. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20996. /**
  20997. * Binds the lights information from the scene to the effect for the given mesh.
  20998. * @param light Light to bind
  20999. * @param lightIndex Light index
  21000. * @param scene The scene where the light belongs to
  21001. * @param effect The effect we are binding the data to
  21002. * @param useSpecular Defines if specular is supported
  21003. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21004. */
  21005. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  21006. /**
  21007. * Binds the lights information from the scene to the effect for the given mesh.
  21008. * @param scene The scene the lights belongs to
  21009. * @param mesh The mesh we are binding the information to render
  21010. * @param effect The effect we are binding the data to
  21011. * @param defines The generated defines for the effect
  21012. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  21013. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21014. */
  21015. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  21016. private static _tempFogColor;
  21017. /**
  21018. * Binds the fog information from the scene to the effect for the given mesh.
  21019. * @param scene The scene the lights belongs to
  21020. * @param mesh The mesh we are binding the information to render
  21021. * @param effect The effect we are binding the data to
  21022. * @param linearSpace Defines if the fog effect is applied in linear space
  21023. */
  21024. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21025. /**
  21026. * Binds the bones information from the mesh to the effect.
  21027. * @param mesh The mesh we are binding the information to render
  21028. * @param effect The effect we are binding the data to
  21029. */
  21030. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  21031. /**
  21032. * Binds the morph targets information from the mesh to the effect.
  21033. * @param abstractMesh The mesh we are binding the information to render
  21034. * @param effect The effect we are binding the data to
  21035. */
  21036. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21037. /**
  21038. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21039. * @param defines The generated defines used in the effect
  21040. * @param effect The effect we are binding the data to
  21041. * @param scene The scene we are willing to render with logarithmic scale for
  21042. */
  21043. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21044. /**
  21045. * Binds the clip plane information from the scene to the effect.
  21046. * @param scene The scene the clip plane information are extracted from
  21047. * @param effect The effect we are binding the data to
  21048. */
  21049. static BindClipPlane(effect: Effect, scene: Scene): void;
  21050. }
  21051. }
  21052. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21053. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21054. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21055. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21056. import { Nullable } from "babylonjs/types";
  21057. import { Effect } from "babylonjs/Materials/effect";
  21058. import { Matrix } from "babylonjs/Maths/math.vector";
  21059. import { Scene } from "babylonjs/scene";
  21060. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21061. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21062. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21063. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21064. import { Observable } from "babylonjs/Misc/observable";
  21065. /**
  21066. * Block used to expose an input value
  21067. */
  21068. export class InputBlock extends NodeMaterialBlock {
  21069. private _mode;
  21070. private _associatedVariableName;
  21071. private _storedValue;
  21072. private _valueCallback;
  21073. private _type;
  21074. private _animationType;
  21075. /** Gets or set a value used to limit the range of float values */
  21076. min: number;
  21077. /** Gets or set a value used to limit the range of float values */
  21078. max: number;
  21079. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21080. isBoolean: boolean;
  21081. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21082. matrixMode: number;
  21083. /** @hidden */
  21084. _systemValue: Nullable<NodeMaterialSystemValues>;
  21085. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21086. isConstant: boolean;
  21087. /** Gets or sets the group to use to display this block in the Inspector */
  21088. groupInInspector: string;
  21089. /** Gets an observable raised when the value is changed */
  21090. onValueChangedObservable: Observable<InputBlock>;
  21091. /**
  21092. * Gets or sets the connection point type (default is float)
  21093. */
  21094. get type(): NodeMaterialBlockConnectionPointTypes;
  21095. /**
  21096. * Creates a new InputBlock
  21097. * @param name defines the block name
  21098. * @param target defines the target of that block (Vertex by default)
  21099. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21100. */
  21101. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21102. /**
  21103. * Validates if a name is a reserve word.
  21104. * @param newName the new name to be given to the node.
  21105. * @returns false if the name is a reserve word, else true.
  21106. */
  21107. validateBlockName(newName: string): boolean;
  21108. /**
  21109. * Gets the output component
  21110. */
  21111. get output(): NodeMaterialConnectionPoint;
  21112. /**
  21113. * Set the source of this connection point to a vertex attribute
  21114. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21115. * @returns the current connection point
  21116. */
  21117. setAsAttribute(attributeName?: string): InputBlock;
  21118. /**
  21119. * Set the source of this connection point to a system value
  21120. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21121. * @returns the current connection point
  21122. */
  21123. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21124. /**
  21125. * Gets or sets the value of that point.
  21126. * Please note that this value will be ignored if valueCallback is defined
  21127. */
  21128. get value(): any;
  21129. set value(value: any);
  21130. /**
  21131. * Gets or sets a callback used to get the value of that point.
  21132. * Please note that setting this value will force the connection point to ignore the value property
  21133. */
  21134. get valueCallback(): () => any;
  21135. set valueCallback(value: () => any);
  21136. /**
  21137. * Gets or sets the associated variable name in the shader
  21138. */
  21139. get associatedVariableName(): string;
  21140. set associatedVariableName(value: string);
  21141. /** Gets or sets the type of animation applied to the input */
  21142. get animationType(): AnimatedInputBlockTypes;
  21143. set animationType(value: AnimatedInputBlockTypes);
  21144. /**
  21145. * Gets a boolean indicating that this connection point not defined yet
  21146. */
  21147. get isUndefined(): boolean;
  21148. /**
  21149. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21150. * In this case the connection point name must be the name of the uniform to use.
  21151. * Can only be set on inputs
  21152. */
  21153. get isUniform(): boolean;
  21154. set isUniform(value: boolean);
  21155. /**
  21156. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21157. * In this case the connection point name must be the name of the attribute to use
  21158. * Can only be set on inputs
  21159. */
  21160. get isAttribute(): boolean;
  21161. set isAttribute(value: boolean);
  21162. /**
  21163. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21164. * Can only be set on exit points
  21165. */
  21166. get isVarying(): boolean;
  21167. set isVarying(value: boolean);
  21168. /**
  21169. * Gets a boolean indicating that the current connection point is a system value
  21170. */
  21171. get isSystemValue(): boolean;
  21172. /**
  21173. * Gets or sets the current well known value or null if not defined as a system value
  21174. */
  21175. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21176. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21177. /**
  21178. * Gets the current class name
  21179. * @returns the class name
  21180. */
  21181. getClassName(): string;
  21182. /**
  21183. * Animate the input if animationType !== None
  21184. * @param scene defines the rendering scene
  21185. */
  21186. animate(scene: Scene): void;
  21187. private _emitDefine;
  21188. initialize(state: NodeMaterialBuildState): void;
  21189. /**
  21190. * Set the input block to its default value (based on its type)
  21191. */
  21192. setDefaultValue(): void;
  21193. private _emitConstant;
  21194. /** @hidden */
  21195. get _noContextSwitch(): boolean;
  21196. private _emit;
  21197. /** @hidden */
  21198. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21199. /** @hidden */
  21200. _transmit(effect: Effect, scene: Scene): void;
  21201. protected _buildBlock(state: NodeMaterialBuildState): void;
  21202. protected _dumpPropertiesCode(): string;
  21203. dispose(): void;
  21204. serialize(): any;
  21205. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21206. }
  21207. }
  21208. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21209. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21210. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21211. import { Nullable } from "babylonjs/types";
  21212. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21213. import { Observable } from "babylonjs/Misc/observable";
  21214. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21215. /**
  21216. * Enum used to define the compatibility state between two connection points
  21217. */
  21218. export enum NodeMaterialConnectionPointCompatibilityStates {
  21219. /** Points are compatibles */
  21220. Compatible = 0,
  21221. /** Points are incompatible because of their types */
  21222. TypeIncompatible = 1,
  21223. /** Points are incompatible because of their targets (vertex vs fragment) */
  21224. TargetIncompatible = 2
  21225. }
  21226. /**
  21227. * Defines the direction of a connection point
  21228. */
  21229. export enum NodeMaterialConnectionPointDirection {
  21230. /** Input */
  21231. Input = 0,
  21232. /** Output */
  21233. Output = 1
  21234. }
  21235. /**
  21236. * Defines a connection point for a block
  21237. */
  21238. export class NodeMaterialConnectionPoint {
  21239. /** @hidden */
  21240. _ownerBlock: NodeMaterialBlock;
  21241. /** @hidden */
  21242. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21243. private _endpoints;
  21244. private _associatedVariableName;
  21245. private _direction;
  21246. /** @hidden */
  21247. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21248. /** @hidden */
  21249. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21250. private _type;
  21251. /** @hidden */
  21252. _enforceAssociatedVariableName: boolean;
  21253. /** Gets the direction of the point */
  21254. get direction(): NodeMaterialConnectionPointDirection;
  21255. /** Indicates that this connection point needs dual validation before being connected to another point */
  21256. needDualDirectionValidation: boolean;
  21257. /**
  21258. * Gets or sets the additional types supported by this connection point
  21259. */
  21260. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21261. /**
  21262. * Gets or sets the additional types excluded by this connection point
  21263. */
  21264. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21265. /**
  21266. * Observable triggered when this point is connected
  21267. */
  21268. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21269. /**
  21270. * Gets or sets the associated variable name in the shader
  21271. */
  21272. get associatedVariableName(): string;
  21273. set associatedVariableName(value: string);
  21274. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21275. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21276. /**
  21277. * Gets or sets the connection point type (default is float)
  21278. */
  21279. get type(): NodeMaterialBlockConnectionPointTypes;
  21280. set type(value: NodeMaterialBlockConnectionPointTypes);
  21281. /**
  21282. * Gets or sets the connection point name
  21283. */
  21284. name: string;
  21285. /**
  21286. * Gets or sets the connection point name
  21287. */
  21288. displayName: string;
  21289. /**
  21290. * Gets or sets a boolean indicating that this connection point can be omitted
  21291. */
  21292. isOptional: boolean;
  21293. /**
  21294. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21295. */
  21296. isExposedOnFrame: boolean;
  21297. /**
  21298. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21299. */
  21300. define: string;
  21301. /** @hidden */
  21302. _prioritizeVertex: boolean;
  21303. private _target;
  21304. /** Gets or sets the target of that connection point */
  21305. get target(): NodeMaterialBlockTargets;
  21306. set target(value: NodeMaterialBlockTargets);
  21307. /**
  21308. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21309. */
  21310. get isConnected(): boolean;
  21311. /**
  21312. * Gets a boolean indicating that the current point is connected to an input block
  21313. */
  21314. get isConnectedToInputBlock(): boolean;
  21315. /**
  21316. * Gets a the connected input block (if any)
  21317. */
  21318. get connectInputBlock(): Nullable<InputBlock>;
  21319. /** Get the other side of the connection (if any) */
  21320. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21321. /** Get the block that owns this connection point */
  21322. get ownerBlock(): NodeMaterialBlock;
  21323. /** Get the block connected on the other side of this connection (if any) */
  21324. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21325. /** Get the block connected on the endpoints of this connection (if any) */
  21326. get connectedBlocks(): Array<NodeMaterialBlock>;
  21327. /** Gets the list of connected endpoints */
  21328. get endpoints(): NodeMaterialConnectionPoint[];
  21329. /** Gets a boolean indicating if that output point is connected to at least one input */
  21330. get hasEndpoints(): boolean;
  21331. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21332. get isConnectedInVertexShader(): boolean;
  21333. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21334. get isConnectedInFragmentShader(): boolean;
  21335. /**
  21336. * Creates a block suitable to be used as an input for this input point.
  21337. * If null is returned, a block based on the point type will be created.
  21338. * @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
  21339. */
  21340. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21341. /**
  21342. * Creates a new connection point
  21343. * @param name defines the connection point name
  21344. * @param ownerBlock defines the block hosting this connection point
  21345. * @param direction defines the direction of the connection point
  21346. */
  21347. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21348. /**
  21349. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21350. * @returns the class name
  21351. */
  21352. getClassName(): string;
  21353. /**
  21354. * Gets a boolean indicating if the current point can be connected to another point
  21355. * @param connectionPoint defines the other connection point
  21356. * @returns a boolean
  21357. */
  21358. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21359. /**
  21360. * Gets a number indicating if the current point can be connected to another point
  21361. * @param connectionPoint defines the other connection point
  21362. * @returns a number defining the compatibility state
  21363. */
  21364. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21365. /**
  21366. * Connect this point to another connection point
  21367. * @param connectionPoint defines the other connection point
  21368. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21369. * @returns the current connection point
  21370. */
  21371. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21372. /**
  21373. * Disconnect this point from one of his endpoint
  21374. * @param endpoint defines the other connection point
  21375. * @returns the current connection point
  21376. */
  21377. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21378. /**
  21379. * Serializes this point in a JSON representation
  21380. * @param isInput defines if the connection point is an input (default is true)
  21381. * @returns the serialized point object
  21382. */
  21383. serialize(isInput?: boolean): any;
  21384. /**
  21385. * Release resources
  21386. */
  21387. dispose(): void;
  21388. }
  21389. }
  21390. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21391. /**
  21392. * Enum used to define the material modes
  21393. */
  21394. export enum NodeMaterialModes {
  21395. /** Regular material */
  21396. Material = 0,
  21397. /** For post process */
  21398. PostProcess = 1,
  21399. /** For particle system */
  21400. Particle = 2
  21401. }
  21402. }
  21403. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21404. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21405. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21406. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21407. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21409. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21410. import { Effect } from "babylonjs/Materials/effect";
  21411. import { Mesh } from "babylonjs/Meshes/mesh";
  21412. import { Nullable } from "babylonjs/types";
  21413. import { Texture } from "babylonjs/Materials/Textures/texture";
  21414. import { Scene } from "babylonjs/scene";
  21415. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21416. /**
  21417. * Block used to read a texture from a sampler
  21418. */
  21419. export class TextureBlock extends NodeMaterialBlock {
  21420. private _defineName;
  21421. private _linearDefineName;
  21422. private _gammaDefineName;
  21423. private _tempTextureRead;
  21424. private _samplerName;
  21425. private _transformedUVName;
  21426. private _textureTransformName;
  21427. private _textureInfoName;
  21428. private _mainUVName;
  21429. private _mainUVDefineName;
  21430. private _fragmentOnly;
  21431. /**
  21432. * Gets or sets the texture associated with the node
  21433. */
  21434. texture: Nullable<Texture>;
  21435. /**
  21436. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21437. */
  21438. convertToGammaSpace: boolean;
  21439. /**
  21440. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21441. */
  21442. convertToLinearSpace: boolean;
  21443. /**
  21444. * Create a new TextureBlock
  21445. * @param name defines the block name
  21446. */
  21447. constructor(name: string, fragmentOnly?: boolean);
  21448. /**
  21449. * Gets the current class name
  21450. * @returns the class name
  21451. */
  21452. getClassName(): string;
  21453. /**
  21454. * Gets the uv input component
  21455. */
  21456. get uv(): NodeMaterialConnectionPoint;
  21457. /**
  21458. * Gets the rgba output component
  21459. */
  21460. get rgba(): NodeMaterialConnectionPoint;
  21461. /**
  21462. * Gets the rgb output component
  21463. */
  21464. get rgb(): NodeMaterialConnectionPoint;
  21465. /**
  21466. * Gets the r output component
  21467. */
  21468. get r(): NodeMaterialConnectionPoint;
  21469. /**
  21470. * Gets the g output component
  21471. */
  21472. get g(): NodeMaterialConnectionPoint;
  21473. /**
  21474. * Gets the b output component
  21475. */
  21476. get b(): NodeMaterialConnectionPoint;
  21477. /**
  21478. * Gets the a output component
  21479. */
  21480. get a(): NodeMaterialConnectionPoint;
  21481. get target(): NodeMaterialBlockTargets;
  21482. autoConfigure(material: NodeMaterial): void;
  21483. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21484. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21485. isReady(): boolean;
  21486. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21487. private get _isMixed();
  21488. private _injectVertexCode;
  21489. private _writeTextureRead;
  21490. private _writeOutput;
  21491. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21492. protected _dumpPropertiesCode(): string;
  21493. serialize(): any;
  21494. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21495. }
  21496. }
  21497. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21498. /** @hidden */
  21499. export var reflectionFunction: {
  21500. name: string;
  21501. shader: string;
  21502. };
  21503. }
  21504. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21505. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21506. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21507. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21508. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21509. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21510. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21511. import { Effect } from "babylonjs/Materials/effect";
  21512. import { Mesh } from "babylonjs/Meshes/mesh";
  21513. import { Nullable } from "babylonjs/types";
  21514. import { Scene } from "babylonjs/scene";
  21515. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21516. /**
  21517. * Base block used to read a reflection texture from a sampler
  21518. */
  21519. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21520. /** @hidden */
  21521. _define3DName: string;
  21522. /** @hidden */
  21523. _defineCubicName: string;
  21524. /** @hidden */
  21525. _defineExplicitName: string;
  21526. /** @hidden */
  21527. _defineProjectionName: string;
  21528. /** @hidden */
  21529. _defineLocalCubicName: string;
  21530. /** @hidden */
  21531. _defineSphericalName: string;
  21532. /** @hidden */
  21533. _definePlanarName: string;
  21534. /** @hidden */
  21535. _defineEquirectangularName: string;
  21536. /** @hidden */
  21537. _defineMirroredEquirectangularFixedName: string;
  21538. /** @hidden */
  21539. _defineEquirectangularFixedName: string;
  21540. /** @hidden */
  21541. _defineSkyboxName: string;
  21542. /** @hidden */
  21543. _defineOppositeZ: string;
  21544. /** @hidden */
  21545. _cubeSamplerName: string;
  21546. /** @hidden */
  21547. _2DSamplerName: string;
  21548. protected _positionUVWName: string;
  21549. protected _directionWName: string;
  21550. protected _reflectionVectorName: string;
  21551. /** @hidden */
  21552. _reflectionCoordsName: string;
  21553. /** @hidden */
  21554. _reflectionMatrixName: string;
  21555. protected _reflectionColorName: string;
  21556. /**
  21557. * Gets or sets the texture associated with the node
  21558. */
  21559. texture: Nullable<BaseTexture>;
  21560. /**
  21561. * Create a new ReflectionTextureBaseBlock
  21562. * @param name defines the block name
  21563. */
  21564. constructor(name: string);
  21565. /**
  21566. * Gets the current class name
  21567. * @returns the class name
  21568. */
  21569. getClassName(): string;
  21570. /**
  21571. * Gets the world position input component
  21572. */
  21573. abstract get position(): NodeMaterialConnectionPoint;
  21574. /**
  21575. * Gets the world position input component
  21576. */
  21577. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21578. /**
  21579. * Gets the world normal input component
  21580. */
  21581. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21582. /**
  21583. * Gets the world input component
  21584. */
  21585. abstract get world(): NodeMaterialConnectionPoint;
  21586. /**
  21587. * Gets the camera (or eye) position component
  21588. */
  21589. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21590. /**
  21591. * Gets the view input component
  21592. */
  21593. abstract get view(): NodeMaterialConnectionPoint;
  21594. protected _getTexture(): Nullable<BaseTexture>;
  21595. autoConfigure(material: NodeMaterial): void;
  21596. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21597. isReady(): boolean;
  21598. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21599. /**
  21600. * Gets the code to inject in the vertex shader
  21601. * @param state current state of the node material building
  21602. * @returns the shader code
  21603. */
  21604. handleVertexSide(state: NodeMaterialBuildState): string;
  21605. /**
  21606. * Handles the inits for the fragment code path
  21607. * @param state node material build state
  21608. */
  21609. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21610. /**
  21611. * Generates the reflection coords code for the fragment code path
  21612. * @param worldNormalVarName name of the world normal variable
  21613. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21614. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21615. * @returns the shader code
  21616. */
  21617. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21618. /**
  21619. * Generates the reflection color code for the fragment code path
  21620. * @param lodVarName name of the lod variable
  21621. * @param swizzleLookupTexture swizzle to use for the final color variable
  21622. * @returns the shader code
  21623. */
  21624. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21625. /**
  21626. * Generates the code corresponding to the connected output points
  21627. * @param state node material build state
  21628. * @param varName name of the variable to output
  21629. * @returns the shader code
  21630. */
  21631. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21632. protected _buildBlock(state: NodeMaterialBuildState): this;
  21633. protected _dumpPropertiesCode(): string;
  21634. serialize(): any;
  21635. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21636. }
  21637. }
  21638. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21639. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21640. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21641. import { Nullable } from "babylonjs/types";
  21642. /**
  21643. * Defines a connection point to be used for points with a custom object type
  21644. */
  21645. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21646. private _blockType;
  21647. private _blockName;
  21648. private _nameForCheking?;
  21649. /**
  21650. * Creates a new connection point
  21651. * @param name defines the connection point name
  21652. * @param ownerBlock defines the block hosting this connection point
  21653. * @param direction defines the direction of the connection point
  21654. */
  21655. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21656. /**
  21657. * Gets a number indicating if the current point can be connected to another point
  21658. * @param connectionPoint defines the other connection point
  21659. * @returns a number defining the compatibility state
  21660. */
  21661. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21662. /**
  21663. * Creates a block suitable to be used as an input for this input point.
  21664. * If null is returned, a block based on the point type will be created.
  21665. * @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
  21666. */
  21667. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21668. }
  21669. }
  21670. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21671. /**
  21672. * Enum defining the type of properties that can be edited in the property pages in the NME
  21673. */
  21674. export enum PropertyTypeForEdition {
  21675. /** property is a boolean */
  21676. Boolean = 0,
  21677. /** property is a float */
  21678. Float = 1,
  21679. /** property is a Vector2 */
  21680. Vector2 = 2,
  21681. /** property is a list of values */
  21682. List = 3
  21683. }
  21684. /**
  21685. * Interface that defines an option in a variable of type list
  21686. */
  21687. export interface IEditablePropertyListOption {
  21688. /** label of the option */
  21689. "label": string;
  21690. /** value of the option */
  21691. "value": number;
  21692. }
  21693. /**
  21694. * Interface that defines the options available for an editable property
  21695. */
  21696. export interface IEditablePropertyOption {
  21697. /** min value */
  21698. "min"?: number;
  21699. /** max value */
  21700. "max"?: number;
  21701. /** notifiers: indicates which actions to take when the property is changed */
  21702. "notifiers"?: {
  21703. /** the material should be rebuilt */
  21704. "rebuild"?: boolean;
  21705. /** the preview should be updated */
  21706. "update"?: boolean;
  21707. };
  21708. /** list of the options for a variable of type list */
  21709. "options"?: IEditablePropertyListOption[];
  21710. }
  21711. /**
  21712. * Interface that describes an editable property
  21713. */
  21714. export interface IPropertyDescriptionForEdition {
  21715. /** name of the property */
  21716. "propertyName": string;
  21717. /** display name of the property */
  21718. "displayName": string;
  21719. /** type of the property */
  21720. "type": PropertyTypeForEdition;
  21721. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21722. "groupName": string;
  21723. /** options for the property */
  21724. "options": IEditablePropertyOption;
  21725. }
  21726. /**
  21727. * Decorator that flags a property in a node material block as being editable
  21728. */
  21729. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21730. }
  21731. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21732. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21733. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21734. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21735. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21736. import { Nullable } from "babylonjs/types";
  21737. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21738. import { Mesh } from "babylonjs/Meshes/mesh";
  21739. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21740. import { Effect } from "babylonjs/Materials/effect";
  21741. import { Scene } from "babylonjs/scene";
  21742. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21743. /**
  21744. * Block used to implement the refraction part of the sub surface module of the PBR material
  21745. */
  21746. export class RefractionBlock extends NodeMaterialBlock {
  21747. /** @hidden */
  21748. _define3DName: string;
  21749. /** @hidden */
  21750. _refractionMatrixName: string;
  21751. /** @hidden */
  21752. _defineLODRefractionAlpha: string;
  21753. /** @hidden */
  21754. _defineLinearSpecularRefraction: string;
  21755. /** @hidden */
  21756. _defineOppositeZ: string;
  21757. /** @hidden */
  21758. _cubeSamplerName: string;
  21759. /** @hidden */
  21760. _2DSamplerName: string;
  21761. /** @hidden */
  21762. _vRefractionMicrosurfaceInfosName: string;
  21763. /** @hidden */
  21764. _vRefractionInfosName: string;
  21765. private _scene;
  21766. /**
  21767. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21768. * Materials half opaque for instance using refraction could benefit from this control.
  21769. */
  21770. linkRefractionWithTransparency: boolean;
  21771. /**
  21772. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21773. */
  21774. invertRefractionY: boolean;
  21775. /**
  21776. * Gets or sets the texture associated with the node
  21777. */
  21778. texture: Nullable<BaseTexture>;
  21779. /**
  21780. * Create a new RefractionBlock
  21781. * @param name defines the block name
  21782. */
  21783. constructor(name: string);
  21784. /**
  21785. * Gets the current class name
  21786. * @returns the class name
  21787. */
  21788. getClassName(): string;
  21789. /**
  21790. * Gets the intensity input component
  21791. */
  21792. get intensity(): NodeMaterialConnectionPoint;
  21793. /**
  21794. * Gets the index of refraction input component
  21795. */
  21796. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21797. /**
  21798. * Gets the tint at distance input component
  21799. */
  21800. get tintAtDistance(): NodeMaterialConnectionPoint;
  21801. /**
  21802. * Gets the view input component
  21803. */
  21804. get view(): NodeMaterialConnectionPoint;
  21805. /**
  21806. * Gets the refraction object output component
  21807. */
  21808. get refraction(): NodeMaterialConnectionPoint;
  21809. /**
  21810. * Returns true if the block has a texture
  21811. */
  21812. get hasTexture(): boolean;
  21813. protected _getTexture(): Nullable<BaseTexture>;
  21814. autoConfigure(material: NodeMaterial): void;
  21815. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21816. isReady(): boolean;
  21817. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21818. /**
  21819. * Gets the main code of the block (fragment side)
  21820. * @param state current state of the node material building
  21821. * @returns the shader code
  21822. */
  21823. getCode(state: NodeMaterialBuildState): string;
  21824. protected _buildBlock(state: NodeMaterialBuildState): this;
  21825. protected _dumpPropertiesCode(): string;
  21826. serialize(): any;
  21827. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21828. }
  21829. }
  21830. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21831. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21832. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21833. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21834. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21836. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21837. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21838. import { Nullable } from "babylonjs/types";
  21839. import { Scene } from "babylonjs/scene";
  21840. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21841. /**
  21842. * Base block used as input for post process
  21843. */
  21844. export class CurrentScreenBlock extends NodeMaterialBlock {
  21845. private _samplerName;
  21846. private _linearDefineName;
  21847. private _gammaDefineName;
  21848. private _mainUVName;
  21849. private _tempTextureRead;
  21850. /**
  21851. * Gets or sets the texture associated with the node
  21852. */
  21853. texture: Nullable<BaseTexture>;
  21854. /**
  21855. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21856. */
  21857. convertToGammaSpace: boolean;
  21858. /**
  21859. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21860. */
  21861. convertToLinearSpace: boolean;
  21862. /**
  21863. * Create a new CurrentScreenBlock
  21864. * @param name defines the block name
  21865. */
  21866. constructor(name: string);
  21867. /**
  21868. * Gets the current class name
  21869. * @returns the class name
  21870. */
  21871. getClassName(): string;
  21872. /**
  21873. * Gets the uv input component
  21874. */
  21875. get uv(): NodeMaterialConnectionPoint;
  21876. /**
  21877. * Gets the rgba output component
  21878. */
  21879. get rgba(): NodeMaterialConnectionPoint;
  21880. /**
  21881. * Gets the rgb output component
  21882. */
  21883. get rgb(): NodeMaterialConnectionPoint;
  21884. /**
  21885. * Gets the r output component
  21886. */
  21887. get r(): NodeMaterialConnectionPoint;
  21888. /**
  21889. * Gets the g output component
  21890. */
  21891. get g(): NodeMaterialConnectionPoint;
  21892. /**
  21893. * Gets the b output component
  21894. */
  21895. get b(): NodeMaterialConnectionPoint;
  21896. /**
  21897. * Gets the a output component
  21898. */
  21899. get a(): NodeMaterialConnectionPoint;
  21900. /**
  21901. * Initialize the block and prepare the context for build
  21902. * @param state defines the state that will be used for the build
  21903. */
  21904. initialize(state: NodeMaterialBuildState): void;
  21905. get target(): NodeMaterialBlockTargets;
  21906. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21907. isReady(): boolean;
  21908. private _injectVertexCode;
  21909. private _writeTextureRead;
  21910. private _writeOutput;
  21911. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21912. serialize(): any;
  21913. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21914. }
  21915. }
  21916. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21917. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21918. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21919. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21920. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21921. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21922. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21923. import { Nullable } from "babylonjs/types";
  21924. import { Scene } from "babylonjs/scene";
  21925. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21926. /**
  21927. * Base block used for the particle texture
  21928. */
  21929. export class ParticleTextureBlock extends NodeMaterialBlock {
  21930. private _samplerName;
  21931. private _linearDefineName;
  21932. private _gammaDefineName;
  21933. private _tempTextureRead;
  21934. /**
  21935. * Gets or sets the texture associated with the node
  21936. */
  21937. texture: Nullable<BaseTexture>;
  21938. /**
  21939. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21940. */
  21941. convertToGammaSpace: boolean;
  21942. /**
  21943. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21944. */
  21945. convertToLinearSpace: boolean;
  21946. /**
  21947. * Create a new ParticleTextureBlock
  21948. * @param name defines the block name
  21949. */
  21950. constructor(name: string);
  21951. /**
  21952. * Gets the current class name
  21953. * @returns the class name
  21954. */
  21955. getClassName(): string;
  21956. /**
  21957. * Gets the uv input component
  21958. */
  21959. get uv(): NodeMaterialConnectionPoint;
  21960. /**
  21961. * Gets the rgba output component
  21962. */
  21963. get rgba(): NodeMaterialConnectionPoint;
  21964. /**
  21965. * Gets the rgb output component
  21966. */
  21967. get rgb(): NodeMaterialConnectionPoint;
  21968. /**
  21969. * Gets the r output component
  21970. */
  21971. get r(): NodeMaterialConnectionPoint;
  21972. /**
  21973. * Gets the g output component
  21974. */
  21975. get g(): NodeMaterialConnectionPoint;
  21976. /**
  21977. * Gets the b output component
  21978. */
  21979. get b(): NodeMaterialConnectionPoint;
  21980. /**
  21981. * Gets the a output component
  21982. */
  21983. get a(): NodeMaterialConnectionPoint;
  21984. /**
  21985. * Initialize the block and prepare the context for build
  21986. * @param state defines the state that will be used for the build
  21987. */
  21988. initialize(state: NodeMaterialBuildState): void;
  21989. autoConfigure(material: NodeMaterial): void;
  21990. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21991. isReady(): boolean;
  21992. private _writeOutput;
  21993. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21994. serialize(): any;
  21995. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21996. }
  21997. }
  21998. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  21999. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22000. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22001. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22002. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22003. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22004. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22005. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22006. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22007. import { Scene } from "babylonjs/scene";
  22008. /**
  22009. * Class used to store shared data between 2 NodeMaterialBuildState
  22010. */
  22011. export class NodeMaterialBuildStateSharedData {
  22012. /**
  22013. * Gets the list of emitted varyings
  22014. */
  22015. temps: string[];
  22016. /**
  22017. * Gets the list of emitted varyings
  22018. */
  22019. varyings: string[];
  22020. /**
  22021. * Gets the varying declaration string
  22022. */
  22023. varyingDeclaration: string;
  22024. /**
  22025. * Input blocks
  22026. */
  22027. inputBlocks: InputBlock[];
  22028. /**
  22029. * Input blocks
  22030. */
  22031. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22032. /**
  22033. * Bindable blocks (Blocks that need to set data to the effect)
  22034. */
  22035. bindableBlocks: NodeMaterialBlock[];
  22036. /**
  22037. * List of blocks that can provide a compilation fallback
  22038. */
  22039. blocksWithFallbacks: NodeMaterialBlock[];
  22040. /**
  22041. * List of blocks that can provide a define update
  22042. */
  22043. blocksWithDefines: NodeMaterialBlock[];
  22044. /**
  22045. * List of blocks that can provide a repeatable content
  22046. */
  22047. repeatableContentBlocks: NodeMaterialBlock[];
  22048. /**
  22049. * List of blocks that can provide a dynamic list of uniforms
  22050. */
  22051. dynamicUniformBlocks: NodeMaterialBlock[];
  22052. /**
  22053. * List of blocks that can block the isReady function for the material
  22054. */
  22055. blockingBlocks: NodeMaterialBlock[];
  22056. /**
  22057. * Gets the list of animated inputs
  22058. */
  22059. animatedInputs: InputBlock[];
  22060. /**
  22061. * Build Id used to avoid multiple recompilations
  22062. */
  22063. buildId: number;
  22064. /** List of emitted variables */
  22065. variableNames: {
  22066. [key: string]: number;
  22067. };
  22068. /** List of emitted defines */
  22069. defineNames: {
  22070. [key: string]: number;
  22071. };
  22072. /** Should emit comments? */
  22073. emitComments: boolean;
  22074. /** Emit build activity */
  22075. verbose: boolean;
  22076. /** Gets or sets the hosting scene */
  22077. scene: Scene;
  22078. /**
  22079. * Gets the compilation hints emitted at compilation time
  22080. */
  22081. hints: {
  22082. needWorldViewMatrix: boolean;
  22083. needWorldViewProjectionMatrix: boolean;
  22084. needAlphaBlending: boolean;
  22085. needAlphaTesting: boolean;
  22086. };
  22087. /**
  22088. * List of compilation checks
  22089. */
  22090. checks: {
  22091. emitVertex: boolean;
  22092. emitFragment: boolean;
  22093. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22094. };
  22095. /**
  22096. * Is vertex program allowed to be empty?
  22097. */
  22098. allowEmptyVertexProgram: boolean;
  22099. /** Creates a new shared data */
  22100. constructor();
  22101. /**
  22102. * Emits console errors and exceptions if there is a failing check
  22103. */
  22104. emitErrors(): void;
  22105. }
  22106. }
  22107. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22108. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22109. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22110. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22111. /**
  22112. * Class used to store node based material build state
  22113. */
  22114. export class NodeMaterialBuildState {
  22115. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22116. supportUniformBuffers: boolean;
  22117. /**
  22118. * Gets the list of emitted attributes
  22119. */
  22120. attributes: string[];
  22121. /**
  22122. * Gets the list of emitted uniforms
  22123. */
  22124. uniforms: string[];
  22125. /**
  22126. * Gets the list of emitted constants
  22127. */
  22128. constants: string[];
  22129. /**
  22130. * Gets the list of emitted samplers
  22131. */
  22132. samplers: string[];
  22133. /**
  22134. * Gets the list of emitted functions
  22135. */
  22136. functions: {
  22137. [key: string]: string;
  22138. };
  22139. /**
  22140. * Gets the list of emitted extensions
  22141. */
  22142. extensions: {
  22143. [key: string]: string;
  22144. };
  22145. /**
  22146. * Gets the target of the compilation state
  22147. */
  22148. target: NodeMaterialBlockTargets;
  22149. /**
  22150. * Gets the list of emitted counters
  22151. */
  22152. counters: {
  22153. [key: string]: number;
  22154. };
  22155. /**
  22156. * Shared data between multiple NodeMaterialBuildState instances
  22157. */
  22158. sharedData: NodeMaterialBuildStateSharedData;
  22159. /** @hidden */
  22160. _vertexState: NodeMaterialBuildState;
  22161. /** @hidden */
  22162. _attributeDeclaration: string;
  22163. /** @hidden */
  22164. _uniformDeclaration: string;
  22165. /** @hidden */
  22166. _constantDeclaration: string;
  22167. /** @hidden */
  22168. _samplerDeclaration: string;
  22169. /** @hidden */
  22170. _varyingTransfer: string;
  22171. /** @hidden */
  22172. _injectAtEnd: string;
  22173. private _repeatableContentAnchorIndex;
  22174. /** @hidden */
  22175. _builtCompilationString: string;
  22176. /**
  22177. * Gets the emitted compilation strings
  22178. */
  22179. compilationString: string;
  22180. /**
  22181. * Finalize the compilation strings
  22182. * @param state defines the current compilation state
  22183. */
  22184. finalize(state: NodeMaterialBuildState): void;
  22185. /** @hidden */
  22186. get _repeatableContentAnchor(): string;
  22187. /** @hidden */
  22188. _getFreeVariableName(prefix: string): string;
  22189. /** @hidden */
  22190. _getFreeDefineName(prefix: string): string;
  22191. /** @hidden */
  22192. _excludeVariableName(name: string): void;
  22193. /** @hidden */
  22194. _emit2DSampler(name: string): void;
  22195. /** @hidden */
  22196. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22197. /** @hidden */
  22198. _emitExtension(name: string, extension: string, define?: string): void;
  22199. /** @hidden */
  22200. _emitFunction(name: string, code: string, comments: string): void;
  22201. /** @hidden */
  22202. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22203. replaceStrings?: {
  22204. search: RegExp;
  22205. replace: string;
  22206. }[];
  22207. repeatKey?: string;
  22208. }): string;
  22209. /** @hidden */
  22210. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22211. repeatKey?: string;
  22212. removeAttributes?: boolean;
  22213. removeUniforms?: boolean;
  22214. removeVaryings?: boolean;
  22215. removeIfDef?: boolean;
  22216. replaceStrings?: {
  22217. search: RegExp;
  22218. replace: string;
  22219. }[];
  22220. }, storeKey?: string): void;
  22221. /** @hidden */
  22222. _registerTempVariable(name: string): boolean;
  22223. /** @hidden */
  22224. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22225. /** @hidden */
  22226. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22227. /** @hidden */
  22228. _emitFloat(value: number): string;
  22229. }
  22230. }
  22231. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22232. /**
  22233. * Helper class used to generate session unique ID
  22234. */
  22235. export class UniqueIdGenerator {
  22236. private static _UniqueIdCounter;
  22237. /**
  22238. * Gets an unique (relatively to the current scene) Id
  22239. */
  22240. static get UniqueId(): number;
  22241. }
  22242. }
  22243. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22244. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22245. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22246. import { Nullable } from "babylonjs/types";
  22247. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22248. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22249. import { Effect } from "babylonjs/Materials/effect";
  22250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22251. import { Mesh } from "babylonjs/Meshes/mesh";
  22252. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22253. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22254. import { Scene } from "babylonjs/scene";
  22255. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22256. /**
  22257. * Defines a block that can be used inside a node based material
  22258. */
  22259. export class NodeMaterialBlock {
  22260. private _buildId;
  22261. private _buildTarget;
  22262. private _target;
  22263. private _isFinalMerger;
  22264. private _isInput;
  22265. private _name;
  22266. protected _isUnique: boolean;
  22267. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22268. inputsAreExclusive: boolean;
  22269. /** @hidden */
  22270. _codeVariableName: string;
  22271. /** @hidden */
  22272. _inputs: NodeMaterialConnectionPoint[];
  22273. /** @hidden */
  22274. _outputs: NodeMaterialConnectionPoint[];
  22275. /** @hidden */
  22276. _preparationId: number;
  22277. /**
  22278. * Gets the name of the block
  22279. */
  22280. get name(): string;
  22281. /**
  22282. * Sets the name of the block. Will check if the name is valid.
  22283. */
  22284. set name(newName: string);
  22285. /**
  22286. * Gets or sets the unique id of the node
  22287. */
  22288. uniqueId: number;
  22289. /**
  22290. * Gets or sets the comments associated with this block
  22291. */
  22292. comments: string;
  22293. /**
  22294. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22295. */
  22296. get isUnique(): boolean;
  22297. /**
  22298. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22299. */
  22300. get isFinalMerger(): boolean;
  22301. /**
  22302. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22303. */
  22304. get isInput(): boolean;
  22305. /**
  22306. * Gets or sets the build Id
  22307. */
  22308. get buildId(): number;
  22309. set buildId(value: number);
  22310. /**
  22311. * Gets or sets the target of the block
  22312. */
  22313. get target(): NodeMaterialBlockTargets;
  22314. set target(value: NodeMaterialBlockTargets);
  22315. /**
  22316. * Gets the list of input points
  22317. */
  22318. get inputs(): NodeMaterialConnectionPoint[];
  22319. /** Gets the list of output points */
  22320. get outputs(): NodeMaterialConnectionPoint[];
  22321. /**
  22322. * Find an input by its name
  22323. * @param name defines the name of the input to look for
  22324. * @returns the input or null if not found
  22325. */
  22326. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22327. /**
  22328. * Find an output by its name
  22329. * @param name defines the name of the outputto look for
  22330. * @returns the output or null if not found
  22331. */
  22332. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22333. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22334. visibleInInspector: boolean;
  22335. /**
  22336. * Creates a new NodeMaterialBlock
  22337. * @param name defines the block name
  22338. * @param target defines the target of that block (Vertex by default)
  22339. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22340. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22341. */
  22342. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22343. /**
  22344. * Initialize the block and prepare the context for build
  22345. * @param state defines the state that will be used for the build
  22346. */
  22347. initialize(state: NodeMaterialBuildState): void;
  22348. /**
  22349. * Bind data to effect. Will only be called for blocks with isBindable === true
  22350. * @param effect defines the effect to bind data to
  22351. * @param nodeMaterial defines the hosting NodeMaterial
  22352. * @param mesh defines the mesh that will be rendered
  22353. * @param subMesh defines the submesh that will be rendered
  22354. */
  22355. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22356. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22357. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22358. protected _writeFloat(value: number): string;
  22359. /**
  22360. * Gets the current class name e.g. "NodeMaterialBlock"
  22361. * @returns the class name
  22362. */
  22363. getClassName(): string;
  22364. /**
  22365. * Register a new input. Must be called inside a block constructor
  22366. * @param name defines the connection point name
  22367. * @param type defines the connection point type
  22368. * @param isOptional defines a boolean indicating that this input can be omitted
  22369. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22370. * @param point an already created connection point. If not provided, create a new one
  22371. * @returns the current block
  22372. */
  22373. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22374. /**
  22375. * Register a new output. Must be called inside a block constructor
  22376. * @param name defines the connection point name
  22377. * @param type defines the connection point type
  22378. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22379. * @param point an already created connection point. If not provided, create a new one
  22380. * @returns the current block
  22381. */
  22382. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22383. /**
  22384. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22385. * @param forOutput defines an optional connection point to check compatibility with
  22386. * @returns the first available input or null
  22387. */
  22388. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22389. /**
  22390. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22391. * @param forBlock defines an optional block to check compatibility with
  22392. * @returns the first available input or null
  22393. */
  22394. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22395. /**
  22396. * Gets the sibling of the given output
  22397. * @param current defines the current output
  22398. * @returns the next output in the list or null
  22399. */
  22400. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22401. /**
  22402. * Connect current block with another block
  22403. * @param other defines the block to connect with
  22404. * @param options define the various options to help pick the right connections
  22405. * @returns the current block
  22406. */
  22407. connectTo(other: NodeMaterialBlock, options?: {
  22408. input?: string;
  22409. output?: string;
  22410. outputSwizzle?: string;
  22411. }): this | undefined;
  22412. protected _buildBlock(state: NodeMaterialBuildState): void;
  22413. /**
  22414. * Add uniforms, samplers and uniform buffers at compilation time
  22415. * @param state defines the state to update
  22416. * @param nodeMaterial defines the node material requesting the update
  22417. * @param defines defines the material defines to update
  22418. * @param uniformBuffers defines the list of uniform buffer names
  22419. */
  22420. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22421. /**
  22422. * Add potential fallbacks if shader compilation fails
  22423. * @param mesh defines the mesh to be rendered
  22424. * @param fallbacks defines the current prioritized list of fallbacks
  22425. */
  22426. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22427. /**
  22428. * Initialize defines for shader compilation
  22429. * @param mesh defines the mesh to be rendered
  22430. * @param nodeMaterial defines the node material requesting the update
  22431. * @param defines defines the material defines to update
  22432. * @param useInstances specifies that instances should be used
  22433. */
  22434. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22435. /**
  22436. * Update defines for shader compilation
  22437. * @param mesh defines the mesh to be rendered
  22438. * @param nodeMaterial defines the node material requesting the update
  22439. * @param defines defines the material defines to update
  22440. * @param useInstances specifies that instances should be used
  22441. * @param subMesh defines which submesh to render
  22442. */
  22443. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22444. /**
  22445. * Lets the block try to connect some inputs automatically
  22446. * @param material defines the hosting NodeMaterial
  22447. */
  22448. autoConfigure(material: NodeMaterial): void;
  22449. /**
  22450. * Function called when a block is declared as repeatable content generator
  22451. * @param vertexShaderState defines the current compilation state for the vertex shader
  22452. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22453. * @param mesh defines the mesh to be rendered
  22454. * @param defines defines the material defines to update
  22455. */
  22456. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22457. /**
  22458. * Checks if the block is ready
  22459. * @param mesh defines the mesh to be rendered
  22460. * @param nodeMaterial defines the node material requesting the update
  22461. * @param defines defines the material defines to update
  22462. * @param useInstances specifies that instances should be used
  22463. * @returns true if the block is ready
  22464. */
  22465. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22466. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22467. private _processBuild;
  22468. /**
  22469. * Validates the new name for the block node.
  22470. * @param newName the new name to be given to the node.
  22471. * @returns false if the name is a reserve word, else true.
  22472. */
  22473. validateBlockName(newName: string): boolean;
  22474. /**
  22475. * Compile the current node and generate the shader code
  22476. * @param state defines the current compilation state (uniforms, samplers, current string)
  22477. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22478. * @returns true if already built
  22479. */
  22480. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22481. protected _inputRename(name: string): string;
  22482. protected _outputRename(name: string): string;
  22483. protected _dumpPropertiesCode(): string;
  22484. /** @hidden */
  22485. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22486. /** @hidden */
  22487. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22488. /**
  22489. * Clone the current block to a new identical block
  22490. * @param scene defines the hosting scene
  22491. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22492. * @returns a copy of the current block
  22493. */
  22494. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22495. /**
  22496. * Serializes this block in a JSON representation
  22497. * @returns the serialized block object
  22498. */
  22499. serialize(): any;
  22500. /** @hidden */
  22501. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22502. private _deserializePortDisplayNamesAndExposedOnFrame;
  22503. /**
  22504. * Release resources
  22505. */
  22506. dispose(): void;
  22507. }
  22508. }
  22509. declare module "babylonjs/Materials/pushMaterial" {
  22510. import { Nullable } from "babylonjs/types";
  22511. import { Scene } from "babylonjs/scene";
  22512. import { Matrix } from "babylonjs/Maths/math.vector";
  22513. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22514. import { Mesh } from "babylonjs/Meshes/mesh";
  22515. import { Material } from "babylonjs/Materials/material";
  22516. import { Effect } from "babylonjs/Materials/effect";
  22517. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22518. /**
  22519. * Base class of materials working in push mode in babylon JS
  22520. * @hidden
  22521. */
  22522. export class PushMaterial extends Material {
  22523. protected _activeEffect: Effect;
  22524. protected _normalMatrix: Matrix;
  22525. constructor(name: string, scene: Scene);
  22526. getEffect(): Effect;
  22527. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22528. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22529. /**
  22530. * Binds the given world matrix to the active effect
  22531. *
  22532. * @param world the matrix to bind
  22533. */
  22534. bindOnlyWorldMatrix(world: Matrix): void;
  22535. /**
  22536. * Binds the given normal matrix to the active effect
  22537. *
  22538. * @param normalMatrix the matrix to bind
  22539. */
  22540. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22541. bind(world: Matrix, mesh?: Mesh): void;
  22542. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22543. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22544. }
  22545. }
  22546. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22547. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22548. /**
  22549. * Root class for all node material optimizers
  22550. */
  22551. export class NodeMaterialOptimizer {
  22552. /**
  22553. * Function used to optimize a NodeMaterial graph
  22554. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22555. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22556. */
  22557. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22558. }
  22559. }
  22560. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22561. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22562. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22563. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22564. import { Scene } from "babylonjs/scene";
  22565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22566. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22567. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22568. /**
  22569. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22570. */
  22571. export class TransformBlock extends NodeMaterialBlock {
  22572. /**
  22573. * Defines the value to use to complement W value to transform it to a Vector4
  22574. */
  22575. complementW: number;
  22576. /**
  22577. * Defines the value to use to complement z value to transform it to a Vector4
  22578. */
  22579. complementZ: number;
  22580. /**
  22581. * Creates a new TransformBlock
  22582. * @param name defines the block name
  22583. */
  22584. constructor(name: string);
  22585. /**
  22586. * Gets the current class name
  22587. * @returns the class name
  22588. */
  22589. getClassName(): string;
  22590. /**
  22591. * Gets the vector input
  22592. */
  22593. get vector(): NodeMaterialConnectionPoint;
  22594. /**
  22595. * Gets the output component
  22596. */
  22597. get output(): NodeMaterialConnectionPoint;
  22598. /**
  22599. * Gets the xyz output component
  22600. */
  22601. get xyz(): NodeMaterialConnectionPoint;
  22602. /**
  22603. * Gets the matrix transform input
  22604. */
  22605. get transform(): NodeMaterialConnectionPoint;
  22606. protected _buildBlock(state: NodeMaterialBuildState): this;
  22607. /**
  22608. * Update defines for shader compilation
  22609. * @param mesh defines the mesh to be rendered
  22610. * @param nodeMaterial defines the node material requesting the update
  22611. * @param defines defines the material defines to update
  22612. * @param useInstances specifies that instances should be used
  22613. * @param subMesh defines which submesh to render
  22614. */
  22615. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22616. serialize(): any;
  22617. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22618. protected _dumpPropertiesCode(): string;
  22619. }
  22620. }
  22621. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22622. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22623. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22624. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22625. /**
  22626. * Block used to output the vertex position
  22627. */
  22628. export class VertexOutputBlock extends NodeMaterialBlock {
  22629. /**
  22630. * Creates a new VertexOutputBlock
  22631. * @param name defines the block name
  22632. */
  22633. constructor(name: string);
  22634. /**
  22635. * Gets the current class name
  22636. * @returns the class name
  22637. */
  22638. getClassName(): string;
  22639. /**
  22640. * Gets the vector input component
  22641. */
  22642. get vector(): NodeMaterialConnectionPoint;
  22643. protected _buildBlock(state: NodeMaterialBuildState): this;
  22644. }
  22645. }
  22646. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22647. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22648. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22649. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22650. /**
  22651. * Block used to output the final color
  22652. */
  22653. export class FragmentOutputBlock extends NodeMaterialBlock {
  22654. /**
  22655. * Create a new FragmentOutputBlock
  22656. * @param name defines the block name
  22657. */
  22658. constructor(name: string);
  22659. /**
  22660. * Gets the current class name
  22661. * @returns the class name
  22662. */
  22663. getClassName(): string;
  22664. /**
  22665. * Gets the rgba input component
  22666. */
  22667. get rgba(): NodeMaterialConnectionPoint;
  22668. /**
  22669. * Gets the rgb input component
  22670. */
  22671. get rgb(): NodeMaterialConnectionPoint;
  22672. /**
  22673. * Gets the a input component
  22674. */
  22675. get a(): NodeMaterialConnectionPoint;
  22676. protected _buildBlock(state: NodeMaterialBuildState): this;
  22677. }
  22678. }
  22679. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22680. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22681. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22682. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22683. /**
  22684. * Block used for the particle ramp gradient section
  22685. */
  22686. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22687. /**
  22688. * Create a new ParticleRampGradientBlock
  22689. * @param name defines the block name
  22690. */
  22691. constructor(name: string);
  22692. /**
  22693. * Gets the current class name
  22694. * @returns the class name
  22695. */
  22696. getClassName(): string;
  22697. /**
  22698. * Gets the color input component
  22699. */
  22700. get color(): NodeMaterialConnectionPoint;
  22701. /**
  22702. * Gets the rampColor output component
  22703. */
  22704. get rampColor(): NodeMaterialConnectionPoint;
  22705. /**
  22706. * Initialize the block and prepare the context for build
  22707. * @param state defines the state that will be used for the build
  22708. */
  22709. initialize(state: NodeMaterialBuildState): void;
  22710. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22711. }
  22712. }
  22713. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22714. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22715. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22716. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22717. /**
  22718. * Block used for the particle blend multiply section
  22719. */
  22720. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22721. /**
  22722. * Create a new ParticleBlendMultiplyBlock
  22723. * @param name defines the block name
  22724. */
  22725. constructor(name: string);
  22726. /**
  22727. * Gets the current class name
  22728. * @returns the class name
  22729. */
  22730. getClassName(): string;
  22731. /**
  22732. * Gets the color input component
  22733. */
  22734. get color(): NodeMaterialConnectionPoint;
  22735. /**
  22736. * Gets the alphaTexture input component
  22737. */
  22738. get alphaTexture(): NodeMaterialConnectionPoint;
  22739. /**
  22740. * Gets the alphaColor input component
  22741. */
  22742. get alphaColor(): NodeMaterialConnectionPoint;
  22743. /**
  22744. * Gets the blendColor output component
  22745. */
  22746. get blendColor(): NodeMaterialConnectionPoint;
  22747. /**
  22748. * Initialize the block and prepare the context for build
  22749. * @param state defines the state that will be used for the build
  22750. */
  22751. initialize(state: NodeMaterialBuildState): void;
  22752. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22753. }
  22754. }
  22755. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22756. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22757. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22758. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22759. /**
  22760. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22761. */
  22762. export class VectorMergerBlock extends NodeMaterialBlock {
  22763. /**
  22764. * Create a new VectorMergerBlock
  22765. * @param name defines the block name
  22766. */
  22767. constructor(name: string);
  22768. /**
  22769. * Gets the current class name
  22770. * @returns the class name
  22771. */
  22772. getClassName(): string;
  22773. /**
  22774. * Gets the xyz component (input)
  22775. */
  22776. get xyzIn(): NodeMaterialConnectionPoint;
  22777. /**
  22778. * Gets the xy component (input)
  22779. */
  22780. get xyIn(): NodeMaterialConnectionPoint;
  22781. /**
  22782. * Gets the x component (input)
  22783. */
  22784. get x(): NodeMaterialConnectionPoint;
  22785. /**
  22786. * Gets the y component (input)
  22787. */
  22788. get y(): NodeMaterialConnectionPoint;
  22789. /**
  22790. * Gets the z component (input)
  22791. */
  22792. get z(): NodeMaterialConnectionPoint;
  22793. /**
  22794. * Gets the w component (input)
  22795. */
  22796. get w(): NodeMaterialConnectionPoint;
  22797. /**
  22798. * Gets the xyzw component (output)
  22799. */
  22800. get xyzw(): NodeMaterialConnectionPoint;
  22801. /**
  22802. * Gets the xyz component (output)
  22803. */
  22804. get xyzOut(): NodeMaterialConnectionPoint;
  22805. /**
  22806. * Gets the xy component (output)
  22807. */
  22808. get xyOut(): NodeMaterialConnectionPoint;
  22809. /**
  22810. * Gets the xy component (output)
  22811. * @deprecated Please use xyOut instead.
  22812. */
  22813. get xy(): NodeMaterialConnectionPoint;
  22814. /**
  22815. * Gets the xyz component (output)
  22816. * @deprecated Please use xyzOut instead.
  22817. */
  22818. get xyz(): NodeMaterialConnectionPoint;
  22819. protected _buildBlock(state: NodeMaterialBuildState): this;
  22820. }
  22821. }
  22822. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22823. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22824. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22825. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22826. import { Vector2 } from "babylonjs/Maths/math.vector";
  22827. import { Scene } from "babylonjs/scene";
  22828. /**
  22829. * Block used to remap a float from a range to a new one
  22830. */
  22831. export class RemapBlock extends NodeMaterialBlock {
  22832. /**
  22833. * Gets or sets the source range
  22834. */
  22835. sourceRange: Vector2;
  22836. /**
  22837. * Gets or sets the target range
  22838. */
  22839. targetRange: Vector2;
  22840. /**
  22841. * Creates a new RemapBlock
  22842. * @param name defines the block name
  22843. */
  22844. constructor(name: string);
  22845. /**
  22846. * Gets the current class name
  22847. * @returns the class name
  22848. */
  22849. getClassName(): string;
  22850. /**
  22851. * Gets the input component
  22852. */
  22853. get input(): NodeMaterialConnectionPoint;
  22854. /**
  22855. * Gets the source min input component
  22856. */
  22857. get sourceMin(): NodeMaterialConnectionPoint;
  22858. /**
  22859. * Gets the source max input component
  22860. */
  22861. get sourceMax(): NodeMaterialConnectionPoint;
  22862. /**
  22863. * Gets the target min input component
  22864. */
  22865. get targetMin(): NodeMaterialConnectionPoint;
  22866. /**
  22867. * Gets the target max input component
  22868. */
  22869. get targetMax(): NodeMaterialConnectionPoint;
  22870. /**
  22871. * Gets the output component
  22872. */
  22873. get output(): NodeMaterialConnectionPoint;
  22874. protected _buildBlock(state: NodeMaterialBuildState): this;
  22875. protected _dumpPropertiesCode(): string;
  22876. serialize(): any;
  22877. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22878. }
  22879. }
  22880. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22881. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22882. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22883. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22884. /**
  22885. * Block used to multiply 2 values
  22886. */
  22887. export class MultiplyBlock extends NodeMaterialBlock {
  22888. /**
  22889. * Creates a new MultiplyBlock
  22890. * @param name defines the block name
  22891. */
  22892. constructor(name: string);
  22893. /**
  22894. * Gets the current class name
  22895. * @returns the class name
  22896. */
  22897. getClassName(): string;
  22898. /**
  22899. * Gets the left operand input component
  22900. */
  22901. get left(): NodeMaterialConnectionPoint;
  22902. /**
  22903. * Gets the right operand input component
  22904. */
  22905. get right(): NodeMaterialConnectionPoint;
  22906. /**
  22907. * Gets the output component
  22908. */
  22909. get output(): NodeMaterialConnectionPoint;
  22910. protected _buildBlock(state: NodeMaterialBuildState): this;
  22911. }
  22912. }
  22913. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22914. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22915. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22916. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22917. /**
  22918. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22919. */
  22920. export class ColorSplitterBlock extends NodeMaterialBlock {
  22921. /**
  22922. * Create a new ColorSplitterBlock
  22923. * @param name defines the block name
  22924. */
  22925. constructor(name: string);
  22926. /**
  22927. * Gets the current class name
  22928. * @returns the class name
  22929. */
  22930. getClassName(): string;
  22931. /**
  22932. * Gets the rgba component (input)
  22933. */
  22934. get rgba(): NodeMaterialConnectionPoint;
  22935. /**
  22936. * Gets the rgb component (input)
  22937. */
  22938. get rgbIn(): NodeMaterialConnectionPoint;
  22939. /**
  22940. * Gets the rgb component (output)
  22941. */
  22942. get rgbOut(): NodeMaterialConnectionPoint;
  22943. /**
  22944. * Gets the r component (output)
  22945. */
  22946. get r(): NodeMaterialConnectionPoint;
  22947. /**
  22948. * Gets the g component (output)
  22949. */
  22950. get g(): NodeMaterialConnectionPoint;
  22951. /**
  22952. * Gets the b component (output)
  22953. */
  22954. get b(): NodeMaterialConnectionPoint;
  22955. /**
  22956. * Gets the a component (output)
  22957. */
  22958. get a(): NodeMaterialConnectionPoint;
  22959. protected _inputRename(name: string): string;
  22960. protected _outputRename(name: string): string;
  22961. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22962. }
  22963. }
  22964. declare module "babylonjs/Materials/Node/nodeMaterial" {
  22965. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22966. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22967. import { Scene } from "babylonjs/scene";
  22968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22969. import { Matrix } from "babylonjs/Maths/math.vector";
  22970. import { Mesh } from "babylonjs/Meshes/mesh";
  22971. import { Engine } from "babylonjs/Engines/engine";
  22972. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22973. import { Observable } from "babylonjs/Misc/observable";
  22974. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22975. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22976. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  22977. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22978. import { Nullable } from "babylonjs/types";
  22979. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22980. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22981. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22982. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22983. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22984. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22985. import { Effect } from "babylonjs/Materials/effect";
  22986. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  22987. import { Camera } from "babylonjs/Cameras/camera";
  22988. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  22989. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22990. /**
  22991. * Interface used to configure the node material editor
  22992. */
  22993. export interface INodeMaterialEditorOptions {
  22994. /** Define the URl to load node editor script */
  22995. editorURL?: string;
  22996. }
  22997. /** @hidden */
  22998. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22999. NORMAL: boolean;
  23000. TANGENT: boolean;
  23001. UV1: boolean;
  23002. /** BONES */
  23003. NUM_BONE_INFLUENCERS: number;
  23004. BonesPerMesh: number;
  23005. BONETEXTURE: boolean;
  23006. /** MORPH TARGETS */
  23007. MORPHTARGETS: boolean;
  23008. MORPHTARGETS_NORMAL: boolean;
  23009. MORPHTARGETS_TANGENT: boolean;
  23010. MORPHTARGETS_UV: boolean;
  23011. NUM_MORPH_INFLUENCERS: number;
  23012. /** IMAGE PROCESSING */
  23013. IMAGEPROCESSING: boolean;
  23014. VIGNETTE: boolean;
  23015. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23016. VIGNETTEBLENDMODEOPAQUE: boolean;
  23017. TONEMAPPING: boolean;
  23018. TONEMAPPING_ACES: boolean;
  23019. CONTRAST: boolean;
  23020. EXPOSURE: boolean;
  23021. COLORCURVES: boolean;
  23022. COLORGRADING: boolean;
  23023. COLORGRADING3D: boolean;
  23024. SAMPLER3DGREENDEPTH: boolean;
  23025. SAMPLER3DBGRMAP: boolean;
  23026. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23027. /** MISC. */
  23028. BUMPDIRECTUV: number;
  23029. constructor();
  23030. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23031. }
  23032. /**
  23033. * Class used to configure NodeMaterial
  23034. */
  23035. export interface INodeMaterialOptions {
  23036. /**
  23037. * Defines if blocks should emit comments
  23038. */
  23039. emitComments: boolean;
  23040. }
  23041. /**
  23042. * Class used to create a node based material built by assembling shader blocks
  23043. */
  23044. export class NodeMaterial extends PushMaterial {
  23045. private static _BuildIdGenerator;
  23046. private _options;
  23047. private _vertexCompilationState;
  23048. private _fragmentCompilationState;
  23049. private _sharedData;
  23050. private _buildId;
  23051. private _buildWasSuccessful;
  23052. private _cachedWorldViewMatrix;
  23053. private _cachedWorldViewProjectionMatrix;
  23054. private _optimizers;
  23055. private _animationFrame;
  23056. /** Define the Url to load node editor script */
  23057. static EditorURL: string;
  23058. /** Define the Url to load snippets */
  23059. static SnippetUrl: string;
  23060. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23061. static IgnoreTexturesAtLoadTime: boolean;
  23062. private BJSNODEMATERIALEDITOR;
  23063. /** Get the inspector from bundle or global */
  23064. private _getGlobalNodeMaterialEditor;
  23065. /**
  23066. * Snippet ID if the material was created from the snippet server
  23067. */
  23068. snippetId: string;
  23069. /**
  23070. * Gets or sets data used by visual editor
  23071. * @see https://nme.babylonjs.com
  23072. */
  23073. editorData: any;
  23074. /**
  23075. * 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)
  23076. */
  23077. ignoreAlpha: boolean;
  23078. /**
  23079. * Defines the maximum number of lights that can be used in the material
  23080. */
  23081. maxSimultaneousLights: number;
  23082. /**
  23083. * Observable raised when the material is built
  23084. */
  23085. onBuildObservable: Observable<NodeMaterial>;
  23086. /**
  23087. * Gets or sets the root nodes of the material vertex shader
  23088. */
  23089. _vertexOutputNodes: NodeMaterialBlock[];
  23090. /**
  23091. * Gets or sets the root nodes of the material fragment (pixel) shader
  23092. */
  23093. _fragmentOutputNodes: NodeMaterialBlock[];
  23094. /** Gets or sets options to control the node material overall behavior */
  23095. get options(): INodeMaterialOptions;
  23096. set options(options: INodeMaterialOptions);
  23097. /**
  23098. * Default configuration related to image processing available in the standard Material.
  23099. */
  23100. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23101. /**
  23102. * Gets the image processing configuration used either in this material.
  23103. */
  23104. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23105. /**
  23106. * Sets the Default image processing configuration used either in the this material.
  23107. *
  23108. * If sets to null, the scene one is in use.
  23109. */
  23110. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23111. /**
  23112. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23113. */
  23114. attachedBlocks: NodeMaterialBlock[];
  23115. /**
  23116. * Specifies the mode of the node material
  23117. * @hidden
  23118. */
  23119. _mode: NodeMaterialModes;
  23120. /**
  23121. * Gets the mode property
  23122. */
  23123. get mode(): NodeMaterialModes;
  23124. /**
  23125. * Create a new node based material
  23126. * @param name defines the material name
  23127. * @param scene defines the hosting scene
  23128. * @param options defines creation option
  23129. */
  23130. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23131. /**
  23132. * Gets the current class name of the material e.g. "NodeMaterial"
  23133. * @returns the class name
  23134. */
  23135. getClassName(): string;
  23136. /**
  23137. * Keep track of the image processing observer to allow dispose and replace.
  23138. */
  23139. private _imageProcessingObserver;
  23140. /**
  23141. * Attaches a new image processing configuration to the Standard Material.
  23142. * @param configuration
  23143. */
  23144. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23145. /**
  23146. * Get a block by its name
  23147. * @param name defines the name of the block to retrieve
  23148. * @returns the required block or null if not found
  23149. */
  23150. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23151. /**
  23152. * Get a block by its name
  23153. * @param predicate defines the predicate used to find the good candidate
  23154. * @returns the required block or null if not found
  23155. */
  23156. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23157. /**
  23158. * Get an input block by its name
  23159. * @param predicate defines the predicate used to find the good candidate
  23160. * @returns the required input block or null if not found
  23161. */
  23162. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23163. /**
  23164. * Gets the list of input blocks attached to this material
  23165. * @returns an array of InputBlocks
  23166. */
  23167. getInputBlocks(): InputBlock[];
  23168. /**
  23169. * Adds a new optimizer to the list of optimizers
  23170. * @param optimizer defines the optimizers to add
  23171. * @returns the current material
  23172. */
  23173. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23174. /**
  23175. * Remove an optimizer from the list of optimizers
  23176. * @param optimizer defines the optimizers to remove
  23177. * @returns the current material
  23178. */
  23179. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23180. /**
  23181. * Add a new block to the list of output nodes
  23182. * @param node defines the node to add
  23183. * @returns the current material
  23184. */
  23185. addOutputNode(node: NodeMaterialBlock): this;
  23186. /**
  23187. * Remove a block from the list of root nodes
  23188. * @param node defines the node to remove
  23189. * @returns the current material
  23190. */
  23191. removeOutputNode(node: NodeMaterialBlock): this;
  23192. private _addVertexOutputNode;
  23193. private _removeVertexOutputNode;
  23194. private _addFragmentOutputNode;
  23195. private _removeFragmentOutputNode;
  23196. /**
  23197. * Specifies if the material will require alpha blending
  23198. * @returns a boolean specifying if alpha blending is needed
  23199. */
  23200. needAlphaBlending(): boolean;
  23201. /**
  23202. * Specifies if this material should be rendered in alpha test mode
  23203. * @returns a boolean specifying if an alpha test is needed.
  23204. */
  23205. needAlphaTesting(): boolean;
  23206. private _initializeBlock;
  23207. private _resetDualBlocks;
  23208. /**
  23209. * Remove a block from the current node material
  23210. * @param block defines the block to remove
  23211. */
  23212. removeBlock(block: NodeMaterialBlock): void;
  23213. /**
  23214. * Build the material and generates the inner effect
  23215. * @param verbose defines if the build should log activity
  23216. */
  23217. build(verbose?: boolean): void;
  23218. /**
  23219. * Runs an otpimization phase to try to improve the shader code
  23220. */
  23221. optimize(): void;
  23222. private _prepareDefinesForAttributes;
  23223. /**
  23224. * Create a post process from the material
  23225. * @param camera The camera to apply the render pass to.
  23226. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23227. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23228. * @param engine The engine which the post process will be applied. (default: current engine)
  23229. * @param reusable If the post process can be reused on the same frame. (default: false)
  23230. * @param textureType Type of textures used when performing the post process. (default: 0)
  23231. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23232. * @returns the post process created
  23233. */
  23234. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  23235. /**
  23236. * Create the post process effect from the material
  23237. * @param postProcess The post process to create the effect for
  23238. */
  23239. createEffectForPostProcess(postProcess: PostProcess): void;
  23240. private _createEffectOrPostProcess;
  23241. private _createEffectForParticles;
  23242. /**
  23243. * Create the effect to be used as the custom effect for a particle system
  23244. * @param particleSystem Particle system to create the effect for
  23245. * @param onCompiled defines a function to call when the effect creation is successful
  23246. * @param onError defines a function to call when the effect creation has failed
  23247. */
  23248. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23249. private _processDefines;
  23250. /**
  23251. * Get if the submesh is ready to be used and all its information available.
  23252. * Child classes can use it to update shaders
  23253. * @param mesh defines the mesh to check
  23254. * @param subMesh defines which submesh to check
  23255. * @param useInstances specifies that instances should be used
  23256. * @returns a boolean indicating that the submesh is ready or not
  23257. */
  23258. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23259. /**
  23260. * Get a string representing the shaders built by the current node graph
  23261. */
  23262. get compiledShaders(): string;
  23263. /**
  23264. * Binds the world matrix to the material
  23265. * @param world defines the world transformation matrix
  23266. */
  23267. bindOnlyWorldMatrix(world: Matrix): void;
  23268. /**
  23269. * Binds the submesh to this material by preparing the effect and shader to draw
  23270. * @param world defines the world transformation matrix
  23271. * @param mesh defines the mesh containing the submesh
  23272. * @param subMesh defines the submesh to bind the material to
  23273. */
  23274. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23275. /**
  23276. * Gets the active textures from the material
  23277. * @returns an array of textures
  23278. */
  23279. getActiveTextures(): BaseTexture[];
  23280. /**
  23281. * Gets the list of texture blocks
  23282. * @returns an array of texture blocks
  23283. */
  23284. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23285. /**
  23286. * Specifies if the material uses a texture
  23287. * @param texture defines the texture to check against the material
  23288. * @returns a boolean specifying if the material uses the texture
  23289. */
  23290. hasTexture(texture: BaseTexture): boolean;
  23291. /**
  23292. * Disposes the material
  23293. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23294. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23295. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23296. */
  23297. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23298. /** Creates the node editor window. */
  23299. private _createNodeEditor;
  23300. /**
  23301. * Launch the node material editor
  23302. * @param config Define the configuration of the editor
  23303. * @return a promise fulfilled when the node editor is visible
  23304. */
  23305. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23306. /**
  23307. * Clear the current material
  23308. */
  23309. clear(): void;
  23310. /**
  23311. * Clear the current material and set it to a default state
  23312. */
  23313. setToDefault(): void;
  23314. /**
  23315. * Clear the current material and set it to a default state for post process
  23316. */
  23317. setToDefaultPostProcess(): void;
  23318. /**
  23319. * Clear the current material and set it to a default state for particle
  23320. */
  23321. setToDefaultParticle(): void;
  23322. /**
  23323. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23324. * @param url defines the url to load from
  23325. * @returns a promise that will fullfil when the material is fully loaded
  23326. */
  23327. loadAsync(url: string): Promise<void>;
  23328. private _gatherBlocks;
  23329. /**
  23330. * Generate a string containing the code declaration required to create an equivalent of this material
  23331. * @returns a string
  23332. */
  23333. generateCode(): string;
  23334. /**
  23335. * Serializes this material in a JSON representation
  23336. * @returns the serialized material object
  23337. */
  23338. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23339. private _restoreConnections;
  23340. /**
  23341. * Clear the current graph and load a new one from a serialization object
  23342. * @param source defines the JSON representation of the material
  23343. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23344. * @param merge defines whether or not the source must be merged or replace the current content
  23345. */
  23346. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23347. /**
  23348. * Makes a duplicate of the current material.
  23349. * @param name - name to use for the new material.
  23350. */
  23351. clone(name: string): NodeMaterial;
  23352. /**
  23353. * Creates a node material from parsed material data
  23354. * @param source defines the JSON representation of the material
  23355. * @param scene defines the hosting scene
  23356. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23357. * @returns a new node material
  23358. */
  23359. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23360. /**
  23361. * Creates a node material from a snippet saved in a remote file
  23362. * @param name defines the name of the material to create
  23363. * @param url defines the url to load from
  23364. * @param scene defines the hosting scene
  23365. * @returns a promise that will resolve to the new node material
  23366. */
  23367. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23368. /**
  23369. * Creates a node material from a snippet saved by the node material editor
  23370. * @param snippetId defines the snippet to load
  23371. * @param scene defines the hosting scene
  23372. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23373. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23374. * @returns a promise that will resolve to the new node material
  23375. */
  23376. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23377. /**
  23378. * Creates a new node material set to default basic configuration
  23379. * @param name defines the name of the material
  23380. * @param scene defines the hosting scene
  23381. * @returns a new NodeMaterial
  23382. */
  23383. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23384. }
  23385. }
  23386. declare module "babylonjs/PostProcesses/postProcess" {
  23387. import { Nullable } from "babylonjs/types";
  23388. import { SmartArray } from "babylonjs/Misc/smartArray";
  23389. import { Observable } from "babylonjs/Misc/observable";
  23390. import { Vector2 } from "babylonjs/Maths/math.vector";
  23391. import { Camera } from "babylonjs/Cameras/camera";
  23392. import { Effect } from "babylonjs/Materials/effect";
  23393. import "babylonjs/Shaders/postprocess.vertex";
  23394. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23395. import { Engine } from "babylonjs/Engines/engine";
  23396. import { Color4 } from "babylonjs/Maths/math.color";
  23397. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23398. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23399. import { Scene } from "babylonjs/scene";
  23400. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23401. /**
  23402. * Size options for a post process
  23403. */
  23404. export type PostProcessOptions = {
  23405. width: number;
  23406. height: number;
  23407. };
  23408. /**
  23409. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23410. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23411. */
  23412. export class PostProcess {
  23413. /**
  23414. * Gets or sets the unique id of the post process
  23415. */
  23416. uniqueId: number;
  23417. /** Name of the PostProcess. */
  23418. name: string;
  23419. /**
  23420. * Width of the texture to apply the post process on
  23421. */
  23422. width: number;
  23423. /**
  23424. * Height of the texture to apply the post process on
  23425. */
  23426. height: number;
  23427. /**
  23428. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23429. */
  23430. nodeMaterialSource: Nullable<NodeMaterial>;
  23431. /**
  23432. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23433. * @hidden
  23434. */
  23435. _outputTexture: Nullable<InternalTexture>;
  23436. /**
  23437. * Sampling mode used by the shader
  23438. * See https://doc.babylonjs.com/classes/3.1/texture
  23439. */
  23440. renderTargetSamplingMode: number;
  23441. /**
  23442. * Clear color to use when screen clearing
  23443. */
  23444. clearColor: Color4;
  23445. /**
  23446. * If the buffer needs to be cleared before applying the post process. (default: true)
  23447. * Should be set to false if shader will overwrite all previous pixels.
  23448. */
  23449. autoClear: boolean;
  23450. /**
  23451. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23452. */
  23453. alphaMode: number;
  23454. /**
  23455. * Sets the setAlphaBlendConstants of the babylon engine
  23456. */
  23457. alphaConstants: Color4;
  23458. /**
  23459. * Animations to be used for the post processing
  23460. */
  23461. animations: import("babylonjs/Animations/animation").Animation[];
  23462. /**
  23463. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23464. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23465. */
  23466. enablePixelPerfectMode: boolean;
  23467. /**
  23468. * Force the postprocess to be applied without taking in account viewport
  23469. */
  23470. forceFullscreenViewport: boolean;
  23471. /**
  23472. * List of inspectable custom properties (used by the Inspector)
  23473. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23474. */
  23475. inspectableCustomProperties: IInspectable[];
  23476. /**
  23477. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23478. *
  23479. * | Value | Type | Description |
  23480. * | ----- | ----------------------------------- | ----------- |
  23481. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23482. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23483. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23484. *
  23485. */
  23486. scaleMode: number;
  23487. /**
  23488. * Force textures to be a power of two (default: false)
  23489. */
  23490. alwaysForcePOT: boolean;
  23491. private _samples;
  23492. /**
  23493. * Number of sample textures (default: 1)
  23494. */
  23495. get samples(): number;
  23496. set samples(n: number);
  23497. /**
  23498. * Modify the scale of the post process to be the same as the viewport (default: false)
  23499. */
  23500. adaptScaleToCurrentViewport: boolean;
  23501. private _camera;
  23502. protected _scene: Scene;
  23503. private _engine;
  23504. private _options;
  23505. private _reusable;
  23506. private _textureType;
  23507. private _textureFormat;
  23508. /**
  23509. * Smart array of input and output textures for the post process.
  23510. * @hidden
  23511. */
  23512. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23513. /**
  23514. * The index in _textures that corresponds to the output texture.
  23515. * @hidden
  23516. */
  23517. _currentRenderTextureInd: number;
  23518. private _effect;
  23519. private _samplers;
  23520. private _fragmentUrl;
  23521. private _vertexUrl;
  23522. private _parameters;
  23523. private _scaleRatio;
  23524. protected _indexParameters: any;
  23525. private _shareOutputWithPostProcess;
  23526. private _texelSize;
  23527. private _forcedOutputTexture;
  23528. /**
  23529. * Returns the fragment url or shader name used in the post process.
  23530. * @returns the fragment url or name in the shader store.
  23531. */
  23532. getEffectName(): string;
  23533. /**
  23534. * An event triggered when the postprocess is activated.
  23535. */
  23536. onActivateObservable: Observable<Camera>;
  23537. private _onActivateObserver;
  23538. /**
  23539. * A function that is added to the onActivateObservable
  23540. */
  23541. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23542. /**
  23543. * An event triggered when the postprocess changes its size.
  23544. */
  23545. onSizeChangedObservable: Observable<PostProcess>;
  23546. private _onSizeChangedObserver;
  23547. /**
  23548. * A function that is added to the onSizeChangedObservable
  23549. */
  23550. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23551. /**
  23552. * An event triggered when the postprocess applies its effect.
  23553. */
  23554. onApplyObservable: Observable<Effect>;
  23555. private _onApplyObserver;
  23556. /**
  23557. * A function that is added to the onApplyObservable
  23558. */
  23559. set onApply(callback: (effect: Effect) => void);
  23560. /**
  23561. * An event triggered before rendering the postprocess
  23562. */
  23563. onBeforeRenderObservable: Observable<Effect>;
  23564. private _onBeforeRenderObserver;
  23565. /**
  23566. * A function that is added to the onBeforeRenderObservable
  23567. */
  23568. set onBeforeRender(callback: (effect: Effect) => void);
  23569. /**
  23570. * An event triggered after rendering the postprocess
  23571. */
  23572. onAfterRenderObservable: Observable<Effect>;
  23573. private _onAfterRenderObserver;
  23574. /**
  23575. * A function that is added to the onAfterRenderObservable
  23576. */
  23577. set onAfterRender(callback: (efect: Effect) => void);
  23578. /**
  23579. * 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
  23580. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23581. */
  23582. get inputTexture(): InternalTexture;
  23583. set inputTexture(value: InternalTexture);
  23584. /**
  23585. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23586. * the only way to unset it is to use this function to restore its internal state
  23587. */
  23588. restoreDefaultInputTexture(): void;
  23589. /**
  23590. * Gets the camera which post process is applied to.
  23591. * @returns The camera the post process is applied to.
  23592. */
  23593. getCamera(): Camera;
  23594. /**
  23595. * Gets the texel size of the postprocess.
  23596. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23597. */
  23598. get texelSize(): Vector2;
  23599. /**
  23600. * Creates a new instance PostProcess
  23601. * @param name The name of the PostProcess.
  23602. * @param fragmentUrl The url of the fragment shader to be used.
  23603. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23604. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23605. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23606. * @param camera The camera to apply the render pass to.
  23607. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23608. * @param engine The engine which the post process will be applied. (default: current engine)
  23609. * @param reusable If the post process can be reused on the same frame. (default: false)
  23610. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23611. * @param textureType Type of textures used when performing the post process. (default: 0)
  23612. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23613. * @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
  23614. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23615. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23616. */
  23617. 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);
  23618. /**
  23619. * Gets a string identifying the name of the class
  23620. * @returns "PostProcess" string
  23621. */
  23622. getClassName(): string;
  23623. /**
  23624. * Gets the engine which this post process belongs to.
  23625. * @returns The engine the post process was enabled with.
  23626. */
  23627. getEngine(): Engine;
  23628. /**
  23629. * The effect that is created when initializing the post process.
  23630. * @returns The created effect corresponding the the postprocess.
  23631. */
  23632. getEffect(): Effect;
  23633. /**
  23634. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23635. * @param postProcess The post process to share the output with.
  23636. * @returns This post process.
  23637. */
  23638. shareOutputWith(postProcess: PostProcess): PostProcess;
  23639. /**
  23640. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23641. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23642. */
  23643. useOwnOutput(): void;
  23644. /**
  23645. * Updates the effect with the current post process compile time values and recompiles the shader.
  23646. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23647. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23648. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23649. * @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
  23650. * @param onCompiled Called when the shader has been compiled.
  23651. * @param onError Called if there is an error when compiling a shader.
  23652. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23653. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23654. */
  23655. 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;
  23656. /**
  23657. * The post process is reusable if it can be used multiple times within one frame.
  23658. * @returns If the post process is reusable
  23659. */
  23660. isReusable(): boolean;
  23661. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23662. markTextureDirty(): void;
  23663. /**
  23664. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23665. * 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.
  23666. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23667. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23668. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23669. * @returns The target texture that was bound to be written to.
  23670. */
  23671. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23672. /**
  23673. * If the post process is supported.
  23674. */
  23675. get isSupported(): boolean;
  23676. /**
  23677. * The aspect ratio of the output texture.
  23678. */
  23679. get aspectRatio(): number;
  23680. /**
  23681. * Get a value indicating if the post-process is ready to be used
  23682. * @returns true if the post-process is ready (shader is compiled)
  23683. */
  23684. isReady(): boolean;
  23685. /**
  23686. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23687. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23688. */
  23689. apply(): Nullable<Effect>;
  23690. private _disposeTextures;
  23691. /**
  23692. * Disposes the post process.
  23693. * @param camera The camera to dispose the post process on.
  23694. */
  23695. dispose(camera?: Camera): void;
  23696. /**
  23697. * Serializes the particle system to a JSON object
  23698. * @returns the JSON object
  23699. */
  23700. serialize(): any;
  23701. /**
  23702. * Creates a material from parsed material data
  23703. * @param parsedPostProcess defines parsed post process data
  23704. * @param scene defines the hosting scene
  23705. * @param rootUrl defines the root URL to use to load textures
  23706. * @returns a new post process
  23707. */
  23708. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23709. }
  23710. }
  23711. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23712. /** @hidden */
  23713. export var kernelBlurVaryingDeclaration: {
  23714. name: string;
  23715. shader: string;
  23716. };
  23717. }
  23718. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23719. /** @hidden */
  23720. export var kernelBlurFragment: {
  23721. name: string;
  23722. shader: string;
  23723. };
  23724. }
  23725. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23726. /** @hidden */
  23727. export var kernelBlurFragment2: {
  23728. name: string;
  23729. shader: string;
  23730. };
  23731. }
  23732. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23733. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23734. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23735. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23736. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23737. /** @hidden */
  23738. export var kernelBlurPixelShader: {
  23739. name: string;
  23740. shader: string;
  23741. };
  23742. }
  23743. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23744. /** @hidden */
  23745. export var kernelBlurVertex: {
  23746. name: string;
  23747. shader: string;
  23748. };
  23749. }
  23750. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23751. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23752. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23753. /** @hidden */
  23754. export var kernelBlurVertexShader: {
  23755. name: string;
  23756. shader: string;
  23757. };
  23758. }
  23759. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23760. import { Vector2 } from "babylonjs/Maths/math.vector";
  23761. import { Nullable } from "babylonjs/types";
  23762. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23763. import { Camera } from "babylonjs/Cameras/camera";
  23764. import { Effect } from "babylonjs/Materials/effect";
  23765. import { Engine } from "babylonjs/Engines/engine";
  23766. import "babylonjs/Shaders/kernelBlur.fragment";
  23767. import "babylonjs/Shaders/kernelBlur.vertex";
  23768. import { Scene } from "babylonjs/scene";
  23769. /**
  23770. * The Blur Post Process which blurs an image based on a kernel and direction.
  23771. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23772. */
  23773. export class BlurPostProcess extends PostProcess {
  23774. private blockCompilation;
  23775. protected _kernel: number;
  23776. protected _idealKernel: number;
  23777. protected _packedFloat: boolean;
  23778. private _staticDefines;
  23779. /** The direction in which to blur the image. */
  23780. direction: Vector2;
  23781. /**
  23782. * Sets the length in pixels of the blur sample region
  23783. */
  23784. set kernel(v: number);
  23785. /**
  23786. * Gets the length in pixels of the blur sample region
  23787. */
  23788. get kernel(): number;
  23789. /**
  23790. * Sets wether or not the blur needs to unpack/repack floats
  23791. */
  23792. set packedFloat(v: boolean);
  23793. /**
  23794. * Gets wether or not the blur is unpacking/repacking floats
  23795. */
  23796. get packedFloat(): boolean;
  23797. /**
  23798. * Gets a string identifying the name of the class
  23799. * @returns "BlurPostProcess" string
  23800. */
  23801. getClassName(): string;
  23802. /**
  23803. * Creates a new instance BlurPostProcess
  23804. * @param name The name of the effect.
  23805. * @param direction The direction in which to blur the image.
  23806. * @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.
  23807. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23808. * @param camera The camera to apply the render pass to.
  23809. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23810. * @param engine The engine which the post process will be applied. (default: current engine)
  23811. * @param reusable If the post process can be reused on the same frame. (default: false)
  23812. * @param textureType Type of textures used when performing the post process. (default: 0)
  23813. * @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)
  23814. */
  23815. 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);
  23816. /**
  23817. * Updates the effect with the current post process compile time values and recompiles the shader.
  23818. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23819. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23820. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23821. * @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
  23822. * @param onCompiled Called when the shader has been compiled.
  23823. * @param onError Called if there is an error when compiling a shader.
  23824. */
  23825. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23826. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23827. /**
  23828. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23829. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23830. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23831. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23832. * The gaps between physical kernels are compensated for in the weighting of the samples
  23833. * @param idealKernel Ideal blur kernel.
  23834. * @return Nearest best kernel.
  23835. */
  23836. protected _nearestBestKernel(idealKernel: number): number;
  23837. /**
  23838. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23839. * @param x The point on the Gaussian distribution to sample.
  23840. * @return the value of the Gaussian function at x.
  23841. */
  23842. protected _gaussianWeight(x: number): number;
  23843. /**
  23844. * Generates a string that can be used as a floating point number in GLSL.
  23845. * @param x Value to print.
  23846. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23847. * @return GLSL float string.
  23848. */
  23849. protected _glslFloat(x: number, decimalFigures?: number): string;
  23850. /** @hidden */
  23851. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23852. }
  23853. }
  23854. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23855. import { Scene } from "babylonjs/scene";
  23856. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23857. import { Plane } from "babylonjs/Maths/math.plane";
  23858. /**
  23859. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23860. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23861. * You can then easily use it as a reflectionTexture on a flat surface.
  23862. * In case the surface is not a plane, please consider relying on reflection probes.
  23863. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23864. */
  23865. export class MirrorTexture extends RenderTargetTexture {
  23866. private scene;
  23867. /**
  23868. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23869. * 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.
  23870. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23871. */
  23872. mirrorPlane: Plane;
  23873. /**
  23874. * Define the blur ratio used to blur the reflection if needed.
  23875. */
  23876. set blurRatio(value: number);
  23877. get blurRatio(): number;
  23878. /**
  23879. * Define the adaptive blur kernel used to blur the reflection if needed.
  23880. * This will autocompute the closest best match for the `blurKernel`
  23881. */
  23882. set adaptiveBlurKernel(value: number);
  23883. /**
  23884. * Define the blur kernel used to blur the reflection if needed.
  23885. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23886. */
  23887. set blurKernel(value: number);
  23888. /**
  23889. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23890. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23891. */
  23892. set blurKernelX(value: number);
  23893. get blurKernelX(): number;
  23894. /**
  23895. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23896. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23897. */
  23898. set blurKernelY(value: number);
  23899. get blurKernelY(): number;
  23900. private _autoComputeBlurKernel;
  23901. protected _onRatioRescale(): void;
  23902. private _updateGammaSpace;
  23903. private _imageProcessingConfigChangeObserver;
  23904. private _transformMatrix;
  23905. private _mirrorMatrix;
  23906. private _savedViewMatrix;
  23907. private _blurX;
  23908. private _blurY;
  23909. private _adaptiveBlurKernel;
  23910. private _blurKernelX;
  23911. private _blurKernelY;
  23912. private _blurRatio;
  23913. /**
  23914. * Instantiates a Mirror Texture.
  23915. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23916. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23917. * You can then easily use it as a reflectionTexture on a flat surface.
  23918. * In case the surface is not a plane, please consider relying on reflection probes.
  23919. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23920. * @param name
  23921. * @param size
  23922. * @param scene
  23923. * @param generateMipMaps
  23924. * @param type
  23925. * @param samplingMode
  23926. * @param generateDepthBuffer
  23927. */
  23928. constructor(name: string, size: number | {
  23929. width: number;
  23930. height: number;
  23931. } | {
  23932. ratio: number;
  23933. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23934. private _preparePostProcesses;
  23935. /**
  23936. * Clone the mirror texture.
  23937. * @returns the cloned texture
  23938. */
  23939. clone(): MirrorTexture;
  23940. /**
  23941. * Serialize the texture to a JSON representation you could use in Parse later on
  23942. * @returns the serialized JSON representation
  23943. */
  23944. serialize(): any;
  23945. /**
  23946. * Dispose the texture and release its associated resources.
  23947. */
  23948. dispose(): void;
  23949. }
  23950. }
  23951. declare module "babylonjs/Materials/Textures/texture" {
  23952. import { Observable } from "babylonjs/Misc/observable";
  23953. import { Nullable } from "babylonjs/types";
  23954. import { Matrix } from "babylonjs/Maths/math.vector";
  23955. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23956. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23957. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23958. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  23959. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  23960. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23961. import { Scene } from "babylonjs/scene";
  23962. /**
  23963. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23964. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23965. */
  23966. export class Texture extends BaseTexture {
  23967. /**
  23968. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23969. */
  23970. static SerializeBuffers: boolean;
  23971. /** @hidden */
  23972. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23973. /** @hidden */
  23974. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23975. /** @hidden */
  23976. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23977. /** nearest is mag = nearest and min = nearest and mip = linear */
  23978. static readonly NEAREST_SAMPLINGMODE: number;
  23979. /** nearest is mag = nearest and min = nearest and mip = linear */
  23980. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23981. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23982. static readonly BILINEAR_SAMPLINGMODE: number;
  23983. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23984. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23985. /** Trilinear is mag = linear and min = linear and mip = linear */
  23986. static readonly TRILINEAR_SAMPLINGMODE: number;
  23987. /** Trilinear is mag = linear and min = linear and mip = linear */
  23988. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23989. /** mag = nearest and min = nearest and mip = nearest */
  23990. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23991. /** mag = nearest and min = linear and mip = nearest */
  23992. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23993. /** mag = nearest and min = linear and mip = linear */
  23994. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23995. /** mag = nearest and min = linear and mip = none */
  23996. static readonly NEAREST_LINEAR: number;
  23997. /** mag = nearest and min = nearest and mip = none */
  23998. static readonly NEAREST_NEAREST: number;
  23999. /** mag = linear and min = nearest and mip = nearest */
  24000. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  24001. /** mag = linear and min = nearest and mip = linear */
  24002. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  24003. /** mag = linear and min = linear and mip = none */
  24004. static readonly LINEAR_LINEAR: number;
  24005. /** mag = linear and min = nearest and mip = none */
  24006. static readonly LINEAR_NEAREST: number;
  24007. /** Explicit coordinates mode */
  24008. static readonly EXPLICIT_MODE: number;
  24009. /** Spherical coordinates mode */
  24010. static readonly SPHERICAL_MODE: number;
  24011. /** Planar coordinates mode */
  24012. static readonly PLANAR_MODE: number;
  24013. /** Cubic coordinates mode */
  24014. static readonly CUBIC_MODE: number;
  24015. /** Projection coordinates mode */
  24016. static readonly PROJECTION_MODE: number;
  24017. /** Inverse Cubic coordinates mode */
  24018. static readonly SKYBOX_MODE: number;
  24019. /** Inverse Cubic coordinates mode */
  24020. static readonly INVCUBIC_MODE: number;
  24021. /** Equirectangular coordinates mode */
  24022. static readonly EQUIRECTANGULAR_MODE: number;
  24023. /** Equirectangular Fixed coordinates mode */
  24024. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  24025. /** Equirectangular Fixed Mirrored coordinates mode */
  24026. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  24027. /** Texture is not repeating outside of 0..1 UVs */
  24028. static readonly CLAMP_ADDRESSMODE: number;
  24029. /** Texture is repeating outside of 0..1 UVs */
  24030. static readonly WRAP_ADDRESSMODE: number;
  24031. /** Texture is repeating and mirrored */
  24032. static readonly MIRROR_ADDRESSMODE: number;
  24033. /**
  24034. * 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
  24035. */
  24036. static UseSerializedUrlIfAny: boolean;
  24037. /**
  24038. * Define the url of the texture.
  24039. */
  24040. url: Nullable<string>;
  24041. /**
  24042. * Define an offset on the texture to offset the u coordinates of the UVs
  24043. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24044. */
  24045. uOffset: number;
  24046. /**
  24047. * Define an offset on the texture to offset the v coordinates of the UVs
  24048. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24049. */
  24050. vOffset: number;
  24051. /**
  24052. * Define an offset on the texture to scale the u coordinates of the UVs
  24053. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24054. */
  24055. uScale: number;
  24056. /**
  24057. * Define an offset on the texture to scale the v coordinates of the UVs
  24058. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24059. */
  24060. vScale: number;
  24061. /**
  24062. * Define an offset on the texture to rotate around the u coordinates of the UVs
  24063. * @see https://doc.babylonjs.com/how_to/more_materials
  24064. */
  24065. uAng: number;
  24066. /**
  24067. * Define an offset on the texture to rotate around the v coordinates of the UVs
  24068. * @see https://doc.babylonjs.com/how_to/more_materials
  24069. */
  24070. vAng: number;
  24071. /**
  24072. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  24073. * @see https://doc.babylonjs.com/how_to/more_materials
  24074. */
  24075. wAng: number;
  24076. /**
  24077. * Defines the center of rotation (U)
  24078. */
  24079. uRotationCenter: number;
  24080. /**
  24081. * Defines the center of rotation (V)
  24082. */
  24083. vRotationCenter: number;
  24084. /**
  24085. * Defines the center of rotation (W)
  24086. */
  24087. wRotationCenter: number;
  24088. /**
  24089. * Are mip maps generated for this texture or not.
  24090. */
  24091. get noMipmap(): boolean;
  24092. /**
  24093. * List of inspectable custom properties (used by the Inspector)
  24094. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24095. */
  24096. inspectableCustomProperties: Nullable<IInspectable[]>;
  24097. private _noMipmap;
  24098. /** @hidden */
  24099. _invertY: boolean;
  24100. private _rowGenerationMatrix;
  24101. private _cachedTextureMatrix;
  24102. private _projectionModeMatrix;
  24103. private _t0;
  24104. private _t1;
  24105. private _t2;
  24106. private _cachedUOffset;
  24107. private _cachedVOffset;
  24108. private _cachedUScale;
  24109. private _cachedVScale;
  24110. private _cachedUAng;
  24111. private _cachedVAng;
  24112. private _cachedWAng;
  24113. private _cachedProjectionMatrixId;
  24114. private _cachedCoordinatesMode;
  24115. /** @hidden */
  24116. protected _initialSamplingMode: number;
  24117. /** @hidden */
  24118. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24119. private _deleteBuffer;
  24120. protected _format: Nullable<number>;
  24121. private _delayedOnLoad;
  24122. private _delayedOnError;
  24123. private _mimeType?;
  24124. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  24125. get mimeType(): string | undefined;
  24126. /**
  24127. * Observable triggered once the texture has been loaded.
  24128. */
  24129. onLoadObservable: Observable<Texture>;
  24130. protected _isBlocking: boolean;
  24131. /**
  24132. * Is the texture preventing material to render while loading.
  24133. * If false, a default texture will be used instead of the loading one during the preparation step.
  24134. */
  24135. set isBlocking(value: boolean);
  24136. get isBlocking(): boolean;
  24137. /**
  24138. * Get the current sampling mode associated with the texture.
  24139. */
  24140. get samplingMode(): number;
  24141. /**
  24142. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24143. */
  24144. get invertY(): boolean;
  24145. /**
  24146. * Instantiates a new texture.
  24147. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24148. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24149. * @param url defines the url of the picture to load as a texture
  24150. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24151. * @param noMipmap defines if the texture will require mip maps or not
  24152. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24153. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24154. * @param onLoad defines a callback triggered when the texture has been loaded
  24155. * @param onError defines a callback triggered when an error occurred during the loading session
  24156. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24157. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24158. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24159. * @param mimeType defines an optional mime type information
  24160. */
  24161. 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);
  24162. /**
  24163. * Update the url (and optional buffer) of this texture if url was null during construction.
  24164. * @param url the url of the texture
  24165. * @param buffer the buffer of the texture (defaults to null)
  24166. * @param onLoad callback called when the texture is loaded (defaults to null)
  24167. */
  24168. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24169. /**
  24170. * Finish the loading sequence of a texture flagged as delayed load.
  24171. * @hidden
  24172. */
  24173. delayLoad(): void;
  24174. private _prepareRowForTextureGeneration;
  24175. /**
  24176. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24177. * @returns the transform matrix of the texture.
  24178. */
  24179. getTextureMatrix(uBase?: number): Matrix;
  24180. /**
  24181. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24182. * @returns The reflection texture transform
  24183. */
  24184. getReflectionTextureMatrix(): Matrix;
  24185. /**
  24186. * Clones the texture.
  24187. * @returns the cloned texture
  24188. */
  24189. clone(): Texture;
  24190. /**
  24191. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24192. * @returns The JSON representation of the texture
  24193. */
  24194. serialize(): any;
  24195. /**
  24196. * Get the current class name of the texture useful for serialization or dynamic coding.
  24197. * @returns "Texture"
  24198. */
  24199. getClassName(): string;
  24200. /**
  24201. * Dispose the texture and release its associated resources.
  24202. */
  24203. dispose(): void;
  24204. /**
  24205. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24206. * @param parsedTexture Define the JSON representation of the texture
  24207. * @param scene Define the scene the parsed texture should be instantiated in
  24208. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24209. * @returns The parsed texture if successful
  24210. */
  24211. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24212. /**
  24213. * Creates a texture from its base 64 representation.
  24214. * @param data Define the base64 payload without the data: prefix
  24215. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24216. * @param scene Define the scene the texture should belong to
  24217. * @param noMipmap Forces the texture to not create mip map information if true
  24218. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24219. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24220. * @param onLoad define a callback triggered when the texture has been loaded
  24221. * @param onError define a callback triggered when an error occurred during the loading session
  24222. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24223. * @returns the created texture
  24224. */
  24225. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24226. /**
  24227. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24228. * @param data Define the base64 payload without the data: prefix
  24229. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24230. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24231. * @param scene Define the scene the texture should belong to
  24232. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24233. * @param noMipmap Forces the texture to not create mip map information if true
  24234. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24235. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24236. * @param onLoad define a callback triggered when the texture has been loaded
  24237. * @param onError define a callback triggered when an error occurred during the loading session
  24238. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24239. * @returns the created texture
  24240. */
  24241. 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;
  24242. }
  24243. }
  24244. declare module "babylonjs/PostProcesses/postProcessManager" {
  24245. import { Nullable } from "babylonjs/types";
  24246. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24247. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24248. import { Scene } from "babylonjs/scene";
  24249. /**
  24250. * PostProcessManager is used to manage one or more post processes or post process pipelines
  24251. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24252. */
  24253. export class PostProcessManager {
  24254. private _scene;
  24255. private _indexBuffer;
  24256. private _vertexBuffers;
  24257. /**
  24258. * Creates a new instance PostProcess
  24259. * @param scene The scene that the post process is associated with.
  24260. */
  24261. constructor(scene: Scene);
  24262. private _prepareBuffers;
  24263. private _buildIndexBuffer;
  24264. /**
  24265. * Rebuilds the vertex buffers of the manager.
  24266. * @hidden
  24267. */
  24268. _rebuild(): void;
  24269. /**
  24270. * Prepares a frame to be run through a post process.
  24271. * @param sourceTexture The input texture to the post procesess. (default: null)
  24272. * @param postProcesses An array of post processes to be run. (default: null)
  24273. * @returns True if the post processes were able to be run.
  24274. * @hidden
  24275. */
  24276. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  24277. /**
  24278. * Manually render a set of post processes to a texture.
  24279. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  24280. * @param postProcesses An array of post processes to be run.
  24281. * @param targetTexture The target texture to render to.
  24282. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  24283. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  24284. * @param lodLevel defines which lod of the texture to render to
  24285. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  24286. */
  24287. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  24288. /**
  24289. * Finalize the result of the output of the postprocesses.
  24290. * @param doNotPresent If true the result will not be displayed to the screen.
  24291. * @param targetTexture The target texture to render to.
  24292. * @param faceIndex The index of the face to bind the target texture to.
  24293. * @param postProcesses The array of post processes to render.
  24294. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  24295. * @hidden
  24296. */
  24297. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24298. /**
  24299. * Disposes of the post process manager.
  24300. */
  24301. dispose(): void;
  24302. }
  24303. }
  24304. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  24305. import { Observable } from "babylonjs/Misc/observable";
  24306. import { SmartArray } from "babylonjs/Misc/smartArray";
  24307. import { Nullable, Immutable } from "babylonjs/types";
  24308. import { Camera } from "babylonjs/Cameras/camera";
  24309. import { Scene } from "babylonjs/scene";
  24310. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24311. import { Color4 } from "babylonjs/Maths/math.color";
  24312. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24314. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24315. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24316. import { Texture } from "babylonjs/Materials/Textures/texture";
  24317. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24318. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24319. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24320. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24321. import { Engine } from "babylonjs/Engines/engine";
  24322. /**
  24323. * This Helps creating a texture that will be created from a camera in your scene.
  24324. * It is basically a dynamic texture that could be used to create special effects for instance.
  24325. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24326. */
  24327. export class RenderTargetTexture extends Texture {
  24328. /**
  24329. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24330. */
  24331. static readonly REFRESHRATE_RENDER_ONCE: number;
  24332. /**
  24333. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24334. */
  24335. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24336. /**
  24337. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24338. * the central point of your effect and can save a lot of performances.
  24339. */
  24340. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24341. /**
  24342. * Use this predicate to dynamically define the list of mesh you want to render.
  24343. * If set, the renderList property will be overwritten.
  24344. */
  24345. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24346. private _renderList;
  24347. /**
  24348. * Use this list to define the list of mesh you want to render.
  24349. */
  24350. get renderList(): Nullable<Array<AbstractMesh>>;
  24351. set renderList(value: Nullable<Array<AbstractMesh>>);
  24352. /**
  24353. * Use this function to overload the renderList array at rendering time.
  24354. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24355. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24356. * the cube (if the RTT is a cube, else layerOrFace=0).
  24357. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24358. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24359. * hold dummy elements!
  24360. */
  24361. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24362. private _hookArray;
  24363. /**
  24364. * Define if particles should be rendered in your texture.
  24365. */
  24366. renderParticles: boolean;
  24367. /**
  24368. * Define if sprites should be rendered in your texture.
  24369. */
  24370. renderSprites: boolean;
  24371. /**
  24372. * Define the camera used to render the texture.
  24373. */
  24374. activeCamera: Nullable<Camera>;
  24375. /**
  24376. * Override the mesh isReady function with your own one.
  24377. */
  24378. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24379. /**
  24380. * Override the render function of the texture with your own one.
  24381. */
  24382. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24383. /**
  24384. * Define if camera post processes should be use while rendering the texture.
  24385. */
  24386. useCameraPostProcesses: boolean;
  24387. /**
  24388. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24389. */
  24390. ignoreCameraViewport: boolean;
  24391. private _postProcessManager;
  24392. private _postProcesses;
  24393. private _resizeObserver;
  24394. /**
  24395. * An event triggered when the texture is unbind.
  24396. */
  24397. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24398. /**
  24399. * An event triggered when the texture is unbind.
  24400. */
  24401. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24402. private _onAfterUnbindObserver;
  24403. /**
  24404. * Set a after unbind callback in the texture.
  24405. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24406. */
  24407. set onAfterUnbind(callback: () => void);
  24408. /**
  24409. * An event triggered before rendering the texture
  24410. */
  24411. onBeforeRenderObservable: Observable<number>;
  24412. private _onBeforeRenderObserver;
  24413. /**
  24414. * Set a before render callback in the texture.
  24415. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24416. */
  24417. set onBeforeRender(callback: (faceIndex: number) => void);
  24418. /**
  24419. * An event triggered after rendering the texture
  24420. */
  24421. onAfterRenderObservable: Observable<number>;
  24422. private _onAfterRenderObserver;
  24423. /**
  24424. * Set a after render callback in the texture.
  24425. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24426. */
  24427. set onAfterRender(callback: (faceIndex: number) => void);
  24428. /**
  24429. * An event triggered after the texture clear
  24430. */
  24431. onClearObservable: Observable<Engine>;
  24432. private _onClearObserver;
  24433. /**
  24434. * Set a clear callback in the texture.
  24435. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24436. */
  24437. set onClear(callback: (Engine: Engine) => void);
  24438. /**
  24439. * An event triggered when the texture is resized.
  24440. */
  24441. onResizeObservable: Observable<RenderTargetTexture>;
  24442. /**
  24443. * Define the clear color of the Render Target if it should be different from the scene.
  24444. */
  24445. clearColor: Color4;
  24446. protected _size: number | {
  24447. width: number;
  24448. height: number;
  24449. layers?: number;
  24450. };
  24451. protected _initialSizeParameter: number | {
  24452. width: number;
  24453. height: number;
  24454. } | {
  24455. ratio: number;
  24456. };
  24457. protected _sizeRatio: Nullable<number>;
  24458. /** @hidden */
  24459. _generateMipMaps: boolean;
  24460. protected _renderingManager: RenderingManager;
  24461. /** @hidden */
  24462. _waitingRenderList?: string[];
  24463. protected _doNotChangeAspectRatio: boolean;
  24464. protected _currentRefreshId: number;
  24465. protected _refreshRate: number;
  24466. protected _textureMatrix: Matrix;
  24467. protected _samples: number;
  24468. protected _renderTargetOptions: RenderTargetCreationOptions;
  24469. /**
  24470. * Gets render target creation options that were used.
  24471. */
  24472. get renderTargetOptions(): RenderTargetCreationOptions;
  24473. protected _onRatioRescale(): void;
  24474. /**
  24475. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24476. * It must define where the camera used to render the texture is set
  24477. */
  24478. boundingBoxPosition: Vector3;
  24479. private _boundingBoxSize;
  24480. /**
  24481. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24482. * When defined, the cubemap will switch to local mode
  24483. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24484. * @example https://www.babylonjs-playground.com/#RNASML
  24485. */
  24486. set boundingBoxSize(value: Vector3);
  24487. get boundingBoxSize(): Vector3;
  24488. /**
  24489. * In case the RTT has been created with a depth texture, get the associated
  24490. * depth texture.
  24491. * Otherwise, return null.
  24492. */
  24493. get depthStencilTexture(): Nullable<InternalTexture>;
  24494. /**
  24495. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24496. * or used a shadow, depth texture...
  24497. * @param name The friendly name of the texture
  24498. * @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)
  24499. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24500. * @param generateMipMaps True if mip maps need to be generated after render.
  24501. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24502. * @param type The type of the buffer in the RTT (int, half float, float...)
  24503. * @param isCube True if a cube texture needs to be created
  24504. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24505. * @param generateDepthBuffer True to generate a depth buffer
  24506. * @param generateStencilBuffer True to generate a stencil buffer
  24507. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24508. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24509. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24510. */
  24511. constructor(name: string, size: number | {
  24512. width: number;
  24513. height: number;
  24514. layers?: number;
  24515. } | {
  24516. ratio: number;
  24517. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24518. /**
  24519. * Creates a depth stencil texture.
  24520. * This is only available in WebGL 2 or with the depth texture extension available.
  24521. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24522. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24523. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24524. */
  24525. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24526. private _processSizeParameter;
  24527. /**
  24528. * Define the number of samples to use in case of MSAA.
  24529. * It defaults to one meaning no MSAA has been enabled.
  24530. */
  24531. get samples(): number;
  24532. set samples(value: number);
  24533. /**
  24534. * Resets the refresh counter of the texture and start bak from scratch.
  24535. * Could be useful to regenerate the texture if it is setup to render only once.
  24536. */
  24537. resetRefreshCounter(): void;
  24538. /**
  24539. * Define the refresh rate of the texture or the rendering frequency.
  24540. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24541. */
  24542. get refreshRate(): number;
  24543. set refreshRate(value: number);
  24544. /**
  24545. * Adds a post process to the render target rendering passes.
  24546. * @param postProcess define the post process to add
  24547. */
  24548. addPostProcess(postProcess: PostProcess): void;
  24549. /**
  24550. * Clear all the post processes attached to the render target
  24551. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24552. */
  24553. clearPostProcesses(dispose?: boolean): void;
  24554. /**
  24555. * Remove one of the post process from the list of attached post processes to the texture
  24556. * @param postProcess define the post process to remove from the list
  24557. */
  24558. removePostProcess(postProcess: PostProcess): void;
  24559. /** @hidden */
  24560. _shouldRender(): boolean;
  24561. /**
  24562. * Gets the actual render size of the texture.
  24563. * @returns the width of the render size
  24564. */
  24565. getRenderSize(): number;
  24566. /**
  24567. * Gets the actual render width of the texture.
  24568. * @returns the width of the render size
  24569. */
  24570. getRenderWidth(): number;
  24571. /**
  24572. * Gets the actual render height of the texture.
  24573. * @returns the height of the render size
  24574. */
  24575. getRenderHeight(): number;
  24576. /**
  24577. * Gets the actual number of layers of the texture.
  24578. * @returns the number of layers
  24579. */
  24580. getRenderLayers(): number;
  24581. /**
  24582. * Get if the texture can be rescaled or not.
  24583. */
  24584. get canRescale(): boolean;
  24585. /**
  24586. * Resize the texture using a ratio.
  24587. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24588. */
  24589. scale(ratio: number): void;
  24590. /**
  24591. * Get the texture reflection matrix used to rotate/transform the reflection.
  24592. * @returns the reflection matrix
  24593. */
  24594. getReflectionTextureMatrix(): Matrix;
  24595. /**
  24596. * Resize the texture to a new desired size.
  24597. * Be carrefull as it will recreate all the data in the new texture.
  24598. * @param size Define the new size. It can be:
  24599. * - a number for squared texture,
  24600. * - an object containing { width: number, height: number }
  24601. * - or an object containing a ratio { ratio: number }
  24602. */
  24603. resize(size: number | {
  24604. width: number;
  24605. height: number;
  24606. } | {
  24607. ratio: number;
  24608. }): void;
  24609. private _defaultRenderListPrepared;
  24610. /**
  24611. * Renders all the objects from the render list into the texture.
  24612. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24613. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24614. */
  24615. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24616. private _bestReflectionRenderTargetDimension;
  24617. private _prepareRenderingManager;
  24618. /**
  24619. * @hidden
  24620. * @param faceIndex face index to bind to if this is a cubetexture
  24621. * @param layer defines the index of the texture to bind in the array
  24622. */
  24623. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24624. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24625. private renderToTarget;
  24626. /**
  24627. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24628. * This allowed control for front to back rendering or reversly depending of the special needs.
  24629. *
  24630. * @param renderingGroupId The rendering group id corresponding to its index
  24631. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24632. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24633. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24634. */
  24635. 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;
  24636. /**
  24637. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24638. *
  24639. * @param renderingGroupId The rendering group id corresponding to its index
  24640. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24641. */
  24642. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24643. /**
  24644. * Clones the texture.
  24645. * @returns the cloned texture
  24646. */
  24647. clone(): RenderTargetTexture;
  24648. /**
  24649. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24650. * @returns The JSON representation of the texture
  24651. */
  24652. serialize(): any;
  24653. /**
  24654. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24655. */
  24656. disposeFramebufferObjects(): void;
  24657. /**
  24658. * Dispose the texture and release its associated resources.
  24659. */
  24660. dispose(): void;
  24661. /** @hidden */
  24662. _rebuild(): void;
  24663. /**
  24664. * Clear the info related to rendering groups preventing retention point in material dispose.
  24665. */
  24666. freeRenderingGroups(): void;
  24667. /**
  24668. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24669. * @returns the view count
  24670. */
  24671. getViewCount(): number;
  24672. }
  24673. }
  24674. declare module "babylonjs/Misc/guid" {
  24675. /**
  24676. * Class used to manipulate GUIDs
  24677. */
  24678. export class GUID {
  24679. /**
  24680. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24681. * Be aware Math.random() could cause collisions, but:
  24682. * "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"
  24683. * @returns a pseudo random id
  24684. */
  24685. static RandomId(): string;
  24686. }
  24687. }
  24688. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24689. import { Nullable } from "babylonjs/types";
  24690. import { Scene } from "babylonjs/scene";
  24691. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24692. import { Material } from "babylonjs/Materials/material";
  24693. import { Effect } from "babylonjs/Materials/effect";
  24694. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24695. /**
  24696. * Options to be used when creating a shadow depth material
  24697. */
  24698. export interface IIOptionShadowDepthMaterial {
  24699. /** Variables in the vertex shader code that need to have their names remapped.
  24700. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24701. * "var_name" should be either: worldPos or vNormalW
  24702. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24703. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24704. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24705. */
  24706. remappedVariables?: string[];
  24707. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24708. standalone?: boolean;
  24709. }
  24710. /**
  24711. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24712. */
  24713. export class ShadowDepthWrapper {
  24714. private _scene;
  24715. private _options?;
  24716. private _baseMaterial;
  24717. private _onEffectCreatedObserver;
  24718. private _subMeshToEffect;
  24719. private _subMeshToDepthEffect;
  24720. private _meshes;
  24721. /** @hidden */
  24722. _matriceNames: any;
  24723. /** Gets the standalone status of the wrapper */
  24724. get standalone(): boolean;
  24725. /** Gets the base material the wrapper is built upon */
  24726. get baseMaterial(): Material;
  24727. /**
  24728. * Instantiate a new shadow depth wrapper.
  24729. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24730. * generate the shadow depth map. For more information, please refer to the documentation:
  24731. * https://doc.babylonjs.com/babylon101/shadows
  24732. * @param baseMaterial Material to wrap
  24733. * @param scene Define the scene the material belongs to
  24734. * @param options Options used to create the wrapper
  24735. */
  24736. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24737. /**
  24738. * Gets the effect to use to generate the depth map
  24739. * @param subMesh subMesh to get the effect for
  24740. * @param shadowGenerator shadow generator to get the effect for
  24741. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24742. */
  24743. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24744. /**
  24745. * Specifies that the submesh is ready to be used for depth rendering
  24746. * @param subMesh submesh to check
  24747. * @param defines the list of defines to take into account when checking the effect
  24748. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24749. * @param useInstances specifies that instances should be used
  24750. * @returns a boolean indicating that the submesh is ready or not
  24751. */
  24752. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24753. /**
  24754. * Disposes the resources
  24755. */
  24756. dispose(): void;
  24757. private _makeEffect;
  24758. }
  24759. }
  24760. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  24761. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24762. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  24763. import { Nullable } from "babylonjs/types";
  24764. module "babylonjs/Engines/thinEngine" {
  24765. interface ThinEngine {
  24766. /**
  24767. * Unbind a list of render target textures from the webGL context
  24768. * This is used only when drawBuffer extension or webGL2 are active
  24769. * @param textures defines the render target textures to unbind
  24770. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  24771. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  24772. */
  24773. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  24774. /**
  24775. * Create a multi render target texture
  24776. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  24777. * @param size defines the size of the texture
  24778. * @param options defines the creation options
  24779. * @returns the cube texture as an InternalTexture
  24780. */
  24781. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  24782. /**
  24783. * Update the sample count for a given multiple render target texture
  24784. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  24785. * @param textures defines the textures to update
  24786. * @param samples defines the sample count to set
  24787. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  24788. */
  24789. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  24790. /**
  24791. * Select a subsets of attachments to draw to.
  24792. * @param attachments gl attachments
  24793. */
  24794. bindAttachments(attachments: number[]): void;
  24795. }
  24796. }
  24797. }
  24798. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  24799. import { Scene } from "babylonjs/scene";
  24800. import { Engine } from "babylonjs/Engines/engine";
  24801. import { Texture } from "babylonjs/Materials/Textures/texture";
  24802. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24803. import "babylonjs/Engines/Extensions/engine.multiRender";
  24804. /**
  24805. * Creation options of the multi render target texture.
  24806. */
  24807. export interface IMultiRenderTargetOptions {
  24808. /**
  24809. * Define if the texture needs to create mip maps after render.
  24810. */
  24811. generateMipMaps?: boolean;
  24812. /**
  24813. * Define the types of all the draw buffers we want to create
  24814. */
  24815. types?: number[];
  24816. /**
  24817. * Define the sampling modes of all the draw buffers we want to create
  24818. */
  24819. samplingModes?: number[];
  24820. /**
  24821. * Define if a depth buffer is required
  24822. */
  24823. generateDepthBuffer?: boolean;
  24824. /**
  24825. * Define if a stencil buffer is required
  24826. */
  24827. generateStencilBuffer?: boolean;
  24828. /**
  24829. * Define if a depth texture is required instead of a depth buffer
  24830. */
  24831. generateDepthTexture?: boolean;
  24832. /**
  24833. * Define the number of desired draw buffers
  24834. */
  24835. textureCount?: number;
  24836. /**
  24837. * Define if aspect ratio should be adapted to the texture or stay the scene one
  24838. */
  24839. doNotChangeAspectRatio?: boolean;
  24840. /**
  24841. * Define the default type of the buffers we are creating
  24842. */
  24843. defaultType?: number;
  24844. }
  24845. /**
  24846. * A multi render target, like a render target provides the ability to render to a texture.
  24847. * Unlike the render target, it can render to several draw buffers in one draw.
  24848. * This is specially interesting in deferred rendering or for any effects requiring more than
  24849. * just one color from a single pass.
  24850. */
  24851. export class MultiRenderTarget extends RenderTargetTexture {
  24852. private _internalTextures;
  24853. private _textures;
  24854. private _multiRenderTargetOptions;
  24855. private _count;
  24856. /**
  24857. * Get if draw buffers are currently supported by the used hardware and browser.
  24858. */
  24859. get isSupported(): boolean;
  24860. /**
  24861. * Get the list of textures generated by the multi render target.
  24862. */
  24863. get textures(): Texture[];
  24864. /**
  24865. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  24866. */
  24867. get count(): number;
  24868. /**
  24869. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  24870. */
  24871. get depthTexture(): Texture;
  24872. /**
  24873. * Set the wrapping mode on U of all the textures we are rendering to.
  24874. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24875. */
  24876. set wrapU(wrap: number);
  24877. /**
  24878. * Set the wrapping mode on V of all the textures we are rendering to.
  24879. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24880. */
  24881. set wrapV(wrap: number);
  24882. /**
  24883. * Instantiate a new multi render target texture.
  24884. * A multi render target, like a render target provides the ability to render to a texture.
  24885. * Unlike the render target, it can render to several draw buffers in one draw.
  24886. * This is specially interesting in deferred rendering or for any effects requiring more than
  24887. * just one color from a single pass.
  24888. * @param name Define the name of the texture
  24889. * @param size Define the size of the buffers to render to
  24890. * @param count Define the number of target we are rendering into
  24891. * @param scene Define the scene the texture belongs to
  24892. * @param options Define the options used to create the multi render target
  24893. */
  24894. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24895. /** @hidden */
  24896. _rebuild(): void;
  24897. private _createInternalTextures;
  24898. private _createTextures;
  24899. /**
  24900. * Define the number of samples used if MSAA is enabled.
  24901. */
  24902. get samples(): number;
  24903. set samples(value: number);
  24904. /**
  24905. * Resize all the textures in the multi render target.
  24906. * Be carrefull as it will recreate all the data in the new texture.
  24907. * @param size Define the new size
  24908. */
  24909. resize(size: any): void;
  24910. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24911. /**
  24912. * Dispose the render targets and their associated resources
  24913. */
  24914. dispose(): void;
  24915. /**
  24916. * Release all the underlying texture used as draw buffers.
  24917. */
  24918. releaseInternalTextures(): void;
  24919. }
  24920. }
  24921. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  24922. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  24923. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24924. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  24925. /** @hidden */
  24926. export var imageProcessingPixelShader: {
  24927. name: string;
  24928. shader: string;
  24929. };
  24930. }
  24931. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  24932. import { Nullable } from "babylonjs/types";
  24933. import { Color4 } from "babylonjs/Maths/math.color";
  24934. import { Camera } from "babylonjs/Cameras/camera";
  24935. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24936. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  24937. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  24938. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  24939. import { Engine } from "babylonjs/Engines/engine";
  24940. import "babylonjs/Shaders/imageProcessing.fragment";
  24941. import "babylonjs/Shaders/postprocess.vertex";
  24942. /**
  24943. * ImageProcessingPostProcess
  24944. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24945. */
  24946. export class ImageProcessingPostProcess extends PostProcess {
  24947. /**
  24948. * Default configuration related to image processing available in the PBR Material.
  24949. */
  24950. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24951. /**
  24952. * Gets the image processing configuration used either in this material.
  24953. */
  24954. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24955. /**
  24956. * Sets the Default image processing configuration used either in the this material.
  24957. *
  24958. * If sets to null, the scene one is in use.
  24959. */
  24960. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24961. /**
  24962. * Keep track of the image processing observer to allow dispose and replace.
  24963. */
  24964. private _imageProcessingObserver;
  24965. /**
  24966. * Attaches a new image processing configuration to the PBR Material.
  24967. * @param configuration
  24968. */
  24969. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24970. /**
  24971. * If the post process is supported.
  24972. */
  24973. get isSupported(): boolean;
  24974. /**
  24975. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24976. */
  24977. get colorCurves(): Nullable<ColorCurves>;
  24978. /**
  24979. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24980. */
  24981. set colorCurves(value: Nullable<ColorCurves>);
  24982. /**
  24983. * Gets wether the color curves effect is enabled.
  24984. */
  24985. get colorCurvesEnabled(): boolean;
  24986. /**
  24987. * Sets wether the color curves effect is enabled.
  24988. */
  24989. set colorCurvesEnabled(value: boolean);
  24990. /**
  24991. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24992. */
  24993. get colorGradingTexture(): Nullable<BaseTexture>;
  24994. /**
  24995. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24996. */
  24997. set colorGradingTexture(value: Nullable<BaseTexture>);
  24998. /**
  24999. * Gets wether the color grading effect is enabled.
  25000. */
  25001. get colorGradingEnabled(): boolean;
  25002. /**
  25003. * Gets wether the color grading effect is enabled.
  25004. */
  25005. set colorGradingEnabled(value: boolean);
  25006. /**
  25007. * Gets exposure used in the effect.
  25008. */
  25009. get exposure(): number;
  25010. /**
  25011. * Sets exposure used in the effect.
  25012. */
  25013. set exposure(value: number);
  25014. /**
  25015. * Gets wether tonemapping is enabled or not.
  25016. */
  25017. get toneMappingEnabled(): boolean;
  25018. /**
  25019. * Sets wether tonemapping is enabled or not
  25020. */
  25021. set toneMappingEnabled(value: boolean);
  25022. /**
  25023. * Gets the type of tone mapping effect.
  25024. */
  25025. get toneMappingType(): number;
  25026. /**
  25027. * Sets the type of tone mapping effect.
  25028. */
  25029. set toneMappingType(value: number);
  25030. /**
  25031. * Gets contrast used in the effect.
  25032. */
  25033. get contrast(): number;
  25034. /**
  25035. * Sets contrast used in the effect.
  25036. */
  25037. set contrast(value: number);
  25038. /**
  25039. * Gets Vignette stretch size.
  25040. */
  25041. get vignetteStretch(): number;
  25042. /**
  25043. * Sets Vignette stretch size.
  25044. */
  25045. set vignetteStretch(value: number);
  25046. /**
  25047. * Gets Vignette centre X Offset.
  25048. */
  25049. get vignetteCentreX(): number;
  25050. /**
  25051. * Sets Vignette centre X Offset.
  25052. */
  25053. set vignetteCentreX(value: number);
  25054. /**
  25055. * Gets Vignette centre Y Offset.
  25056. */
  25057. get vignetteCentreY(): number;
  25058. /**
  25059. * Sets Vignette centre Y Offset.
  25060. */
  25061. set vignetteCentreY(value: number);
  25062. /**
  25063. * Gets Vignette weight or intensity of the vignette effect.
  25064. */
  25065. get vignetteWeight(): number;
  25066. /**
  25067. * Sets Vignette weight or intensity of the vignette effect.
  25068. */
  25069. set vignetteWeight(value: number);
  25070. /**
  25071. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25072. * if vignetteEnabled is set to true.
  25073. */
  25074. get vignetteColor(): Color4;
  25075. /**
  25076. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25077. * if vignetteEnabled is set to true.
  25078. */
  25079. set vignetteColor(value: Color4);
  25080. /**
  25081. * Gets Camera field of view used by the Vignette effect.
  25082. */
  25083. get vignetteCameraFov(): number;
  25084. /**
  25085. * Sets Camera field of view used by the Vignette effect.
  25086. */
  25087. set vignetteCameraFov(value: number);
  25088. /**
  25089. * Gets the vignette blend mode allowing different kind of effect.
  25090. */
  25091. get vignetteBlendMode(): number;
  25092. /**
  25093. * Sets the vignette blend mode allowing different kind of effect.
  25094. */
  25095. set vignetteBlendMode(value: number);
  25096. /**
  25097. * Gets wether the vignette effect is enabled.
  25098. */
  25099. get vignetteEnabled(): boolean;
  25100. /**
  25101. * Sets wether the vignette effect is enabled.
  25102. */
  25103. set vignetteEnabled(value: boolean);
  25104. private _fromLinearSpace;
  25105. /**
  25106. * Gets wether the input of the processing is in Gamma or Linear Space.
  25107. */
  25108. get fromLinearSpace(): boolean;
  25109. /**
  25110. * Sets wether the input of the processing is in Gamma or Linear Space.
  25111. */
  25112. set fromLinearSpace(value: boolean);
  25113. /**
  25114. * Defines cache preventing GC.
  25115. */
  25116. private _defines;
  25117. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  25118. /**
  25119. * "ImageProcessingPostProcess"
  25120. * @returns "ImageProcessingPostProcess"
  25121. */
  25122. getClassName(): string;
  25123. /**
  25124. * @hidden
  25125. */
  25126. _updateParameters(): void;
  25127. dispose(camera?: Camera): void;
  25128. }
  25129. }
  25130. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  25131. /** @hidden */
  25132. export var fibonacci: {
  25133. name: string;
  25134. shader: string;
  25135. };
  25136. }
  25137. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  25138. /** @hidden */
  25139. export var subSurfaceScatteringFunctions: {
  25140. name: string;
  25141. shader: string;
  25142. };
  25143. }
  25144. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  25145. /** @hidden */
  25146. export var diffusionProfile: {
  25147. name: string;
  25148. shader: string;
  25149. };
  25150. }
  25151. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  25152. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  25153. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25154. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  25155. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  25156. /** @hidden */
  25157. export var subSurfaceScatteringPixelShader: {
  25158. name: string;
  25159. shader: string;
  25160. };
  25161. }
  25162. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  25163. import { Nullable } from "babylonjs/types";
  25164. import { Camera } from "babylonjs/Cameras/camera";
  25165. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  25166. import { Engine } from "babylonjs/Engines/engine";
  25167. import { Scene } from "babylonjs/scene";
  25168. import "babylonjs/Shaders/imageProcessing.fragment";
  25169. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  25170. import "babylonjs/Shaders/postprocess.vertex";
  25171. /**
  25172. * Sub surface scattering post process
  25173. */
  25174. export class SubSurfaceScatteringPostProcess extends PostProcess {
  25175. /**
  25176. * Gets a string identifying the name of the class
  25177. * @returns "SubSurfaceScatteringPostProcess" string
  25178. */
  25179. getClassName(): string;
  25180. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  25181. }
  25182. }
  25183. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  25184. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25185. /**
  25186. * Interface for defining prepass effects in the prepass post-process pipeline
  25187. */
  25188. export interface PrePassEffectConfiguration {
  25189. /**
  25190. * Post process to attach for this effect
  25191. */
  25192. postProcess: PostProcess;
  25193. /**
  25194. * Is the effect enabled
  25195. */
  25196. enabled: boolean;
  25197. /**
  25198. * Disposes the effect configuration
  25199. */
  25200. dispose(): void;
  25201. /**
  25202. * Disposes the effect configuration
  25203. */
  25204. createPostProcess: () => PostProcess;
  25205. }
  25206. }
  25207. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  25208. import { Scene } from "babylonjs/scene";
  25209. import { Color3 } from "babylonjs/Maths/math.color";
  25210. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  25211. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  25212. /**
  25213. * Contains all parameters needed for the prepass to perform
  25214. * screen space subsurface scattering
  25215. */
  25216. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  25217. private _ssDiffusionS;
  25218. private _ssFilterRadii;
  25219. private _ssDiffusionD;
  25220. /**
  25221. * Post process to attach for screen space subsurface scattering
  25222. */
  25223. postProcess: SubSurfaceScatteringPostProcess;
  25224. /**
  25225. * Diffusion profile color for subsurface scattering
  25226. */
  25227. get ssDiffusionS(): number[];
  25228. /**
  25229. * Diffusion profile max color channel value for subsurface scattering
  25230. */
  25231. get ssDiffusionD(): number[];
  25232. /**
  25233. * Diffusion profile filter radius for subsurface scattering
  25234. */
  25235. get ssFilterRadii(): number[];
  25236. /**
  25237. * Is subsurface enabled
  25238. */
  25239. enabled: boolean;
  25240. /**
  25241. * Diffusion profile colors for subsurface scattering
  25242. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  25243. * See ...
  25244. * Note that you can only store up to 5 of them
  25245. */
  25246. ssDiffusionProfileColors: Color3[];
  25247. /**
  25248. * Defines the ratio real world => scene units.
  25249. * Used for subsurface scattering
  25250. */
  25251. metersPerUnit: number;
  25252. private _scene;
  25253. /**
  25254. * Builds a subsurface configuration object
  25255. * @param scene The scene
  25256. */
  25257. constructor(scene: Scene);
  25258. /**
  25259. * Adds a new diffusion profile.
  25260. * Useful for more realistic subsurface scattering on diverse materials.
  25261. * @param color The color of the diffusion profile. Should be the average color of the material.
  25262. * @return The index of the diffusion profile for the material subsurface configuration
  25263. */
  25264. addDiffusionProfile(color: Color3): number;
  25265. /**
  25266. * Creates the sss post process
  25267. * @return The created post process
  25268. */
  25269. createPostProcess(): SubSurfaceScatteringPostProcess;
  25270. /**
  25271. * Deletes all diffusion profiles.
  25272. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  25273. */
  25274. clearAllDiffusionProfiles(): void;
  25275. /**
  25276. * Disposes this object
  25277. */
  25278. dispose(): void;
  25279. /**
  25280. * @hidden
  25281. * https://zero-radiance.github.io/post/sampling-diffusion/
  25282. *
  25283. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  25284. * ------------------------------------------------------------------------------------
  25285. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  25286. * PDF[r, phi, s] = r * R[r, phi, s]
  25287. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  25288. * ------------------------------------------------------------------------------------
  25289. * We importance sample the color channel with the widest scattering distance.
  25290. */
  25291. getDiffusionProfileParameters(color: Color3): number;
  25292. /**
  25293. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  25294. * 'u' is the random number (the value of the CDF): [0, 1).
  25295. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  25296. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  25297. */
  25298. private _sampleBurleyDiffusionProfile;
  25299. }
  25300. }
  25301. declare module "babylonjs/Rendering/prePassRenderer" {
  25302. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  25303. import { Scene } from "babylonjs/scene";
  25304. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  25305. import { Effect } from "babylonjs/Materials/effect";
  25306. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  25307. /**
  25308. * Renders a pre pass of the scene
  25309. * This means every mesh in the scene will be rendered to a render target texture
  25310. * And then this texture will be composited to the rendering canvas with post processes
  25311. * It is necessary for effects like subsurface scattering or deferred shading
  25312. */
  25313. export class PrePassRenderer {
  25314. /** @hidden */
  25315. static _SceneComponentInitialization: (scene: Scene) => void;
  25316. private _scene;
  25317. private _engine;
  25318. private _isDirty;
  25319. /**
  25320. * Number of textures in the multi render target texture where the scene is directly rendered
  25321. */
  25322. readonly mrtCount: number;
  25323. /**
  25324. * The render target where the scene is directly rendered
  25325. */
  25326. prePassRT: MultiRenderTarget;
  25327. private _mrtTypes;
  25328. private _multiRenderAttachments;
  25329. private _defaultAttachments;
  25330. private _clearAttachments;
  25331. private _postProcesses;
  25332. private readonly _clearColor;
  25333. /**
  25334. * Image processing post process for composition
  25335. */
  25336. imageProcessingPostProcess: ImageProcessingPostProcess;
  25337. /**
  25338. * Configuration for sub surface scattering post process
  25339. */
  25340. subSurfaceConfiguration: SubSurfaceConfiguration;
  25341. /**
  25342. * Should materials render their geometry on the MRT
  25343. */
  25344. materialsShouldRenderGeometry: boolean;
  25345. /**
  25346. * Should materials render the irradiance information on the MRT
  25347. */
  25348. materialsShouldRenderIrradiance: boolean;
  25349. private _enabled;
  25350. /**
  25351. * Indicates if the prepass is enabled
  25352. */
  25353. get enabled(): boolean;
  25354. /**
  25355. * How many samples are used for MSAA of the scene render target
  25356. */
  25357. get samples(): number;
  25358. set samples(n: number);
  25359. /**
  25360. * Instanciates a prepass renderer
  25361. * @param scene The scene
  25362. */
  25363. constructor(scene: Scene);
  25364. private _initializeAttachments;
  25365. private _createCompositionEffect;
  25366. /**
  25367. * Indicates if rendering a prepass is supported
  25368. */
  25369. get isSupported(): boolean;
  25370. /**
  25371. * Sets the proper output textures to draw in the engine.
  25372. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  25373. */
  25374. bindAttachmentsForEffect(effect: Effect): void;
  25375. /**
  25376. * @hidden
  25377. */
  25378. _beforeCameraDraw(): void;
  25379. /**
  25380. * @hidden
  25381. */
  25382. _afterCameraDraw(): void;
  25383. private _checkRTSize;
  25384. private _bindFrameBuffer;
  25385. /**
  25386. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  25387. */
  25388. clear(): void;
  25389. private _setState;
  25390. private _enable;
  25391. private _disable;
  25392. private _resetPostProcessChain;
  25393. private _bindPostProcessChain;
  25394. /**
  25395. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  25396. */
  25397. markAsDirty(): void;
  25398. private _update;
  25399. /**
  25400. * Disposes the prepass renderer.
  25401. */
  25402. dispose(): void;
  25403. }
  25404. }
  25405. declare module "babylonjs/Materials/material" {
  25406. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25407. import { SmartArray } from "babylonjs/Misc/smartArray";
  25408. import { Observable } from "babylonjs/Misc/observable";
  25409. import { Nullable } from "babylonjs/types";
  25410. import { Scene } from "babylonjs/scene";
  25411. import { Matrix } from "babylonjs/Maths/math.vector";
  25412. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25414. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25415. import { Effect } from "babylonjs/Materials/effect";
  25416. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25417. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25418. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25419. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25420. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  25421. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  25422. import { Mesh } from "babylonjs/Meshes/mesh";
  25423. import { Animation } from "babylonjs/Animations/animation";
  25424. /**
  25425. * Options for compiling materials.
  25426. */
  25427. export interface IMaterialCompilationOptions {
  25428. /**
  25429. * Defines whether clip planes are enabled.
  25430. */
  25431. clipPlane: boolean;
  25432. /**
  25433. * Defines whether instances are enabled.
  25434. */
  25435. useInstances: boolean;
  25436. }
  25437. /**
  25438. * Options passed when calling customShaderNameResolve
  25439. */
  25440. export interface ICustomShaderNameResolveOptions {
  25441. /**
  25442. * 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
  25443. */
  25444. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  25445. }
  25446. /**
  25447. * Base class for the main features of a material in Babylon.js
  25448. */
  25449. export class Material implements IAnimatable {
  25450. /**
  25451. * Returns the triangle fill mode
  25452. */
  25453. static readonly TriangleFillMode: number;
  25454. /**
  25455. * Returns the wireframe mode
  25456. */
  25457. static readonly WireFrameFillMode: number;
  25458. /**
  25459. * Returns the point fill mode
  25460. */
  25461. static readonly PointFillMode: number;
  25462. /**
  25463. * Returns the point list draw mode
  25464. */
  25465. static readonly PointListDrawMode: number;
  25466. /**
  25467. * Returns the line list draw mode
  25468. */
  25469. static readonly LineListDrawMode: number;
  25470. /**
  25471. * Returns the line loop draw mode
  25472. */
  25473. static readonly LineLoopDrawMode: number;
  25474. /**
  25475. * Returns the line strip draw mode
  25476. */
  25477. static readonly LineStripDrawMode: number;
  25478. /**
  25479. * Returns the triangle strip draw mode
  25480. */
  25481. static readonly TriangleStripDrawMode: number;
  25482. /**
  25483. * Returns the triangle fan draw mode
  25484. */
  25485. static readonly TriangleFanDrawMode: number;
  25486. /**
  25487. * Stores the clock-wise side orientation
  25488. */
  25489. static readonly ClockWiseSideOrientation: number;
  25490. /**
  25491. * Stores the counter clock-wise side orientation
  25492. */
  25493. static readonly CounterClockWiseSideOrientation: number;
  25494. /**
  25495. * The dirty texture flag value
  25496. */
  25497. static readonly TextureDirtyFlag: number;
  25498. /**
  25499. * The dirty light flag value
  25500. */
  25501. static readonly LightDirtyFlag: number;
  25502. /**
  25503. * The dirty fresnel flag value
  25504. */
  25505. static readonly FresnelDirtyFlag: number;
  25506. /**
  25507. * The dirty attribute flag value
  25508. */
  25509. static readonly AttributesDirtyFlag: number;
  25510. /**
  25511. * The dirty misc flag value
  25512. */
  25513. static readonly MiscDirtyFlag: number;
  25514. /**
  25515. * The all dirty flag value
  25516. */
  25517. static readonly AllDirtyFlag: number;
  25518. /**
  25519. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  25520. */
  25521. static readonly MATERIAL_OPAQUE: number;
  25522. /**
  25523. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25524. */
  25525. static readonly MATERIAL_ALPHATEST: number;
  25526. /**
  25527. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25528. */
  25529. static readonly MATERIAL_ALPHABLEND: number;
  25530. /**
  25531. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25532. * They are also discarded below the alpha cutoff threshold to improve performances.
  25533. */
  25534. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  25535. /**
  25536. * The Whiteout method is used to blend normals.
  25537. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25538. */
  25539. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  25540. /**
  25541. * The Reoriented Normal Mapping method is used to blend normals.
  25542. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25543. */
  25544. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  25545. /**
  25546. * Custom callback helping to override the default shader used in the material.
  25547. */
  25548. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  25549. /**
  25550. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  25551. */
  25552. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  25553. /**
  25554. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  25555. * This means that the material can keep using a previous shader while a new one is being compiled.
  25556. * This is mostly used when shader parallel compilation is supported (true by default)
  25557. */
  25558. allowShaderHotSwapping: boolean;
  25559. /**
  25560. * The ID of the material
  25561. */
  25562. id: string;
  25563. /**
  25564. * Gets or sets the unique id of the material
  25565. */
  25566. uniqueId: number;
  25567. /**
  25568. * The name of the material
  25569. */
  25570. name: string;
  25571. /**
  25572. * Gets or sets user defined metadata
  25573. */
  25574. metadata: any;
  25575. /**
  25576. * For internal use only. Please do not use.
  25577. */
  25578. reservedDataStore: any;
  25579. /**
  25580. * Specifies if the ready state should be checked on each call
  25581. */
  25582. checkReadyOnEveryCall: boolean;
  25583. /**
  25584. * Specifies if the ready state should be checked once
  25585. */
  25586. checkReadyOnlyOnce: boolean;
  25587. /**
  25588. * The state of the material
  25589. */
  25590. state: string;
  25591. /**
  25592. * If the material can be rendered to several textures with MRT extension
  25593. */
  25594. get canRenderToMRT(): boolean;
  25595. /**
  25596. * The alpha value of the material
  25597. */
  25598. protected _alpha: number;
  25599. /**
  25600. * List of inspectable custom properties (used by the Inspector)
  25601. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25602. */
  25603. inspectableCustomProperties: IInspectable[];
  25604. /**
  25605. * Sets the alpha value of the material
  25606. */
  25607. set alpha(value: number);
  25608. /**
  25609. * Gets the alpha value of the material
  25610. */
  25611. get alpha(): number;
  25612. /**
  25613. * Specifies if back face culling is enabled
  25614. */
  25615. protected _backFaceCulling: boolean;
  25616. /**
  25617. * Sets the back-face culling state
  25618. */
  25619. set backFaceCulling(value: boolean);
  25620. /**
  25621. * Gets the back-face culling state
  25622. */
  25623. get backFaceCulling(): boolean;
  25624. /**
  25625. * Stores the value for side orientation
  25626. */
  25627. sideOrientation: number;
  25628. /**
  25629. * Callback triggered when the material is compiled
  25630. */
  25631. onCompiled: Nullable<(effect: Effect) => void>;
  25632. /**
  25633. * Callback triggered when an error occurs
  25634. */
  25635. onError: Nullable<(effect: Effect, errors: string) => void>;
  25636. /**
  25637. * Callback triggered to get the render target textures
  25638. */
  25639. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  25640. /**
  25641. * Gets a boolean indicating that current material needs to register RTT
  25642. */
  25643. get hasRenderTargetTextures(): boolean;
  25644. /**
  25645. * Specifies if the material should be serialized
  25646. */
  25647. doNotSerialize: boolean;
  25648. /**
  25649. * @hidden
  25650. */
  25651. _storeEffectOnSubMeshes: boolean;
  25652. /**
  25653. * Stores the animations for the material
  25654. */
  25655. animations: Nullable<Array<Animation>>;
  25656. /**
  25657. * An event triggered when the material is disposed
  25658. */
  25659. onDisposeObservable: Observable<Material>;
  25660. /**
  25661. * An observer which watches for dispose events
  25662. */
  25663. private _onDisposeObserver;
  25664. private _onUnBindObservable;
  25665. /**
  25666. * Called during a dispose event
  25667. */
  25668. set onDispose(callback: () => void);
  25669. private _onBindObservable;
  25670. /**
  25671. * An event triggered when the material is bound
  25672. */
  25673. get onBindObservable(): Observable<AbstractMesh>;
  25674. /**
  25675. * An observer which watches for bind events
  25676. */
  25677. private _onBindObserver;
  25678. /**
  25679. * Called during a bind event
  25680. */
  25681. set onBind(callback: (Mesh: AbstractMesh) => void);
  25682. /**
  25683. * An event triggered when the material is unbound
  25684. */
  25685. get onUnBindObservable(): Observable<Material>;
  25686. protected _onEffectCreatedObservable: Nullable<Observable<{
  25687. effect: Effect;
  25688. subMesh: Nullable<SubMesh>;
  25689. }>>;
  25690. /**
  25691. * An event triggered when the effect is (re)created
  25692. */
  25693. get onEffectCreatedObservable(): Observable<{
  25694. effect: Effect;
  25695. subMesh: Nullable<SubMesh>;
  25696. }>;
  25697. /**
  25698. * Stores the value of the alpha mode
  25699. */
  25700. private _alphaMode;
  25701. /**
  25702. * Sets the value of the alpha mode.
  25703. *
  25704. * | Value | Type | Description |
  25705. * | --- | --- | --- |
  25706. * | 0 | ALPHA_DISABLE | |
  25707. * | 1 | ALPHA_ADD | |
  25708. * | 2 | ALPHA_COMBINE | |
  25709. * | 3 | ALPHA_SUBTRACT | |
  25710. * | 4 | ALPHA_MULTIPLY | |
  25711. * | 5 | ALPHA_MAXIMIZED | |
  25712. * | 6 | ALPHA_ONEONE | |
  25713. * | 7 | ALPHA_PREMULTIPLIED | |
  25714. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  25715. * | 9 | ALPHA_INTERPOLATE | |
  25716. * | 10 | ALPHA_SCREENMODE | |
  25717. *
  25718. */
  25719. set alphaMode(value: number);
  25720. /**
  25721. * Gets the value of the alpha mode
  25722. */
  25723. get alphaMode(): number;
  25724. /**
  25725. * Stores the state of the need depth pre-pass value
  25726. */
  25727. private _needDepthPrePass;
  25728. /**
  25729. * Sets the need depth pre-pass value
  25730. */
  25731. set needDepthPrePass(value: boolean);
  25732. /**
  25733. * Gets the depth pre-pass value
  25734. */
  25735. get needDepthPrePass(): boolean;
  25736. /**
  25737. * Specifies if depth writing should be disabled
  25738. */
  25739. disableDepthWrite: boolean;
  25740. /**
  25741. * Specifies if color writing should be disabled
  25742. */
  25743. disableColorWrite: boolean;
  25744. /**
  25745. * Specifies if depth writing should be forced
  25746. */
  25747. forceDepthWrite: boolean;
  25748. /**
  25749. * Specifies the depth function that should be used. 0 means the default engine function
  25750. */
  25751. depthFunction: number;
  25752. /**
  25753. * Specifies if there should be a separate pass for culling
  25754. */
  25755. separateCullingPass: boolean;
  25756. /**
  25757. * Stores the state specifing if fog should be enabled
  25758. */
  25759. private _fogEnabled;
  25760. /**
  25761. * Sets the state for enabling fog
  25762. */
  25763. set fogEnabled(value: boolean);
  25764. /**
  25765. * Gets the value of the fog enabled state
  25766. */
  25767. get fogEnabled(): boolean;
  25768. /**
  25769. * Stores the size of points
  25770. */
  25771. pointSize: number;
  25772. /**
  25773. * Stores the z offset value
  25774. */
  25775. zOffset: number;
  25776. get wireframe(): boolean;
  25777. /**
  25778. * Sets the state of wireframe mode
  25779. */
  25780. set wireframe(value: boolean);
  25781. /**
  25782. * Gets the value specifying if point clouds are enabled
  25783. */
  25784. get pointsCloud(): boolean;
  25785. /**
  25786. * Sets the state of point cloud mode
  25787. */
  25788. set pointsCloud(value: boolean);
  25789. /**
  25790. * Gets the material fill mode
  25791. */
  25792. get fillMode(): number;
  25793. /**
  25794. * Sets the material fill mode
  25795. */
  25796. set fillMode(value: number);
  25797. /**
  25798. * @hidden
  25799. * Stores the effects for the material
  25800. */
  25801. _effect: Nullable<Effect>;
  25802. /**
  25803. * Specifies if uniform buffers should be used
  25804. */
  25805. private _useUBO;
  25806. /**
  25807. * Stores a reference to the scene
  25808. */
  25809. private _scene;
  25810. /**
  25811. * Stores the fill mode state
  25812. */
  25813. private _fillMode;
  25814. /**
  25815. * Specifies if the depth write state should be cached
  25816. */
  25817. private _cachedDepthWriteState;
  25818. /**
  25819. * Specifies if the color write state should be cached
  25820. */
  25821. private _cachedColorWriteState;
  25822. /**
  25823. * Specifies if the depth function state should be cached
  25824. */
  25825. private _cachedDepthFunctionState;
  25826. /**
  25827. * Stores the uniform buffer
  25828. */
  25829. protected _uniformBuffer: UniformBuffer;
  25830. /** @hidden */
  25831. _indexInSceneMaterialArray: number;
  25832. /** @hidden */
  25833. meshMap: Nullable<{
  25834. [id: string]: AbstractMesh | undefined;
  25835. }>;
  25836. /**
  25837. * Creates a material instance
  25838. * @param name defines the name of the material
  25839. * @param scene defines the scene to reference
  25840. * @param doNotAdd specifies if the material should be added to the scene
  25841. */
  25842. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  25843. /**
  25844. * Returns a string representation of the current material
  25845. * @param fullDetails defines a boolean indicating which levels of logging is desired
  25846. * @returns a string with material information
  25847. */
  25848. toString(fullDetails?: boolean): string;
  25849. /**
  25850. * Gets the class name of the material
  25851. * @returns a string with the class name of the material
  25852. */
  25853. getClassName(): string;
  25854. /**
  25855. * Specifies if updates for the material been locked
  25856. */
  25857. get isFrozen(): boolean;
  25858. /**
  25859. * Locks updates for the material
  25860. */
  25861. freeze(): void;
  25862. /**
  25863. * Unlocks updates for the material
  25864. */
  25865. unfreeze(): void;
  25866. /**
  25867. * Specifies if the material is ready to be used
  25868. * @param mesh defines the mesh to check
  25869. * @param useInstances specifies if instances should be used
  25870. * @returns a boolean indicating if the material is ready to be used
  25871. */
  25872. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25873. /**
  25874. * Specifies that the submesh is ready to be used
  25875. * @param mesh defines the mesh to check
  25876. * @param subMesh defines which submesh to check
  25877. * @param useInstances specifies that instances should be used
  25878. * @returns a boolean indicating that the submesh is ready or not
  25879. */
  25880. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25881. /**
  25882. * Returns the material effect
  25883. * @returns the effect associated with the material
  25884. */
  25885. getEffect(): Nullable<Effect>;
  25886. /**
  25887. * Returns the current scene
  25888. * @returns a Scene
  25889. */
  25890. getScene(): Scene;
  25891. /**
  25892. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25893. */
  25894. protected _forceAlphaTest: boolean;
  25895. /**
  25896. * The transparency mode of the material.
  25897. */
  25898. protected _transparencyMode: Nullable<number>;
  25899. /**
  25900. * Gets the current transparency mode.
  25901. */
  25902. get transparencyMode(): Nullable<number>;
  25903. /**
  25904. * Sets the transparency mode of the material.
  25905. *
  25906. * | Value | Type | Description |
  25907. * | ----- | ----------------------------------- | ----------- |
  25908. * | 0 | OPAQUE | |
  25909. * | 1 | ALPHATEST | |
  25910. * | 2 | ALPHABLEND | |
  25911. * | 3 | ALPHATESTANDBLEND | |
  25912. *
  25913. */
  25914. set transparencyMode(value: Nullable<number>);
  25915. /**
  25916. * Returns true if alpha blending should be disabled.
  25917. */
  25918. protected get _disableAlphaBlending(): boolean;
  25919. /**
  25920. * Specifies whether or not this material should be rendered in alpha blend mode.
  25921. * @returns a boolean specifying if alpha blending is needed
  25922. */
  25923. needAlphaBlending(): boolean;
  25924. /**
  25925. * Specifies if the mesh will require alpha blending
  25926. * @param mesh defines the mesh to check
  25927. * @returns a boolean specifying if alpha blending is needed for the mesh
  25928. */
  25929. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25930. /**
  25931. * Specifies whether or not this material should be rendered in alpha test mode.
  25932. * @returns a boolean specifying if an alpha test is needed.
  25933. */
  25934. needAlphaTesting(): boolean;
  25935. /**
  25936. * Specifies if material alpha testing should be turned on for the mesh
  25937. * @param mesh defines the mesh to check
  25938. */
  25939. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25940. /**
  25941. * Gets the texture used for the alpha test
  25942. * @returns the texture to use for alpha testing
  25943. */
  25944. getAlphaTestTexture(): Nullable<BaseTexture>;
  25945. /**
  25946. * Marks the material to indicate that it needs to be re-calculated
  25947. */
  25948. markDirty(): void;
  25949. /** @hidden */
  25950. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25951. /**
  25952. * Binds the material to the mesh
  25953. * @param world defines the world transformation matrix
  25954. * @param mesh defines the mesh to bind the material to
  25955. */
  25956. bind(world: Matrix, mesh?: Mesh): void;
  25957. /**
  25958. * Binds the submesh to the material
  25959. * @param world defines the world transformation matrix
  25960. * @param mesh defines the mesh containing the submesh
  25961. * @param subMesh defines the submesh to bind the material to
  25962. */
  25963. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25964. /**
  25965. * Binds the world matrix to the material
  25966. * @param world defines the world transformation matrix
  25967. */
  25968. bindOnlyWorldMatrix(world: Matrix): void;
  25969. /**
  25970. * Binds the scene's uniform buffer to the effect.
  25971. * @param effect defines the effect to bind to the scene uniform buffer
  25972. * @param sceneUbo defines the uniform buffer storing scene data
  25973. */
  25974. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25975. /**
  25976. * Binds the view matrix to the effect
  25977. * @param effect defines the effect to bind the view matrix to
  25978. */
  25979. bindView(effect: Effect): void;
  25980. /**
  25981. * Binds the view projection matrix to the effect
  25982. * @param effect defines the effect to bind the view projection matrix to
  25983. */
  25984. bindViewProjection(effect: Effect): void;
  25985. /**
  25986. * Processes to execute after binding the material to a mesh
  25987. * @param mesh defines the rendered mesh
  25988. */
  25989. protected _afterBind(mesh?: Mesh): void;
  25990. /**
  25991. * Unbinds the material from the mesh
  25992. */
  25993. unbind(): void;
  25994. /**
  25995. * Gets the active textures from the material
  25996. * @returns an array of textures
  25997. */
  25998. getActiveTextures(): BaseTexture[];
  25999. /**
  26000. * Specifies if the material uses a texture
  26001. * @param texture defines the texture to check against the material
  26002. * @returns a boolean specifying if the material uses the texture
  26003. */
  26004. hasTexture(texture: BaseTexture): boolean;
  26005. /**
  26006. * Makes a duplicate of the material, and gives it a new name
  26007. * @param name defines the new name for the duplicated material
  26008. * @returns the cloned material
  26009. */
  26010. clone(name: string): Nullable<Material>;
  26011. /**
  26012. * Gets the meshes bound to the material
  26013. * @returns an array of meshes bound to the material
  26014. */
  26015. getBindedMeshes(): AbstractMesh[];
  26016. /**
  26017. * Force shader compilation
  26018. * @param mesh defines the mesh associated with this material
  26019. * @param onCompiled defines a function to execute once the material is compiled
  26020. * @param options defines the options to configure the compilation
  26021. * @param onError defines a function to execute if the material fails compiling
  26022. */
  26023. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  26024. /**
  26025. * Force shader compilation
  26026. * @param mesh defines the mesh that will use this material
  26027. * @param options defines additional options for compiling the shaders
  26028. * @returns a promise that resolves when the compilation completes
  26029. */
  26030. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  26031. private static readonly _AllDirtyCallBack;
  26032. private static readonly _ImageProcessingDirtyCallBack;
  26033. private static readonly _TextureDirtyCallBack;
  26034. private static readonly _FresnelDirtyCallBack;
  26035. private static readonly _MiscDirtyCallBack;
  26036. private static readonly _LightsDirtyCallBack;
  26037. private static readonly _AttributeDirtyCallBack;
  26038. private static _FresnelAndMiscDirtyCallBack;
  26039. private static _TextureAndMiscDirtyCallBack;
  26040. private static readonly _DirtyCallbackArray;
  26041. private static readonly _RunDirtyCallBacks;
  26042. /**
  26043. * Marks a define in the material to indicate that it needs to be re-computed
  26044. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  26045. */
  26046. markAsDirty(flag: number): void;
  26047. /**
  26048. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  26049. * @param func defines a function which checks material defines against the submeshes
  26050. */
  26051. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  26052. /**
  26053. * Indicates that the scene should check if the rendering now needs a prepass
  26054. */
  26055. protected _markScenePrePassDirty(): void;
  26056. /**
  26057. * Indicates that we need to re-calculated for all submeshes
  26058. */
  26059. protected _markAllSubMeshesAsAllDirty(): void;
  26060. /**
  26061. * Indicates that image processing needs to be re-calculated for all submeshes
  26062. */
  26063. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  26064. /**
  26065. * Indicates that textures need to be re-calculated for all submeshes
  26066. */
  26067. protected _markAllSubMeshesAsTexturesDirty(): void;
  26068. /**
  26069. * Indicates that fresnel needs to be re-calculated for all submeshes
  26070. */
  26071. protected _markAllSubMeshesAsFresnelDirty(): void;
  26072. /**
  26073. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  26074. */
  26075. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  26076. /**
  26077. * Indicates that lights need to be re-calculated for all submeshes
  26078. */
  26079. protected _markAllSubMeshesAsLightsDirty(): void;
  26080. /**
  26081. * Indicates that attributes need to be re-calculated for all submeshes
  26082. */
  26083. protected _markAllSubMeshesAsAttributesDirty(): void;
  26084. /**
  26085. * Indicates that misc needs to be re-calculated for all submeshes
  26086. */
  26087. protected _markAllSubMeshesAsMiscDirty(): void;
  26088. /**
  26089. * Indicates that textures and misc need to be re-calculated for all submeshes
  26090. */
  26091. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  26092. /**
  26093. * Sets the required values to the prepass renderer.
  26094. * @param prePassRenderer defines the prepass renderer to setup.
  26095. * @returns true if the pre pass is needed.
  26096. */
  26097. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26098. /**
  26099. * Disposes the material
  26100. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26101. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26102. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  26103. */
  26104. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  26105. /** @hidden */
  26106. private releaseVertexArrayObject;
  26107. /**
  26108. * Serializes this material
  26109. * @returns the serialized material object
  26110. */
  26111. serialize(): any;
  26112. /**
  26113. * Creates a material from parsed material data
  26114. * @param parsedMaterial defines parsed material data
  26115. * @param scene defines the hosting scene
  26116. * @param rootUrl defines the root URL to use to load textures
  26117. * @returns a new material
  26118. */
  26119. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  26120. }
  26121. }
  26122. declare module "babylonjs/Materials/multiMaterial" {
  26123. import { Nullable } from "babylonjs/types";
  26124. import { Scene } from "babylonjs/scene";
  26125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26126. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26127. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26128. import { Material } from "babylonjs/Materials/material";
  26129. /**
  26130. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26131. * separate meshes. This can be use to improve performances.
  26132. * @see https://doc.babylonjs.com/how_to/multi_materials
  26133. */
  26134. export class MultiMaterial extends Material {
  26135. private _subMaterials;
  26136. /**
  26137. * Gets or Sets the list of Materials used within the multi material.
  26138. * They need to be ordered according to the submeshes order in the associated mesh
  26139. */
  26140. get subMaterials(): Nullable<Material>[];
  26141. set subMaterials(value: Nullable<Material>[]);
  26142. /**
  26143. * Function used to align with Node.getChildren()
  26144. * @returns the list of Materials used within the multi material
  26145. */
  26146. getChildren(): Nullable<Material>[];
  26147. /**
  26148. * Instantiates a new Multi Material
  26149. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26150. * separate meshes. This can be use to improve performances.
  26151. * @see https://doc.babylonjs.com/how_to/multi_materials
  26152. * @param name Define the name in the scene
  26153. * @param scene Define the scene the material belongs to
  26154. */
  26155. constructor(name: string, scene: Scene);
  26156. private _hookArray;
  26157. /**
  26158. * Get one of the submaterial by its index in the submaterials array
  26159. * @param index The index to look the sub material at
  26160. * @returns The Material if the index has been defined
  26161. */
  26162. getSubMaterial(index: number): Nullable<Material>;
  26163. /**
  26164. * Get the list of active textures for the whole sub materials list.
  26165. * @returns All the textures that will be used during the rendering
  26166. */
  26167. getActiveTextures(): BaseTexture[];
  26168. /**
  26169. * Gets the current class name of the material e.g. "MultiMaterial"
  26170. * Mainly use in serialization.
  26171. * @returns the class name
  26172. */
  26173. getClassName(): string;
  26174. /**
  26175. * Checks if the material is ready to render the requested sub mesh
  26176. * @param mesh Define the mesh the submesh belongs to
  26177. * @param subMesh Define the sub mesh to look readyness for
  26178. * @param useInstances Define whether or not the material is used with instances
  26179. * @returns true if ready, otherwise false
  26180. */
  26181. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26182. /**
  26183. * Clones the current material and its related sub materials
  26184. * @param name Define the name of the newly cloned material
  26185. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  26186. * @returns the cloned material
  26187. */
  26188. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  26189. /**
  26190. * Serializes the materials into a JSON representation.
  26191. * @returns the JSON representation
  26192. */
  26193. serialize(): any;
  26194. /**
  26195. * Dispose the material and release its associated resources
  26196. * @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)
  26197. * @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)
  26198. * @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)
  26199. */
  26200. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  26201. /**
  26202. * Creates a MultiMaterial from parsed MultiMaterial data.
  26203. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  26204. * @param scene defines the hosting scene
  26205. * @returns a new MultiMaterial
  26206. */
  26207. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  26208. }
  26209. }
  26210. declare module "babylonjs/Meshes/subMesh" {
  26211. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  26212. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  26213. import { Engine } from "babylonjs/Engines/engine";
  26214. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  26215. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26216. import { Effect } from "babylonjs/Materials/effect";
  26217. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26218. import { Plane } from "babylonjs/Maths/math.plane";
  26219. import { Collider } from "babylonjs/Collisions/collider";
  26220. import { Material } from "babylonjs/Materials/material";
  26221. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26223. import { Mesh } from "babylonjs/Meshes/mesh";
  26224. import { Ray } from "babylonjs/Culling/ray";
  26225. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26226. /**
  26227. * Defines a subdivision inside a mesh
  26228. */
  26229. export class SubMesh implements ICullable {
  26230. /** the material index to use */
  26231. materialIndex: number;
  26232. /** vertex index start */
  26233. verticesStart: number;
  26234. /** vertices count */
  26235. verticesCount: number;
  26236. /** index start */
  26237. indexStart: number;
  26238. /** indices count */
  26239. indexCount: number;
  26240. /** @hidden */
  26241. _materialDefines: Nullable<MaterialDefines>;
  26242. /** @hidden */
  26243. _materialEffect: Nullable<Effect>;
  26244. /** @hidden */
  26245. _effectOverride: Nullable<Effect>;
  26246. /**
  26247. * Gets material defines used by the effect associated to the sub mesh
  26248. */
  26249. get materialDefines(): Nullable<MaterialDefines>;
  26250. /**
  26251. * Sets material defines used by the effect associated to the sub mesh
  26252. */
  26253. set materialDefines(defines: Nullable<MaterialDefines>);
  26254. /**
  26255. * Gets associated effect
  26256. */
  26257. get effect(): Nullable<Effect>;
  26258. /**
  26259. * Sets associated effect (effect used to render this submesh)
  26260. * @param effect defines the effect to associate with
  26261. * @param defines defines the set of defines used to compile this effect
  26262. */
  26263. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  26264. /** @hidden */
  26265. _linesIndexCount: number;
  26266. private _mesh;
  26267. private _renderingMesh;
  26268. private _boundingInfo;
  26269. private _linesIndexBuffer;
  26270. /** @hidden */
  26271. _lastColliderWorldVertices: Nullable<Vector3[]>;
  26272. /** @hidden */
  26273. _trianglePlanes: Plane[];
  26274. /** @hidden */
  26275. _lastColliderTransformMatrix: Nullable<Matrix>;
  26276. /** @hidden */
  26277. _renderId: number;
  26278. /** @hidden */
  26279. _alphaIndex: number;
  26280. /** @hidden */
  26281. _distanceToCamera: number;
  26282. /** @hidden */
  26283. _id: number;
  26284. private _currentMaterial;
  26285. /**
  26286. * Add a new submesh to a mesh
  26287. * @param materialIndex defines the material index to use
  26288. * @param verticesStart defines vertex index start
  26289. * @param verticesCount defines vertices count
  26290. * @param indexStart defines index start
  26291. * @param indexCount defines indices count
  26292. * @param mesh defines the parent mesh
  26293. * @param renderingMesh defines an optional rendering mesh
  26294. * @param createBoundingBox defines if bounding box should be created for this submesh
  26295. * @returns the new submesh
  26296. */
  26297. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  26298. /**
  26299. * Creates a new submesh
  26300. * @param materialIndex defines the material index to use
  26301. * @param verticesStart defines vertex index start
  26302. * @param verticesCount defines vertices count
  26303. * @param indexStart defines index start
  26304. * @param indexCount defines indices count
  26305. * @param mesh defines the parent mesh
  26306. * @param renderingMesh defines an optional rendering mesh
  26307. * @param createBoundingBox defines if bounding box should be created for this submesh
  26308. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  26309. */
  26310. constructor(
  26311. /** the material index to use */
  26312. materialIndex: number,
  26313. /** vertex index start */
  26314. verticesStart: number,
  26315. /** vertices count */
  26316. verticesCount: number,
  26317. /** index start */
  26318. indexStart: number,
  26319. /** indices count */
  26320. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  26321. /**
  26322. * Returns true if this submesh covers the entire parent mesh
  26323. * @ignorenaming
  26324. */
  26325. get IsGlobal(): boolean;
  26326. /**
  26327. * Returns the submesh BoudingInfo object
  26328. * @returns current bounding info (or mesh's one if the submesh is global)
  26329. */
  26330. getBoundingInfo(): BoundingInfo;
  26331. /**
  26332. * Sets the submesh BoundingInfo
  26333. * @param boundingInfo defines the new bounding info to use
  26334. * @returns the SubMesh
  26335. */
  26336. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  26337. /**
  26338. * Returns the mesh of the current submesh
  26339. * @return the parent mesh
  26340. */
  26341. getMesh(): AbstractMesh;
  26342. /**
  26343. * Returns the rendering mesh of the submesh
  26344. * @returns the rendering mesh (could be different from parent mesh)
  26345. */
  26346. getRenderingMesh(): Mesh;
  26347. /**
  26348. * Returns the replacement mesh of the submesh
  26349. * @returns the replacement mesh (could be different from parent mesh)
  26350. */
  26351. getReplacementMesh(): Nullable<AbstractMesh>;
  26352. /**
  26353. * Returns the effective mesh of the submesh
  26354. * @returns the effective mesh (could be different from parent mesh)
  26355. */
  26356. getEffectiveMesh(): AbstractMesh;
  26357. /**
  26358. * Returns the submesh material
  26359. * @returns null or the current material
  26360. */
  26361. getMaterial(): Nullable<Material>;
  26362. private _IsMultiMaterial;
  26363. /**
  26364. * Sets a new updated BoundingInfo object to the submesh
  26365. * @param data defines an optional position array to use to determine the bounding info
  26366. * @returns the SubMesh
  26367. */
  26368. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  26369. /** @hidden */
  26370. _checkCollision(collider: Collider): boolean;
  26371. /**
  26372. * Updates the submesh BoundingInfo
  26373. * @param world defines the world matrix to use to update the bounding info
  26374. * @returns the submesh
  26375. */
  26376. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  26377. /**
  26378. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  26379. * @param frustumPlanes defines the frustum planes
  26380. * @returns true if the submesh is intersecting with the frustum
  26381. */
  26382. isInFrustum(frustumPlanes: Plane[]): boolean;
  26383. /**
  26384. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  26385. * @param frustumPlanes defines the frustum planes
  26386. * @returns true if the submesh is inside the frustum
  26387. */
  26388. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26389. /**
  26390. * Renders the submesh
  26391. * @param enableAlphaMode defines if alpha needs to be used
  26392. * @returns the submesh
  26393. */
  26394. render(enableAlphaMode: boolean): SubMesh;
  26395. /**
  26396. * @hidden
  26397. */
  26398. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  26399. /**
  26400. * Checks if the submesh intersects with a ray
  26401. * @param ray defines the ray to test
  26402. * @returns true is the passed ray intersects the submesh bounding box
  26403. */
  26404. canIntersects(ray: Ray): boolean;
  26405. /**
  26406. * Intersects current submesh with a ray
  26407. * @param ray defines the ray to test
  26408. * @param positions defines mesh's positions array
  26409. * @param indices defines mesh's indices array
  26410. * @param fastCheck defines if the first intersection will be used (and not the closest)
  26411. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26412. * @returns intersection info or null if no intersection
  26413. */
  26414. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  26415. /** @hidden */
  26416. private _intersectLines;
  26417. /** @hidden */
  26418. private _intersectUnIndexedLines;
  26419. /** @hidden */
  26420. private _intersectTriangles;
  26421. /** @hidden */
  26422. private _intersectUnIndexedTriangles;
  26423. /** @hidden */
  26424. _rebuild(): void;
  26425. /**
  26426. * Creates a new submesh from the passed mesh
  26427. * @param newMesh defines the new hosting mesh
  26428. * @param newRenderingMesh defines an optional rendering mesh
  26429. * @returns the new submesh
  26430. */
  26431. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  26432. /**
  26433. * Release associated resources
  26434. */
  26435. dispose(): void;
  26436. /**
  26437. * Gets the class name
  26438. * @returns the string "SubMesh".
  26439. */
  26440. getClassName(): string;
  26441. /**
  26442. * Creates a new submesh from indices data
  26443. * @param materialIndex the index of the main mesh material
  26444. * @param startIndex the index where to start the copy in the mesh indices array
  26445. * @param indexCount the number of indices to copy then from the startIndex
  26446. * @param mesh the main mesh to create the submesh from
  26447. * @param renderingMesh the optional rendering mesh
  26448. * @returns a new submesh
  26449. */
  26450. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  26451. }
  26452. }
  26453. declare module "babylonjs/Loading/sceneLoaderFlags" {
  26454. /**
  26455. * Class used to represent data loading progression
  26456. */
  26457. export class SceneLoaderFlags {
  26458. private static _ForceFullSceneLoadingForIncremental;
  26459. private static _ShowLoadingScreen;
  26460. private static _CleanBoneMatrixWeights;
  26461. private static _loggingLevel;
  26462. /**
  26463. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  26464. */
  26465. static get ForceFullSceneLoadingForIncremental(): boolean;
  26466. static set ForceFullSceneLoadingForIncremental(value: boolean);
  26467. /**
  26468. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  26469. */
  26470. static get ShowLoadingScreen(): boolean;
  26471. static set ShowLoadingScreen(value: boolean);
  26472. /**
  26473. * Defines the current logging level (while loading the scene)
  26474. * @ignorenaming
  26475. */
  26476. static get loggingLevel(): number;
  26477. static set loggingLevel(value: number);
  26478. /**
  26479. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  26480. */
  26481. static get CleanBoneMatrixWeights(): boolean;
  26482. static set CleanBoneMatrixWeights(value: boolean);
  26483. }
  26484. }
  26485. declare module "babylonjs/Meshes/geometry" {
  26486. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26487. import { Scene } from "babylonjs/scene";
  26488. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26489. import { Engine } from "babylonjs/Engines/engine";
  26490. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  26491. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26492. import { Effect } from "babylonjs/Materials/effect";
  26493. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26494. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26495. import { Mesh } from "babylonjs/Meshes/mesh";
  26496. /**
  26497. * Class used to store geometry data (vertex buffers + index buffer)
  26498. */
  26499. export class Geometry implements IGetSetVerticesData {
  26500. /**
  26501. * Gets or sets the ID of the geometry
  26502. */
  26503. id: string;
  26504. /**
  26505. * Gets or sets the unique ID of the geometry
  26506. */
  26507. uniqueId: number;
  26508. /**
  26509. * Gets the delay loading state of the geometry (none by default which means not delayed)
  26510. */
  26511. delayLoadState: number;
  26512. /**
  26513. * Gets the file containing the data to load when running in delay load state
  26514. */
  26515. delayLoadingFile: Nullable<string>;
  26516. /**
  26517. * Callback called when the geometry is updated
  26518. */
  26519. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  26520. private _scene;
  26521. private _engine;
  26522. private _meshes;
  26523. private _totalVertices;
  26524. /** @hidden */
  26525. _indices: IndicesArray;
  26526. /** @hidden */
  26527. _vertexBuffers: {
  26528. [key: string]: VertexBuffer;
  26529. };
  26530. private _isDisposed;
  26531. private _extend;
  26532. private _boundingBias;
  26533. /** @hidden */
  26534. _delayInfo: Array<string>;
  26535. private _indexBuffer;
  26536. private _indexBufferIsUpdatable;
  26537. /** @hidden */
  26538. _boundingInfo: Nullable<BoundingInfo>;
  26539. /** @hidden */
  26540. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  26541. /** @hidden */
  26542. _softwareSkinningFrameId: number;
  26543. private _vertexArrayObjects;
  26544. private _updatable;
  26545. /** @hidden */
  26546. _positions: Nullable<Vector3[]>;
  26547. /**
  26548. * 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
  26549. */
  26550. get boundingBias(): Vector2;
  26551. /**
  26552. * 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
  26553. */
  26554. set boundingBias(value: Vector2);
  26555. /**
  26556. * Static function used to attach a new empty geometry to a mesh
  26557. * @param mesh defines the mesh to attach the geometry to
  26558. * @returns the new Geometry
  26559. */
  26560. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  26561. /** Get the list of meshes using this geometry */
  26562. get meshes(): Mesh[];
  26563. /**
  26564. * 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
  26565. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  26566. */
  26567. useBoundingInfoFromGeometry: boolean;
  26568. /**
  26569. * Creates a new geometry
  26570. * @param id defines the unique ID
  26571. * @param scene defines the hosting scene
  26572. * @param vertexData defines the VertexData used to get geometry data
  26573. * @param updatable defines if geometry must be updatable (false by default)
  26574. * @param mesh defines the mesh that will be associated with the geometry
  26575. */
  26576. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  26577. /**
  26578. * Gets the current extend of the geometry
  26579. */
  26580. get extend(): {
  26581. minimum: Vector3;
  26582. maximum: Vector3;
  26583. };
  26584. /**
  26585. * Gets the hosting scene
  26586. * @returns the hosting Scene
  26587. */
  26588. getScene(): Scene;
  26589. /**
  26590. * Gets the hosting engine
  26591. * @returns the hosting Engine
  26592. */
  26593. getEngine(): Engine;
  26594. /**
  26595. * Defines if the geometry is ready to use
  26596. * @returns true if the geometry is ready to be used
  26597. */
  26598. isReady(): boolean;
  26599. /**
  26600. * Gets a value indicating that the geometry should not be serialized
  26601. */
  26602. get doNotSerialize(): boolean;
  26603. /** @hidden */
  26604. _rebuild(): void;
  26605. /**
  26606. * Affects all geometry data in one call
  26607. * @param vertexData defines the geometry data
  26608. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  26609. */
  26610. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  26611. /**
  26612. * Set specific vertex data
  26613. * @param kind defines the data kind (Position, normal, etc...)
  26614. * @param data defines the vertex data to use
  26615. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26616. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26617. */
  26618. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  26619. /**
  26620. * Removes a specific vertex data
  26621. * @param kind defines the data kind (Position, normal, etc...)
  26622. */
  26623. removeVerticesData(kind: string): void;
  26624. /**
  26625. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  26626. * @param buffer defines the vertex buffer to use
  26627. * @param totalVertices defines the total number of vertices for position kind (could be null)
  26628. */
  26629. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  26630. /**
  26631. * Update a specific vertex buffer
  26632. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  26633. * It will do nothing if the buffer is not updatable
  26634. * @param kind defines the data kind (Position, normal, etc...)
  26635. * @param data defines the data to use
  26636. * @param offset defines the offset in the target buffer where to store the data
  26637. * @param useBytes set to true if the offset is in bytes
  26638. */
  26639. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  26640. /**
  26641. * Update a specific vertex buffer
  26642. * This function will create a new buffer if the current one is not updatable
  26643. * @param kind defines the data kind (Position, normal, etc...)
  26644. * @param data defines the data to use
  26645. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  26646. */
  26647. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  26648. private _updateBoundingInfo;
  26649. /** @hidden */
  26650. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  26651. /**
  26652. * Gets total number of vertices
  26653. * @returns the total number of vertices
  26654. */
  26655. getTotalVertices(): number;
  26656. /**
  26657. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26658. * @param kind defines the data kind (Position, normal, etc...)
  26659. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26660. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26661. * @returns a float array containing vertex data
  26662. */
  26663. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26664. /**
  26665. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  26666. * @param kind defines the data kind (Position, normal, etc...)
  26667. * @returns true if the vertex buffer with the specified kind is updatable
  26668. */
  26669. isVertexBufferUpdatable(kind: string): boolean;
  26670. /**
  26671. * Gets a specific vertex buffer
  26672. * @param kind defines the data kind (Position, normal, etc...)
  26673. * @returns a VertexBuffer
  26674. */
  26675. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26676. /**
  26677. * Returns all vertex buffers
  26678. * @return an object holding all vertex buffers indexed by kind
  26679. */
  26680. getVertexBuffers(): Nullable<{
  26681. [key: string]: VertexBuffer;
  26682. }>;
  26683. /**
  26684. * Gets a boolean indicating if specific vertex buffer is present
  26685. * @param kind defines the data kind (Position, normal, etc...)
  26686. * @returns true if data is present
  26687. */
  26688. isVerticesDataPresent(kind: string): boolean;
  26689. /**
  26690. * Gets a list of all attached data kinds (Position, normal, etc...)
  26691. * @returns a list of string containing all kinds
  26692. */
  26693. getVerticesDataKinds(): string[];
  26694. /**
  26695. * Update index buffer
  26696. * @param indices defines the indices to store in the index buffer
  26697. * @param offset defines the offset in the target buffer where to store the data
  26698. * @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)
  26699. */
  26700. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  26701. /**
  26702. * Creates a new index buffer
  26703. * @param indices defines the indices to store in the index buffer
  26704. * @param totalVertices defines the total number of vertices (could be null)
  26705. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26706. */
  26707. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  26708. /**
  26709. * Return the total number of indices
  26710. * @returns the total number of indices
  26711. */
  26712. getTotalIndices(): number;
  26713. /**
  26714. * Gets the index buffer array
  26715. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26716. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26717. * @returns the index buffer array
  26718. */
  26719. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26720. /**
  26721. * Gets the index buffer
  26722. * @return the index buffer
  26723. */
  26724. getIndexBuffer(): Nullable<DataBuffer>;
  26725. /** @hidden */
  26726. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  26727. /**
  26728. * Release the associated resources for a specific mesh
  26729. * @param mesh defines the source mesh
  26730. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  26731. */
  26732. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  26733. /**
  26734. * Apply current geometry to a given mesh
  26735. * @param mesh defines the mesh to apply geometry to
  26736. */
  26737. applyToMesh(mesh: Mesh): void;
  26738. private _updateExtend;
  26739. private _applyToMesh;
  26740. private notifyUpdate;
  26741. /**
  26742. * Load the geometry if it was flagged as delay loaded
  26743. * @param scene defines the hosting scene
  26744. * @param onLoaded defines a callback called when the geometry is loaded
  26745. */
  26746. load(scene: Scene, onLoaded?: () => void): void;
  26747. private _queueLoad;
  26748. /**
  26749. * Invert the geometry to move from a right handed system to a left handed one.
  26750. */
  26751. toLeftHanded(): void;
  26752. /** @hidden */
  26753. _resetPointsArrayCache(): void;
  26754. /** @hidden */
  26755. _generatePointsArray(): boolean;
  26756. /**
  26757. * Gets a value indicating if the geometry is disposed
  26758. * @returns true if the geometry was disposed
  26759. */
  26760. isDisposed(): boolean;
  26761. private _disposeVertexArrayObjects;
  26762. /**
  26763. * Free all associated resources
  26764. */
  26765. dispose(): void;
  26766. /**
  26767. * Clone the current geometry into a new geometry
  26768. * @param id defines the unique ID of the new geometry
  26769. * @returns a new geometry object
  26770. */
  26771. copy(id: string): Geometry;
  26772. /**
  26773. * Serialize the current geometry info (and not the vertices data) into a JSON object
  26774. * @return a JSON representation of the current geometry data (without the vertices data)
  26775. */
  26776. serialize(): any;
  26777. private toNumberArray;
  26778. /**
  26779. * Serialize all vertices data into a JSON oject
  26780. * @returns a JSON representation of the current geometry data
  26781. */
  26782. serializeVerticeData(): any;
  26783. /**
  26784. * Extracts a clone of a mesh geometry
  26785. * @param mesh defines the source mesh
  26786. * @param id defines the unique ID of the new geometry object
  26787. * @returns the new geometry object
  26788. */
  26789. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  26790. /**
  26791. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  26792. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  26793. * Be aware Math.random() could cause collisions, but:
  26794. * "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"
  26795. * @returns a string containing a new GUID
  26796. */
  26797. static RandomId(): string;
  26798. /** @hidden */
  26799. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  26800. private static _CleanMatricesWeights;
  26801. /**
  26802. * Create a new geometry from persisted data (Using .babylon file format)
  26803. * @param parsedVertexData defines the persisted data
  26804. * @param scene defines the hosting scene
  26805. * @param rootUrl defines the root url to use to load assets (like delayed data)
  26806. * @returns the new geometry object
  26807. */
  26808. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  26809. }
  26810. }
  26811. declare module "babylonjs/Meshes/mesh.vertexData" {
  26812. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  26813. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  26814. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  26815. import { Geometry } from "babylonjs/Meshes/geometry";
  26816. import { Mesh } from "babylonjs/Meshes/mesh";
  26817. /**
  26818. * Define an interface for all classes that will get and set the data on vertices
  26819. */
  26820. export interface IGetSetVerticesData {
  26821. /**
  26822. * Gets a boolean indicating if specific vertex data is present
  26823. * @param kind defines the vertex data kind to use
  26824. * @returns true is data kind is present
  26825. */
  26826. isVerticesDataPresent(kind: string): boolean;
  26827. /**
  26828. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26829. * @param kind defines the data kind (Position, normal, etc...)
  26830. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26831. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26832. * @returns a float array containing vertex data
  26833. */
  26834. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26835. /**
  26836. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26837. * @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.
  26838. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26839. * @returns the indices array or an empty array if the mesh has no geometry
  26840. */
  26841. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26842. /**
  26843. * Set specific vertex data
  26844. * @param kind defines the data kind (Position, normal, etc...)
  26845. * @param data defines the vertex data to use
  26846. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26847. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26848. */
  26849. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  26850. /**
  26851. * Update a specific associated vertex buffer
  26852. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26853. * - VertexBuffer.PositionKind
  26854. * - VertexBuffer.UVKind
  26855. * - VertexBuffer.UV2Kind
  26856. * - VertexBuffer.UV3Kind
  26857. * - VertexBuffer.UV4Kind
  26858. * - VertexBuffer.UV5Kind
  26859. * - VertexBuffer.UV6Kind
  26860. * - VertexBuffer.ColorKind
  26861. * - VertexBuffer.MatricesIndicesKind
  26862. * - VertexBuffer.MatricesIndicesExtraKind
  26863. * - VertexBuffer.MatricesWeightsKind
  26864. * - VertexBuffer.MatricesWeightsExtraKind
  26865. * @param data defines the data source
  26866. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26867. * @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)
  26868. */
  26869. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  26870. /**
  26871. * Creates a new index buffer
  26872. * @param indices defines the indices to store in the index buffer
  26873. * @param totalVertices defines the total number of vertices (could be null)
  26874. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26875. */
  26876. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  26877. }
  26878. /**
  26879. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  26880. */
  26881. export class VertexData {
  26882. /**
  26883. * Mesh side orientation : usually the external or front surface
  26884. */
  26885. static readonly FRONTSIDE: number;
  26886. /**
  26887. * Mesh side orientation : usually the internal or back surface
  26888. */
  26889. static readonly BACKSIDE: number;
  26890. /**
  26891. * Mesh side orientation : both internal and external or front and back surfaces
  26892. */
  26893. static readonly DOUBLESIDE: number;
  26894. /**
  26895. * Mesh side orientation : by default, `FRONTSIDE`
  26896. */
  26897. static readonly DEFAULTSIDE: number;
  26898. /**
  26899. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26900. */
  26901. positions: Nullable<FloatArray>;
  26902. /**
  26903. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26904. */
  26905. normals: Nullable<FloatArray>;
  26906. /**
  26907. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26908. */
  26909. tangents: Nullable<FloatArray>;
  26910. /**
  26911. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26912. */
  26913. uvs: Nullable<FloatArray>;
  26914. /**
  26915. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26916. */
  26917. uvs2: Nullable<FloatArray>;
  26918. /**
  26919. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26920. */
  26921. uvs3: Nullable<FloatArray>;
  26922. /**
  26923. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26924. */
  26925. uvs4: Nullable<FloatArray>;
  26926. /**
  26927. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26928. */
  26929. uvs5: Nullable<FloatArray>;
  26930. /**
  26931. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26932. */
  26933. uvs6: Nullable<FloatArray>;
  26934. /**
  26935. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  26936. */
  26937. colors: Nullable<FloatArray>;
  26938. /**
  26939. * 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).
  26940. */
  26941. matricesIndices: Nullable<FloatArray>;
  26942. /**
  26943. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26944. */
  26945. matricesWeights: Nullable<FloatArray>;
  26946. /**
  26947. * An array extending the number of possible indices
  26948. */
  26949. matricesIndicesExtra: Nullable<FloatArray>;
  26950. /**
  26951. * An array extending the number of possible weights when the number of indices is extended
  26952. */
  26953. matricesWeightsExtra: Nullable<FloatArray>;
  26954. /**
  26955. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26956. */
  26957. indices: Nullable<IndicesArray>;
  26958. /**
  26959. * Uses the passed data array to set the set the values for the specified kind of data
  26960. * @param data a linear array of floating numbers
  26961. * @param kind the type of data that is being set, eg positions, colors etc
  26962. */
  26963. set(data: FloatArray, kind: string): void;
  26964. /**
  26965. * Associates the vertexData to the passed Mesh.
  26966. * Sets it as updatable or not (default `false`)
  26967. * @param mesh the mesh the vertexData is applied to
  26968. * @param updatable when used and having the value true allows new data to update the vertexData
  26969. * @returns the VertexData
  26970. */
  26971. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26972. /**
  26973. * Associates the vertexData to the passed Geometry.
  26974. * Sets it as updatable or not (default `false`)
  26975. * @param geometry the geometry the vertexData is applied to
  26976. * @param updatable when used and having the value true allows new data to update the vertexData
  26977. * @returns VertexData
  26978. */
  26979. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26980. /**
  26981. * Updates the associated mesh
  26982. * @param mesh the mesh to be updated
  26983. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26984. * @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
  26985. * @returns VertexData
  26986. */
  26987. updateMesh(mesh: Mesh): VertexData;
  26988. /**
  26989. * Updates the associated geometry
  26990. * @param geometry the geometry to be updated
  26991. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26992. * @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
  26993. * @returns VertexData.
  26994. */
  26995. updateGeometry(geometry: Geometry): VertexData;
  26996. private _applyTo;
  26997. private _update;
  26998. /**
  26999. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27000. * @param matrix the transforming matrix
  27001. * @returns the VertexData
  27002. */
  27003. transform(matrix: Matrix): VertexData;
  27004. /**
  27005. * Merges the passed VertexData into the current one
  27006. * @param other the VertexData to be merged into the current one
  27007. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27008. * @returns the modified VertexData
  27009. */
  27010. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27011. private _mergeElement;
  27012. private _validate;
  27013. /**
  27014. * Serializes the VertexData
  27015. * @returns a serialized object
  27016. */
  27017. serialize(): any;
  27018. /**
  27019. * Extracts the vertexData from a mesh
  27020. * @param mesh the mesh from which to extract the VertexData
  27021. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27022. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27023. * @returns the object VertexData associated to the passed mesh
  27024. */
  27025. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27026. /**
  27027. * Extracts the vertexData from the geometry
  27028. * @param geometry the geometry from which to extract the VertexData
  27029. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27030. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27031. * @returns the object VertexData associated to the passed mesh
  27032. */
  27033. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27034. private static _ExtractFrom;
  27035. /**
  27036. * Creates the VertexData for a Ribbon
  27037. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27038. * * pathArray array of paths, each of which an array of successive Vector3
  27039. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27040. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27041. * * 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
  27042. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27043. * * 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)
  27044. * * 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)
  27045. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27046. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27047. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27048. * @returns the VertexData of the ribbon
  27049. */
  27050. static CreateRibbon(options: {
  27051. pathArray: Vector3[][];
  27052. closeArray?: boolean;
  27053. closePath?: boolean;
  27054. offset?: number;
  27055. sideOrientation?: number;
  27056. frontUVs?: Vector4;
  27057. backUVs?: Vector4;
  27058. invertUV?: boolean;
  27059. uvs?: Vector2[];
  27060. colors?: Color4[];
  27061. }): VertexData;
  27062. /**
  27063. * Creates the VertexData for a box
  27064. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27065. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27066. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27067. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27068. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27069. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27070. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27071. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27072. * * 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)
  27073. * * 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)
  27074. * @returns the VertexData of the box
  27075. */
  27076. static CreateBox(options: {
  27077. size?: number;
  27078. width?: number;
  27079. height?: number;
  27080. depth?: number;
  27081. faceUV?: Vector4[];
  27082. faceColors?: Color4[];
  27083. sideOrientation?: number;
  27084. frontUVs?: Vector4;
  27085. backUVs?: Vector4;
  27086. }): VertexData;
  27087. /**
  27088. * Creates the VertexData for a tiled box
  27089. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27090. * * faceTiles sets the pattern, tile size and number of tiles for a face
  27091. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27092. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27093. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27094. * @returns the VertexData of the box
  27095. */
  27096. static CreateTiledBox(options: {
  27097. pattern?: number;
  27098. width?: number;
  27099. height?: number;
  27100. depth?: number;
  27101. tileSize?: number;
  27102. tileWidth?: number;
  27103. tileHeight?: number;
  27104. alignHorizontal?: number;
  27105. alignVertical?: number;
  27106. faceUV?: Vector4[];
  27107. faceColors?: Color4[];
  27108. sideOrientation?: number;
  27109. }): VertexData;
  27110. /**
  27111. * Creates the VertexData for a tiled plane
  27112. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27113. * * pattern a limited pattern arrangement depending on the number
  27114. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  27115. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  27116. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  27117. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27118. * * 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)
  27119. * * 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)
  27120. * @returns the VertexData of the tiled plane
  27121. */
  27122. static CreateTiledPlane(options: {
  27123. pattern?: number;
  27124. tileSize?: number;
  27125. tileWidth?: number;
  27126. tileHeight?: number;
  27127. size?: number;
  27128. width?: number;
  27129. height?: number;
  27130. alignHorizontal?: number;
  27131. alignVertical?: number;
  27132. sideOrientation?: number;
  27133. frontUVs?: Vector4;
  27134. backUVs?: Vector4;
  27135. }): VertexData;
  27136. /**
  27137. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27138. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27139. * * segments sets the number of horizontal strips optional, default 32
  27140. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27141. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27142. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27143. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27144. * * 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
  27145. * * 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
  27146. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27147. * * 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)
  27148. * * 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)
  27149. * @returns the VertexData of the ellipsoid
  27150. */
  27151. static CreateSphere(options: {
  27152. segments?: number;
  27153. diameter?: number;
  27154. diameterX?: number;
  27155. diameterY?: number;
  27156. diameterZ?: number;
  27157. arc?: number;
  27158. slice?: number;
  27159. sideOrientation?: number;
  27160. frontUVs?: Vector4;
  27161. backUVs?: Vector4;
  27162. }): VertexData;
  27163. /**
  27164. * Creates the VertexData for a cylinder, cone or prism
  27165. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27166. * * height sets the height (y direction) of the cylinder, optional, default 2
  27167. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27168. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27169. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27170. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27171. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27172. * * 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
  27173. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27174. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27175. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27176. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27177. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27178. * * 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)
  27179. * * 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)
  27180. * @returns the VertexData of the cylinder, cone or prism
  27181. */
  27182. static CreateCylinder(options: {
  27183. height?: number;
  27184. diameterTop?: number;
  27185. diameterBottom?: number;
  27186. diameter?: number;
  27187. tessellation?: number;
  27188. subdivisions?: number;
  27189. arc?: number;
  27190. faceColors?: Color4[];
  27191. faceUV?: Vector4[];
  27192. hasRings?: boolean;
  27193. enclose?: boolean;
  27194. sideOrientation?: number;
  27195. frontUVs?: Vector4;
  27196. backUVs?: Vector4;
  27197. }): VertexData;
  27198. /**
  27199. * Creates the VertexData for a torus
  27200. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27201. * * diameter the diameter of the torus, optional default 1
  27202. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27203. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27204. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27205. * * 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)
  27206. * * 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)
  27207. * @returns the VertexData of the torus
  27208. */
  27209. static CreateTorus(options: {
  27210. diameter?: number;
  27211. thickness?: number;
  27212. tessellation?: number;
  27213. sideOrientation?: number;
  27214. frontUVs?: Vector4;
  27215. backUVs?: Vector4;
  27216. }): VertexData;
  27217. /**
  27218. * Creates the VertexData of the LineSystem
  27219. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27220. * - lines an array of lines, each line being an array of successive Vector3
  27221. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27222. * @returns the VertexData of the LineSystem
  27223. */
  27224. static CreateLineSystem(options: {
  27225. lines: Vector3[][];
  27226. colors?: Nullable<Color4[][]>;
  27227. }): VertexData;
  27228. /**
  27229. * Create the VertexData for a DashedLines
  27230. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27231. * - points an array successive Vector3
  27232. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27233. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27234. * - dashNb the intended total number of dashes, optional, default 200
  27235. * @returns the VertexData for the DashedLines
  27236. */
  27237. static CreateDashedLines(options: {
  27238. points: Vector3[];
  27239. dashSize?: number;
  27240. gapSize?: number;
  27241. dashNb?: number;
  27242. }): VertexData;
  27243. /**
  27244. * Creates the VertexData for a Ground
  27245. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27246. * - width the width (x direction) of the ground, optional, default 1
  27247. * - height the height (z direction) of the ground, optional, default 1
  27248. * - subdivisions the number of subdivisions per side, optional, default 1
  27249. * @returns the VertexData of the Ground
  27250. */
  27251. static CreateGround(options: {
  27252. width?: number;
  27253. height?: number;
  27254. subdivisions?: number;
  27255. subdivisionsX?: number;
  27256. subdivisionsY?: number;
  27257. }): VertexData;
  27258. /**
  27259. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27260. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27261. * * xmin the ground minimum X coordinate, optional, default -1
  27262. * * zmin the ground minimum Z coordinate, optional, default -1
  27263. * * xmax the ground maximum X coordinate, optional, default 1
  27264. * * zmax the ground maximum Z coordinate, optional, default 1
  27265. * * 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}
  27266. * * 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}
  27267. * @returns the VertexData of the TiledGround
  27268. */
  27269. static CreateTiledGround(options: {
  27270. xmin: number;
  27271. zmin: number;
  27272. xmax: number;
  27273. zmax: number;
  27274. subdivisions?: {
  27275. w: number;
  27276. h: number;
  27277. };
  27278. precision?: {
  27279. w: number;
  27280. h: number;
  27281. };
  27282. }): VertexData;
  27283. /**
  27284. * Creates the VertexData of the Ground designed from a heightmap
  27285. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27286. * * width the width (x direction) of the ground
  27287. * * height the height (z direction) of the ground
  27288. * * subdivisions the number of subdivisions per side
  27289. * * minHeight the minimum altitude on the ground, optional, default 0
  27290. * * maxHeight the maximum altitude on the ground, optional default 1
  27291. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27292. * * buffer the array holding the image color data
  27293. * * bufferWidth the width of image
  27294. * * bufferHeight the height of image
  27295. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27296. * @returns the VertexData of the Ground designed from a heightmap
  27297. */
  27298. static CreateGroundFromHeightMap(options: {
  27299. width: number;
  27300. height: number;
  27301. subdivisions: number;
  27302. minHeight: number;
  27303. maxHeight: number;
  27304. colorFilter: Color3;
  27305. buffer: Uint8Array;
  27306. bufferWidth: number;
  27307. bufferHeight: number;
  27308. alphaFilter: number;
  27309. }): VertexData;
  27310. /**
  27311. * Creates the VertexData for a Plane
  27312. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27313. * * size sets the width and height of the plane to the value of size, optional default 1
  27314. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27315. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27316. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27317. * * 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)
  27318. * * 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)
  27319. * @returns the VertexData of the box
  27320. */
  27321. static CreatePlane(options: {
  27322. size?: number;
  27323. width?: number;
  27324. height?: number;
  27325. sideOrientation?: number;
  27326. frontUVs?: Vector4;
  27327. backUVs?: Vector4;
  27328. }): VertexData;
  27329. /**
  27330. * Creates the VertexData of the Disc or regular Polygon
  27331. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27332. * * radius the radius of the disc, optional default 0.5
  27333. * * tessellation the number of polygon sides, optional, default 64
  27334. * * 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
  27335. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27336. * * 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)
  27337. * * 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)
  27338. * @returns the VertexData of the box
  27339. */
  27340. static CreateDisc(options: {
  27341. radius?: number;
  27342. tessellation?: number;
  27343. arc?: number;
  27344. sideOrientation?: number;
  27345. frontUVs?: Vector4;
  27346. backUVs?: Vector4;
  27347. }): VertexData;
  27348. /**
  27349. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27350. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27351. * @param polygon a mesh built from polygonTriangulation.build()
  27352. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27353. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27354. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27355. * @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)
  27356. * @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)
  27357. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  27358. * @returns the VertexData of the Polygon
  27359. */
  27360. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  27361. /**
  27362. * Creates the VertexData of the IcoSphere
  27363. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27364. * * radius the radius of the IcoSphere, optional default 1
  27365. * * radiusX allows stretching in the x direction, optional, default radius
  27366. * * radiusY allows stretching in the y direction, optional, default radius
  27367. * * radiusZ allows stretching in the z direction, optional, default radius
  27368. * * flat when true creates a flat shaded mesh, optional, default true
  27369. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27370. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27371. * * 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)
  27372. * * 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)
  27373. * @returns the VertexData of the IcoSphere
  27374. */
  27375. static CreateIcoSphere(options: {
  27376. radius?: number;
  27377. radiusX?: number;
  27378. radiusY?: number;
  27379. radiusZ?: number;
  27380. flat?: boolean;
  27381. subdivisions?: number;
  27382. sideOrientation?: number;
  27383. frontUVs?: Vector4;
  27384. backUVs?: Vector4;
  27385. }): VertexData;
  27386. /**
  27387. * Creates the VertexData for a Polyhedron
  27388. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27389. * * type provided types are:
  27390. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27391. * * 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)
  27392. * * size the size of the IcoSphere, optional default 1
  27393. * * sizeX allows stretching in the x direction, optional, default size
  27394. * * sizeY allows stretching in the y direction, optional, default size
  27395. * * sizeZ allows stretching in the z direction, optional, default size
  27396. * * 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
  27397. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27398. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27399. * * flat when true creates a flat shaded mesh, optional, default true
  27400. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27401. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27402. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27403. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27404. * @returns the VertexData of the Polyhedron
  27405. */
  27406. static CreatePolyhedron(options: {
  27407. type?: number;
  27408. size?: number;
  27409. sizeX?: number;
  27410. sizeY?: number;
  27411. sizeZ?: number;
  27412. custom?: any;
  27413. faceUV?: Vector4[];
  27414. faceColors?: Color4[];
  27415. flat?: boolean;
  27416. sideOrientation?: number;
  27417. frontUVs?: Vector4;
  27418. backUVs?: Vector4;
  27419. }): VertexData;
  27420. /**
  27421. * Creates the VertexData for a TorusKnot
  27422. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27423. * * radius the radius of the torus knot, optional, default 2
  27424. * * tube the thickness of the tube, optional, default 0.5
  27425. * * radialSegments the number of sides on each tube segments, optional, default 32
  27426. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27427. * * p the number of windings around the z axis, optional, default 2
  27428. * * q the number of windings around the x axis, optional, default 3
  27429. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27430. * * 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)
  27431. * * 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)
  27432. * @returns the VertexData of the Torus Knot
  27433. */
  27434. static CreateTorusKnot(options: {
  27435. radius?: number;
  27436. tube?: number;
  27437. radialSegments?: number;
  27438. tubularSegments?: number;
  27439. p?: number;
  27440. q?: number;
  27441. sideOrientation?: number;
  27442. frontUVs?: Vector4;
  27443. backUVs?: Vector4;
  27444. }): VertexData;
  27445. /**
  27446. * Compute normals for given positions and indices
  27447. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27448. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27449. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27450. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27451. * * facetNormals : optional array of facet normals (vector3)
  27452. * * facetPositions : optional array of facet positions (vector3)
  27453. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27454. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27455. * * bInfo : optional bounding info, required for facetPartitioning computation
  27456. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27457. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27458. * * useRightHandedSystem: optional boolean to for right handed system computation
  27459. * * depthSort : optional boolean to enable the facet depth sort computation
  27460. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27461. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27462. */
  27463. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27464. facetNormals?: any;
  27465. facetPositions?: any;
  27466. facetPartitioning?: any;
  27467. ratio?: number;
  27468. bInfo?: any;
  27469. bbSize?: Vector3;
  27470. subDiv?: any;
  27471. useRightHandedSystem?: boolean;
  27472. depthSort?: boolean;
  27473. distanceTo?: Vector3;
  27474. depthSortedFacets?: any;
  27475. }): void;
  27476. /** @hidden */
  27477. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  27478. /**
  27479. * Applies VertexData created from the imported parameters to the geometry
  27480. * @param parsedVertexData the parsed data from an imported file
  27481. * @param geometry the geometry to apply the VertexData to
  27482. */
  27483. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27484. }
  27485. }
  27486. declare module "babylonjs/Morph/morphTarget" {
  27487. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27488. import { Observable } from "babylonjs/Misc/observable";
  27489. import { Nullable, FloatArray } from "babylonjs/types";
  27490. import { Scene } from "babylonjs/scene";
  27491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27492. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27493. /**
  27494. * Defines a target to use with MorphTargetManager
  27495. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27496. */
  27497. export class MorphTarget implements IAnimatable {
  27498. /** defines the name of the target */
  27499. name: string;
  27500. /**
  27501. * Gets or sets the list of animations
  27502. */
  27503. animations: import("babylonjs/Animations/animation").Animation[];
  27504. private _scene;
  27505. private _positions;
  27506. private _normals;
  27507. private _tangents;
  27508. private _uvs;
  27509. private _influence;
  27510. private _uniqueId;
  27511. /**
  27512. * Observable raised when the influence changes
  27513. */
  27514. onInfluenceChanged: Observable<boolean>;
  27515. /** @hidden */
  27516. _onDataLayoutChanged: Observable<void>;
  27517. /**
  27518. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  27519. */
  27520. get influence(): number;
  27521. set influence(influence: number);
  27522. /**
  27523. * Gets or sets the id of the morph Target
  27524. */
  27525. id: string;
  27526. private _animationPropertiesOverride;
  27527. /**
  27528. * Gets or sets the animation properties override
  27529. */
  27530. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27531. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  27532. /**
  27533. * Creates a new MorphTarget
  27534. * @param name defines the name of the target
  27535. * @param influence defines the influence to use
  27536. * @param scene defines the scene the morphtarget belongs to
  27537. */
  27538. constructor(
  27539. /** defines the name of the target */
  27540. name: string, influence?: number, scene?: Nullable<Scene>);
  27541. /**
  27542. * Gets the unique ID of this manager
  27543. */
  27544. get uniqueId(): number;
  27545. /**
  27546. * Gets a boolean defining if the target contains position data
  27547. */
  27548. get hasPositions(): boolean;
  27549. /**
  27550. * Gets a boolean defining if the target contains normal data
  27551. */
  27552. get hasNormals(): boolean;
  27553. /**
  27554. * Gets a boolean defining if the target contains tangent data
  27555. */
  27556. get hasTangents(): boolean;
  27557. /**
  27558. * Gets a boolean defining if the target contains texture coordinates data
  27559. */
  27560. get hasUVs(): boolean;
  27561. /**
  27562. * Affects position data to this target
  27563. * @param data defines the position data to use
  27564. */
  27565. setPositions(data: Nullable<FloatArray>): void;
  27566. /**
  27567. * Gets the position data stored in this target
  27568. * @returns a FloatArray containing the position data (or null if not present)
  27569. */
  27570. getPositions(): Nullable<FloatArray>;
  27571. /**
  27572. * Affects normal data to this target
  27573. * @param data defines the normal data to use
  27574. */
  27575. setNormals(data: Nullable<FloatArray>): void;
  27576. /**
  27577. * Gets the normal data stored in this target
  27578. * @returns a FloatArray containing the normal data (or null if not present)
  27579. */
  27580. getNormals(): Nullable<FloatArray>;
  27581. /**
  27582. * Affects tangent data to this target
  27583. * @param data defines the tangent data to use
  27584. */
  27585. setTangents(data: Nullable<FloatArray>): void;
  27586. /**
  27587. * Gets the tangent data stored in this target
  27588. * @returns a FloatArray containing the tangent data (or null if not present)
  27589. */
  27590. getTangents(): Nullable<FloatArray>;
  27591. /**
  27592. * Affects texture coordinates data to this target
  27593. * @param data defines the texture coordinates data to use
  27594. */
  27595. setUVs(data: Nullable<FloatArray>): void;
  27596. /**
  27597. * Gets the texture coordinates data stored in this target
  27598. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  27599. */
  27600. getUVs(): Nullable<FloatArray>;
  27601. /**
  27602. * Clone the current target
  27603. * @returns a new MorphTarget
  27604. */
  27605. clone(): MorphTarget;
  27606. /**
  27607. * Serializes the current target into a Serialization object
  27608. * @returns the serialized object
  27609. */
  27610. serialize(): any;
  27611. /**
  27612. * Returns the string "MorphTarget"
  27613. * @returns "MorphTarget"
  27614. */
  27615. getClassName(): string;
  27616. /**
  27617. * Creates a new target from serialized data
  27618. * @param serializationObject defines the serialized data to use
  27619. * @returns a new MorphTarget
  27620. */
  27621. static Parse(serializationObject: any): MorphTarget;
  27622. /**
  27623. * Creates a MorphTarget from mesh data
  27624. * @param mesh defines the source mesh
  27625. * @param name defines the name to use for the new target
  27626. * @param influence defines the influence to attach to the target
  27627. * @returns a new MorphTarget
  27628. */
  27629. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  27630. }
  27631. }
  27632. declare module "babylonjs/Morph/morphTargetManager" {
  27633. import { Nullable } from "babylonjs/types";
  27634. import { Scene } from "babylonjs/scene";
  27635. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  27636. /**
  27637. * This class is used to deform meshes using morphing between different targets
  27638. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27639. */
  27640. export class MorphTargetManager {
  27641. private _targets;
  27642. private _targetInfluenceChangedObservers;
  27643. private _targetDataLayoutChangedObservers;
  27644. private _activeTargets;
  27645. private _scene;
  27646. private _influences;
  27647. private _supportsNormals;
  27648. private _supportsTangents;
  27649. private _supportsUVs;
  27650. private _vertexCount;
  27651. private _uniqueId;
  27652. private _tempInfluences;
  27653. /**
  27654. * Gets or sets a boolean indicating if normals must be morphed
  27655. */
  27656. enableNormalMorphing: boolean;
  27657. /**
  27658. * Gets or sets a boolean indicating if tangents must be morphed
  27659. */
  27660. enableTangentMorphing: boolean;
  27661. /**
  27662. * Gets or sets a boolean indicating if UV must be morphed
  27663. */
  27664. enableUVMorphing: boolean;
  27665. /**
  27666. * Creates a new MorphTargetManager
  27667. * @param scene defines the current scene
  27668. */
  27669. constructor(scene?: Nullable<Scene>);
  27670. /**
  27671. * Gets the unique ID of this manager
  27672. */
  27673. get uniqueId(): number;
  27674. /**
  27675. * Gets the number of vertices handled by this manager
  27676. */
  27677. get vertexCount(): number;
  27678. /**
  27679. * Gets a boolean indicating if this manager supports morphing of normals
  27680. */
  27681. get supportsNormals(): boolean;
  27682. /**
  27683. * Gets a boolean indicating if this manager supports morphing of tangents
  27684. */
  27685. get supportsTangents(): boolean;
  27686. /**
  27687. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  27688. */
  27689. get supportsUVs(): boolean;
  27690. /**
  27691. * Gets the number of targets stored in this manager
  27692. */
  27693. get numTargets(): number;
  27694. /**
  27695. * Gets the number of influencers (ie. the number of targets with influences > 0)
  27696. */
  27697. get numInfluencers(): number;
  27698. /**
  27699. * Gets the list of influences (one per target)
  27700. */
  27701. get influences(): Float32Array;
  27702. /**
  27703. * Gets the active target at specified index. An active target is a target with an influence > 0
  27704. * @param index defines the index to check
  27705. * @returns the requested target
  27706. */
  27707. getActiveTarget(index: number): MorphTarget;
  27708. /**
  27709. * Gets the target at specified index
  27710. * @param index defines the index to check
  27711. * @returns the requested target
  27712. */
  27713. getTarget(index: number): MorphTarget;
  27714. /**
  27715. * Add a new target to this manager
  27716. * @param target defines the target to add
  27717. */
  27718. addTarget(target: MorphTarget): void;
  27719. /**
  27720. * Removes a target from the manager
  27721. * @param target defines the target to remove
  27722. */
  27723. removeTarget(target: MorphTarget): void;
  27724. /**
  27725. * Clone the current manager
  27726. * @returns a new MorphTargetManager
  27727. */
  27728. clone(): MorphTargetManager;
  27729. /**
  27730. * Serializes the current manager into a Serialization object
  27731. * @returns the serialized object
  27732. */
  27733. serialize(): any;
  27734. private _syncActiveTargets;
  27735. /**
  27736. * Syncrhonize the targets with all the meshes using this morph target manager
  27737. */
  27738. synchronize(): void;
  27739. /**
  27740. * Creates a new MorphTargetManager from serialized data
  27741. * @param serializationObject defines the serialized data
  27742. * @param scene defines the hosting scene
  27743. * @returns the new MorphTargetManager
  27744. */
  27745. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  27746. }
  27747. }
  27748. declare module "babylonjs/Meshes/meshLODLevel" {
  27749. import { Mesh } from "babylonjs/Meshes/mesh";
  27750. import { Nullable } from "babylonjs/types";
  27751. /**
  27752. * Class used to represent a specific level of detail of a mesh
  27753. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27754. */
  27755. export class MeshLODLevel {
  27756. /** Defines the distance where this level should start being displayed */
  27757. distance: number;
  27758. /** Defines the mesh to use to render this level */
  27759. mesh: Nullable<Mesh>;
  27760. /**
  27761. * Creates a new LOD level
  27762. * @param distance defines the distance where this level should star being displayed
  27763. * @param mesh defines the mesh to use to render this level
  27764. */
  27765. constructor(
  27766. /** Defines the distance where this level should start being displayed */
  27767. distance: number,
  27768. /** Defines the mesh to use to render this level */
  27769. mesh: Nullable<Mesh>);
  27770. }
  27771. }
  27772. declare module "babylonjs/Misc/canvasGenerator" {
  27773. /**
  27774. * Helper class used to generate a canvas to manipulate images
  27775. */
  27776. export class CanvasGenerator {
  27777. /**
  27778. * Create a new canvas (or offscreen canvas depending on the context)
  27779. * @param width defines the expected width
  27780. * @param height defines the expected height
  27781. * @return a new canvas or offscreen canvas
  27782. */
  27783. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  27784. }
  27785. }
  27786. declare module "babylonjs/Meshes/groundMesh" {
  27787. import { Scene } from "babylonjs/scene";
  27788. import { Vector3 } from "babylonjs/Maths/math.vector";
  27789. import { Mesh } from "babylonjs/Meshes/mesh";
  27790. /**
  27791. * Mesh representing the gorund
  27792. */
  27793. export class GroundMesh extends Mesh {
  27794. /** If octree should be generated */
  27795. generateOctree: boolean;
  27796. private _heightQuads;
  27797. /** @hidden */
  27798. _subdivisionsX: number;
  27799. /** @hidden */
  27800. _subdivisionsY: number;
  27801. /** @hidden */
  27802. _width: number;
  27803. /** @hidden */
  27804. _height: number;
  27805. /** @hidden */
  27806. _minX: number;
  27807. /** @hidden */
  27808. _maxX: number;
  27809. /** @hidden */
  27810. _minZ: number;
  27811. /** @hidden */
  27812. _maxZ: number;
  27813. constructor(name: string, scene: Scene);
  27814. /**
  27815. * "GroundMesh"
  27816. * @returns "GroundMesh"
  27817. */
  27818. getClassName(): string;
  27819. /**
  27820. * The minimum of x and y subdivisions
  27821. */
  27822. get subdivisions(): number;
  27823. /**
  27824. * X subdivisions
  27825. */
  27826. get subdivisionsX(): number;
  27827. /**
  27828. * Y subdivisions
  27829. */
  27830. get subdivisionsY(): number;
  27831. /**
  27832. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  27833. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  27834. * @param chunksCount the number of subdivisions for x and y
  27835. * @param octreeBlocksSize (Default: 32)
  27836. */
  27837. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  27838. /**
  27839. * Returns a height (y) value in the Worl system :
  27840. * the ground altitude at the coordinates (x, z) expressed in the World system.
  27841. * @param x x coordinate
  27842. * @param z z coordinate
  27843. * @returns the ground y position if (x, z) are outside the ground surface.
  27844. */
  27845. getHeightAtCoordinates(x: number, z: number): number;
  27846. /**
  27847. * Returns a normalized vector (Vector3) orthogonal to the ground
  27848. * at the ground coordinates (x, z) expressed in the World system.
  27849. * @param x x coordinate
  27850. * @param z z coordinate
  27851. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  27852. */
  27853. getNormalAtCoordinates(x: number, z: number): Vector3;
  27854. /**
  27855. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  27856. * at the ground coordinates (x, z) expressed in the World system.
  27857. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  27858. * @param x x coordinate
  27859. * @param z z coordinate
  27860. * @param ref vector to store the result
  27861. * @returns the GroundMesh.
  27862. */
  27863. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  27864. /**
  27865. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  27866. * if the ground has been updated.
  27867. * This can be used in the render loop.
  27868. * @returns the GroundMesh.
  27869. */
  27870. updateCoordinateHeights(): GroundMesh;
  27871. private _getFacetAt;
  27872. private _initHeightQuads;
  27873. private _computeHeightQuads;
  27874. /**
  27875. * Serializes this ground mesh
  27876. * @param serializationObject object to write serialization to
  27877. */
  27878. serialize(serializationObject: any): void;
  27879. /**
  27880. * Parses a serialized ground mesh
  27881. * @param parsedMesh the serialized mesh
  27882. * @param scene the scene to create the ground mesh in
  27883. * @returns the created ground mesh
  27884. */
  27885. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  27886. }
  27887. }
  27888. declare module "babylonjs/Physics/physicsJoint" {
  27889. import { Vector3 } from "babylonjs/Maths/math.vector";
  27890. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  27891. /**
  27892. * Interface for Physics-Joint data
  27893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27894. */
  27895. export interface PhysicsJointData {
  27896. /**
  27897. * The main pivot of the joint
  27898. */
  27899. mainPivot?: Vector3;
  27900. /**
  27901. * The connected pivot of the joint
  27902. */
  27903. connectedPivot?: Vector3;
  27904. /**
  27905. * The main axis of the joint
  27906. */
  27907. mainAxis?: Vector3;
  27908. /**
  27909. * The connected axis of the joint
  27910. */
  27911. connectedAxis?: Vector3;
  27912. /**
  27913. * The collision of the joint
  27914. */
  27915. collision?: boolean;
  27916. /**
  27917. * Native Oimo/Cannon/Energy data
  27918. */
  27919. nativeParams?: any;
  27920. }
  27921. /**
  27922. * This is a holder class for the physics joint created by the physics plugin
  27923. * It holds a set of functions to control the underlying joint
  27924. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27925. */
  27926. export class PhysicsJoint {
  27927. /**
  27928. * The type of the physics joint
  27929. */
  27930. type: number;
  27931. /**
  27932. * The data for the physics joint
  27933. */
  27934. jointData: PhysicsJointData;
  27935. private _physicsJoint;
  27936. protected _physicsPlugin: IPhysicsEnginePlugin;
  27937. /**
  27938. * Initializes the physics joint
  27939. * @param type The type of the physics joint
  27940. * @param jointData The data for the physics joint
  27941. */
  27942. constructor(
  27943. /**
  27944. * The type of the physics joint
  27945. */
  27946. type: number,
  27947. /**
  27948. * The data for the physics joint
  27949. */
  27950. jointData: PhysicsJointData);
  27951. /**
  27952. * Gets the physics joint
  27953. */
  27954. get physicsJoint(): any;
  27955. /**
  27956. * Sets the physics joint
  27957. */
  27958. set physicsJoint(newJoint: any);
  27959. /**
  27960. * Sets the physics plugin
  27961. */
  27962. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  27963. /**
  27964. * Execute a function that is physics-plugin specific.
  27965. * @param {Function} func the function that will be executed.
  27966. * It accepts two parameters: the physics world and the physics joint
  27967. */
  27968. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27969. /**
  27970. * Distance-Joint type
  27971. */
  27972. static DistanceJoint: number;
  27973. /**
  27974. * Hinge-Joint type
  27975. */
  27976. static HingeJoint: number;
  27977. /**
  27978. * Ball-and-Socket joint type
  27979. */
  27980. static BallAndSocketJoint: number;
  27981. /**
  27982. * Wheel-Joint type
  27983. */
  27984. static WheelJoint: number;
  27985. /**
  27986. * Slider-Joint type
  27987. */
  27988. static SliderJoint: number;
  27989. /**
  27990. * Prismatic-Joint type
  27991. */
  27992. static PrismaticJoint: number;
  27993. /**
  27994. * Universal-Joint type
  27995. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27996. */
  27997. static UniversalJoint: number;
  27998. /**
  27999. * Hinge-Joint 2 type
  28000. */
  28001. static Hinge2Joint: number;
  28002. /**
  28003. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  28004. */
  28005. static PointToPointJoint: number;
  28006. /**
  28007. * Spring-Joint type
  28008. */
  28009. static SpringJoint: number;
  28010. /**
  28011. * Lock-Joint type
  28012. */
  28013. static LockJoint: number;
  28014. }
  28015. /**
  28016. * A class representing a physics distance joint
  28017. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28018. */
  28019. export class DistanceJoint extends PhysicsJoint {
  28020. /**
  28021. *
  28022. * @param jointData The data for the Distance-Joint
  28023. */
  28024. constructor(jointData: DistanceJointData);
  28025. /**
  28026. * Update the predefined distance.
  28027. * @param maxDistance The maximum preferred distance
  28028. * @param minDistance The minimum preferred distance
  28029. */
  28030. updateDistance(maxDistance: number, minDistance?: number): void;
  28031. }
  28032. /**
  28033. * Represents a Motor-Enabled Joint
  28034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28035. */
  28036. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  28037. /**
  28038. * Initializes the Motor-Enabled Joint
  28039. * @param type The type of the joint
  28040. * @param jointData The physica joint data for the joint
  28041. */
  28042. constructor(type: number, jointData: PhysicsJointData);
  28043. /**
  28044. * Set the motor values.
  28045. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28046. * @param force the force to apply
  28047. * @param maxForce max force for this motor.
  28048. */
  28049. setMotor(force?: number, maxForce?: number): void;
  28050. /**
  28051. * Set the motor's limits.
  28052. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28053. * @param upperLimit The upper limit of the motor
  28054. * @param lowerLimit The lower limit of the motor
  28055. */
  28056. setLimit(upperLimit: number, lowerLimit?: number): void;
  28057. }
  28058. /**
  28059. * This class represents a single physics Hinge-Joint
  28060. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28061. */
  28062. export class HingeJoint extends MotorEnabledJoint {
  28063. /**
  28064. * Initializes the Hinge-Joint
  28065. * @param jointData The joint data for the Hinge-Joint
  28066. */
  28067. constructor(jointData: PhysicsJointData);
  28068. /**
  28069. * Set the motor values.
  28070. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28071. * @param {number} force the force to apply
  28072. * @param {number} maxForce max force for this motor.
  28073. */
  28074. setMotor(force?: number, maxForce?: number): void;
  28075. /**
  28076. * Set the motor's limits.
  28077. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28078. * @param upperLimit The upper limit of the motor
  28079. * @param lowerLimit The lower limit of the motor
  28080. */
  28081. setLimit(upperLimit: number, lowerLimit?: number): void;
  28082. }
  28083. /**
  28084. * This class represents a dual hinge physics joint (same as wheel joint)
  28085. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28086. */
  28087. export class Hinge2Joint extends MotorEnabledJoint {
  28088. /**
  28089. * Initializes the Hinge2-Joint
  28090. * @param jointData The joint data for the Hinge2-Joint
  28091. */
  28092. constructor(jointData: PhysicsJointData);
  28093. /**
  28094. * Set the motor values.
  28095. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28096. * @param {number} targetSpeed the speed the motor is to reach
  28097. * @param {number} maxForce max force for this motor.
  28098. * @param {motorIndex} the motor's index, 0 or 1.
  28099. */
  28100. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  28101. /**
  28102. * Set the motor limits.
  28103. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28104. * @param {number} upperLimit the upper limit
  28105. * @param {number} lowerLimit lower limit
  28106. * @param {motorIndex} the motor's index, 0 or 1.
  28107. */
  28108. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28109. }
  28110. /**
  28111. * Interface for a motor enabled joint
  28112. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28113. */
  28114. export interface IMotorEnabledJoint {
  28115. /**
  28116. * Physics joint
  28117. */
  28118. physicsJoint: any;
  28119. /**
  28120. * Sets the motor of the motor-enabled joint
  28121. * @param force The force of the motor
  28122. * @param maxForce The maximum force of the motor
  28123. * @param motorIndex The index of the motor
  28124. */
  28125. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  28126. /**
  28127. * Sets the limit of the motor
  28128. * @param upperLimit The upper limit of the motor
  28129. * @param lowerLimit The lower limit of the motor
  28130. * @param motorIndex The index of the motor
  28131. */
  28132. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28133. }
  28134. /**
  28135. * Joint data for a Distance-Joint
  28136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28137. */
  28138. export interface DistanceJointData extends PhysicsJointData {
  28139. /**
  28140. * Max distance the 2 joint objects can be apart
  28141. */
  28142. maxDistance: number;
  28143. }
  28144. /**
  28145. * Joint data from a spring joint
  28146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28147. */
  28148. export interface SpringJointData extends PhysicsJointData {
  28149. /**
  28150. * Length of the spring
  28151. */
  28152. length: number;
  28153. /**
  28154. * Stiffness of the spring
  28155. */
  28156. stiffness: number;
  28157. /**
  28158. * Damping of the spring
  28159. */
  28160. damping: number;
  28161. /** this callback will be called when applying the force to the impostors. */
  28162. forceApplicationCallback: () => void;
  28163. }
  28164. }
  28165. declare module "babylonjs/Physics/physicsRaycastResult" {
  28166. import { Vector3 } from "babylonjs/Maths/math.vector";
  28167. /**
  28168. * Holds the data for the raycast result
  28169. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28170. */
  28171. export class PhysicsRaycastResult {
  28172. private _hasHit;
  28173. private _hitDistance;
  28174. private _hitNormalWorld;
  28175. private _hitPointWorld;
  28176. private _rayFromWorld;
  28177. private _rayToWorld;
  28178. /**
  28179. * Gets if there was a hit
  28180. */
  28181. get hasHit(): boolean;
  28182. /**
  28183. * Gets the distance from the hit
  28184. */
  28185. get hitDistance(): number;
  28186. /**
  28187. * Gets the hit normal/direction in the world
  28188. */
  28189. get hitNormalWorld(): Vector3;
  28190. /**
  28191. * Gets the hit point in the world
  28192. */
  28193. get hitPointWorld(): Vector3;
  28194. /**
  28195. * Gets the ray "start point" of the ray in the world
  28196. */
  28197. get rayFromWorld(): Vector3;
  28198. /**
  28199. * Gets the ray "end point" of the ray in the world
  28200. */
  28201. get rayToWorld(): Vector3;
  28202. /**
  28203. * Sets the hit data (normal & point in world space)
  28204. * @param hitNormalWorld defines the normal in world space
  28205. * @param hitPointWorld defines the point in world space
  28206. */
  28207. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  28208. /**
  28209. * Sets the distance from the start point to the hit point
  28210. * @param distance
  28211. */
  28212. setHitDistance(distance: number): void;
  28213. /**
  28214. * Calculates the distance manually
  28215. */
  28216. calculateHitDistance(): void;
  28217. /**
  28218. * Resets all the values to default
  28219. * @param from The from point on world space
  28220. * @param to The to point on world space
  28221. */
  28222. reset(from?: Vector3, to?: Vector3): void;
  28223. }
  28224. /**
  28225. * Interface for the size containing width and height
  28226. */
  28227. interface IXYZ {
  28228. /**
  28229. * X
  28230. */
  28231. x: number;
  28232. /**
  28233. * Y
  28234. */
  28235. y: number;
  28236. /**
  28237. * Z
  28238. */
  28239. z: number;
  28240. }
  28241. }
  28242. declare module "babylonjs/Physics/IPhysicsEngine" {
  28243. import { Nullable } from "babylonjs/types";
  28244. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  28245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28246. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28247. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  28248. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  28249. /**
  28250. * Interface used to describe a physics joint
  28251. */
  28252. export interface PhysicsImpostorJoint {
  28253. /** Defines the main impostor to which the joint is linked */
  28254. mainImpostor: PhysicsImpostor;
  28255. /** Defines the impostor that is connected to the main impostor using this joint */
  28256. connectedImpostor: PhysicsImpostor;
  28257. /** Defines the joint itself */
  28258. joint: PhysicsJoint;
  28259. }
  28260. /** @hidden */
  28261. export interface IPhysicsEnginePlugin {
  28262. world: any;
  28263. name: string;
  28264. setGravity(gravity: Vector3): void;
  28265. setTimeStep(timeStep: number): void;
  28266. getTimeStep(): number;
  28267. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28268. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28269. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28270. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28271. removePhysicsBody(impostor: PhysicsImpostor): void;
  28272. generateJoint(joint: PhysicsImpostorJoint): void;
  28273. removeJoint(joint: PhysicsImpostorJoint): void;
  28274. isSupported(): boolean;
  28275. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28276. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28277. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28278. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28279. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28280. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28281. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28282. getBodyMass(impostor: PhysicsImpostor): number;
  28283. getBodyFriction(impostor: PhysicsImpostor): number;
  28284. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28285. getBodyRestitution(impostor: PhysicsImpostor): number;
  28286. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28287. getBodyPressure?(impostor: PhysicsImpostor): number;
  28288. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  28289. getBodyStiffness?(impostor: PhysicsImpostor): number;
  28290. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  28291. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  28292. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  28293. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  28294. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  28295. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28296. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28297. sleepBody(impostor: PhysicsImpostor): void;
  28298. wakeUpBody(impostor: PhysicsImpostor): void;
  28299. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28300. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28301. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  28302. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28303. getRadius(impostor: PhysicsImpostor): number;
  28304. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28305. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28306. dispose(): void;
  28307. }
  28308. /**
  28309. * Interface used to define a physics engine
  28310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28311. */
  28312. export interface IPhysicsEngine {
  28313. /**
  28314. * Gets the gravity vector used by the simulation
  28315. */
  28316. gravity: Vector3;
  28317. /**
  28318. * Sets the gravity vector used by the simulation
  28319. * @param gravity defines the gravity vector to use
  28320. */
  28321. setGravity(gravity: Vector3): void;
  28322. /**
  28323. * Set the time step of the physics engine.
  28324. * Default is 1/60.
  28325. * To slow it down, enter 1/600 for example.
  28326. * To speed it up, 1/30
  28327. * @param newTimeStep the new timestep to apply to this world.
  28328. */
  28329. setTimeStep(newTimeStep: number): void;
  28330. /**
  28331. * Get the time step of the physics engine.
  28332. * @returns the current time step
  28333. */
  28334. getTimeStep(): number;
  28335. /**
  28336. * Set the sub time step of the physics engine.
  28337. * Default is 0 meaning there is no sub steps
  28338. * To increase physics resolution precision, set a small value (like 1 ms)
  28339. * @param subTimeStep defines the new sub timestep used for physics resolution.
  28340. */
  28341. setSubTimeStep(subTimeStep: number): void;
  28342. /**
  28343. * Get the sub time step of the physics engine.
  28344. * @returns the current sub time step
  28345. */
  28346. getSubTimeStep(): number;
  28347. /**
  28348. * Release all resources
  28349. */
  28350. dispose(): void;
  28351. /**
  28352. * Gets the name of the current physics plugin
  28353. * @returns the name of the plugin
  28354. */
  28355. getPhysicsPluginName(): string;
  28356. /**
  28357. * Adding a new impostor for the impostor tracking.
  28358. * This will be done by the impostor itself.
  28359. * @param impostor the impostor to add
  28360. */
  28361. addImpostor(impostor: PhysicsImpostor): void;
  28362. /**
  28363. * Remove an impostor from the engine.
  28364. * This impostor and its mesh will not longer be updated by the physics engine.
  28365. * @param impostor the impostor to remove
  28366. */
  28367. removeImpostor(impostor: PhysicsImpostor): void;
  28368. /**
  28369. * Add a joint to the physics engine
  28370. * @param mainImpostor defines the main impostor to which the joint is added.
  28371. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  28372. * @param joint defines the joint that will connect both impostors.
  28373. */
  28374. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28375. /**
  28376. * Removes a joint from the simulation
  28377. * @param mainImpostor defines the impostor used with the joint
  28378. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  28379. * @param joint defines the joint to remove
  28380. */
  28381. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28382. /**
  28383. * Gets the current plugin used to run the simulation
  28384. * @returns current plugin
  28385. */
  28386. getPhysicsPlugin(): IPhysicsEnginePlugin;
  28387. /**
  28388. * Gets the list of physic impostors
  28389. * @returns an array of PhysicsImpostor
  28390. */
  28391. getImpostors(): Array<PhysicsImpostor>;
  28392. /**
  28393. * Gets the impostor for a physics enabled object
  28394. * @param object defines the object impersonated by the impostor
  28395. * @returns the PhysicsImpostor or null if not found
  28396. */
  28397. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28398. /**
  28399. * Gets the impostor for a physics body object
  28400. * @param body defines physics body used by the impostor
  28401. * @returns the PhysicsImpostor or null if not found
  28402. */
  28403. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  28404. /**
  28405. * Does a raycast in the physics world
  28406. * @param from when should the ray start?
  28407. * @param to when should the ray end?
  28408. * @returns PhysicsRaycastResult
  28409. */
  28410. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28411. /**
  28412. * Called by the scene. No need to call it.
  28413. * @param delta defines the timespam between frames
  28414. */
  28415. _step(delta: number): void;
  28416. }
  28417. }
  28418. declare module "babylonjs/Physics/physicsImpostor" {
  28419. import { Nullable, IndicesArray } from "babylonjs/types";
  28420. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  28421. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28423. import { Scene } from "babylonjs/scene";
  28424. import { Bone } from "babylonjs/Bones/bone";
  28425. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28426. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  28427. import { Space } from "babylonjs/Maths/math.axis";
  28428. /**
  28429. * The interface for the physics imposter parameters
  28430. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28431. */
  28432. export interface PhysicsImpostorParameters {
  28433. /**
  28434. * The mass of the physics imposter
  28435. */
  28436. mass: number;
  28437. /**
  28438. * The friction of the physics imposter
  28439. */
  28440. friction?: number;
  28441. /**
  28442. * The coefficient of restitution of the physics imposter
  28443. */
  28444. restitution?: number;
  28445. /**
  28446. * The native options of the physics imposter
  28447. */
  28448. nativeOptions?: any;
  28449. /**
  28450. * Specifies if the parent should be ignored
  28451. */
  28452. ignoreParent?: boolean;
  28453. /**
  28454. * Specifies if bi-directional transformations should be disabled
  28455. */
  28456. disableBidirectionalTransformation?: boolean;
  28457. /**
  28458. * The pressure inside the physics imposter, soft object only
  28459. */
  28460. pressure?: number;
  28461. /**
  28462. * The stiffness the physics imposter, soft object only
  28463. */
  28464. stiffness?: number;
  28465. /**
  28466. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  28467. */
  28468. velocityIterations?: number;
  28469. /**
  28470. * The number of iterations used in maintaining consistent vertex positions, soft object only
  28471. */
  28472. positionIterations?: number;
  28473. /**
  28474. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  28475. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  28476. * Add to fix multiple points
  28477. */
  28478. fixedPoints?: number;
  28479. /**
  28480. * The collision margin around a soft object
  28481. */
  28482. margin?: number;
  28483. /**
  28484. * The collision margin around a soft object
  28485. */
  28486. damping?: number;
  28487. /**
  28488. * The path for a rope based on an extrusion
  28489. */
  28490. path?: any;
  28491. /**
  28492. * The shape of an extrusion used for a rope based on an extrusion
  28493. */
  28494. shape?: any;
  28495. }
  28496. /**
  28497. * Interface for a physics-enabled object
  28498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28499. */
  28500. export interface IPhysicsEnabledObject {
  28501. /**
  28502. * The position of the physics-enabled object
  28503. */
  28504. position: Vector3;
  28505. /**
  28506. * The rotation of the physics-enabled object
  28507. */
  28508. rotationQuaternion: Nullable<Quaternion>;
  28509. /**
  28510. * The scale of the physics-enabled object
  28511. */
  28512. scaling: Vector3;
  28513. /**
  28514. * The rotation of the physics-enabled object
  28515. */
  28516. rotation?: Vector3;
  28517. /**
  28518. * The parent of the physics-enabled object
  28519. */
  28520. parent?: any;
  28521. /**
  28522. * The bounding info of the physics-enabled object
  28523. * @returns The bounding info of the physics-enabled object
  28524. */
  28525. getBoundingInfo(): BoundingInfo;
  28526. /**
  28527. * Computes the world matrix
  28528. * @param force Specifies if the world matrix should be computed by force
  28529. * @returns A world matrix
  28530. */
  28531. computeWorldMatrix(force: boolean): Matrix;
  28532. /**
  28533. * Gets the world matrix
  28534. * @returns A world matrix
  28535. */
  28536. getWorldMatrix?(): Matrix;
  28537. /**
  28538. * Gets the child meshes
  28539. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  28540. * @returns An array of abstract meshes
  28541. */
  28542. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  28543. /**
  28544. * Gets the vertex data
  28545. * @param kind The type of vertex data
  28546. * @returns A nullable array of numbers, or a float32 array
  28547. */
  28548. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  28549. /**
  28550. * Gets the indices from the mesh
  28551. * @returns A nullable array of index arrays
  28552. */
  28553. getIndices?(): Nullable<IndicesArray>;
  28554. /**
  28555. * Gets the scene from the mesh
  28556. * @returns the indices array or null
  28557. */
  28558. getScene?(): Scene;
  28559. /**
  28560. * Gets the absolute position from the mesh
  28561. * @returns the absolute position
  28562. */
  28563. getAbsolutePosition(): Vector3;
  28564. /**
  28565. * Gets the absolute pivot point from the mesh
  28566. * @returns the absolute pivot point
  28567. */
  28568. getAbsolutePivotPoint(): Vector3;
  28569. /**
  28570. * Rotates the mesh
  28571. * @param axis The axis of rotation
  28572. * @param amount The amount of rotation
  28573. * @param space The space of the rotation
  28574. * @returns The rotation transform node
  28575. */
  28576. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  28577. /**
  28578. * Translates the mesh
  28579. * @param axis The axis of translation
  28580. * @param distance The distance of translation
  28581. * @param space The space of the translation
  28582. * @returns The transform node
  28583. */
  28584. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28585. /**
  28586. * Sets the absolute position of the mesh
  28587. * @param absolutePosition The absolute position of the mesh
  28588. * @returns The transform node
  28589. */
  28590. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28591. /**
  28592. * Gets the class name of the mesh
  28593. * @returns The class name
  28594. */
  28595. getClassName(): string;
  28596. }
  28597. /**
  28598. * Represents a physics imposter
  28599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28600. */
  28601. export class PhysicsImpostor {
  28602. /**
  28603. * The physics-enabled object used as the physics imposter
  28604. */
  28605. object: IPhysicsEnabledObject;
  28606. /**
  28607. * The type of the physics imposter
  28608. */
  28609. type: number;
  28610. private _options;
  28611. private _scene?;
  28612. /**
  28613. * The default object size of the imposter
  28614. */
  28615. static DEFAULT_OBJECT_SIZE: Vector3;
  28616. /**
  28617. * The identity quaternion of the imposter
  28618. */
  28619. static IDENTITY_QUATERNION: Quaternion;
  28620. /** @hidden */
  28621. _pluginData: any;
  28622. private _physicsEngine;
  28623. private _physicsBody;
  28624. private _bodyUpdateRequired;
  28625. private _onBeforePhysicsStepCallbacks;
  28626. private _onAfterPhysicsStepCallbacks;
  28627. /** @hidden */
  28628. _onPhysicsCollideCallbacks: Array<{
  28629. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  28630. otherImpostors: Array<PhysicsImpostor>;
  28631. }>;
  28632. private _deltaPosition;
  28633. private _deltaRotation;
  28634. private _deltaRotationConjugated;
  28635. /** @hidden */
  28636. _isFromLine: boolean;
  28637. private _parent;
  28638. private _isDisposed;
  28639. private static _tmpVecs;
  28640. private static _tmpQuat;
  28641. /**
  28642. * Specifies if the physics imposter is disposed
  28643. */
  28644. get isDisposed(): boolean;
  28645. /**
  28646. * Gets the mass of the physics imposter
  28647. */
  28648. get mass(): number;
  28649. set mass(value: number);
  28650. /**
  28651. * Gets the coefficient of friction
  28652. */
  28653. get friction(): number;
  28654. /**
  28655. * Sets the coefficient of friction
  28656. */
  28657. set friction(value: number);
  28658. /**
  28659. * Gets the coefficient of restitution
  28660. */
  28661. get restitution(): number;
  28662. /**
  28663. * Sets the coefficient of restitution
  28664. */
  28665. set restitution(value: number);
  28666. /**
  28667. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  28668. */
  28669. get pressure(): number;
  28670. /**
  28671. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  28672. */
  28673. set pressure(value: number);
  28674. /**
  28675. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28676. */
  28677. get stiffness(): number;
  28678. /**
  28679. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28680. */
  28681. set stiffness(value: number);
  28682. /**
  28683. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28684. */
  28685. get velocityIterations(): number;
  28686. /**
  28687. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28688. */
  28689. set velocityIterations(value: number);
  28690. /**
  28691. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28692. */
  28693. get positionIterations(): number;
  28694. /**
  28695. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28696. */
  28697. set positionIterations(value: number);
  28698. /**
  28699. * The unique id of the physics imposter
  28700. * set by the physics engine when adding this impostor to the array
  28701. */
  28702. uniqueId: number;
  28703. /**
  28704. * @hidden
  28705. */
  28706. soft: boolean;
  28707. /**
  28708. * @hidden
  28709. */
  28710. segments: number;
  28711. private _joints;
  28712. /**
  28713. * Initializes the physics imposter
  28714. * @param object The physics-enabled object used as the physics imposter
  28715. * @param type The type of the physics imposter
  28716. * @param _options The options for the physics imposter
  28717. * @param _scene The Babylon scene
  28718. */
  28719. constructor(
  28720. /**
  28721. * The physics-enabled object used as the physics imposter
  28722. */
  28723. object: IPhysicsEnabledObject,
  28724. /**
  28725. * The type of the physics imposter
  28726. */
  28727. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  28728. /**
  28729. * This function will completly initialize this impostor.
  28730. * It will create a new body - but only if this mesh has no parent.
  28731. * If it has, this impostor will not be used other than to define the impostor
  28732. * of the child mesh.
  28733. * @hidden
  28734. */
  28735. _init(): void;
  28736. private _getPhysicsParent;
  28737. /**
  28738. * Should a new body be generated.
  28739. * @returns boolean specifying if body initialization is required
  28740. */
  28741. isBodyInitRequired(): boolean;
  28742. /**
  28743. * Sets the updated scaling
  28744. * @param updated Specifies if the scaling is updated
  28745. */
  28746. setScalingUpdated(): void;
  28747. /**
  28748. * Force a regeneration of this or the parent's impostor's body.
  28749. * Use under cautious - This will remove all joints already implemented.
  28750. */
  28751. forceUpdate(): void;
  28752. /**
  28753. * Gets the body that holds this impostor. Either its own, or its parent.
  28754. */
  28755. get physicsBody(): any;
  28756. /**
  28757. * Get the parent of the physics imposter
  28758. * @returns Physics imposter or null
  28759. */
  28760. get parent(): Nullable<PhysicsImpostor>;
  28761. /**
  28762. * Sets the parent of the physics imposter
  28763. */
  28764. set parent(value: Nullable<PhysicsImpostor>);
  28765. /**
  28766. * Set the physics body. Used mainly by the physics engine/plugin
  28767. */
  28768. set physicsBody(physicsBody: any);
  28769. /**
  28770. * Resets the update flags
  28771. */
  28772. resetUpdateFlags(): void;
  28773. /**
  28774. * Gets the object extend size
  28775. * @returns the object extend size
  28776. */
  28777. getObjectExtendSize(): Vector3;
  28778. /**
  28779. * Gets the object center
  28780. * @returns The object center
  28781. */
  28782. getObjectCenter(): Vector3;
  28783. /**
  28784. * Get a specific parameter from the options parameters
  28785. * @param paramName The object parameter name
  28786. * @returns The object parameter
  28787. */
  28788. getParam(paramName: string): any;
  28789. /**
  28790. * Sets a specific parameter in the options given to the physics plugin
  28791. * @param paramName The parameter name
  28792. * @param value The value of the parameter
  28793. */
  28794. setParam(paramName: string, value: number): void;
  28795. /**
  28796. * Specifically change the body's mass option. Won't recreate the physics body object
  28797. * @param mass The mass of the physics imposter
  28798. */
  28799. setMass(mass: number): void;
  28800. /**
  28801. * Gets the linear velocity
  28802. * @returns linear velocity or null
  28803. */
  28804. getLinearVelocity(): Nullable<Vector3>;
  28805. /**
  28806. * Sets the linear velocity
  28807. * @param velocity linear velocity or null
  28808. */
  28809. setLinearVelocity(velocity: Nullable<Vector3>): void;
  28810. /**
  28811. * Gets the angular velocity
  28812. * @returns angular velocity or null
  28813. */
  28814. getAngularVelocity(): Nullable<Vector3>;
  28815. /**
  28816. * Sets the angular velocity
  28817. * @param velocity The velocity or null
  28818. */
  28819. setAngularVelocity(velocity: Nullable<Vector3>): void;
  28820. /**
  28821. * Execute a function with the physics plugin native code
  28822. * Provide a function the will have two variables - the world object and the physics body object
  28823. * @param func The function to execute with the physics plugin native code
  28824. */
  28825. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  28826. /**
  28827. * Register a function that will be executed before the physics world is stepping forward
  28828. * @param func The function to execute before the physics world is stepped forward
  28829. */
  28830. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28831. /**
  28832. * Unregister a function that will be executed before the physics world is stepping forward
  28833. * @param func The function to execute before the physics world is stepped forward
  28834. */
  28835. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28836. /**
  28837. * Register a function that will be executed after the physics step
  28838. * @param func The function to execute after physics step
  28839. */
  28840. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28841. /**
  28842. * Unregisters a function that will be executed after the physics step
  28843. * @param func The function to execute after physics step
  28844. */
  28845. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28846. /**
  28847. * register a function that will be executed when this impostor collides against a different body
  28848. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  28849. * @param func Callback that is executed on collision
  28850. */
  28851. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  28852. /**
  28853. * Unregisters the physics imposter on contact
  28854. * @param collideAgainst The physics object to collide against
  28855. * @param func Callback to execute on collision
  28856. */
  28857. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  28858. private _tmpQuat;
  28859. private _tmpQuat2;
  28860. /**
  28861. * Get the parent rotation
  28862. * @returns The parent rotation
  28863. */
  28864. getParentsRotation(): Quaternion;
  28865. /**
  28866. * this function is executed by the physics engine.
  28867. */
  28868. beforeStep: () => void;
  28869. /**
  28870. * this function is executed by the physics engine
  28871. */
  28872. afterStep: () => void;
  28873. /**
  28874. * Legacy collision detection event support
  28875. */
  28876. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  28877. /**
  28878. * event and body object due to cannon's event-based architecture.
  28879. */
  28880. onCollide: (e: {
  28881. body: any;
  28882. }) => void;
  28883. /**
  28884. * Apply a force
  28885. * @param force The force to apply
  28886. * @param contactPoint The contact point for the force
  28887. * @returns The physics imposter
  28888. */
  28889. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28890. /**
  28891. * Apply an impulse
  28892. * @param force The impulse force
  28893. * @param contactPoint The contact point for the impulse force
  28894. * @returns The physics imposter
  28895. */
  28896. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28897. /**
  28898. * A help function to create a joint
  28899. * @param otherImpostor A physics imposter used to create a joint
  28900. * @param jointType The type of joint
  28901. * @param jointData The data for the joint
  28902. * @returns The physics imposter
  28903. */
  28904. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  28905. /**
  28906. * Add a joint to this impostor with a different impostor
  28907. * @param otherImpostor A physics imposter used to add a joint
  28908. * @param joint The joint to add
  28909. * @returns The physics imposter
  28910. */
  28911. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  28912. /**
  28913. * Add an anchor to a cloth impostor
  28914. * @param otherImpostor rigid impostor to anchor to
  28915. * @param width ratio across width from 0 to 1
  28916. * @param height ratio up height from 0 to 1
  28917. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  28918. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  28919. * @returns impostor the soft imposter
  28920. */
  28921. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28922. /**
  28923. * Add a hook to a rope impostor
  28924. * @param otherImpostor rigid impostor to anchor to
  28925. * @param length ratio across rope from 0 to 1
  28926. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  28927. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  28928. * @returns impostor the rope imposter
  28929. */
  28930. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28931. /**
  28932. * Will keep this body still, in a sleep mode.
  28933. * @returns the physics imposter
  28934. */
  28935. sleep(): PhysicsImpostor;
  28936. /**
  28937. * Wake the body up.
  28938. * @returns The physics imposter
  28939. */
  28940. wakeUp(): PhysicsImpostor;
  28941. /**
  28942. * Clones the physics imposter
  28943. * @param newObject The physics imposter clones to this physics-enabled object
  28944. * @returns A nullable physics imposter
  28945. */
  28946. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28947. /**
  28948. * Disposes the physics imposter
  28949. */
  28950. dispose(): void;
  28951. /**
  28952. * Sets the delta position
  28953. * @param position The delta position amount
  28954. */
  28955. setDeltaPosition(position: Vector3): void;
  28956. /**
  28957. * Sets the delta rotation
  28958. * @param rotation The delta rotation amount
  28959. */
  28960. setDeltaRotation(rotation: Quaternion): void;
  28961. /**
  28962. * Gets the box size of the physics imposter and stores the result in the input parameter
  28963. * @param result Stores the box size
  28964. * @returns The physics imposter
  28965. */
  28966. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  28967. /**
  28968. * Gets the radius of the physics imposter
  28969. * @returns Radius of the physics imposter
  28970. */
  28971. getRadius(): number;
  28972. /**
  28973. * Sync a bone with this impostor
  28974. * @param bone The bone to sync to the impostor.
  28975. * @param boneMesh The mesh that the bone is influencing.
  28976. * @param jointPivot The pivot of the joint / bone in local space.
  28977. * @param distToJoint Optional distance from the impostor to the joint.
  28978. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28979. */
  28980. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  28981. /**
  28982. * Sync impostor to a bone
  28983. * @param bone The bone that the impostor will be synced to.
  28984. * @param boneMesh The mesh that the bone is influencing.
  28985. * @param jointPivot The pivot of the joint / bone in local space.
  28986. * @param distToJoint Optional distance from the impostor to the joint.
  28987. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28988. * @param boneAxis Optional vector3 axis the bone is aligned with
  28989. */
  28990. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28991. /**
  28992. * No-Imposter type
  28993. */
  28994. static NoImpostor: number;
  28995. /**
  28996. * Sphere-Imposter type
  28997. */
  28998. static SphereImpostor: number;
  28999. /**
  29000. * Box-Imposter type
  29001. */
  29002. static BoxImpostor: number;
  29003. /**
  29004. * Plane-Imposter type
  29005. */
  29006. static PlaneImpostor: number;
  29007. /**
  29008. * Mesh-imposter type
  29009. */
  29010. static MeshImpostor: number;
  29011. /**
  29012. * Capsule-Impostor type (Ammo.js plugin only)
  29013. */
  29014. static CapsuleImpostor: number;
  29015. /**
  29016. * Cylinder-Imposter type
  29017. */
  29018. static CylinderImpostor: number;
  29019. /**
  29020. * Particle-Imposter type
  29021. */
  29022. static ParticleImpostor: number;
  29023. /**
  29024. * Heightmap-Imposter type
  29025. */
  29026. static HeightmapImpostor: number;
  29027. /**
  29028. * ConvexHull-Impostor type (Ammo.js plugin only)
  29029. */
  29030. static ConvexHullImpostor: number;
  29031. /**
  29032. * Custom-Imposter type (Ammo.js plugin only)
  29033. */
  29034. static CustomImpostor: number;
  29035. /**
  29036. * Rope-Imposter type
  29037. */
  29038. static RopeImpostor: number;
  29039. /**
  29040. * Cloth-Imposter type
  29041. */
  29042. static ClothImpostor: number;
  29043. /**
  29044. * Softbody-Imposter type
  29045. */
  29046. static SoftbodyImpostor: number;
  29047. }
  29048. }
  29049. declare module "babylonjs/Meshes/mesh" {
  29050. import { Observable } from "babylonjs/Misc/observable";
  29051. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29052. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  29053. import { Camera } from "babylonjs/Cameras/camera";
  29054. import { Scene } from "babylonjs/scene";
  29055. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  29056. import { Color4 } from "babylonjs/Maths/math.color";
  29057. import { Engine } from "babylonjs/Engines/engine";
  29058. import { Node } from "babylonjs/node";
  29059. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29060. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  29061. import { Buffer } from "babylonjs/Meshes/buffer";
  29062. import { Geometry } from "babylonjs/Meshes/geometry";
  29063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29064. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29065. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  29066. import { Effect } from "babylonjs/Materials/effect";
  29067. import { Material } from "babylonjs/Materials/material";
  29068. import { Skeleton } from "babylonjs/Bones/skeleton";
  29069. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  29070. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  29071. import { Path3D } from "babylonjs/Maths/math.path";
  29072. import { Plane } from "babylonjs/Maths/math.plane";
  29073. import { TransformNode } from "babylonjs/Meshes/transformNode";
  29074. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  29075. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  29076. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  29077. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  29078. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  29079. /**
  29080. * @hidden
  29081. **/
  29082. export class _CreationDataStorage {
  29083. closePath?: boolean;
  29084. closeArray?: boolean;
  29085. idx: number[];
  29086. dashSize: number;
  29087. gapSize: number;
  29088. path3D: Path3D;
  29089. pathArray: Vector3[][];
  29090. arc: number;
  29091. radius: number;
  29092. cap: number;
  29093. tessellation: number;
  29094. }
  29095. /**
  29096. * @hidden
  29097. **/
  29098. class _InstanceDataStorage {
  29099. visibleInstances: any;
  29100. batchCache: _InstancesBatch;
  29101. instancesBufferSize: number;
  29102. instancesBuffer: Nullable<Buffer>;
  29103. instancesData: Float32Array;
  29104. overridenInstanceCount: number;
  29105. isFrozen: boolean;
  29106. previousBatch: Nullable<_InstancesBatch>;
  29107. hardwareInstancedRendering: boolean;
  29108. sideOrientation: number;
  29109. manualUpdate: boolean;
  29110. }
  29111. /**
  29112. * @hidden
  29113. **/
  29114. export class _InstancesBatch {
  29115. mustReturn: boolean;
  29116. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  29117. renderSelf: boolean[];
  29118. hardwareInstancedRendering: boolean[];
  29119. }
  29120. /**
  29121. * @hidden
  29122. **/
  29123. class _ThinInstanceDataStorage {
  29124. instancesCount: number;
  29125. matrixBuffer: Nullable<Buffer>;
  29126. matrixBufferSize: number;
  29127. matrixData: Nullable<Float32Array>;
  29128. boundingVectors: Array<Vector3>;
  29129. worldMatrices: Nullable<Matrix[]>;
  29130. }
  29131. /**
  29132. * Class used to represent renderable models
  29133. */
  29134. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  29135. /**
  29136. * Mesh side orientation : usually the external or front surface
  29137. */
  29138. static readonly FRONTSIDE: number;
  29139. /**
  29140. * Mesh side orientation : usually the internal or back surface
  29141. */
  29142. static readonly BACKSIDE: number;
  29143. /**
  29144. * Mesh side orientation : both internal and external or front and back surfaces
  29145. */
  29146. static readonly DOUBLESIDE: number;
  29147. /**
  29148. * Mesh side orientation : by default, `FRONTSIDE`
  29149. */
  29150. static readonly DEFAULTSIDE: number;
  29151. /**
  29152. * Mesh cap setting : no cap
  29153. */
  29154. static readonly NO_CAP: number;
  29155. /**
  29156. * Mesh cap setting : one cap at the beginning of the mesh
  29157. */
  29158. static readonly CAP_START: number;
  29159. /**
  29160. * Mesh cap setting : one cap at the end of the mesh
  29161. */
  29162. static readonly CAP_END: number;
  29163. /**
  29164. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  29165. */
  29166. static readonly CAP_ALL: number;
  29167. /**
  29168. * Mesh pattern setting : no flip or rotate
  29169. */
  29170. static readonly NO_FLIP: number;
  29171. /**
  29172. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  29173. */
  29174. static readonly FLIP_TILE: number;
  29175. /**
  29176. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  29177. */
  29178. static readonly ROTATE_TILE: number;
  29179. /**
  29180. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  29181. */
  29182. static readonly FLIP_ROW: number;
  29183. /**
  29184. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  29185. */
  29186. static readonly ROTATE_ROW: number;
  29187. /**
  29188. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  29189. */
  29190. static readonly FLIP_N_ROTATE_TILE: number;
  29191. /**
  29192. * Mesh pattern setting : rotate pattern and rotate
  29193. */
  29194. static readonly FLIP_N_ROTATE_ROW: number;
  29195. /**
  29196. * Mesh tile positioning : part tiles same on left/right or top/bottom
  29197. */
  29198. static readonly CENTER: number;
  29199. /**
  29200. * Mesh tile positioning : part tiles on left
  29201. */
  29202. static readonly LEFT: number;
  29203. /**
  29204. * Mesh tile positioning : part tiles on right
  29205. */
  29206. static readonly RIGHT: number;
  29207. /**
  29208. * Mesh tile positioning : part tiles on top
  29209. */
  29210. static readonly TOP: number;
  29211. /**
  29212. * Mesh tile positioning : part tiles on bottom
  29213. */
  29214. static readonly BOTTOM: number;
  29215. /**
  29216. * Gets the default side orientation.
  29217. * @param orientation the orientation to value to attempt to get
  29218. * @returns the default orientation
  29219. * @hidden
  29220. */
  29221. static _GetDefaultSideOrientation(orientation?: number): number;
  29222. private _internalMeshDataInfo;
  29223. get computeBonesUsingShaders(): boolean;
  29224. set computeBonesUsingShaders(value: boolean);
  29225. /**
  29226. * An event triggered before rendering the mesh
  29227. */
  29228. get onBeforeRenderObservable(): Observable<Mesh>;
  29229. /**
  29230. * An event triggered before binding the mesh
  29231. */
  29232. get onBeforeBindObservable(): Observable<Mesh>;
  29233. /**
  29234. * An event triggered after rendering the mesh
  29235. */
  29236. get onAfterRenderObservable(): Observable<Mesh>;
  29237. /**
  29238. * An event triggered before drawing the mesh
  29239. */
  29240. get onBeforeDrawObservable(): Observable<Mesh>;
  29241. private _onBeforeDrawObserver;
  29242. /**
  29243. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  29244. */
  29245. set onBeforeDraw(callback: () => void);
  29246. get hasInstances(): boolean;
  29247. get hasThinInstances(): boolean;
  29248. /**
  29249. * Gets the delay loading state of the mesh (when delay loading is turned on)
  29250. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  29251. */
  29252. delayLoadState: number;
  29253. /**
  29254. * Gets the list of instances created from this mesh
  29255. * it is not supposed to be modified manually.
  29256. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  29257. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29258. */
  29259. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  29260. /**
  29261. * Gets the file containing delay loading data for this mesh
  29262. */
  29263. delayLoadingFile: string;
  29264. /** @hidden */
  29265. _binaryInfo: any;
  29266. /**
  29267. * User defined function used to change how LOD level selection is done
  29268. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29269. */
  29270. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  29271. /**
  29272. * Gets or sets the morph target manager
  29273. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29274. */
  29275. get morphTargetManager(): Nullable<MorphTargetManager>;
  29276. set morphTargetManager(value: Nullable<MorphTargetManager>);
  29277. /** @hidden */
  29278. _creationDataStorage: Nullable<_CreationDataStorage>;
  29279. /** @hidden */
  29280. _geometry: Nullable<Geometry>;
  29281. /** @hidden */
  29282. _delayInfo: Array<string>;
  29283. /** @hidden */
  29284. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  29285. /** @hidden */
  29286. _instanceDataStorage: _InstanceDataStorage;
  29287. /** @hidden */
  29288. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  29289. private _effectiveMaterial;
  29290. /** @hidden */
  29291. _shouldGenerateFlatShading: boolean;
  29292. /** @hidden */
  29293. _originalBuilderSideOrientation: number;
  29294. /**
  29295. * Use this property to change the original side orientation defined at construction time
  29296. */
  29297. overrideMaterialSideOrientation: Nullable<number>;
  29298. /**
  29299. * Gets the source mesh (the one used to clone this one from)
  29300. */
  29301. get source(): Nullable<Mesh>;
  29302. /**
  29303. * Gets the list of clones of this mesh
  29304. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  29305. * Note that useClonedMeshMap=true is the default setting
  29306. */
  29307. get cloneMeshMap(): Nullable<{
  29308. [id: string]: Mesh | undefined;
  29309. }>;
  29310. /**
  29311. * Gets or sets a boolean indicating that this mesh does not use index buffer
  29312. */
  29313. get isUnIndexed(): boolean;
  29314. set isUnIndexed(value: boolean);
  29315. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  29316. get worldMatrixInstancedBuffer(): Float32Array;
  29317. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  29318. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  29319. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  29320. /**
  29321. * @constructor
  29322. * @param name The value used by scene.getMeshByName() to do a lookup.
  29323. * @param scene The scene to add this mesh to.
  29324. * @param parent The parent of this mesh, if it has one
  29325. * @param source An optional Mesh from which geometry is shared, cloned.
  29326. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29327. * When false, achieved by calling a clone(), also passing False.
  29328. * This will make creation of children, recursive.
  29329. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  29330. */
  29331. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  29332. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  29333. doNotInstantiate: boolean;
  29334. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  29335. /**
  29336. * Gets the class name
  29337. * @returns the string "Mesh".
  29338. */
  29339. getClassName(): string;
  29340. /** @hidden */
  29341. get _isMesh(): boolean;
  29342. /**
  29343. * Returns a description of this mesh
  29344. * @param fullDetails define if full details about this mesh must be used
  29345. * @returns a descriptive string representing this mesh
  29346. */
  29347. toString(fullDetails?: boolean): string;
  29348. /** @hidden */
  29349. _unBindEffect(): void;
  29350. /**
  29351. * Gets a boolean indicating if this mesh has LOD
  29352. */
  29353. get hasLODLevels(): boolean;
  29354. /**
  29355. * Gets the list of MeshLODLevel associated with the current mesh
  29356. * @returns an array of MeshLODLevel
  29357. */
  29358. getLODLevels(): MeshLODLevel[];
  29359. private _sortLODLevels;
  29360. /**
  29361. * Add a mesh as LOD level triggered at the given distance.
  29362. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29363. * @param distance The distance from the center of the object to show this level
  29364. * @param mesh The mesh to be added as LOD level (can be null)
  29365. * @return This mesh (for chaining)
  29366. */
  29367. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  29368. /**
  29369. * Returns the LOD level mesh at the passed distance or null if not found.
  29370. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29371. * @param distance The distance from the center of the object to show this level
  29372. * @returns a Mesh or `null`
  29373. */
  29374. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  29375. /**
  29376. * Remove a mesh from the LOD array
  29377. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29378. * @param mesh defines the mesh to be removed
  29379. * @return This mesh (for chaining)
  29380. */
  29381. removeLODLevel(mesh: Mesh): Mesh;
  29382. /**
  29383. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  29384. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29385. * @param camera defines the camera to use to compute distance
  29386. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  29387. * @return This mesh (for chaining)
  29388. */
  29389. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  29390. /**
  29391. * Gets the mesh internal Geometry object
  29392. */
  29393. get geometry(): Nullable<Geometry>;
  29394. /**
  29395. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  29396. * @returns the total number of vertices
  29397. */
  29398. getTotalVertices(): number;
  29399. /**
  29400. * Returns the content of an associated vertex buffer
  29401. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29402. * - VertexBuffer.PositionKind
  29403. * - VertexBuffer.UVKind
  29404. * - VertexBuffer.UV2Kind
  29405. * - VertexBuffer.UV3Kind
  29406. * - VertexBuffer.UV4Kind
  29407. * - VertexBuffer.UV5Kind
  29408. * - VertexBuffer.UV6Kind
  29409. * - VertexBuffer.ColorKind
  29410. * - VertexBuffer.MatricesIndicesKind
  29411. * - VertexBuffer.MatricesIndicesExtraKind
  29412. * - VertexBuffer.MatricesWeightsKind
  29413. * - VertexBuffer.MatricesWeightsExtraKind
  29414. * @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
  29415. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  29416. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  29417. */
  29418. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  29419. /**
  29420. * Returns the mesh VertexBuffer object from the requested `kind`
  29421. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29422. * - VertexBuffer.PositionKind
  29423. * - VertexBuffer.NormalKind
  29424. * - VertexBuffer.UVKind
  29425. * - VertexBuffer.UV2Kind
  29426. * - VertexBuffer.UV3Kind
  29427. * - VertexBuffer.UV4Kind
  29428. * - VertexBuffer.UV5Kind
  29429. * - VertexBuffer.UV6Kind
  29430. * - VertexBuffer.ColorKind
  29431. * - VertexBuffer.MatricesIndicesKind
  29432. * - VertexBuffer.MatricesIndicesExtraKind
  29433. * - VertexBuffer.MatricesWeightsKind
  29434. * - VertexBuffer.MatricesWeightsExtraKind
  29435. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  29436. */
  29437. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  29438. /**
  29439. * Tests if a specific vertex buffer is associated with this mesh
  29440. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29441. * - VertexBuffer.PositionKind
  29442. * - VertexBuffer.NormalKind
  29443. * - VertexBuffer.UVKind
  29444. * - VertexBuffer.UV2Kind
  29445. * - VertexBuffer.UV3Kind
  29446. * - VertexBuffer.UV4Kind
  29447. * - VertexBuffer.UV5Kind
  29448. * - VertexBuffer.UV6Kind
  29449. * - VertexBuffer.ColorKind
  29450. * - VertexBuffer.MatricesIndicesKind
  29451. * - VertexBuffer.MatricesIndicesExtraKind
  29452. * - VertexBuffer.MatricesWeightsKind
  29453. * - VertexBuffer.MatricesWeightsExtraKind
  29454. * @returns a boolean
  29455. */
  29456. isVerticesDataPresent(kind: string): boolean;
  29457. /**
  29458. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  29459. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29460. * - VertexBuffer.PositionKind
  29461. * - VertexBuffer.UVKind
  29462. * - VertexBuffer.UV2Kind
  29463. * - VertexBuffer.UV3Kind
  29464. * - VertexBuffer.UV4Kind
  29465. * - VertexBuffer.UV5Kind
  29466. * - VertexBuffer.UV6Kind
  29467. * - VertexBuffer.ColorKind
  29468. * - VertexBuffer.MatricesIndicesKind
  29469. * - VertexBuffer.MatricesIndicesExtraKind
  29470. * - VertexBuffer.MatricesWeightsKind
  29471. * - VertexBuffer.MatricesWeightsExtraKind
  29472. * @returns a boolean
  29473. */
  29474. isVertexBufferUpdatable(kind: string): boolean;
  29475. /**
  29476. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  29477. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29478. * - VertexBuffer.PositionKind
  29479. * - VertexBuffer.NormalKind
  29480. * - VertexBuffer.UVKind
  29481. * - VertexBuffer.UV2Kind
  29482. * - VertexBuffer.UV3Kind
  29483. * - VertexBuffer.UV4Kind
  29484. * - VertexBuffer.UV5Kind
  29485. * - VertexBuffer.UV6Kind
  29486. * - VertexBuffer.ColorKind
  29487. * - VertexBuffer.MatricesIndicesKind
  29488. * - VertexBuffer.MatricesIndicesExtraKind
  29489. * - VertexBuffer.MatricesWeightsKind
  29490. * - VertexBuffer.MatricesWeightsExtraKind
  29491. * @returns an array of strings
  29492. */
  29493. getVerticesDataKinds(): string[];
  29494. /**
  29495. * Returns a positive integer : the total number of indices in this mesh geometry.
  29496. * @returns the numner of indices or zero if the mesh has no geometry.
  29497. */
  29498. getTotalIndices(): number;
  29499. /**
  29500. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  29501. * @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.
  29502. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  29503. * @returns the indices array or an empty array if the mesh has no geometry
  29504. */
  29505. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  29506. get isBlocked(): boolean;
  29507. /**
  29508. * Determine if the current mesh is ready to be rendered
  29509. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29510. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  29511. * @returns true if all associated assets are ready (material, textures, shaders)
  29512. */
  29513. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  29514. /**
  29515. * 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.
  29516. */
  29517. get areNormalsFrozen(): boolean;
  29518. /**
  29519. * 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.
  29520. * @returns the current mesh
  29521. */
  29522. freezeNormals(): Mesh;
  29523. /**
  29524. * 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
  29525. * @returns the current mesh
  29526. */
  29527. unfreezeNormals(): Mesh;
  29528. /**
  29529. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  29530. */
  29531. set overridenInstanceCount(count: number);
  29532. /** @hidden */
  29533. _preActivate(): Mesh;
  29534. /** @hidden */
  29535. _preActivateForIntermediateRendering(renderId: number): Mesh;
  29536. /** @hidden */
  29537. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  29538. protected _afterComputeWorldMatrix(): void;
  29539. /** @hidden */
  29540. _postActivate(): void;
  29541. /**
  29542. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29543. * This means the mesh underlying bounding box and sphere are recomputed.
  29544. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29545. * @returns the current mesh
  29546. */
  29547. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  29548. /** @hidden */
  29549. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  29550. /**
  29551. * This function will subdivide the mesh into multiple submeshes
  29552. * @param count defines the expected number of submeshes
  29553. */
  29554. subdivide(count: number): void;
  29555. /**
  29556. * Copy a FloatArray into a specific associated vertex buffer
  29557. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29558. * - VertexBuffer.PositionKind
  29559. * - VertexBuffer.UVKind
  29560. * - VertexBuffer.UV2Kind
  29561. * - VertexBuffer.UV3Kind
  29562. * - VertexBuffer.UV4Kind
  29563. * - VertexBuffer.UV5Kind
  29564. * - VertexBuffer.UV6Kind
  29565. * - VertexBuffer.ColorKind
  29566. * - VertexBuffer.MatricesIndicesKind
  29567. * - VertexBuffer.MatricesIndicesExtraKind
  29568. * - VertexBuffer.MatricesWeightsKind
  29569. * - VertexBuffer.MatricesWeightsExtraKind
  29570. * @param data defines the data source
  29571. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29572. * @param stride defines the data stride size (can be null)
  29573. * @returns the current mesh
  29574. */
  29575. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29576. /**
  29577. * Delete a vertex buffer associated with this mesh
  29578. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  29579. * - VertexBuffer.PositionKind
  29580. * - VertexBuffer.UVKind
  29581. * - VertexBuffer.UV2Kind
  29582. * - VertexBuffer.UV3Kind
  29583. * - VertexBuffer.UV4Kind
  29584. * - VertexBuffer.UV5Kind
  29585. * - VertexBuffer.UV6Kind
  29586. * - VertexBuffer.ColorKind
  29587. * - VertexBuffer.MatricesIndicesKind
  29588. * - VertexBuffer.MatricesIndicesExtraKind
  29589. * - VertexBuffer.MatricesWeightsKind
  29590. * - VertexBuffer.MatricesWeightsExtraKind
  29591. */
  29592. removeVerticesData(kind: string): void;
  29593. /**
  29594. * Flags an associated vertex buffer as updatable
  29595. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  29596. * - VertexBuffer.PositionKind
  29597. * - VertexBuffer.UVKind
  29598. * - VertexBuffer.UV2Kind
  29599. * - VertexBuffer.UV3Kind
  29600. * - VertexBuffer.UV4Kind
  29601. * - VertexBuffer.UV5Kind
  29602. * - VertexBuffer.UV6Kind
  29603. * - VertexBuffer.ColorKind
  29604. * - VertexBuffer.MatricesIndicesKind
  29605. * - VertexBuffer.MatricesIndicesExtraKind
  29606. * - VertexBuffer.MatricesWeightsKind
  29607. * - VertexBuffer.MatricesWeightsExtraKind
  29608. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29609. */
  29610. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  29611. /**
  29612. * Sets the mesh global Vertex Buffer
  29613. * @param buffer defines the buffer to use
  29614. * @returns the current mesh
  29615. */
  29616. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  29617. /**
  29618. * Update a specific associated vertex buffer
  29619. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29620. * - VertexBuffer.PositionKind
  29621. * - VertexBuffer.UVKind
  29622. * - VertexBuffer.UV2Kind
  29623. * - VertexBuffer.UV3Kind
  29624. * - VertexBuffer.UV4Kind
  29625. * - VertexBuffer.UV5Kind
  29626. * - VertexBuffer.UV6Kind
  29627. * - VertexBuffer.ColorKind
  29628. * - VertexBuffer.MatricesIndicesKind
  29629. * - VertexBuffer.MatricesIndicesExtraKind
  29630. * - VertexBuffer.MatricesWeightsKind
  29631. * - VertexBuffer.MatricesWeightsExtraKind
  29632. * @param data defines the data source
  29633. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  29634. * @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)
  29635. * @returns the current mesh
  29636. */
  29637. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29638. /**
  29639. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  29640. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  29641. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  29642. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  29643. * @returns the current mesh
  29644. */
  29645. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  29646. /**
  29647. * Creates a un-shared specific occurence of the geometry for the mesh.
  29648. * @returns the current mesh
  29649. */
  29650. makeGeometryUnique(): Mesh;
  29651. /**
  29652. * Set the index buffer of this mesh
  29653. * @param indices defines the source data
  29654. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  29655. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  29656. * @returns the current mesh
  29657. */
  29658. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  29659. /**
  29660. * Update the current index buffer
  29661. * @param indices defines the source data
  29662. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29663. * @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)
  29664. * @returns the current mesh
  29665. */
  29666. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29667. /**
  29668. * Invert the geometry to move from a right handed system to a left handed one.
  29669. * @returns the current mesh
  29670. */
  29671. toLeftHanded(): Mesh;
  29672. /** @hidden */
  29673. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29674. /** @hidden */
  29675. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29676. /**
  29677. * Registers for this mesh a javascript function called just before the rendering process
  29678. * @param func defines the function to call before rendering this mesh
  29679. * @returns the current mesh
  29680. */
  29681. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29682. /**
  29683. * Disposes a previously registered javascript function called before the rendering
  29684. * @param func defines the function to remove
  29685. * @returns the current mesh
  29686. */
  29687. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29688. /**
  29689. * Registers for this mesh a javascript function called just after the rendering is complete
  29690. * @param func defines the function to call after rendering this mesh
  29691. * @returns the current mesh
  29692. */
  29693. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29694. /**
  29695. * Disposes a previously registered javascript function called after the rendering.
  29696. * @param func defines the function to remove
  29697. * @returns the current mesh
  29698. */
  29699. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29700. /** @hidden */
  29701. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  29702. /** @hidden */
  29703. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  29704. /** @hidden */
  29705. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  29706. /** @hidden */
  29707. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  29708. /** @hidden */
  29709. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  29710. /** @hidden */
  29711. _rebuild(): void;
  29712. /** @hidden */
  29713. _freeze(): void;
  29714. /** @hidden */
  29715. _unFreeze(): void;
  29716. /**
  29717. * 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
  29718. * @param subMesh defines the subMesh to render
  29719. * @param enableAlphaMode defines if alpha mode can be changed
  29720. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  29721. * @returns the current mesh
  29722. */
  29723. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  29724. private _onBeforeDraw;
  29725. /**
  29726. * Renormalize the mesh and patch it up if there are no weights
  29727. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  29728. * However in the case of zero weights then we set just a single influence to 1.
  29729. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  29730. */
  29731. cleanMatrixWeights(): void;
  29732. private normalizeSkinFourWeights;
  29733. private normalizeSkinWeightsAndExtra;
  29734. /**
  29735. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  29736. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  29737. * the user know there was an issue with importing the mesh
  29738. * @returns a validation object with skinned, valid and report string
  29739. */
  29740. validateSkinning(): {
  29741. skinned: boolean;
  29742. valid: boolean;
  29743. report: string;
  29744. };
  29745. /** @hidden */
  29746. _checkDelayState(): Mesh;
  29747. private _queueLoad;
  29748. /**
  29749. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29750. * A mesh is in the frustum if its bounding box intersects the frustum
  29751. * @param frustumPlanes defines the frustum to test
  29752. * @returns true if the mesh is in the frustum planes
  29753. */
  29754. isInFrustum(frustumPlanes: Plane[]): boolean;
  29755. /**
  29756. * Sets the mesh material by the material or multiMaterial `id` property
  29757. * @param id is a string identifying the material or the multiMaterial
  29758. * @returns the current mesh
  29759. */
  29760. setMaterialByID(id: string): Mesh;
  29761. /**
  29762. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  29763. * @returns an array of IAnimatable
  29764. */
  29765. getAnimatables(): IAnimatable[];
  29766. /**
  29767. * Modifies the mesh geometry according to the passed transformation matrix.
  29768. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  29769. * The mesh normals are modified using the same transformation.
  29770. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29771. * @param transform defines the transform matrix to use
  29772. * @see https://doc.babylonjs.com/resources/baking_transformations
  29773. * @returns the current mesh
  29774. */
  29775. bakeTransformIntoVertices(transform: Matrix): Mesh;
  29776. /**
  29777. * Modifies the mesh geometry according to its own current World Matrix.
  29778. * The mesh World Matrix is then reset.
  29779. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  29780. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29781. * @see https://doc.babylonjs.com/resources/baking_transformations
  29782. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  29783. * @returns the current mesh
  29784. */
  29785. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  29786. /** @hidden */
  29787. get _positions(): Nullable<Vector3[]>;
  29788. /** @hidden */
  29789. _resetPointsArrayCache(): Mesh;
  29790. /** @hidden */
  29791. _generatePointsArray(): boolean;
  29792. /**
  29793. * Returns a new Mesh object generated from the current mesh properties.
  29794. * This method must not get confused with createInstance()
  29795. * @param name is a string, the name given to the new mesh
  29796. * @param newParent can be any Node object (default `null`)
  29797. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  29798. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  29799. * @returns a new mesh
  29800. */
  29801. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  29802. /**
  29803. * Releases resources associated with this mesh.
  29804. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29805. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29806. */
  29807. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29808. /** @hidden */
  29809. _disposeInstanceSpecificData(): void;
  29810. /** @hidden */
  29811. _disposeThinInstanceSpecificData(): void;
  29812. /**
  29813. * Modifies the mesh geometry according to a displacement map.
  29814. * 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.
  29815. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29816. * @param url is a string, the URL from the image file is to be downloaded.
  29817. * @param minHeight is the lower limit of the displacement.
  29818. * @param maxHeight is the upper limit of the displacement.
  29819. * @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.
  29820. * @param uvOffset is an optional vector2 used to offset UV.
  29821. * @param uvScale is an optional vector2 used to scale UV.
  29822. * @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.
  29823. * @returns the Mesh.
  29824. */
  29825. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29826. /**
  29827. * Modifies the mesh geometry according to a displacementMap buffer.
  29828. * 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.
  29829. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29830. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  29831. * @param heightMapWidth is the width of the buffer image.
  29832. * @param heightMapHeight is the height of the buffer image.
  29833. * @param minHeight is the lower limit of the displacement.
  29834. * @param maxHeight is the upper limit of the displacement.
  29835. * @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.
  29836. * @param uvOffset is an optional vector2 used to offset UV.
  29837. * @param uvScale is an optional vector2 used to scale UV.
  29838. * @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.
  29839. * @returns the Mesh.
  29840. */
  29841. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29842. /**
  29843. * Modify the mesh to get a flat shading rendering.
  29844. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  29845. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  29846. * @returns current mesh
  29847. */
  29848. convertToFlatShadedMesh(): Mesh;
  29849. /**
  29850. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  29851. * In other words, more vertices, no more indices and a single bigger VBO.
  29852. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  29853. * @returns current mesh
  29854. */
  29855. convertToUnIndexedMesh(): Mesh;
  29856. /**
  29857. * Inverses facet orientations.
  29858. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29859. * @param flipNormals will also inverts the normals
  29860. * @returns current mesh
  29861. */
  29862. flipFaces(flipNormals?: boolean): Mesh;
  29863. /**
  29864. * Increase the number of facets and hence vertices in a mesh
  29865. * Vertex normals are interpolated from existing vertex normals
  29866. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29867. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  29868. */
  29869. increaseVertices(numberPerEdge: number): void;
  29870. /**
  29871. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  29872. * This will undo any application of covertToFlatShadedMesh
  29873. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29874. */
  29875. forceSharedVertices(): void;
  29876. /** @hidden */
  29877. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  29878. /** @hidden */
  29879. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  29880. /**
  29881. * Creates a new InstancedMesh object from the mesh model.
  29882. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29883. * @param name defines the name of the new instance
  29884. * @returns a new InstancedMesh
  29885. */
  29886. createInstance(name: string): InstancedMesh;
  29887. /**
  29888. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  29889. * After this call, all the mesh instances have the same submeshes than the current mesh.
  29890. * @returns the current mesh
  29891. */
  29892. synchronizeInstances(): Mesh;
  29893. /**
  29894. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  29895. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  29896. * This should be used together with the simplification to avoid disappearing triangles.
  29897. * @param successCallback an optional success callback to be called after the optimization finished.
  29898. * @returns the current mesh
  29899. */
  29900. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  29901. /**
  29902. * Serialize current mesh
  29903. * @param serializationObject defines the object which will receive the serialization data
  29904. */
  29905. serialize(serializationObject: any): void;
  29906. /** @hidden */
  29907. _syncGeometryWithMorphTargetManager(): void;
  29908. /** @hidden */
  29909. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  29910. /**
  29911. * Returns a new Mesh object parsed from the source provided.
  29912. * @param parsedMesh is the source
  29913. * @param scene defines the hosting scene
  29914. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  29915. * @returns a new Mesh
  29916. */
  29917. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  29918. /**
  29919. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  29920. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29921. * @param name defines the name of the mesh to create
  29922. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  29923. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  29924. * @param closePath creates a seam between the first and the last points of each path of the path array
  29925. * @param offset is taken in account only if the `pathArray` is containing a single path
  29926. * @param scene defines the hosting scene
  29927. * @param updatable defines if the mesh must be flagged as updatable
  29928. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29929. * @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)
  29930. * @returns a new Mesh
  29931. */
  29932. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29933. /**
  29934. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  29935. * @param name defines the name of the mesh to create
  29936. * @param radius sets the radius size (float) of the polygon (default 0.5)
  29937. * @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
  29938. * @param scene defines the hosting scene
  29939. * @param updatable defines if the mesh must be flagged as updatable
  29940. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29941. * @returns a new Mesh
  29942. */
  29943. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29944. /**
  29945. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  29946. * @param name defines the name of the mesh to create
  29947. * @param size sets the size (float) of each box side (default 1)
  29948. * @param scene defines the hosting scene
  29949. * @param updatable defines if the mesh must be flagged as updatable
  29950. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29951. * @returns a new Mesh
  29952. */
  29953. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29954. /**
  29955. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  29956. * @param name defines the name of the mesh to create
  29957. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29958. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29959. * @param scene defines the hosting scene
  29960. * @param updatable defines if the mesh must be flagged as updatable
  29961. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29962. * @returns a new Mesh
  29963. */
  29964. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29965. /**
  29966. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  29967. * @param name defines the name of the mesh to create
  29968. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29969. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29970. * @param scene defines the hosting scene
  29971. * @returns a new Mesh
  29972. */
  29973. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  29974. /**
  29975. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  29976. * @param name defines the name of the mesh to create
  29977. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  29978. * @param diameterTop set the top cap diameter (floats, default 1)
  29979. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  29980. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  29981. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  29982. * @param scene defines the hosting scene
  29983. * @param updatable defines if the mesh must be flagged as updatable
  29984. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29985. * @returns a new Mesh
  29986. */
  29987. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  29988. /**
  29989. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  29990. * @param name defines the name of the mesh to create
  29991. * @param diameter sets the diameter size (float) of the torus (default 1)
  29992. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  29993. * @param tessellation sets the number of torus sides (postive integer, default 16)
  29994. * @param scene defines the hosting scene
  29995. * @param updatable defines if the mesh must be flagged as updatable
  29996. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29997. * @returns a new Mesh
  29998. */
  29999. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30000. /**
  30001. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  30002. * @param name defines the name of the mesh to create
  30003. * @param radius sets the global radius size (float) of the torus knot (default 2)
  30004. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  30005. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  30006. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  30007. * @param p the number of windings on X axis (positive integers, default 2)
  30008. * @param q the number of windings on Y axis (positive integers, default 3)
  30009. * @param scene defines the hosting scene
  30010. * @param updatable defines if the mesh must be flagged as updatable
  30011. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30012. * @returns a new Mesh
  30013. */
  30014. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30015. /**
  30016. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  30017. * @param name defines the name of the mesh to create
  30018. * @param points is an array successive Vector3
  30019. * @param scene defines the hosting scene
  30020. * @param updatable defines if the mesh must be flagged as updatable
  30021. * @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).
  30022. * @returns a new Mesh
  30023. */
  30024. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  30025. /**
  30026. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  30027. * @param name defines the name of the mesh to create
  30028. * @param points is an array successive Vector3
  30029. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  30030. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  30031. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  30032. * @param scene defines the hosting scene
  30033. * @param updatable defines if the mesh must be flagged as updatable
  30034. * @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)
  30035. * @returns a new Mesh
  30036. */
  30037. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  30038. /**
  30039. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  30040. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  30041. * 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.
  30042. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30043. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  30044. * Remember you can only change the shape positions, not their number when updating a polygon.
  30045. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  30046. * @param name defines the name of the mesh to create
  30047. * @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
  30048. * @param scene defines the hosting scene
  30049. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30050. * @param updatable defines if the mesh must be flagged as updatable
  30051. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30052. * @param earcutInjection can be used to inject your own earcut reference
  30053. * @returns a new Mesh
  30054. */
  30055. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30056. /**
  30057. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  30058. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  30059. * @param name defines the name of the mesh to create
  30060. * @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
  30061. * @param depth defines the height of extrusion
  30062. * @param scene defines the hosting scene
  30063. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30064. * @param updatable defines if the mesh must be flagged as updatable
  30065. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30066. * @param earcutInjection can be used to inject your own earcut reference
  30067. * @returns a new Mesh
  30068. */
  30069. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30070. /**
  30071. * Creates an extruded shape mesh.
  30072. * 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
  30073. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30074. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30075. * @param name defines the name of the mesh to create
  30076. * @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
  30077. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30078. * @param scale is the value to scale the shape
  30079. * @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
  30080. * @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
  30081. * @param scene defines the hosting scene
  30082. * @param updatable defines if the mesh must be flagged as updatable
  30083. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30084. * @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)
  30085. * @returns a new Mesh
  30086. */
  30087. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30088. /**
  30089. * Creates an custom extruded shape mesh.
  30090. * The custom extrusion is a parametric shape.
  30091. * It has no predefined shape. Its final shape will depend on the input parameters.
  30092. * Please consider using the same method from the MeshBuilder class instead
  30093. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30094. * @param name defines the name of the mesh to create
  30095. * @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
  30096. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30097. * @param scaleFunction is a custom Javascript function called on each path point
  30098. * @param rotationFunction is a custom Javascript function called on each path point
  30099. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  30100. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  30101. * @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
  30102. * @param scene defines the hosting scene
  30103. * @param updatable defines if the mesh must be flagged as updatable
  30104. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30105. * @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)
  30106. * @returns a new Mesh
  30107. */
  30108. 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;
  30109. /**
  30110. * Creates lathe mesh.
  30111. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  30112. * Please consider using the same method from the MeshBuilder class instead
  30113. * @param name defines the name of the mesh to create
  30114. * @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
  30115. * @param radius is the radius value of the lathe
  30116. * @param tessellation is the side number of the lathe.
  30117. * @param scene defines the hosting scene
  30118. * @param updatable defines if the mesh must be flagged as updatable
  30119. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30120. * @returns a new Mesh
  30121. */
  30122. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30123. /**
  30124. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  30125. * @param name defines the name of the mesh to create
  30126. * @param size sets the size (float) of both sides of the plane at once (default 1)
  30127. * @param scene defines the hosting scene
  30128. * @param updatable defines if the mesh must be flagged as updatable
  30129. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30130. * @returns a new Mesh
  30131. */
  30132. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30133. /**
  30134. * Creates a ground mesh.
  30135. * Please consider using the same method from the MeshBuilder class instead
  30136. * @param name defines the name of the mesh to create
  30137. * @param width set the width of the ground
  30138. * @param height set the height of the ground
  30139. * @param subdivisions sets the number of subdivisions per side
  30140. * @param scene defines the hosting scene
  30141. * @param updatable defines if the mesh must be flagged as updatable
  30142. * @returns a new Mesh
  30143. */
  30144. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  30145. /**
  30146. * Creates a tiled ground mesh.
  30147. * Please consider using the same method from the MeshBuilder class instead
  30148. * @param name defines the name of the mesh to create
  30149. * @param xmin set the ground minimum X coordinate
  30150. * @param zmin set the ground minimum Y coordinate
  30151. * @param xmax set the ground maximum X coordinate
  30152. * @param zmax set the ground maximum Z coordinate
  30153. * @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
  30154. * @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
  30155. * @param scene defines the hosting scene
  30156. * @param updatable defines if the mesh must be flagged as updatable
  30157. * @returns a new Mesh
  30158. */
  30159. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  30160. w: number;
  30161. h: number;
  30162. }, precision: {
  30163. w: number;
  30164. h: number;
  30165. }, scene: Scene, updatable?: boolean): Mesh;
  30166. /**
  30167. * Creates a ground mesh from a height map.
  30168. * Please consider using the same method from the MeshBuilder class instead
  30169. * @see https://doc.babylonjs.com/babylon101/height_map
  30170. * @param name defines the name of the mesh to create
  30171. * @param url sets the URL of the height map image resource
  30172. * @param width set the ground width size
  30173. * @param height set the ground height size
  30174. * @param subdivisions sets the number of subdivision per side
  30175. * @param minHeight is the minimum altitude on the ground
  30176. * @param maxHeight is the maximum altitude on the ground
  30177. * @param scene defines the hosting scene
  30178. * @param updatable defines if the mesh must be flagged as updatable
  30179. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  30180. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  30181. * @returns a new Mesh
  30182. */
  30183. 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;
  30184. /**
  30185. * Creates a tube mesh.
  30186. * The tube is a parametric shape.
  30187. * It has no predefined shape. Its final shape will depend on the input parameters.
  30188. * Please consider using the same method from the MeshBuilder class instead
  30189. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30190. * @param name defines the name of the mesh to create
  30191. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  30192. * @param radius sets the tube radius size
  30193. * @param tessellation is the number of sides on the tubular surface
  30194. * @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
  30195. * @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
  30196. * @param scene defines the hosting scene
  30197. * @param updatable defines if the mesh must be flagged as updatable
  30198. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30199. * @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)
  30200. * @returns a new Mesh
  30201. */
  30202. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  30203. (i: number, distance: number): number;
  30204. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30205. /**
  30206. * Creates a polyhedron mesh.
  30207. * Please consider using the same method from the MeshBuilder class instead.
  30208. * * 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
  30209. * * The parameter `size` (positive float, default 1) sets the polygon size
  30210. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  30211. * * 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`
  30212. * * 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
  30213. * * 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)`)
  30214. * * 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
  30215. * * 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
  30216. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30217. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30219. * @param name defines the name of the mesh to create
  30220. * @param options defines the options used to create the mesh
  30221. * @param scene defines the hosting scene
  30222. * @returns a new Mesh
  30223. */
  30224. static CreatePolyhedron(name: string, options: {
  30225. type?: number;
  30226. size?: number;
  30227. sizeX?: number;
  30228. sizeY?: number;
  30229. sizeZ?: number;
  30230. custom?: any;
  30231. faceUV?: Vector4[];
  30232. faceColors?: Color4[];
  30233. updatable?: boolean;
  30234. sideOrientation?: number;
  30235. }, scene: Scene): Mesh;
  30236. /**
  30237. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  30238. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  30239. * * 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`)
  30240. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  30241. * * 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
  30242. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30243. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30245. * @param name defines the name of the mesh
  30246. * @param options defines the options used to create the mesh
  30247. * @param scene defines the hosting scene
  30248. * @returns a new Mesh
  30249. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  30250. */
  30251. static CreateIcoSphere(name: string, options: {
  30252. radius?: number;
  30253. flat?: boolean;
  30254. subdivisions?: number;
  30255. sideOrientation?: number;
  30256. updatable?: boolean;
  30257. }, scene: Scene): Mesh;
  30258. /**
  30259. * Creates a decal mesh.
  30260. * Please consider using the same method from the MeshBuilder class instead.
  30261. * A decal is a mesh usually applied as a model onto the surface of another mesh
  30262. * @param name defines the name of the mesh
  30263. * @param sourceMesh defines the mesh receiving the decal
  30264. * @param position sets the position of the decal in world coordinates
  30265. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  30266. * @param size sets the decal scaling
  30267. * @param angle sets the angle to rotate the decal
  30268. * @returns a new Mesh
  30269. */
  30270. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  30271. /**
  30272. * Prepare internal position array for software CPU skinning
  30273. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  30274. */
  30275. setPositionsForCPUSkinning(): Float32Array;
  30276. /**
  30277. * Prepare internal normal array for software CPU skinning
  30278. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  30279. */
  30280. setNormalsForCPUSkinning(): Float32Array;
  30281. /**
  30282. * Updates the vertex buffer by applying transformation from the bones
  30283. * @param skeleton defines the skeleton to apply to current mesh
  30284. * @returns the current mesh
  30285. */
  30286. applySkeleton(skeleton: Skeleton): Mesh;
  30287. /**
  30288. * 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
  30289. * @param meshes defines the list of meshes to scan
  30290. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  30291. */
  30292. static MinMax(meshes: AbstractMesh[]): {
  30293. min: Vector3;
  30294. max: Vector3;
  30295. };
  30296. /**
  30297. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  30298. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  30299. * @returns a vector3
  30300. */
  30301. static Center(meshesOrMinMaxVector: {
  30302. min: Vector3;
  30303. max: Vector3;
  30304. } | AbstractMesh[]): Vector3;
  30305. /**
  30306. * Merge the array of meshes into a single mesh for performance reasons.
  30307. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  30308. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  30309. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  30310. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  30311. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  30312. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  30313. * @returns a new mesh
  30314. */
  30315. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  30316. /** @hidden */
  30317. addInstance(instance: InstancedMesh): void;
  30318. /** @hidden */
  30319. removeInstance(instance: InstancedMesh): void;
  30320. }
  30321. }
  30322. declare module "babylonjs/Cameras/camera" {
  30323. import { SmartArray } from "babylonjs/Misc/smartArray";
  30324. import { Observable } from "babylonjs/Misc/observable";
  30325. import { Nullable } from "babylonjs/types";
  30326. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30327. import { Scene } from "babylonjs/scene";
  30328. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  30329. import { Node } from "babylonjs/node";
  30330. import { Mesh } from "babylonjs/Meshes/mesh";
  30331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30332. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30333. import { Viewport } from "babylonjs/Maths/math.viewport";
  30334. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30335. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30336. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30337. import { Ray } from "babylonjs/Culling/ray";
  30338. /**
  30339. * This is the base class of all the camera used in the application.
  30340. * @see https://doc.babylonjs.com/features/cameras
  30341. */
  30342. export class Camera extends Node {
  30343. /** @hidden */
  30344. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30345. /**
  30346. * This is the default projection mode used by the cameras.
  30347. * It helps recreating a feeling of perspective and better appreciate depth.
  30348. * This is the best way to simulate real life cameras.
  30349. */
  30350. static readonly PERSPECTIVE_CAMERA: number;
  30351. /**
  30352. * This helps creating camera with an orthographic mode.
  30353. * 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.
  30354. */
  30355. static readonly ORTHOGRAPHIC_CAMERA: number;
  30356. /**
  30357. * This is the default FOV mode for perspective cameras.
  30358. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30359. */
  30360. static readonly FOVMODE_VERTICAL_FIXED: number;
  30361. /**
  30362. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30363. */
  30364. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30365. /**
  30366. * This specifies ther is no need for a camera rig.
  30367. * Basically only one eye is rendered corresponding to the camera.
  30368. */
  30369. static readonly RIG_MODE_NONE: number;
  30370. /**
  30371. * Simulates a camera Rig with one blue eye and one red eye.
  30372. * This can be use with 3d blue and red glasses.
  30373. */
  30374. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30375. /**
  30376. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30377. */
  30378. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30379. /**
  30380. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30381. */
  30382. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30383. /**
  30384. * Defines that both eyes of the camera will be rendered over under each other.
  30385. */
  30386. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30387. /**
  30388. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  30389. */
  30390. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  30391. /**
  30392. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30393. */
  30394. static readonly RIG_MODE_VR: number;
  30395. /**
  30396. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30397. */
  30398. static readonly RIG_MODE_WEBVR: number;
  30399. /**
  30400. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30401. */
  30402. static readonly RIG_MODE_CUSTOM: number;
  30403. /**
  30404. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30405. */
  30406. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30407. /**
  30408. * Define the input manager associated with the camera.
  30409. */
  30410. inputs: CameraInputsManager<Camera>;
  30411. /** @hidden */
  30412. _position: Vector3;
  30413. /**
  30414. * Define the current local position of the camera in the scene
  30415. */
  30416. get position(): Vector3;
  30417. set position(newPosition: Vector3);
  30418. protected _upVector: Vector3;
  30419. /**
  30420. * The vector the camera should consider as up.
  30421. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30422. */
  30423. set upVector(vec: Vector3);
  30424. get upVector(): Vector3;
  30425. /**
  30426. * Define the current limit on the left side for an orthographic camera
  30427. * In scene unit
  30428. */
  30429. orthoLeft: Nullable<number>;
  30430. /**
  30431. * Define the current limit on the right side for an orthographic camera
  30432. * In scene unit
  30433. */
  30434. orthoRight: Nullable<number>;
  30435. /**
  30436. * Define the current limit on the bottom side for an orthographic camera
  30437. * In scene unit
  30438. */
  30439. orthoBottom: Nullable<number>;
  30440. /**
  30441. * Define the current limit on the top side for an orthographic camera
  30442. * In scene unit
  30443. */
  30444. orthoTop: Nullable<number>;
  30445. /**
  30446. * Field Of View is set in Radians. (default is 0.8)
  30447. */
  30448. fov: number;
  30449. /**
  30450. * Define the minimum distance the camera can see from.
  30451. * This is important to note that the depth buffer are not infinite and the closer it starts
  30452. * the more your scene might encounter depth fighting issue.
  30453. */
  30454. minZ: number;
  30455. /**
  30456. * Define the maximum distance the camera can see to.
  30457. * This is important to note that the depth buffer are not infinite and the further it end
  30458. * the more your scene might encounter depth fighting issue.
  30459. */
  30460. maxZ: number;
  30461. /**
  30462. * Define the default inertia of the camera.
  30463. * This helps giving a smooth feeling to the camera movement.
  30464. */
  30465. inertia: number;
  30466. /**
  30467. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30468. */
  30469. mode: number;
  30470. /**
  30471. * Define whether the camera is intermediate.
  30472. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30473. */
  30474. isIntermediate: boolean;
  30475. /**
  30476. * Define the viewport of the camera.
  30477. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30478. */
  30479. viewport: Viewport;
  30480. /**
  30481. * Restricts the camera to viewing objects with the same layerMask.
  30482. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30483. */
  30484. layerMask: number;
  30485. /**
  30486. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30487. */
  30488. fovMode: number;
  30489. /**
  30490. * Rig mode of the camera.
  30491. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30492. * This is normally controlled byt the camera themselves as internal use.
  30493. */
  30494. cameraRigMode: number;
  30495. /**
  30496. * Defines the distance between both "eyes" in case of a RIG
  30497. */
  30498. interaxialDistance: number;
  30499. /**
  30500. * Defines if stereoscopic rendering is done side by side or over under.
  30501. */
  30502. isStereoscopicSideBySide: boolean;
  30503. /**
  30504. * 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
  30505. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30506. * else in the scene. (Eg. security camera)
  30507. *
  30508. * 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)
  30509. */
  30510. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30511. /**
  30512. * When set, the camera will render to this render target instead of the default canvas
  30513. *
  30514. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  30515. */
  30516. outputRenderTarget: Nullable<RenderTargetTexture>;
  30517. /**
  30518. * Observable triggered when the camera view matrix has changed.
  30519. */
  30520. onViewMatrixChangedObservable: Observable<Camera>;
  30521. /**
  30522. * Observable triggered when the camera Projection matrix has changed.
  30523. */
  30524. onProjectionMatrixChangedObservable: Observable<Camera>;
  30525. /**
  30526. * Observable triggered when the inputs have been processed.
  30527. */
  30528. onAfterCheckInputsObservable: Observable<Camera>;
  30529. /**
  30530. * Observable triggered when reset has been called and applied to the camera.
  30531. */
  30532. onRestoreStateObservable: Observable<Camera>;
  30533. /**
  30534. * Is this camera a part of a rig system?
  30535. */
  30536. isRigCamera: boolean;
  30537. /**
  30538. * If isRigCamera set to true this will be set with the parent camera.
  30539. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  30540. */
  30541. rigParent?: Camera;
  30542. /** @hidden */
  30543. _cameraRigParams: any;
  30544. /** @hidden */
  30545. _rigCameras: Camera[];
  30546. /** @hidden */
  30547. _rigPostProcess: Nullable<PostProcess>;
  30548. protected _webvrViewMatrix: Matrix;
  30549. /** @hidden */
  30550. _skipRendering: boolean;
  30551. /** @hidden */
  30552. _projectionMatrix: Matrix;
  30553. /** @hidden */
  30554. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30555. /** @hidden */
  30556. _activeMeshes: SmartArray<AbstractMesh>;
  30557. protected _globalPosition: Vector3;
  30558. /** @hidden */
  30559. _computedViewMatrix: Matrix;
  30560. private _doNotComputeProjectionMatrix;
  30561. private _transformMatrix;
  30562. private _frustumPlanes;
  30563. private _refreshFrustumPlanes;
  30564. private _storedFov;
  30565. private _stateStored;
  30566. /**
  30567. * Instantiates a new camera object.
  30568. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30569. * @see https://doc.babylonjs.com/features/cameras
  30570. * @param name Defines the name of the camera in the scene
  30571. * @param position Defines the position of the camera
  30572. * @param scene Defines the scene the camera belongs too
  30573. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30574. */
  30575. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30576. /**
  30577. * Store current camera state (fov, position, etc..)
  30578. * @returns the camera
  30579. */
  30580. storeState(): Camera;
  30581. /**
  30582. * Restores the camera state values if it has been stored. You must call storeState() first
  30583. */
  30584. protected _restoreStateValues(): boolean;
  30585. /**
  30586. * Restored camera state. You must call storeState() first.
  30587. * @returns true if restored and false otherwise
  30588. */
  30589. restoreState(): boolean;
  30590. /**
  30591. * Gets the class name of the camera.
  30592. * @returns the class name
  30593. */
  30594. getClassName(): string;
  30595. /** @hidden */
  30596. readonly _isCamera: boolean;
  30597. /**
  30598. * Gets a string representation of the camera useful for debug purpose.
  30599. * @param fullDetails Defines that a more verboe level of logging is required
  30600. * @returns the string representation
  30601. */
  30602. toString(fullDetails?: boolean): string;
  30603. /**
  30604. * Gets the current world space position of the camera.
  30605. */
  30606. get globalPosition(): Vector3;
  30607. /**
  30608. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30609. * @returns the active meshe list
  30610. */
  30611. getActiveMeshes(): SmartArray<AbstractMesh>;
  30612. /**
  30613. * Check whether a mesh is part of the current active mesh list of the camera
  30614. * @param mesh Defines the mesh to check
  30615. * @returns true if active, false otherwise
  30616. */
  30617. isActiveMesh(mesh: Mesh): boolean;
  30618. /**
  30619. * Is this camera ready to be used/rendered
  30620. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30621. * @return true if the camera is ready
  30622. */
  30623. isReady(completeCheck?: boolean): boolean;
  30624. /** @hidden */
  30625. _initCache(): void;
  30626. /** @hidden */
  30627. _updateCache(ignoreParentClass?: boolean): void;
  30628. /** @hidden */
  30629. _isSynchronized(): boolean;
  30630. /** @hidden */
  30631. _isSynchronizedViewMatrix(): boolean;
  30632. /** @hidden */
  30633. _isSynchronizedProjectionMatrix(): boolean;
  30634. /**
  30635. * Attach the input controls to a specific dom element to get the input from.
  30636. * @param element Defines the element the controls should be listened from
  30637. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30638. */
  30639. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30640. /**
  30641. * Detach the current controls from the specified dom element.
  30642. * @param element Defines the element to stop listening the inputs from
  30643. */
  30644. detachControl(element: HTMLElement): void;
  30645. /**
  30646. * Update the camera state according to the different inputs gathered during the frame.
  30647. */
  30648. update(): void;
  30649. /** @hidden */
  30650. _checkInputs(): void;
  30651. /** @hidden */
  30652. get rigCameras(): Camera[];
  30653. /**
  30654. * Gets the post process used by the rig cameras
  30655. */
  30656. get rigPostProcess(): Nullable<PostProcess>;
  30657. /**
  30658. * Internal, gets the first post proces.
  30659. * @returns the first post process to be run on this camera.
  30660. */
  30661. _getFirstPostProcess(): Nullable<PostProcess>;
  30662. private _cascadePostProcessesToRigCams;
  30663. /**
  30664. * Attach a post process to the camera.
  30665. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30666. * @param postProcess The post process to attach to the camera
  30667. * @param insertAt The position of the post process in case several of them are in use in the scene
  30668. * @returns the position the post process has been inserted at
  30669. */
  30670. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30671. /**
  30672. * Detach a post process to the camera.
  30673. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30674. * @param postProcess The post process to detach from the camera
  30675. */
  30676. detachPostProcess(postProcess: PostProcess): void;
  30677. /**
  30678. * Gets the current world matrix of the camera
  30679. */
  30680. getWorldMatrix(): Matrix;
  30681. /** @hidden */
  30682. _getViewMatrix(): Matrix;
  30683. /**
  30684. * Gets the current view matrix of the camera.
  30685. * @param force forces the camera to recompute the matrix without looking at the cached state
  30686. * @returns the view matrix
  30687. */
  30688. getViewMatrix(force?: boolean): Matrix;
  30689. /**
  30690. * Freeze the projection matrix.
  30691. * It will prevent the cache check of the camera projection compute and can speed up perf
  30692. * if no parameter of the camera are meant to change
  30693. * @param projection Defines manually a projection if necessary
  30694. */
  30695. freezeProjectionMatrix(projection?: Matrix): void;
  30696. /**
  30697. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30698. */
  30699. unfreezeProjectionMatrix(): void;
  30700. /**
  30701. * Gets the current projection matrix of the camera.
  30702. * @param force forces the camera to recompute the matrix without looking at the cached state
  30703. * @returns the projection matrix
  30704. */
  30705. getProjectionMatrix(force?: boolean): Matrix;
  30706. /**
  30707. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30708. * @returns a Matrix
  30709. */
  30710. getTransformationMatrix(): Matrix;
  30711. private _updateFrustumPlanes;
  30712. /**
  30713. * Checks if a cullable object (mesh...) is in the camera frustum
  30714. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30715. * @param target The object to check
  30716. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30717. * @returns true if the object is in frustum otherwise false
  30718. */
  30719. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30720. /**
  30721. * Checks if a cullable object (mesh...) is in the camera frustum
  30722. * Unlike isInFrustum this cheks the full bounding box
  30723. * @param target The object to check
  30724. * @returns true if the object is in frustum otherwise false
  30725. */
  30726. isCompletelyInFrustum(target: ICullable): boolean;
  30727. /**
  30728. * Gets a ray in the forward direction from the camera.
  30729. * @param length Defines the length of the ray to create
  30730. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30731. * @param origin Defines the start point of the ray which defaults to the camera position
  30732. * @returns the forward ray
  30733. */
  30734. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30735. /**
  30736. * Gets a ray in the forward direction from the camera.
  30737. * @param refRay the ray to (re)use when setting the values
  30738. * @param length Defines the length of the ray to create
  30739. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30740. * @param origin Defines the start point of the ray which defaults to the camera position
  30741. * @returns the forward ray
  30742. */
  30743. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30744. /**
  30745. * Releases resources associated with this node.
  30746. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30747. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30748. */
  30749. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30750. /** @hidden */
  30751. _isLeftCamera: boolean;
  30752. /**
  30753. * Gets the left camera of a rig setup in case of Rigged Camera
  30754. */
  30755. get isLeftCamera(): boolean;
  30756. /** @hidden */
  30757. _isRightCamera: boolean;
  30758. /**
  30759. * Gets the right camera of a rig setup in case of Rigged Camera
  30760. */
  30761. get isRightCamera(): boolean;
  30762. /**
  30763. * Gets the left camera of a rig setup in case of Rigged Camera
  30764. */
  30765. get leftCamera(): Nullable<FreeCamera>;
  30766. /**
  30767. * Gets the right camera of a rig setup in case of Rigged Camera
  30768. */
  30769. get rightCamera(): Nullable<FreeCamera>;
  30770. /**
  30771. * Gets the left camera target of a rig setup in case of Rigged Camera
  30772. * @returns the target position
  30773. */
  30774. getLeftTarget(): Nullable<Vector3>;
  30775. /**
  30776. * Gets the right camera target of a rig setup in case of Rigged Camera
  30777. * @returns the target position
  30778. */
  30779. getRightTarget(): Nullable<Vector3>;
  30780. /**
  30781. * @hidden
  30782. */
  30783. setCameraRigMode(mode: number, rigParams: any): void;
  30784. /** @hidden */
  30785. static _setStereoscopicRigMode(camera: Camera): void;
  30786. /** @hidden */
  30787. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30788. /** @hidden */
  30789. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30790. /** @hidden */
  30791. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30792. /** @hidden */
  30793. _getVRProjectionMatrix(): Matrix;
  30794. protected _updateCameraRotationMatrix(): void;
  30795. protected _updateWebVRCameraRotationMatrix(): void;
  30796. /**
  30797. * This function MUST be overwritten by the different WebVR cameras available.
  30798. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30799. * @hidden
  30800. */
  30801. _getWebVRProjectionMatrix(): Matrix;
  30802. /**
  30803. * This function MUST be overwritten by the different WebVR cameras available.
  30804. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30805. * @hidden
  30806. */
  30807. _getWebVRViewMatrix(): Matrix;
  30808. /** @hidden */
  30809. setCameraRigParameter(name: string, value: any): void;
  30810. /**
  30811. * needs to be overridden by children so sub has required properties to be copied
  30812. * @hidden
  30813. */
  30814. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30815. /**
  30816. * May need to be overridden by children
  30817. * @hidden
  30818. */
  30819. _updateRigCameras(): void;
  30820. /** @hidden */
  30821. _setupInputs(): void;
  30822. /**
  30823. * Serialiaze the camera setup to a json represention
  30824. * @returns the JSON representation
  30825. */
  30826. serialize(): any;
  30827. /**
  30828. * Clones the current camera.
  30829. * @param name The cloned camera name
  30830. * @returns the cloned camera
  30831. */
  30832. clone(name: string): Camera;
  30833. /**
  30834. * Gets the direction of the camera relative to a given local axis.
  30835. * @param localAxis Defines the reference axis to provide a relative direction.
  30836. * @return the direction
  30837. */
  30838. getDirection(localAxis: Vector3): Vector3;
  30839. /**
  30840. * Returns the current camera absolute rotation
  30841. */
  30842. get absoluteRotation(): Quaternion;
  30843. /**
  30844. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30845. * @param localAxis Defines the reference axis to provide a relative direction.
  30846. * @param result Defines the vector to store the result in
  30847. */
  30848. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30849. /**
  30850. * Gets a camera constructor for a given camera type
  30851. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30852. * @param name The name of the camera the result will be able to instantiate
  30853. * @param scene The scene the result will construct the camera in
  30854. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30855. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30856. * @returns a factory method to construc the camera
  30857. */
  30858. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30859. /**
  30860. * Compute the world matrix of the camera.
  30861. * @returns the camera world matrix
  30862. */
  30863. computeWorldMatrix(): Matrix;
  30864. /**
  30865. * Parse a JSON and creates the camera from the parsed information
  30866. * @param parsedCamera The JSON to parse
  30867. * @param scene The scene to instantiate the camera in
  30868. * @returns the newly constructed camera
  30869. */
  30870. static Parse(parsedCamera: any, scene: Scene): Camera;
  30871. }
  30872. }
  30873. declare module "babylonjs/Meshes/Builders/discBuilder" {
  30874. import { Nullable } from "babylonjs/types";
  30875. import { Scene } from "babylonjs/scene";
  30876. import { Vector4 } from "babylonjs/Maths/math.vector";
  30877. import { Mesh } from "babylonjs/Meshes/mesh";
  30878. /**
  30879. * Class containing static functions to help procedurally build meshes
  30880. */
  30881. export class DiscBuilder {
  30882. /**
  30883. * Creates a plane polygonal mesh. By default, this is a disc
  30884. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  30885. * * 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
  30886. * * 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
  30887. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  30888. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30890. * @param name defines the name of the mesh
  30891. * @param options defines the options used to create the mesh
  30892. * @param scene defines the hosting scene
  30893. * @returns the plane polygonal mesh
  30894. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  30895. */
  30896. static CreateDisc(name: string, options: {
  30897. radius?: number;
  30898. tessellation?: number;
  30899. arc?: number;
  30900. updatable?: boolean;
  30901. sideOrientation?: number;
  30902. frontUVs?: Vector4;
  30903. backUVs?: Vector4;
  30904. }, scene?: Nullable<Scene>): Mesh;
  30905. }
  30906. }
  30907. declare module "babylonjs/Materials/fresnelParameters" {
  30908. import { DeepImmutable } from "babylonjs/types";
  30909. import { Color3 } from "babylonjs/Maths/math.color";
  30910. /**
  30911. * Options to be used when creating a FresnelParameters.
  30912. */
  30913. export type IFresnelParametersCreationOptions = {
  30914. /**
  30915. * Define the color used on edges (grazing angle)
  30916. */
  30917. leftColor?: Color3;
  30918. /**
  30919. * Define the color used on center
  30920. */
  30921. rightColor?: Color3;
  30922. /**
  30923. * Define bias applied to computed fresnel term
  30924. */
  30925. bias?: number;
  30926. /**
  30927. * Defined the power exponent applied to fresnel term
  30928. */
  30929. power?: number;
  30930. /**
  30931. * Define if the fresnel effect is enable or not.
  30932. */
  30933. isEnabled?: boolean;
  30934. };
  30935. /**
  30936. * Serialized format for FresnelParameters.
  30937. */
  30938. export type IFresnelParametersSerialized = {
  30939. /**
  30940. * Define the color used on edges (grazing angle) [as an array]
  30941. */
  30942. leftColor: number[];
  30943. /**
  30944. * Define the color used on center [as an array]
  30945. */
  30946. rightColor: number[];
  30947. /**
  30948. * Define bias applied to computed fresnel term
  30949. */
  30950. bias: number;
  30951. /**
  30952. * Defined the power exponent applied to fresnel term
  30953. */
  30954. power?: number;
  30955. /**
  30956. * Define if the fresnel effect is enable or not.
  30957. */
  30958. isEnabled: boolean;
  30959. };
  30960. /**
  30961. * This represents all the required information to add a fresnel effect on a material:
  30962. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30963. */
  30964. export class FresnelParameters {
  30965. private _isEnabled;
  30966. /**
  30967. * Define if the fresnel effect is enable or not.
  30968. */
  30969. get isEnabled(): boolean;
  30970. set isEnabled(value: boolean);
  30971. /**
  30972. * Define the color used on edges (grazing angle)
  30973. */
  30974. leftColor: Color3;
  30975. /**
  30976. * Define the color used on center
  30977. */
  30978. rightColor: Color3;
  30979. /**
  30980. * Define bias applied to computed fresnel term
  30981. */
  30982. bias: number;
  30983. /**
  30984. * Defined the power exponent applied to fresnel term
  30985. */
  30986. power: number;
  30987. /**
  30988. * Creates a new FresnelParameters object.
  30989. *
  30990. * @param options provide your own settings to optionally to override defaults
  30991. */
  30992. constructor(options?: IFresnelParametersCreationOptions);
  30993. /**
  30994. * Clones the current fresnel and its valuues
  30995. * @returns a clone fresnel configuration
  30996. */
  30997. clone(): FresnelParameters;
  30998. /**
  30999. * Determines equality between FresnelParameters objects
  31000. * @param otherFresnelParameters defines the second operand
  31001. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  31002. */
  31003. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  31004. /**
  31005. * Serializes the current fresnel parameters to a JSON representation.
  31006. * @return the JSON serialization
  31007. */
  31008. serialize(): IFresnelParametersSerialized;
  31009. /**
  31010. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31011. * @param parsedFresnelParameters Define the JSON representation
  31012. * @returns the parsed parameters
  31013. */
  31014. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  31015. }
  31016. }
  31017. declare module "babylonjs/Materials/materialFlags" {
  31018. /**
  31019. * This groups all the flags used to control the materials channel.
  31020. */
  31021. export class MaterialFlags {
  31022. private static _DiffuseTextureEnabled;
  31023. /**
  31024. * Are diffuse textures enabled in the application.
  31025. */
  31026. static get DiffuseTextureEnabled(): boolean;
  31027. static set DiffuseTextureEnabled(value: boolean);
  31028. private static _DetailTextureEnabled;
  31029. /**
  31030. * Are detail textures enabled in the application.
  31031. */
  31032. static get DetailTextureEnabled(): boolean;
  31033. static set DetailTextureEnabled(value: boolean);
  31034. private static _AmbientTextureEnabled;
  31035. /**
  31036. * Are ambient textures enabled in the application.
  31037. */
  31038. static get AmbientTextureEnabled(): boolean;
  31039. static set AmbientTextureEnabled(value: boolean);
  31040. private static _OpacityTextureEnabled;
  31041. /**
  31042. * Are opacity textures enabled in the application.
  31043. */
  31044. static get OpacityTextureEnabled(): boolean;
  31045. static set OpacityTextureEnabled(value: boolean);
  31046. private static _ReflectionTextureEnabled;
  31047. /**
  31048. * Are reflection textures enabled in the application.
  31049. */
  31050. static get ReflectionTextureEnabled(): boolean;
  31051. static set ReflectionTextureEnabled(value: boolean);
  31052. private static _EmissiveTextureEnabled;
  31053. /**
  31054. * Are emissive textures enabled in the application.
  31055. */
  31056. static get EmissiveTextureEnabled(): boolean;
  31057. static set EmissiveTextureEnabled(value: boolean);
  31058. private static _SpecularTextureEnabled;
  31059. /**
  31060. * Are specular textures enabled in the application.
  31061. */
  31062. static get SpecularTextureEnabled(): boolean;
  31063. static set SpecularTextureEnabled(value: boolean);
  31064. private static _BumpTextureEnabled;
  31065. /**
  31066. * Are bump textures enabled in the application.
  31067. */
  31068. static get BumpTextureEnabled(): boolean;
  31069. static set BumpTextureEnabled(value: boolean);
  31070. private static _LightmapTextureEnabled;
  31071. /**
  31072. * Are lightmap textures enabled in the application.
  31073. */
  31074. static get LightmapTextureEnabled(): boolean;
  31075. static set LightmapTextureEnabled(value: boolean);
  31076. private static _RefractionTextureEnabled;
  31077. /**
  31078. * Are refraction textures enabled in the application.
  31079. */
  31080. static get RefractionTextureEnabled(): boolean;
  31081. static set RefractionTextureEnabled(value: boolean);
  31082. private static _ColorGradingTextureEnabled;
  31083. /**
  31084. * Are color grading textures enabled in the application.
  31085. */
  31086. static get ColorGradingTextureEnabled(): boolean;
  31087. static set ColorGradingTextureEnabled(value: boolean);
  31088. private static _FresnelEnabled;
  31089. /**
  31090. * Are fresnels enabled in the application.
  31091. */
  31092. static get FresnelEnabled(): boolean;
  31093. static set FresnelEnabled(value: boolean);
  31094. private static _ClearCoatTextureEnabled;
  31095. /**
  31096. * Are clear coat textures enabled in the application.
  31097. */
  31098. static get ClearCoatTextureEnabled(): boolean;
  31099. static set ClearCoatTextureEnabled(value: boolean);
  31100. private static _ClearCoatBumpTextureEnabled;
  31101. /**
  31102. * Are clear coat bump textures enabled in the application.
  31103. */
  31104. static get ClearCoatBumpTextureEnabled(): boolean;
  31105. static set ClearCoatBumpTextureEnabled(value: boolean);
  31106. private static _ClearCoatTintTextureEnabled;
  31107. /**
  31108. * Are clear coat tint textures enabled in the application.
  31109. */
  31110. static get ClearCoatTintTextureEnabled(): boolean;
  31111. static set ClearCoatTintTextureEnabled(value: boolean);
  31112. private static _SheenTextureEnabled;
  31113. /**
  31114. * Are sheen textures enabled in the application.
  31115. */
  31116. static get SheenTextureEnabled(): boolean;
  31117. static set SheenTextureEnabled(value: boolean);
  31118. private static _AnisotropicTextureEnabled;
  31119. /**
  31120. * Are anisotropic textures enabled in the application.
  31121. */
  31122. static get AnisotropicTextureEnabled(): boolean;
  31123. static set AnisotropicTextureEnabled(value: boolean);
  31124. private static _ThicknessTextureEnabled;
  31125. /**
  31126. * Are thickness textures enabled in the application.
  31127. */
  31128. static get ThicknessTextureEnabled(): boolean;
  31129. static set ThicknessTextureEnabled(value: boolean);
  31130. }
  31131. }
  31132. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  31133. /** @hidden */
  31134. export var defaultFragmentDeclaration: {
  31135. name: string;
  31136. shader: string;
  31137. };
  31138. }
  31139. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  31140. /** @hidden */
  31141. export var defaultUboDeclaration: {
  31142. name: string;
  31143. shader: string;
  31144. };
  31145. }
  31146. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  31147. /** @hidden */
  31148. export var prePassDeclaration: {
  31149. name: string;
  31150. shader: string;
  31151. };
  31152. }
  31153. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  31154. /** @hidden */
  31155. export var lightFragmentDeclaration: {
  31156. name: string;
  31157. shader: string;
  31158. };
  31159. }
  31160. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  31161. /** @hidden */
  31162. export var lightUboDeclaration: {
  31163. name: string;
  31164. shader: string;
  31165. };
  31166. }
  31167. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  31168. /** @hidden */
  31169. export var lightsFragmentFunctions: {
  31170. name: string;
  31171. shader: string;
  31172. };
  31173. }
  31174. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  31175. /** @hidden */
  31176. export var shadowsFragmentFunctions: {
  31177. name: string;
  31178. shader: string;
  31179. };
  31180. }
  31181. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  31182. /** @hidden */
  31183. export var fresnelFunction: {
  31184. name: string;
  31185. shader: string;
  31186. };
  31187. }
  31188. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  31189. /** @hidden */
  31190. export var bumpFragmentMainFunctions: {
  31191. name: string;
  31192. shader: string;
  31193. };
  31194. }
  31195. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  31196. /** @hidden */
  31197. export var bumpFragmentFunctions: {
  31198. name: string;
  31199. shader: string;
  31200. };
  31201. }
  31202. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  31203. /** @hidden */
  31204. export var logDepthDeclaration: {
  31205. name: string;
  31206. shader: string;
  31207. };
  31208. }
  31209. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  31210. /** @hidden */
  31211. export var bumpFragment: {
  31212. name: string;
  31213. shader: string;
  31214. };
  31215. }
  31216. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  31217. /** @hidden */
  31218. export var depthPrePass: {
  31219. name: string;
  31220. shader: string;
  31221. };
  31222. }
  31223. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  31224. /** @hidden */
  31225. export var lightFragment: {
  31226. name: string;
  31227. shader: string;
  31228. };
  31229. }
  31230. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  31231. /** @hidden */
  31232. export var logDepthFragment: {
  31233. name: string;
  31234. shader: string;
  31235. };
  31236. }
  31237. declare module "babylonjs/Shaders/default.fragment" {
  31238. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  31239. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31240. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  31241. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31242. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31243. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31244. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  31245. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  31246. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  31247. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  31248. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  31249. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  31250. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  31251. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  31252. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  31253. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31254. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  31255. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  31256. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  31257. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  31258. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  31259. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  31260. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  31261. /** @hidden */
  31262. export var defaultPixelShader: {
  31263. name: string;
  31264. shader: string;
  31265. };
  31266. }
  31267. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  31268. /** @hidden */
  31269. export var defaultVertexDeclaration: {
  31270. name: string;
  31271. shader: string;
  31272. };
  31273. }
  31274. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  31275. /** @hidden */
  31276. export var bumpVertexDeclaration: {
  31277. name: string;
  31278. shader: string;
  31279. };
  31280. }
  31281. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  31282. /** @hidden */
  31283. export var bumpVertex: {
  31284. name: string;
  31285. shader: string;
  31286. };
  31287. }
  31288. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  31289. /** @hidden */
  31290. export var fogVertex: {
  31291. name: string;
  31292. shader: string;
  31293. };
  31294. }
  31295. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  31296. /** @hidden */
  31297. export var shadowsVertex: {
  31298. name: string;
  31299. shader: string;
  31300. };
  31301. }
  31302. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  31303. /** @hidden */
  31304. export var pointCloudVertex: {
  31305. name: string;
  31306. shader: string;
  31307. };
  31308. }
  31309. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  31310. /** @hidden */
  31311. export var logDepthVertex: {
  31312. name: string;
  31313. shader: string;
  31314. };
  31315. }
  31316. declare module "babylonjs/Shaders/default.vertex" {
  31317. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  31318. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31319. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31320. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  31321. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  31322. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  31323. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  31324. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  31325. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31326. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31327. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  31328. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  31329. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31330. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  31331. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  31332. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  31333. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  31334. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  31335. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  31336. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  31337. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  31338. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  31339. /** @hidden */
  31340. export var defaultVertexShader: {
  31341. name: string;
  31342. shader: string;
  31343. };
  31344. }
  31345. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  31346. import { Nullable } from "babylonjs/types";
  31347. import { Scene } from "babylonjs/scene";
  31348. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31349. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31350. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31351. /**
  31352. * @hidden
  31353. */
  31354. export interface IMaterialDetailMapDefines {
  31355. DETAIL: boolean;
  31356. DETAILDIRECTUV: number;
  31357. DETAIL_NORMALBLENDMETHOD: number;
  31358. /** @hidden */
  31359. _areTexturesDirty: boolean;
  31360. }
  31361. /**
  31362. * Define the code related to the detail map parameters of a material
  31363. *
  31364. * Inspired from:
  31365. * 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
  31366. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  31367. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  31368. */
  31369. export class DetailMapConfiguration {
  31370. private _texture;
  31371. /**
  31372. * The detail texture of the material.
  31373. */
  31374. texture: Nullable<BaseTexture>;
  31375. /**
  31376. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  31377. * Bigger values mean stronger blending
  31378. */
  31379. diffuseBlendLevel: number;
  31380. /**
  31381. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  31382. * Bigger values mean stronger blending. Only used with PBR materials
  31383. */
  31384. roughnessBlendLevel: number;
  31385. /**
  31386. * Defines how strong the bump effect from the detail map is
  31387. * Bigger values mean stronger effect
  31388. */
  31389. bumpLevel: number;
  31390. private _normalBlendMethod;
  31391. /**
  31392. * The method used to blend the bump and detail normals together
  31393. */
  31394. normalBlendMethod: number;
  31395. private _isEnabled;
  31396. /**
  31397. * Enable or disable the detail map on this material
  31398. */
  31399. isEnabled: boolean;
  31400. /** @hidden */
  31401. private _internalMarkAllSubMeshesAsTexturesDirty;
  31402. /** @hidden */
  31403. _markAllSubMeshesAsTexturesDirty(): void;
  31404. /**
  31405. * Instantiate a new detail map
  31406. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  31407. */
  31408. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  31409. /**
  31410. * Gets whether the submesh is ready to be used or not.
  31411. * @param defines the list of "defines" to update.
  31412. * @param scene defines the scene the material belongs to.
  31413. * @returns - boolean indicating that the submesh is ready or not.
  31414. */
  31415. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  31416. /**
  31417. * Update the defines for detail map usage
  31418. * @param defines the list of "defines" to update.
  31419. * @param scene defines the scene the material belongs to.
  31420. */
  31421. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  31422. /**
  31423. * Binds the material data.
  31424. * @param uniformBuffer defines the Uniform buffer to fill in.
  31425. * @param scene defines the scene the material belongs to.
  31426. * @param isFrozen defines whether the material is frozen or not.
  31427. */
  31428. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  31429. /**
  31430. * Checks to see if a texture is used in the material.
  31431. * @param texture - Base texture to use.
  31432. * @returns - Boolean specifying if a texture is used in the material.
  31433. */
  31434. hasTexture(texture: BaseTexture): boolean;
  31435. /**
  31436. * Returns an array of the actively used textures.
  31437. * @param activeTextures Array of BaseTextures
  31438. */
  31439. getActiveTextures(activeTextures: BaseTexture[]): void;
  31440. /**
  31441. * Returns the animatable textures.
  31442. * @param animatables Array of animatable textures.
  31443. */
  31444. getAnimatables(animatables: IAnimatable[]): void;
  31445. /**
  31446. * Disposes the resources of the material.
  31447. * @param forceDisposeTextures - Forces the disposal of all textures.
  31448. */
  31449. dispose(forceDisposeTextures?: boolean): void;
  31450. /**
  31451. * Get the current class name useful for serialization or dynamic coding.
  31452. * @returns "DetailMap"
  31453. */
  31454. getClassName(): string;
  31455. /**
  31456. * Add the required uniforms to the current list.
  31457. * @param uniforms defines the current uniform list.
  31458. */
  31459. static AddUniforms(uniforms: string[]): void;
  31460. /**
  31461. * Add the required samplers to the current list.
  31462. * @param samplers defines the current sampler list.
  31463. */
  31464. static AddSamplers(samplers: string[]): void;
  31465. /**
  31466. * Add the required uniforms to the current buffer.
  31467. * @param uniformBuffer defines the current uniform buffer.
  31468. */
  31469. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  31470. /**
  31471. * Makes a duplicate of the current instance into another one.
  31472. * @param detailMap define the instance where to copy the info
  31473. */
  31474. copyTo(detailMap: DetailMapConfiguration): void;
  31475. /**
  31476. * Serializes this detail map instance
  31477. * @returns - An object with the serialized instance.
  31478. */
  31479. serialize(): any;
  31480. /**
  31481. * Parses a detail map setting from a serialized object.
  31482. * @param source - Serialized object.
  31483. * @param scene Defines the scene we are parsing for
  31484. * @param rootUrl Defines the rootUrl to load from
  31485. */
  31486. parse(source: any, scene: Scene, rootUrl: string): void;
  31487. }
  31488. }
  31489. declare module "babylonjs/Materials/standardMaterial" {
  31490. import { SmartArray } from "babylonjs/Misc/smartArray";
  31491. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31492. import { Nullable } from "babylonjs/types";
  31493. import { Scene } from "babylonjs/scene";
  31494. import { Matrix } from "babylonjs/Maths/math.vector";
  31495. import { Color3 } from "babylonjs/Maths/math.color";
  31496. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31497. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31498. import { Mesh } from "babylonjs/Meshes/mesh";
  31499. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  31500. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  31501. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  31502. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31503. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  31504. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31505. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31506. import "babylonjs/Shaders/default.fragment";
  31507. import "babylonjs/Shaders/default.vertex";
  31508. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  31509. /** @hidden */
  31510. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  31511. MAINUV1: boolean;
  31512. MAINUV2: boolean;
  31513. DIFFUSE: boolean;
  31514. DIFFUSEDIRECTUV: number;
  31515. DETAIL: boolean;
  31516. DETAILDIRECTUV: number;
  31517. DETAIL_NORMALBLENDMETHOD: number;
  31518. AMBIENT: boolean;
  31519. AMBIENTDIRECTUV: number;
  31520. OPACITY: boolean;
  31521. OPACITYDIRECTUV: number;
  31522. OPACITYRGB: boolean;
  31523. REFLECTION: boolean;
  31524. EMISSIVE: boolean;
  31525. EMISSIVEDIRECTUV: number;
  31526. SPECULAR: boolean;
  31527. SPECULARDIRECTUV: number;
  31528. BUMP: boolean;
  31529. BUMPDIRECTUV: number;
  31530. PARALLAX: boolean;
  31531. PARALLAXOCCLUSION: boolean;
  31532. SPECULAROVERALPHA: boolean;
  31533. CLIPPLANE: boolean;
  31534. CLIPPLANE2: boolean;
  31535. CLIPPLANE3: boolean;
  31536. CLIPPLANE4: boolean;
  31537. CLIPPLANE5: boolean;
  31538. CLIPPLANE6: boolean;
  31539. ALPHATEST: boolean;
  31540. DEPTHPREPASS: boolean;
  31541. ALPHAFROMDIFFUSE: boolean;
  31542. POINTSIZE: boolean;
  31543. FOG: boolean;
  31544. SPECULARTERM: boolean;
  31545. DIFFUSEFRESNEL: boolean;
  31546. OPACITYFRESNEL: boolean;
  31547. REFLECTIONFRESNEL: boolean;
  31548. REFRACTIONFRESNEL: boolean;
  31549. EMISSIVEFRESNEL: boolean;
  31550. FRESNEL: boolean;
  31551. NORMAL: boolean;
  31552. UV1: boolean;
  31553. UV2: boolean;
  31554. VERTEXCOLOR: boolean;
  31555. VERTEXALPHA: boolean;
  31556. NUM_BONE_INFLUENCERS: number;
  31557. BonesPerMesh: number;
  31558. BONETEXTURE: boolean;
  31559. INSTANCES: boolean;
  31560. THIN_INSTANCES: boolean;
  31561. GLOSSINESS: boolean;
  31562. ROUGHNESS: boolean;
  31563. EMISSIVEASILLUMINATION: boolean;
  31564. LINKEMISSIVEWITHDIFFUSE: boolean;
  31565. REFLECTIONFRESNELFROMSPECULAR: boolean;
  31566. LIGHTMAP: boolean;
  31567. LIGHTMAPDIRECTUV: number;
  31568. OBJECTSPACE_NORMALMAP: boolean;
  31569. USELIGHTMAPASSHADOWMAP: boolean;
  31570. REFLECTIONMAP_3D: boolean;
  31571. REFLECTIONMAP_SPHERICAL: boolean;
  31572. REFLECTIONMAP_PLANAR: boolean;
  31573. REFLECTIONMAP_CUBIC: boolean;
  31574. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  31575. REFLECTIONMAP_PROJECTION: boolean;
  31576. REFLECTIONMAP_SKYBOX: boolean;
  31577. REFLECTIONMAP_EXPLICIT: boolean;
  31578. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  31579. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  31580. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  31581. INVERTCUBICMAP: boolean;
  31582. LOGARITHMICDEPTH: boolean;
  31583. REFRACTION: boolean;
  31584. REFRACTIONMAP_3D: boolean;
  31585. REFLECTIONOVERALPHA: boolean;
  31586. TWOSIDEDLIGHTING: boolean;
  31587. SHADOWFLOAT: boolean;
  31588. MORPHTARGETS: boolean;
  31589. MORPHTARGETS_NORMAL: boolean;
  31590. MORPHTARGETS_TANGENT: boolean;
  31591. MORPHTARGETS_UV: boolean;
  31592. NUM_MORPH_INFLUENCERS: number;
  31593. NONUNIFORMSCALING: boolean;
  31594. PREMULTIPLYALPHA: boolean;
  31595. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  31596. ALPHABLEND: boolean;
  31597. PREPASS: boolean;
  31598. SCENE_MRT_COUNT: number;
  31599. RGBDLIGHTMAP: boolean;
  31600. RGBDREFLECTION: boolean;
  31601. RGBDREFRACTION: boolean;
  31602. IMAGEPROCESSING: boolean;
  31603. VIGNETTE: boolean;
  31604. VIGNETTEBLENDMODEMULTIPLY: boolean;
  31605. VIGNETTEBLENDMODEOPAQUE: boolean;
  31606. TONEMAPPING: boolean;
  31607. TONEMAPPING_ACES: boolean;
  31608. CONTRAST: boolean;
  31609. COLORCURVES: boolean;
  31610. COLORGRADING: boolean;
  31611. COLORGRADING3D: boolean;
  31612. SAMPLER3DGREENDEPTH: boolean;
  31613. SAMPLER3DBGRMAP: boolean;
  31614. IMAGEPROCESSINGPOSTPROCESS: boolean;
  31615. MULTIVIEW: boolean;
  31616. /**
  31617. * If the reflection texture on this material is in linear color space
  31618. * @hidden
  31619. */
  31620. IS_REFLECTION_LINEAR: boolean;
  31621. /**
  31622. * If the refraction texture on this material is in linear color space
  31623. * @hidden
  31624. */
  31625. IS_REFRACTION_LINEAR: boolean;
  31626. EXPOSURE: boolean;
  31627. constructor();
  31628. setReflectionMode(modeToEnable: string): void;
  31629. }
  31630. /**
  31631. * This is the default material used in Babylon. It is the best trade off between quality
  31632. * and performances.
  31633. * @see https://doc.babylonjs.com/babylon101/materials
  31634. */
  31635. export class StandardMaterial extends PushMaterial {
  31636. private _diffuseTexture;
  31637. /**
  31638. * The basic texture of the material as viewed under a light.
  31639. */
  31640. diffuseTexture: Nullable<BaseTexture>;
  31641. private _ambientTexture;
  31642. /**
  31643. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  31644. */
  31645. ambientTexture: Nullable<BaseTexture>;
  31646. private _opacityTexture;
  31647. /**
  31648. * Define the transparency of the material from a texture.
  31649. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  31650. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  31651. */
  31652. opacityTexture: Nullable<BaseTexture>;
  31653. private _reflectionTexture;
  31654. /**
  31655. * Define the texture used to display the reflection.
  31656. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31657. */
  31658. reflectionTexture: Nullable<BaseTexture>;
  31659. private _emissiveTexture;
  31660. /**
  31661. * Define texture of the material as if self lit.
  31662. * This will be mixed in the final result even in the absence of light.
  31663. */
  31664. emissiveTexture: Nullable<BaseTexture>;
  31665. private _specularTexture;
  31666. /**
  31667. * Define how the color and intensity of the highlight given by the light in the material.
  31668. */
  31669. specularTexture: Nullable<BaseTexture>;
  31670. private _bumpTexture;
  31671. /**
  31672. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  31673. * 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.
  31674. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  31675. */
  31676. bumpTexture: Nullable<BaseTexture>;
  31677. private _lightmapTexture;
  31678. /**
  31679. * Complex lighting can be computationally expensive to compute at runtime.
  31680. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  31681. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  31682. */
  31683. lightmapTexture: Nullable<BaseTexture>;
  31684. private _refractionTexture;
  31685. /**
  31686. * Define the texture used to display the refraction.
  31687. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31688. */
  31689. refractionTexture: Nullable<BaseTexture>;
  31690. /**
  31691. * The color of the material lit by the environmental background lighting.
  31692. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  31693. */
  31694. ambientColor: Color3;
  31695. /**
  31696. * The basic color of the material as viewed under a light.
  31697. */
  31698. diffuseColor: Color3;
  31699. /**
  31700. * Define how the color and intensity of the highlight given by the light in the material.
  31701. */
  31702. specularColor: Color3;
  31703. /**
  31704. * Define the color of the material as if self lit.
  31705. * This will be mixed in the final result even in the absence of light.
  31706. */
  31707. emissiveColor: Color3;
  31708. /**
  31709. * Defines how sharp are the highlights in the material.
  31710. * The bigger the value the sharper giving a more glossy feeling to the result.
  31711. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  31712. */
  31713. specularPower: number;
  31714. private _useAlphaFromDiffuseTexture;
  31715. /**
  31716. * Does the transparency come from the diffuse texture alpha channel.
  31717. */
  31718. useAlphaFromDiffuseTexture: boolean;
  31719. private _useEmissiveAsIllumination;
  31720. /**
  31721. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  31722. */
  31723. useEmissiveAsIllumination: boolean;
  31724. private _linkEmissiveWithDiffuse;
  31725. /**
  31726. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  31727. * the emissive level when the final color is close to one.
  31728. */
  31729. linkEmissiveWithDiffuse: boolean;
  31730. private _useSpecularOverAlpha;
  31731. /**
  31732. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  31733. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31734. */
  31735. useSpecularOverAlpha: boolean;
  31736. private _useReflectionOverAlpha;
  31737. /**
  31738. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31739. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31740. */
  31741. useReflectionOverAlpha: boolean;
  31742. private _disableLighting;
  31743. /**
  31744. * Does lights from the scene impacts this material.
  31745. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  31746. */
  31747. disableLighting: boolean;
  31748. private _useObjectSpaceNormalMap;
  31749. /**
  31750. * Allows using an object space normal map (instead of tangent space).
  31751. */
  31752. useObjectSpaceNormalMap: boolean;
  31753. private _useParallax;
  31754. /**
  31755. * Is parallax enabled or not.
  31756. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31757. */
  31758. useParallax: boolean;
  31759. private _useParallaxOcclusion;
  31760. /**
  31761. * Is parallax occlusion enabled or not.
  31762. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  31763. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31764. */
  31765. useParallaxOcclusion: boolean;
  31766. /**
  31767. * 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.
  31768. */
  31769. parallaxScaleBias: number;
  31770. private _roughness;
  31771. /**
  31772. * Helps to define how blurry the reflections should appears in the material.
  31773. */
  31774. roughness: number;
  31775. /**
  31776. * In case of refraction, define the value of the index of refraction.
  31777. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31778. */
  31779. indexOfRefraction: number;
  31780. /**
  31781. * Invert the refraction texture alongside the y axis.
  31782. * It can be useful with procedural textures or probe for instance.
  31783. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31784. */
  31785. invertRefractionY: boolean;
  31786. /**
  31787. * Defines the alpha limits in alpha test mode.
  31788. */
  31789. alphaCutOff: number;
  31790. private _useLightmapAsShadowmap;
  31791. /**
  31792. * In case of light mapping, define whether the map contains light or shadow informations.
  31793. */
  31794. useLightmapAsShadowmap: boolean;
  31795. private _diffuseFresnelParameters;
  31796. /**
  31797. * Define the diffuse fresnel parameters of the material.
  31798. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31799. */
  31800. diffuseFresnelParameters: FresnelParameters;
  31801. private _opacityFresnelParameters;
  31802. /**
  31803. * Define the opacity fresnel parameters of the material.
  31804. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31805. */
  31806. opacityFresnelParameters: FresnelParameters;
  31807. private _reflectionFresnelParameters;
  31808. /**
  31809. * Define the reflection fresnel parameters of the material.
  31810. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31811. */
  31812. reflectionFresnelParameters: FresnelParameters;
  31813. private _refractionFresnelParameters;
  31814. /**
  31815. * Define the refraction fresnel parameters of the material.
  31816. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31817. */
  31818. refractionFresnelParameters: FresnelParameters;
  31819. private _emissiveFresnelParameters;
  31820. /**
  31821. * Define the emissive fresnel parameters of the material.
  31822. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31823. */
  31824. emissiveFresnelParameters: FresnelParameters;
  31825. private _useReflectionFresnelFromSpecular;
  31826. /**
  31827. * If true automatically deducts the fresnels values from the material specularity.
  31828. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31829. */
  31830. useReflectionFresnelFromSpecular: boolean;
  31831. private _useGlossinessFromSpecularMapAlpha;
  31832. /**
  31833. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  31834. */
  31835. useGlossinessFromSpecularMapAlpha: boolean;
  31836. private _maxSimultaneousLights;
  31837. /**
  31838. * Defines the maximum number of lights that can be used in the material
  31839. */
  31840. maxSimultaneousLights: number;
  31841. private _invertNormalMapX;
  31842. /**
  31843. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  31844. */
  31845. invertNormalMapX: boolean;
  31846. private _invertNormalMapY;
  31847. /**
  31848. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  31849. */
  31850. invertNormalMapY: boolean;
  31851. private _twoSidedLighting;
  31852. /**
  31853. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31854. */
  31855. twoSidedLighting: boolean;
  31856. /**
  31857. * Default configuration related to image processing available in the standard Material.
  31858. */
  31859. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31860. /**
  31861. * Gets the image processing configuration used either in this material.
  31862. */
  31863. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  31864. /**
  31865. * Sets the Default image processing configuration used either in the this material.
  31866. *
  31867. * If sets to null, the scene one is in use.
  31868. */
  31869. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  31870. /**
  31871. * Keep track of the image processing observer to allow dispose and replace.
  31872. */
  31873. private _imageProcessingObserver;
  31874. /**
  31875. * Attaches a new image processing configuration to the Standard Material.
  31876. * @param configuration
  31877. */
  31878. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31879. /**
  31880. * Gets wether the color curves effect is enabled.
  31881. */
  31882. get cameraColorCurvesEnabled(): boolean;
  31883. /**
  31884. * Sets wether the color curves effect is enabled.
  31885. */
  31886. set cameraColorCurvesEnabled(value: boolean);
  31887. /**
  31888. * Gets wether the color grading effect is enabled.
  31889. */
  31890. get cameraColorGradingEnabled(): boolean;
  31891. /**
  31892. * Gets wether the color grading effect is enabled.
  31893. */
  31894. set cameraColorGradingEnabled(value: boolean);
  31895. /**
  31896. * Gets wether tonemapping is enabled or not.
  31897. */
  31898. get cameraToneMappingEnabled(): boolean;
  31899. /**
  31900. * Sets wether tonemapping is enabled or not
  31901. */
  31902. set cameraToneMappingEnabled(value: boolean);
  31903. /**
  31904. * The camera exposure used on this material.
  31905. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31906. * This corresponds to a photographic exposure.
  31907. */
  31908. get cameraExposure(): number;
  31909. /**
  31910. * The camera exposure used on this material.
  31911. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31912. * This corresponds to a photographic exposure.
  31913. */
  31914. set cameraExposure(value: number);
  31915. /**
  31916. * Gets The camera contrast used on this material.
  31917. */
  31918. get cameraContrast(): number;
  31919. /**
  31920. * Sets The camera contrast used on this material.
  31921. */
  31922. set cameraContrast(value: number);
  31923. /**
  31924. * Gets the Color Grading 2D Lookup Texture.
  31925. */
  31926. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  31927. /**
  31928. * Sets the Color Grading 2D Lookup Texture.
  31929. */
  31930. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  31931. /**
  31932. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31933. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31934. * 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;
  31935. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31936. */
  31937. get cameraColorCurves(): Nullable<ColorCurves>;
  31938. /**
  31939. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31940. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31941. * 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;
  31942. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31943. */
  31944. set cameraColorCurves(value: Nullable<ColorCurves>);
  31945. /**
  31946. * Can this material render to several textures at once
  31947. */
  31948. get canRenderToMRT(): boolean;
  31949. /**
  31950. * Defines the detail map parameters for the material.
  31951. */
  31952. readonly detailMap: DetailMapConfiguration;
  31953. protected _renderTargets: SmartArray<RenderTargetTexture>;
  31954. protected _worldViewProjectionMatrix: Matrix;
  31955. protected _globalAmbientColor: Color3;
  31956. protected _useLogarithmicDepth: boolean;
  31957. protected _rebuildInParallel: boolean;
  31958. /**
  31959. * Instantiates a new standard material.
  31960. * This is the default material used in Babylon. It is the best trade off between quality
  31961. * and performances.
  31962. * @see https://doc.babylonjs.com/babylon101/materials
  31963. * @param name Define the name of the material in the scene
  31964. * @param scene Define the scene the material belong to
  31965. */
  31966. constructor(name: string, scene: Scene);
  31967. /**
  31968. * Gets a boolean indicating that current material needs to register RTT
  31969. */
  31970. get hasRenderTargetTextures(): boolean;
  31971. /**
  31972. * Gets the current class name of the material e.g. "StandardMaterial"
  31973. * Mainly use in serialization.
  31974. * @returns the class name
  31975. */
  31976. getClassName(): string;
  31977. /**
  31978. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  31979. * You can try switching to logarithmic depth.
  31980. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  31981. */
  31982. get useLogarithmicDepth(): boolean;
  31983. set useLogarithmicDepth(value: boolean);
  31984. /**
  31985. * Specifies if the material will require alpha blending
  31986. * @returns a boolean specifying if alpha blending is needed
  31987. */
  31988. needAlphaBlending(): boolean;
  31989. /**
  31990. * Specifies if this material should be rendered in alpha test mode
  31991. * @returns a boolean specifying if an alpha test is needed.
  31992. */
  31993. needAlphaTesting(): boolean;
  31994. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  31995. /**
  31996. * Get the texture used for alpha test purpose.
  31997. * @returns the diffuse texture in case of the standard material.
  31998. */
  31999. getAlphaTestTexture(): Nullable<BaseTexture>;
  32000. /**
  32001. * Get if the submesh is ready to be used and all its information available.
  32002. * Child classes can use it to update shaders
  32003. * @param mesh defines the mesh to check
  32004. * @param subMesh defines which submesh to check
  32005. * @param useInstances specifies that instances should be used
  32006. * @returns a boolean indicating that the submesh is ready or not
  32007. */
  32008. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32009. /**
  32010. * Builds the material UBO layouts.
  32011. * Used internally during the effect preparation.
  32012. */
  32013. buildUniformLayout(): void;
  32014. /**
  32015. * Unbinds the material from the mesh
  32016. */
  32017. unbind(): void;
  32018. /**
  32019. * Binds the submesh to this material by preparing the effect and shader to draw
  32020. * @param world defines the world transformation matrix
  32021. * @param mesh defines the mesh containing the submesh
  32022. * @param subMesh defines the submesh to bind the material to
  32023. */
  32024. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32025. /**
  32026. * Get the list of animatables in the material.
  32027. * @returns the list of animatables object used in the material
  32028. */
  32029. getAnimatables(): IAnimatable[];
  32030. /**
  32031. * Gets the active textures from the material
  32032. * @returns an array of textures
  32033. */
  32034. getActiveTextures(): BaseTexture[];
  32035. /**
  32036. * Specifies if the material uses a texture
  32037. * @param texture defines the texture to check against the material
  32038. * @returns a boolean specifying if the material uses the texture
  32039. */
  32040. hasTexture(texture: BaseTexture): boolean;
  32041. /**
  32042. * Disposes the material
  32043. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  32044. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  32045. */
  32046. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32047. /**
  32048. * Makes a duplicate of the material, and gives it a new name
  32049. * @param name defines the new name for the duplicated material
  32050. * @returns the cloned material
  32051. */
  32052. clone(name: string): StandardMaterial;
  32053. /**
  32054. * Serializes this material in a JSON representation
  32055. * @returns the serialized material object
  32056. */
  32057. serialize(): any;
  32058. /**
  32059. * Creates a standard material from parsed material data
  32060. * @param source defines the JSON representation of the material
  32061. * @param scene defines the hosting scene
  32062. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  32063. * @returns a new standard material
  32064. */
  32065. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  32066. /**
  32067. * Are diffuse textures enabled in the application.
  32068. */
  32069. static get DiffuseTextureEnabled(): boolean;
  32070. static set DiffuseTextureEnabled(value: boolean);
  32071. /**
  32072. * Are detail textures enabled in the application.
  32073. */
  32074. static get DetailTextureEnabled(): boolean;
  32075. static set DetailTextureEnabled(value: boolean);
  32076. /**
  32077. * Are ambient textures enabled in the application.
  32078. */
  32079. static get AmbientTextureEnabled(): boolean;
  32080. static set AmbientTextureEnabled(value: boolean);
  32081. /**
  32082. * Are opacity textures enabled in the application.
  32083. */
  32084. static get OpacityTextureEnabled(): boolean;
  32085. static set OpacityTextureEnabled(value: boolean);
  32086. /**
  32087. * Are reflection textures enabled in the application.
  32088. */
  32089. static get ReflectionTextureEnabled(): boolean;
  32090. static set ReflectionTextureEnabled(value: boolean);
  32091. /**
  32092. * Are emissive textures enabled in the application.
  32093. */
  32094. static get EmissiveTextureEnabled(): boolean;
  32095. static set EmissiveTextureEnabled(value: boolean);
  32096. /**
  32097. * Are specular textures enabled in the application.
  32098. */
  32099. static get SpecularTextureEnabled(): boolean;
  32100. static set SpecularTextureEnabled(value: boolean);
  32101. /**
  32102. * Are bump textures enabled in the application.
  32103. */
  32104. static get BumpTextureEnabled(): boolean;
  32105. static set BumpTextureEnabled(value: boolean);
  32106. /**
  32107. * Are lightmap textures enabled in the application.
  32108. */
  32109. static get LightmapTextureEnabled(): boolean;
  32110. static set LightmapTextureEnabled(value: boolean);
  32111. /**
  32112. * Are refraction textures enabled in the application.
  32113. */
  32114. static get RefractionTextureEnabled(): boolean;
  32115. static set RefractionTextureEnabled(value: boolean);
  32116. /**
  32117. * Are color grading textures enabled in the application.
  32118. */
  32119. static get ColorGradingTextureEnabled(): boolean;
  32120. static set ColorGradingTextureEnabled(value: boolean);
  32121. /**
  32122. * Are fresnels enabled in the application.
  32123. */
  32124. static get FresnelEnabled(): boolean;
  32125. static set FresnelEnabled(value: boolean);
  32126. }
  32127. }
  32128. declare module "babylonjs/Particles/solidParticleSystem" {
  32129. import { Nullable } from "babylonjs/types";
  32130. import { Mesh } from "babylonjs/Meshes/mesh";
  32131. import { Scene, IDisposable } from "babylonjs/scene";
  32132. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  32133. import { Material } from "babylonjs/Materials/material";
  32134. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32135. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32136. /**
  32137. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32138. *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.
  32139. * The SPS is also a particle system. It provides some methods to manage the particles.
  32140. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32141. *
  32142. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  32143. */
  32144. export class SolidParticleSystem implements IDisposable {
  32145. /**
  32146. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32147. * Example : var p = SPS.particles[i];
  32148. */
  32149. particles: SolidParticle[];
  32150. /**
  32151. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32152. */
  32153. nbParticles: number;
  32154. /**
  32155. * If the particles must ever face the camera (default false). Useful for planar particles.
  32156. */
  32157. billboard: boolean;
  32158. /**
  32159. * Recompute normals when adding a shape
  32160. */
  32161. recomputeNormals: boolean;
  32162. /**
  32163. * This a counter ofr your own usage. It's not set by any SPS functions.
  32164. */
  32165. counter: number;
  32166. /**
  32167. * The SPS name. This name is also given to the underlying mesh.
  32168. */
  32169. name: string;
  32170. /**
  32171. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32172. */
  32173. mesh: Mesh;
  32174. /**
  32175. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32176. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  32177. */
  32178. vars: any;
  32179. /**
  32180. * This array is populated when the SPS is set as 'pickable'.
  32181. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32182. * Each element of this array is an object `{idx: int, faceId: int}`.
  32183. * `idx` is the picked particle index in the `SPS.particles` array
  32184. * `faceId` is the picked face index counted within this particle.
  32185. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  32186. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  32187. * Use the method SPS.pickedParticle(pickingInfo) instead.
  32188. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32189. */
  32190. pickedParticles: {
  32191. idx: number;
  32192. faceId: number;
  32193. }[];
  32194. /**
  32195. * This array is populated when the SPS is set as 'pickable'
  32196. * Each key of this array is a submesh index.
  32197. * Each element of this array is a second array defined like this :
  32198. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  32199. * Each element of this second array is an object `{idx: int, faceId: int}`.
  32200. * `idx` is the picked particle index in the `SPS.particles` array
  32201. * `faceId` is the picked face index counted within this particle.
  32202. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  32203. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32204. */
  32205. pickedBySubMesh: {
  32206. idx: number;
  32207. faceId: number;
  32208. }[][];
  32209. /**
  32210. * This array is populated when `enableDepthSort` is set to true.
  32211. * Each element of this array is an instance of the class DepthSortedParticle.
  32212. */
  32213. depthSortedParticles: DepthSortedParticle[];
  32214. /**
  32215. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32216. * @hidden
  32217. */
  32218. _bSphereOnly: boolean;
  32219. /**
  32220. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32221. * @hidden
  32222. */
  32223. _bSphereRadiusFactor: number;
  32224. private _scene;
  32225. private _positions;
  32226. private _indices;
  32227. private _normals;
  32228. private _colors;
  32229. private _uvs;
  32230. private _indices32;
  32231. private _positions32;
  32232. private _normals32;
  32233. private _fixedNormal32;
  32234. private _colors32;
  32235. private _uvs32;
  32236. private _index;
  32237. private _updatable;
  32238. private _pickable;
  32239. private _isVisibilityBoxLocked;
  32240. private _alwaysVisible;
  32241. private _depthSort;
  32242. private _expandable;
  32243. private _shapeCounter;
  32244. private _copy;
  32245. private _color;
  32246. private _computeParticleColor;
  32247. private _computeParticleTexture;
  32248. private _computeParticleRotation;
  32249. private _computeParticleVertex;
  32250. private _computeBoundingBox;
  32251. private _depthSortParticles;
  32252. private _camera;
  32253. private _mustUnrotateFixedNormals;
  32254. private _particlesIntersect;
  32255. private _needs32Bits;
  32256. private _isNotBuilt;
  32257. private _lastParticleId;
  32258. private _idxOfId;
  32259. private _multimaterialEnabled;
  32260. private _useModelMaterial;
  32261. private _indicesByMaterial;
  32262. private _materialIndexes;
  32263. private _depthSortFunction;
  32264. private _materialSortFunction;
  32265. private _materials;
  32266. private _multimaterial;
  32267. private _materialIndexesById;
  32268. private _defaultMaterial;
  32269. private _autoUpdateSubMeshes;
  32270. private _tmpVertex;
  32271. /**
  32272. * Creates a SPS (Solid Particle System) object.
  32273. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32274. * @param scene (Scene) is the scene in which the SPS is added.
  32275. * @param options defines the options of the sps e.g.
  32276. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32277. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32278. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32279. * * 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.
  32280. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  32281. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  32282. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32283. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32284. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32285. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32286. */
  32287. constructor(name: string, scene: Scene, options?: {
  32288. updatable?: boolean;
  32289. isPickable?: boolean;
  32290. enableDepthSort?: boolean;
  32291. particleIntersection?: boolean;
  32292. boundingSphereOnly?: boolean;
  32293. bSphereRadiusFactor?: number;
  32294. expandable?: boolean;
  32295. useModelMaterial?: boolean;
  32296. enableMultiMaterial?: boolean;
  32297. });
  32298. /**
  32299. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32300. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32301. * @returns the created mesh
  32302. */
  32303. buildMesh(): Mesh;
  32304. /**
  32305. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32306. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32307. * Thus the particles generated from `digest()` have their property `position` set yet.
  32308. * @param mesh ( Mesh ) is the mesh to be digested
  32309. * @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
  32310. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32311. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32312. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32313. * @returns the current SPS
  32314. */
  32315. digest(mesh: Mesh, options?: {
  32316. facetNb?: number;
  32317. number?: number;
  32318. delta?: number;
  32319. storage?: [];
  32320. }): SolidParticleSystem;
  32321. /**
  32322. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  32323. * @hidden
  32324. */
  32325. private _unrotateFixedNormals;
  32326. /**
  32327. * Resets the temporary working copy particle
  32328. * @hidden
  32329. */
  32330. private _resetCopy;
  32331. /**
  32332. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  32333. * @param p the current index in the positions array to be updated
  32334. * @param ind the current index in the indices array
  32335. * @param shape a Vector3 array, the shape geometry
  32336. * @param positions the positions array to be updated
  32337. * @param meshInd the shape indices array
  32338. * @param indices the indices array to be updated
  32339. * @param meshUV the shape uv array
  32340. * @param uvs the uv array to be updated
  32341. * @param meshCol the shape color array
  32342. * @param colors the color array to be updated
  32343. * @param meshNor the shape normals array
  32344. * @param normals the normals array to be updated
  32345. * @param idx the particle index
  32346. * @param idxInShape the particle index in its shape
  32347. * @param options the addShape() method passed options
  32348. * @model the particle model
  32349. * @hidden
  32350. */
  32351. private _meshBuilder;
  32352. /**
  32353. * Returns a shape Vector3 array from positions float array
  32354. * @param positions float array
  32355. * @returns a vector3 array
  32356. * @hidden
  32357. */
  32358. private _posToShape;
  32359. /**
  32360. * Returns a shapeUV array from a float uvs (array deep copy)
  32361. * @param uvs as a float array
  32362. * @returns a shapeUV array
  32363. * @hidden
  32364. */
  32365. private _uvsToShapeUV;
  32366. /**
  32367. * Adds a new particle object in the particles array
  32368. * @param idx particle index in particles array
  32369. * @param id particle id
  32370. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  32371. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  32372. * @param model particle ModelShape object
  32373. * @param shapeId model shape identifier
  32374. * @param idxInShape index of the particle in the current model
  32375. * @param bInfo model bounding info object
  32376. * @param storage target storage array, if any
  32377. * @hidden
  32378. */
  32379. private _addParticle;
  32380. /**
  32381. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32382. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  32383. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32384. * @param nb (positive integer) the number of particles to be created from this model
  32385. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32386. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32387. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32388. * @returns the number of shapes in the system
  32389. */
  32390. addShape(mesh: Mesh, nb: number, options?: {
  32391. positionFunction?: any;
  32392. vertexFunction?: any;
  32393. storage?: [];
  32394. }): number;
  32395. /**
  32396. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  32397. * @hidden
  32398. */
  32399. private _rebuildParticle;
  32400. /**
  32401. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32402. * @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.
  32403. * @returns the SPS.
  32404. */
  32405. rebuildMesh(reset?: boolean): SolidParticleSystem;
  32406. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  32407. * Returns an array with the removed particles.
  32408. * 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.
  32409. * The SPS can't be empty so at least one particle needs to remain in place.
  32410. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  32411. * @param start index of the first particle to remove
  32412. * @param end index of the last particle to remove (included)
  32413. * @returns an array populated with the removed particles
  32414. */
  32415. removeParticles(start: number, end: number): SolidParticle[];
  32416. /**
  32417. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  32418. * @param solidParticleArray an array populated with Solid Particles objects
  32419. * @returns the SPS
  32420. */
  32421. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  32422. /**
  32423. * Creates a new particle and modifies the SPS mesh geometry :
  32424. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  32425. * - calls _addParticle() to populate the particle array
  32426. * factorized code from addShape() and insertParticlesFromArray()
  32427. * @param idx particle index in the particles array
  32428. * @param i particle index in its shape
  32429. * @param modelShape particle ModelShape object
  32430. * @param shape shape vertex array
  32431. * @param meshInd shape indices array
  32432. * @param meshUV shape uv array
  32433. * @param meshCol shape color array
  32434. * @param meshNor shape normals array
  32435. * @param bbInfo shape bounding info
  32436. * @param storage target particle storage
  32437. * @options addShape() passed options
  32438. * @hidden
  32439. */
  32440. private _insertNewParticle;
  32441. /**
  32442. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32443. * This method calls `updateParticle()` for each particle of the SPS.
  32444. * For an animated SPS, it is usually called within the render loop.
  32445. * 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.
  32446. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32447. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32448. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32449. * @returns the SPS.
  32450. */
  32451. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32452. /**
  32453. * Disposes the SPS.
  32454. */
  32455. dispose(): void;
  32456. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  32457. * idx is the particle index in the SPS
  32458. * faceId is the picked face index counted within this particle.
  32459. * Returns null if the pickInfo can't identify a picked particle.
  32460. * @param pickingInfo (PickingInfo object)
  32461. * @returns {idx: number, faceId: number} or null
  32462. */
  32463. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  32464. idx: number;
  32465. faceId: number;
  32466. }>;
  32467. /**
  32468. * Returns a SolidParticle object from its identifier : particle.id
  32469. * @param id (integer) the particle Id
  32470. * @returns the searched particle or null if not found in the SPS.
  32471. */
  32472. getParticleById(id: number): Nullable<SolidParticle>;
  32473. /**
  32474. * Returns a new array populated with the particles having the passed shapeId.
  32475. * @param shapeId (integer) the shape identifier
  32476. * @returns a new solid particle array
  32477. */
  32478. getParticlesByShapeId(shapeId: number): SolidParticle[];
  32479. /**
  32480. * Populates the passed array "ref" with the particles having the passed shapeId.
  32481. * @param shapeId the shape identifier
  32482. * @returns the SPS
  32483. * @param ref
  32484. */
  32485. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  32486. /**
  32487. * Computes the required SubMeshes according the materials assigned to the particles.
  32488. * @returns the solid particle system.
  32489. * Does nothing if called before the SPS mesh is built.
  32490. */
  32491. computeSubMeshes(): SolidParticleSystem;
  32492. /**
  32493. * Sorts the solid particles by material when MultiMaterial is enabled.
  32494. * Updates the indices32 array.
  32495. * Updates the indicesByMaterial array.
  32496. * Updates the mesh indices array.
  32497. * @returns the SPS
  32498. * @hidden
  32499. */
  32500. private _sortParticlesByMaterial;
  32501. /**
  32502. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  32503. * @hidden
  32504. */
  32505. private _setMaterialIndexesById;
  32506. /**
  32507. * Returns an array with unique values of Materials from the passed array
  32508. * @param array the material array to be checked and filtered
  32509. * @hidden
  32510. */
  32511. private _filterUniqueMaterialId;
  32512. /**
  32513. * Sets a new Standard Material as _defaultMaterial if not already set.
  32514. * @hidden
  32515. */
  32516. private _setDefaultMaterial;
  32517. /**
  32518. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32519. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32520. * @returns the SPS.
  32521. */
  32522. refreshVisibleSize(): SolidParticleSystem;
  32523. /**
  32524. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32525. * @param size the size (float) of the visibility box
  32526. * note : this doesn't lock the SPS mesh bounding box.
  32527. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32528. */
  32529. setVisibilityBox(size: number): void;
  32530. /**
  32531. * Gets whether the SPS as always visible or not
  32532. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32533. */
  32534. get isAlwaysVisible(): boolean;
  32535. /**
  32536. * Sets the SPS as always visible or not
  32537. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32538. */
  32539. set isAlwaysVisible(val: boolean);
  32540. /**
  32541. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32542. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32543. */
  32544. set isVisibilityBoxLocked(val: boolean);
  32545. /**
  32546. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32547. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32548. */
  32549. get isVisibilityBoxLocked(): boolean;
  32550. /**
  32551. * Tells to `setParticles()` to compute the particle rotations or not.
  32552. * Default value : true. The SPS is faster when it's set to false.
  32553. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32554. */
  32555. set computeParticleRotation(val: boolean);
  32556. /**
  32557. * Tells to `setParticles()` to compute the particle colors or not.
  32558. * Default value : true. The SPS is faster when it's set to false.
  32559. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32560. */
  32561. set computeParticleColor(val: boolean);
  32562. set computeParticleTexture(val: boolean);
  32563. /**
  32564. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32565. * Default value : false. The SPS is faster when it's set to false.
  32566. * Note : the particle custom vertex positions aren't stored values.
  32567. */
  32568. set computeParticleVertex(val: boolean);
  32569. /**
  32570. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32571. */
  32572. set computeBoundingBox(val: boolean);
  32573. /**
  32574. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32575. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32576. * Default : `true`
  32577. */
  32578. set depthSortParticles(val: boolean);
  32579. /**
  32580. * Gets if `setParticles()` computes the particle rotations or not.
  32581. * Default value : true. The SPS is faster when it's set to false.
  32582. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32583. */
  32584. get computeParticleRotation(): boolean;
  32585. /**
  32586. * Gets if `setParticles()` computes the particle colors or not.
  32587. * Default value : true. The SPS is faster when it's set to false.
  32588. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32589. */
  32590. get computeParticleColor(): boolean;
  32591. /**
  32592. * Gets if `setParticles()` computes the particle textures or not.
  32593. * Default value : true. The SPS is faster when it's set to false.
  32594. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32595. */
  32596. get computeParticleTexture(): boolean;
  32597. /**
  32598. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32599. * Default value : false. The SPS is faster when it's set to false.
  32600. * Note : the particle custom vertex positions aren't stored values.
  32601. */
  32602. get computeParticleVertex(): boolean;
  32603. /**
  32604. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32605. */
  32606. get computeBoundingBox(): boolean;
  32607. /**
  32608. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32609. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32610. * Default : `true`
  32611. */
  32612. get depthSortParticles(): boolean;
  32613. /**
  32614. * Gets if the SPS is created as expandable at construction time.
  32615. * Default : `false`
  32616. */
  32617. get expandable(): boolean;
  32618. /**
  32619. * Gets if the SPS supports the Multi Materials
  32620. */
  32621. get multimaterialEnabled(): boolean;
  32622. /**
  32623. * Gets if the SPS uses the model materials for its own multimaterial.
  32624. */
  32625. get useModelMaterial(): boolean;
  32626. /**
  32627. * The SPS used material array.
  32628. */
  32629. get materials(): Material[];
  32630. /**
  32631. * Sets the SPS MultiMaterial from the passed materials.
  32632. * Note : the passed array is internally copied and not used then by reference.
  32633. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  32634. */
  32635. setMultiMaterial(materials: Material[]): void;
  32636. /**
  32637. * The SPS computed multimaterial object
  32638. */
  32639. get multimaterial(): MultiMaterial;
  32640. set multimaterial(mm: MultiMaterial);
  32641. /**
  32642. * If the subMeshes must be updated on the next call to setParticles()
  32643. */
  32644. get autoUpdateSubMeshes(): boolean;
  32645. set autoUpdateSubMeshes(val: boolean);
  32646. /**
  32647. * This function does nothing. It may be overwritten to set all the particle first values.
  32648. * The SPS doesn't call this function, you may have to call it by your own.
  32649. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32650. */
  32651. initParticles(): void;
  32652. /**
  32653. * This function does nothing. It may be overwritten to recycle a particle.
  32654. * The SPS doesn't call this function, you may have to call it by your own.
  32655. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32656. * @param particle The particle to recycle
  32657. * @returns the recycled particle
  32658. */
  32659. recycleParticle(particle: SolidParticle): SolidParticle;
  32660. /**
  32661. * Updates a particle : this function should be overwritten by the user.
  32662. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32663. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32664. * @example : just set a particle position or velocity and recycle conditions
  32665. * @param particle The particle to update
  32666. * @returns the updated particle
  32667. */
  32668. updateParticle(particle: SolidParticle): SolidParticle;
  32669. /**
  32670. * Updates a vertex of a particle : it can be overwritten by the user.
  32671. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32672. * @param particle the current particle
  32673. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  32674. * @param pt the index of the current vertex in the particle shape
  32675. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  32676. * @example : just set a vertex particle position or color
  32677. * @returns the sps
  32678. */
  32679. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  32680. /**
  32681. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32682. * This does nothing and may be overwritten by the user.
  32683. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32684. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32685. * @param update the boolean update value actually passed to setParticles()
  32686. */
  32687. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32688. /**
  32689. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32690. * This will be passed three parameters.
  32691. * This does nothing and may be overwritten by the user.
  32692. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32693. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32694. * @param update the boolean update value actually passed to setParticles()
  32695. */
  32696. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32697. }
  32698. }
  32699. declare module "babylonjs/Particles/solidParticle" {
  32700. import { Nullable } from "babylonjs/types";
  32701. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  32702. import { Color4 } from "babylonjs/Maths/math.color";
  32703. import { Mesh } from "babylonjs/Meshes/mesh";
  32704. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32705. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  32706. import { Plane } from "babylonjs/Maths/math.plane";
  32707. import { Material } from "babylonjs/Materials/material";
  32708. /**
  32709. * Represents one particle of a solid particle system.
  32710. */
  32711. export class SolidParticle {
  32712. /**
  32713. * particle global index
  32714. */
  32715. idx: number;
  32716. /**
  32717. * particle identifier
  32718. */
  32719. id: number;
  32720. /**
  32721. * The color of the particle
  32722. */
  32723. color: Nullable<Color4>;
  32724. /**
  32725. * The world space position of the particle.
  32726. */
  32727. position: Vector3;
  32728. /**
  32729. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32730. */
  32731. rotation: Vector3;
  32732. /**
  32733. * The world space rotation quaternion of the particle.
  32734. */
  32735. rotationQuaternion: Nullable<Quaternion>;
  32736. /**
  32737. * The scaling of the particle.
  32738. */
  32739. scaling: Vector3;
  32740. /**
  32741. * The uvs of the particle.
  32742. */
  32743. uvs: Vector4;
  32744. /**
  32745. * The current speed of the particle.
  32746. */
  32747. velocity: Vector3;
  32748. /**
  32749. * The pivot point in the particle local space.
  32750. */
  32751. pivot: Vector3;
  32752. /**
  32753. * Must the particle be translated from its pivot point in its local space ?
  32754. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32755. * Default : false
  32756. */
  32757. translateFromPivot: boolean;
  32758. /**
  32759. * Is the particle active or not ?
  32760. */
  32761. alive: boolean;
  32762. /**
  32763. * Is the particle visible or not ?
  32764. */
  32765. isVisible: boolean;
  32766. /**
  32767. * Index of this particle in the global "positions" array (Internal use)
  32768. * @hidden
  32769. */
  32770. _pos: number;
  32771. /**
  32772. * @hidden Index of this particle in the global "indices" array (Internal use)
  32773. */
  32774. _ind: number;
  32775. /**
  32776. * @hidden ModelShape of this particle (Internal use)
  32777. */
  32778. _model: ModelShape;
  32779. /**
  32780. * ModelShape id of this particle
  32781. */
  32782. shapeId: number;
  32783. /**
  32784. * Index of the particle in its shape id
  32785. */
  32786. idxInShape: number;
  32787. /**
  32788. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32789. */
  32790. _modelBoundingInfo: BoundingInfo;
  32791. /**
  32792. * @hidden Particle BoundingInfo object (Internal use)
  32793. */
  32794. _boundingInfo: BoundingInfo;
  32795. /**
  32796. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32797. */
  32798. _sps: SolidParticleSystem;
  32799. /**
  32800. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32801. */
  32802. _stillInvisible: boolean;
  32803. /**
  32804. * @hidden Last computed particle rotation matrix
  32805. */
  32806. _rotationMatrix: number[];
  32807. /**
  32808. * Parent particle Id, if any.
  32809. * Default null.
  32810. */
  32811. parentId: Nullable<number>;
  32812. /**
  32813. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  32814. */
  32815. materialIndex: Nullable<number>;
  32816. /**
  32817. * Custom object or properties.
  32818. */
  32819. props: Nullable<any>;
  32820. /**
  32821. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  32822. * The possible values are :
  32823. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32824. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32825. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32826. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32827. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32828. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  32829. * */
  32830. cullingStrategy: number;
  32831. /**
  32832. * @hidden Internal global position in the SPS.
  32833. */
  32834. _globalPosition: Vector3;
  32835. /**
  32836. * Creates a Solid Particle object.
  32837. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32838. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  32839. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  32840. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32841. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32842. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32843. * @param shapeId (integer) is the model shape identifier in the SPS.
  32844. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32845. * @param sps defines the sps it is associated to
  32846. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32847. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  32848. */
  32849. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  32850. /**
  32851. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  32852. * @param target the particle target
  32853. * @returns the current particle
  32854. */
  32855. copyToRef(target: SolidParticle): SolidParticle;
  32856. /**
  32857. * Legacy support, changed scale to scaling
  32858. */
  32859. get scale(): Vector3;
  32860. /**
  32861. * Legacy support, changed scale to scaling
  32862. */
  32863. set scale(scale: Vector3);
  32864. /**
  32865. * Legacy support, changed quaternion to rotationQuaternion
  32866. */
  32867. get quaternion(): Nullable<Quaternion>;
  32868. /**
  32869. * Legacy support, changed quaternion to rotationQuaternion
  32870. */
  32871. set quaternion(q: Nullable<Quaternion>);
  32872. /**
  32873. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32874. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32875. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32876. * @returns true if it intersects
  32877. */
  32878. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32879. /**
  32880. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  32881. * A particle is in the frustum if its bounding box intersects the frustum
  32882. * @param frustumPlanes defines the frustum to test
  32883. * @returns true if the particle is in the frustum planes
  32884. */
  32885. isInFrustum(frustumPlanes: Plane[]): boolean;
  32886. /**
  32887. * get the rotation matrix of the particle
  32888. * @hidden
  32889. */
  32890. getRotationMatrix(m: Matrix): void;
  32891. }
  32892. /**
  32893. * Represents the shape of the model used by one particle of a solid particle system.
  32894. * SPS internal tool, don't use it manually.
  32895. */
  32896. export class ModelShape {
  32897. /**
  32898. * The shape id
  32899. * @hidden
  32900. */
  32901. shapeID: number;
  32902. /**
  32903. * flat array of model positions (internal use)
  32904. * @hidden
  32905. */
  32906. _shape: Vector3[];
  32907. /**
  32908. * flat array of model UVs (internal use)
  32909. * @hidden
  32910. */
  32911. _shapeUV: number[];
  32912. /**
  32913. * color array of the model
  32914. * @hidden
  32915. */
  32916. _shapeColors: number[];
  32917. /**
  32918. * indices array of the model
  32919. * @hidden
  32920. */
  32921. _indices: number[];
  32922. /**
  32923. * normals array of the model
  32924. * @hidden
  32925. */
  32926. _normals: number[];
  32927. /**
  32928. * length of the shape in the model indices array (internal use)
  32929. * @hidden
  32930. */
  32931. _indicesLength: number;
  32932. /**
  32933. * Custom position function (internal use)
  32934. * @hidden
  32935. */
  32936. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32937. /**
  32938. * Custom vertex function (internal use)
  32939. * @hidden
  32940. */
  32941. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  32942. /**
  32943. * Model material (internal use)
  32944. * @hidden
  32945. */
  32946. _material: Nullable<Material>;
  32947. /**
  32948. * 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.
  32949. * SPS internal tool, don't use it manually.
  32950. * @hidden
  32951. */
  32952. 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>);
  32953. }
  32954. /**
  32955. * Represents a Depth Sorted Particle in the solid particle system.
  32956. * @hidden
  32957. */
  32958. export class DepthSortedParticle {
  32959. /**
  32960. * Particle index
  32961. */
  32962. idx: number;
  32963. /**
  32964. * Index of the particle in the "indices" array
  32965. */
  32966. ind: number;
  32967. /**
  32968. * Length of the particle shape in the "indices" array
  32969. */
  32970. indicesLength: number;
  32971. /**
  32972. * Squared distance from the particle to the camera
  32973. */
  32974. sqDistance: number;
  32975. /**
  32976. * Material index when used with MultiMaterials
  32977. */
  32978. materialIndex: number;
  32979. /**
  32980. * Creates a new sorted particle
  32981. * @param materialIndex
  32982. */
  32983. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  32984. }
  32985. /**
  32986. * Represents a solid particle vertex
  32987. */
  32988. export class SolidParticleVertex {
  32989. /**
  32990. * Vertex position
  32991. */
  32992. position: Vector3;
  32993. /**
  32994. * Vertex color
  32995. */
  32996. color: Color4;
  32997. /**
  32998. * Vertex UV
  32999. */
  33000. uv: Vector2;
  33001. /**
  33002. * Creates a new solid particle vertex
  33003. */
  33004. constructor();
  33005. /** Vertex x coordinate */
  33006. get x(): number;
  33007. set x(val: number);
  33008. /** Vertex y coordinate */
  33009. get y(): number;
  33010. set y(val: number);
  33011. /** Vertex z coordinate */
  33012. get z(): number;
  33013. set z(val: number);
  33014. }
  33015. }
  33016. declare module "babylonjs/Collisions/meshCollisionData" {
  33017. import { Collider } from "babylonjs/Collisions/collider";
  33018. import { Vector3 } from "babylonjs/Maths/math.vector";
  33019. import { Nullable } from "babylonjs/types";
  33020. import { Observer } from "babylonjs/Misc/observable";
  33021. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33022. /**
  33023. * @hidden
  33024. */
  33025. export class _MeshCollisionData {
  33026. _checkCollisions: boolean;
  33027. _collisionMask: number;
  33028. _collisionGroup: number;
  33029. _surroundingMeshes: Nullable<AbstractMesh[]>;
  33030. _collider: Nullable<Collider>;
  33031. _oldPositionForCollisions: Vector3;
  33032. _diffPositionForCollisions: Vector3;
  33033. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  33034. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  33035. _collisionResponse: boolean;
  33036. }
  33037. }
  33038. declare module "babylonjs/Meshes/abstractMesh" {
  33039. import { Observable } from "babylonjs/Misc/observable";
  33040. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  33041. import { Camera } from "babylonjs/Cameras/camera";
  33042. import { Scene, IDisposable } from "babylonjs/scene";
  33043. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  33044. import { Node } from "babylonjs/node";
  33045. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33046. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33047. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33048. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33049. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33050. import { Material } from "babylonjs/Materials/material";
  33051. import { Light } from "babylonjs/Lights/light";
  33052. import { Skeleton } from "babylonjs/Bones/skeleton";
  33053. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  33054. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  33055. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33056. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  33057. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33058. import { Plane } from "babylonjs/Maths/math.plane";
  33059. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33060. import { Ray } from "babylonjs/Culling/ray";
  33061. import { Collider } from "babylonjs/Collisions/collider";
  33062. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33063. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  33064. /** @hidden */
  33065. class _FacetDataStorage {
  33066. facetPositions: Vector3[];
  33067. facetNormals: Vector3[];
  33068. facetPartitioning: number[][];
  33069. facetNb: number;
  33070. partitioningSubdivisions: number;
  33071. partitioningBBoxRatio: number;
  33072. facetDataEnabled: boolean;
  33073. facetParameters: any;
  33074. bbSize: Vector3;
  33075. subDiv: {
  33076. max: number;
  33077. X: number;
  33078. Y: number;
  33079. Z: number;
  33080. };
  33081. facetDepthSort: boolean;
  33082. facetDepthSortEnabled: boolean;
  33083. depthSortedIndices: IndicesArray;
  33084. depthSortedFacets: {
  33085. ind: number;
  33086. sqDistance: number;
  33087. }[];
  33088. facetDepthSortFunction: (f1: {
  33089. ind: number;
  33090. sqDistance: number;
  33091. }, f2: {
  33092. ind: number;
  33093. sqDistance: number;
  33094. }) => number;
  33095. facetDepthSortFrom: Vector3;
  33096. facetDepthSortOrigin: Vector3;
  33097. invertedMatrix: Matrix;
  33098. }
  33099. /**
  33100. * @hidden
  33101. **/
  33102. class _InternalAbstractMeshDataInfo {
  33103. _hasVertexAlpha: boolean;
  33104. _useVertexColors: boolean;
  33105. _numBoneInfluencers: number;
  33106. _applyFog: boolean;
  33107. _receiveShadows: boolean;
  33108. _facetData: _FacetDataStorage;
  33109. _visibility: number;
  33110. _skeleton: Nullable<Skeleton>;
  33111. _layerMask: number;
  33112. _computeBonesUsingShaders: boolean;
  33113. _isActive: boolean;
  33114. _onlyForInstances: boolean;
  33115. _isActiveIntermediate: boolean;
  33116. _onlyForInstancesIntermediate: boolean;
  33117. _actAsRegularMesh: boolean;
  33118. }
  33119. /**
  33120. * Class used to store all common mesh properties
  33121. */
  33122. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  33123. /** No occlusion */
  33124. static OCCLUSION_TYPE_NONE: number;
  33125. /** Occlusion set to optimisitic */
  33126. static OCCLUSION_TYPE_OPTIMISTIC: number;
  33127. /** Occlusion set to strict */
  33128. static OCCLUSION_TYPE_STRICT: number;
  33129. /** Use an accurante occlusion algorithm */
  33130. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  33131. /** Use a conservative occlusion algorithm */
  33132. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  33133. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  33134. * Test order :
  33135. * Is the bounding sphere outside the frustum ?
  33136. * If not, are the bounding box vertices outside the frustum ?
  33137. * It not, then the cullable object is in the frustum.
  33138. */
  33139. static readonly CULLINGSTRATEGY_STANDARD: number;
  33140. /** Culling strategy : Bounding Sphere Only.
  33141. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  33142. * It's also less accurate than the standard because some not visible objects can still be selected.
  33143. * Test : is the bounding sphere outside the frustum ?
  33144. * If not, then the cullable object is in the frustum.
  33145. */
  33146. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  33147. /** Culling strategy : Optimistic Inclusion.
  33148. * This in an inclusion test first, then the standard exclusion test.
  33149. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  33150. * 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.
  33151. * Anyway, it's as accurate as the standard strategy.
  33152. * Test :
  33153. * Is the cullable object bounding sphere center in the frustum ?
  33154. * If not, apply the default culling strategy.
  33155. */
  33156. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  33157. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  33158. * This in an inclusion test first, then the bounding sphere only exclusion test.
  33159. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  33160. * 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.
  33161. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  33162. * Test :
  33163. * Is the cullable object bounding sphere center in the frustum ?
  33164. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  33165. */
  33166. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  33167. /**
  33168. * No billboard
  33169. */
  33170. static get BILLBOARDMODE_NONE(): number;
  33171. /** Billboard on X axis */
  33172. static get BILLBOARDMODE_X(): number;
  33173. /** Billboard on Y axis */
  33174. static get BILLBOARDMODE_Y(): number;
  33175. /** Billboard on Z axis */
  33176. static get BILLBOARDMODE_Z(): number;
  33177. /** Billboard on all axes */
  33178. static get BILLBOARDMODE_ALL(): number;
  33179. /** Billboard on using position instead of orientation */
  33180. static get BILLBOARDMODE_USE_POSITION(): number;
  33181. /** @hidden */
  33182. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  33183. /**
  33184. * The culling strategy to use to check whether the mesh must be rendered or not.
  33185. * This value can be changed at any time and will be used on the next render mesh selection.
  33186. * The possible values are :
  33187. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  33188. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  33189. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  33190. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  33191. * Please read each static variable documentation to get details about the culling process.
  33192. * */
  33193. cullingStrategy: number;
  33194. /**
  33195. * Gets the number of facets in the mesh
  33196. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33197. */
  33198. get facetNb(): number;
  33199. /**
  33200. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  33201. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33202. */
  33203. get partitioningSubdivisions(): number;
  33204. set partitioningSubdivisions(nb: number);
  33205. /**
  33206. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  33207. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  33208. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33209. */
  33210. get partitioningBBoxRatio(): number;
  33211. set partitioningBBoxRatio(ratio: number);
  33212. /**
  33213. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  33214. * Works only for updatable meshes.
  33215. * Doesn't work with multi-materials
  33216. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33217. */
  33218. get mustDepthSortFacets(): boolean;
  33219. set mustDepthSortFacets(sort: boolean);
  33220. /**
  33221. * The location (Vector3) where the facet depth sort must be computed from.
  33222. * By default, the active camera position.
  33223. * Used only when facet depth sort is enabled
  33224. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33225. */
  33226. get facetDepthSortFrom(): Vector3;
  33227. set facetDepthSortFrom(location: Vector3);
  33228. /**
  33229. * gets a boolean indicating if facetData is enabled
  33230. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33231. */
  33232. get isFacetDataEnabled(): boolean;
  33233. /** @hidden */
  33234. _updateNonUniformScalingState(value: boolean): boolean;
  33235. /**
  33236. * An event triggered when this mesh collides with another one
  33237. */
  33238. onCollideObservable: Observable<AbstractMesh>;
  33239. /** Set a function to call when this mesh collides with another one */
  33240. set onCollide(callback: () => void);
  33241. /**
  33242. * An event triggered when the collision's position changes
  33243. */
  33244. onCollisionPositionChangeObservable: Observable<Vector3>;
  33245. /** Set a function to call when the collision's position changes */
  33246. set onCollisionPositionChange(callback: () => void);
  33247. /**
  33248. * An event triggered when material is changed
  33249. */
  33250. onMaterialChangedObservable: Observable<AbstractMesh>;
  33251. /**
  33252. * Gets or sets the orientation for POV movement & rotation
  33253. */
  33254. definedFacingForward: boolean;
  33255. /** @hidden */
  33256. _occlusionQuery: Nullable<WebGLQuery>;
  33257. /** @hidden */
  33258. _renderingGroup: Nullable<RenderingGroup>;
  33259. /**
  33260. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33261. */
  33262. get visibility(): number;
  33263. /**
  33264. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33265. */
  33266. set visibility(value: number);
  33267. /** Gets or sets the alpha index used to sort transparent meshes
  33268. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  33269. */
  33270. alphaIndex: number;
  33271. /**
  33272. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  33273. */
  33274. isVisible: boolean;
  33275. /**
  33276. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  33277. */
  33278. isPickable: boolean;
  33279. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  33280. showSubMeshesBoundingBox: boolean;
  33281. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  33282. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  33283. */
  33284. isBlocker: boolean;
  33285. /**
  33286. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  33287. */
  33288. enablePointerMoveEvents: boolean;
  33289. private _renderingGroupId;
  33290. /**
  33291. * Specifies the rendering group id for this mesh (0 by default)
  33292. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  33293. */
  33294. get renderingGroupId(): number;
  33295. set renderingGroupId(value: number);
  33296. private _material;
  33297. /** Gets or sets current material */
  33298. get material(): Nullable<Material>;
  33299. set material(value: Nullable<Material>);
  33300. /**
  33301. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  33302. * @see https://doc.babylonjs.com/babylon101/shadows
  33303. */
  33304. get receiveShadows(): boolean;
  33305. set receiveShadows(value: boolean);
  33306. /** Defines color to use when rendering outline */
  33307. outlineColor: Color3;
  33308. /** Define width to use when rendering outline */
  33309. outlineWidth: number;
  33310. /** Defines color to use when rendering overlay */
  33311. overlayColor: Color3;
  33312. /** Defines alpha to use when rendering overlay */
  33313. overlayAlpha: number;
  33314. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  33315. get hasVertexAlpha(): boolean;
  33316. set hasVertexAlpha(value: boolean);
  33317. /** 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) */
  33318. get useVertexColors(): boolean;
  33319. set useVertexColors(value: boolean);
  33320. /**
  33321. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  33322. */
  33323. get computeBonesUsingShaders(): boolean;
  33324. set computeBonesUsingShaders(value: boolean);
  33325. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  33326. get numBoneInfluencers(): number;
  33327. set numBoneInfluencers(value: number);
  33328. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  33329. get applyFog(): boolean;
  33330. set applyFog(value: boolean);
  33331. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  33332. useOctreeForRenderingSelection: boolean;
  33333. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  33334. useOctreeForPicking: boolean;
  33335. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  33336. useOctreeForCollisions: boolean;
  33337. /**
  33338. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  33339. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  33340. */
  33341. get layerMask(): number;
  33342. set layerMask(value: number);
  33343. /**
  33344. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  33345. */
  33346. alwaysSelectAsActiveMesh: boolean;
  33347. /**
  33348. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  33349. */
  33350. doNotSyncBoundingInfo: boolean;
  33351. /**
  33352. * Gets or sets the current action manager
  33353. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33354. */
  33355. actionManager: Nullable<AbstractActionManager>;
  33356. private _meshCollisionData;
  33357. /**
  33358. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  33359. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33360. */
  33361. ellipsoid: Vector3;
  33362. /**
  33363. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  33364. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33365. */
  33366. ellipsoidOffset: Vector3;
  33367. /**
  33368. * Gets or sets a collision mask used to mask collisions (default is -1).
  33369. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33370. */
  33371. get collisionMask(): number;
  33372. set collisionMask(mask: number);
  33373. /**
  33374. * Gets or sets a collision response flag (default is true).
  33375. * when collisionResponse is false, events are still triggered but colliding entity has no response
  33376. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  33377. * to respond to the collision.
  33378. */
  33379. get collisionResponse(): boolean;
  33380. set collisionResponse(response: boolean);
  33381. /**
  33382. * Gets or sets the current collision group mask (-1 by default).
  33383. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33384. */
  33385. get collisionGroup(): number;
  33386. set collisionGroup(mask: number);
  33387. /**
  33388. * Gets or sets current surrounding meshes (null by default).
  33389. *
  33390. * By default collision detection is tested against every mesh in the scene.
  33391. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  33392. * meshes will be tested for the collision.
  33393. *
  33394. * Note: if set to an empty array no collision will happen when this mesh is moved.
  33395. */
  33396. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  33397. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  33398. /**
  33399. * Defines edge width used when edgesRenderer is enabled
  33400. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33401. */
  33402. edgesWidth: number;
  33403. /**
  33404. * Defines edge color used when edgesRenderer is enabled
  33405. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33406. */
  33407. edgesColor: Color4;
  33408. /** @hidden */
  33409. _edgesRenderer: Nullable<IEdgesRenderer>;
  33410. /** @hidden */
  33411. _masterMesh: Nullable<AbstractMesh>;
  33412. /** @hidden */
  33413. _boundingInfo: Nullable<BoundingInfo>;
  33414. /** @hidden */
  33415. _renderId: number;
  33416. /**
  33417. * Gets or sets the list of subMeshes
  33418. * @see https://doc.babylonjs.com/how_to/multi_materials
  33419. */
  33420. subMeshes: SubMesh[];
  33421. /** @hidden */
  33422. _intersectionsInProgress: AbstractMesh[];
  33423. /** @hidden */
  33424. _unIndexed: boolean;
  33425. /** @hidden */
  33426. _lightSources: Light[];
  33427. /** Gets the list of lights affecting that mesh */
  33428. get lightSources(): Light[];
  33429. /** @hidden */
  33430. get _positions(): Nullable<Vector3[]>;
  33431. /** @hidden */
  33432. _waitingData: {
  33433. lods: Nullable<any>;
  33434. actions: Nullable<any>;
  33435. freezeWorldMatrix: Nullable<boolean>;
  33436. };
  33437. /** @hidden */
  33438. _bonesTransformMatrices: Nullable<Float32Array>;
  33439. /** @hidden */
  33440. _transformMatrixTexture: Nullable<RawTexture>;
  33441. /**
  33442. * Gets or sets a skeleton to apply skining transformations
  33443. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33444. */
  33445. set skeleton(value: Nullable<Skeleton>);
  33446. get skeleton(): Nullable<Skeleton>;
  33447. /**
  33448. * An event triggered when the mesh is rebuilt.
  33449. */
  33450. onRebuildObservable: Observable<AbstractMesh>;
  33451. /**
  33452. * Creates a new AbstractMesh
  33453. * @param name defines the name of the mesh
  33454. * @param scene defines the hosting scene
  33455. */
  33456. constructor(name: string, scene?: Nullable<Scene>);
  33457. /**
  33458. * Returns the string "AbstractMesh"
  33459. * @returns "AbstractMesh"
  33460. */
  33461. getClassName(): string;
  33462. /**
  33463. * Gets a string representation of the current mesh
  33464. * @param fullDetails defines a boolean indicating if full details must be included
  33465. * @returns a string representation of the current mesh
  33466. */
  33467. toString(fullDetails?: boolean): string;
  33468. /**
  33469. * @hidden
  33470. */
  33471. protected _getEffectiveParent(): Nullable<Node>;
  33472. /** @hidden */
  33473. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33474. /** @hidden */
  33475. _rebuild(): void;
  33476. /** @hidden */
  33477. _resyncLightSources(): void;
  33478. /** @hidden */
  33479. _resyncLightSource(light: Light): void;
  33480. /** @hidden */
  33481. _unBindEffect(): void;
  33482. /** @hidden */
  33483. _removeLightSource(light: Light, dispose: boolean): void;
  33484. private _markSubMeshesAsDirty;
  33485. /** @hidden */
  33486. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  33487. /** @hidden */
  33488. _markSubMeshesAsAttributesDirty(): void;
  33489. /** @hidden */
  33490. _markSubMeshesAsMiscDirty(): void;
  33491. /**
  33492. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  33493. */
  33494. get scaling(): Vector3;
  33495. set scaling(newScaling: Vector3);
  33496. /**
  33497. * Returns true if the mesh is blocked. Implemented by child classes
  33498. */
  33499. get isBlocked(): boolean;
  33500. /**
  33501. * Returns the mesh itself by default. Implemented by child classes
  33502. * @param camera defines the camera to use to pick the right LOD level
  33503. * @returns the currentAbstractMesh
  33504. */
  33505. getLOD(camera: Camera): Nullable<AbstractMesh>;
  33506. /**
  33507. * Returns 0 by default. Implemented by child classes
  33508. * @returns an integer
  33509. */
  33510. getTotalVertices(): number;
  33511. /**
  33512. * Returns a positive integer : the total number of indices in this mesh geometry.
  33513. * @returns the numner of indices or zero if the mesh has no geometry.
  33514. */
  33515. getTotalIndices(): number;
  33516. /**
  33517. * Returns null by default. Implemented by child classes
  33518. * @returns null
  33519. */
  33520. getIndices(): Nullable<IndicesArray>;
  33521. /**
  33522. * Returns the array of the requested vertex data kind. Implemented by child classes
  33523. * @param kind defines the vertex data kind to use
  33524. * @returns null
  33525. */
  33526. getVerticesData(kind: string): Nullable<FloatArray>;
  33527. /**
  33528. * Sets the vertex data of the mesh geometry for the requested `kind`.
  33529. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  33530. * Note that a new underlying VertexBuffer object is created each call.
  33531. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  33532. * @param kind defines vertex data kind:
  33533. * * VertexBuffer.PositionKind
  33534. * * VertexBuffer.UVKind
  33535. * * VertexBuffer.UV2Kind
  33536. * * VertexBuffer.UV3Kind
  33537. * * VertexBuffer.UV4Kind
  33538. * * VertexBuffer.UV5Kind
  33539. * * VertexBuffer.UV6Kind
  33540. * * VertexBuffer.ColorKind
  33541. * * VertexBuffer.MatricesIndicesKind
  33542. * * VertexBuffer.MatricesIndicesExtraKind
  33543. * * VertexBuffer.MatricesWeightsKind
  33544. * * VertexBuffer.MatricesWeightsExtraKind
  33545. * @param data defines the data source
  33546. * @param updatable defines if the data must be flagged as updatable (or static)
  33547. * @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
  33548. * @returns the current mesh
  33549. */
  33550. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33551. /**
  33552. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  33553. * If the mesh has no geometry, it is simply returned as it is.
  33554. * @param kind defines vertex data kind:
  33555. * * VertexBuffer.PositionKind
  33556. * * VertexBuffer.UVKind
  33557. * * VertexBuffer.UV2Kind
  33558. * * VertexBuffer.UV3Kind
  33559. * * VertexBuffer.UV4Kind
  33560. * * VertexBuffer.UV5Kind
  33561. * * VertexBuffer.UV6Kind
  33562. * * VertexBuffer.ColorKind
  33563. * * VertexBuffer.MatricesIndicesKind
  33564. * * VertexBuffer.MatricesIndicesExtraKind
  33565. * * VertexBuffer.MatricesWeightsKind
  33566. * * VertexBuffer.MatricesWeightsExtraKind
  33567. * @param data defines the data source
  33568. * @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
  33569. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  33570. * @returns the current mesh
  33571. */
  33572. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33573. /**
  33574. * Sets the mesh indices,
  33575. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  33576. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  33577. * @param totalVertices Defines the total number of vertices
  33578. * @returns the current mesh
  33579. */
  33580. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  33581. /**
  33582. * Gets a boolean indicating if specific vertex data is present
  33583. * @param kind defines the vertex data kind to use
  33584. * @returns true is data kind is present
  33585. */
  33586. isVerticesDataPresent(kind: string): boolean;
  33587. /**
  33588. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  33589. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  33590. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  33591. * @returns a BoundingInfo
  33592. */
  33593. getBoundingInfo(): BoundingInfo;
  33594. /**
  33595. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  33596. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  33597. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  33598. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  33599. * @returns the current mesh
  33600. */
  33601. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  33602. /**
  33603. * Overwrite the current bounding info
  33604. * @param boundingInfo defines the new bounding info
  33605. * @returns the current mesh
  33606. */
  33607. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  33608. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  33609. get useBones(): boolean;
  33610. /** @hidden */
  33611. _preActivate(): void;
  33612. /** @hidden */
  33613. _preActivateForIntermediateRendering(renderId: number): void;
  33614. /** @hidden */
  33615. _activate(renderId: number, intermediateRendering: boolean): boolean;
  33616. /** @hidden */
  33617. _postActivate(): void;
  33618. /** @hidden */
  33619. _freeze(): void;
  33620. /** @hidden */
  33621. _unFreeze(): void;
  33622. /**
  33623. * Gets the current world matrix
  33624. * @returns a Matrix
  33625. */
  33626. getWorldMatrix(): Matrix;
  33627. /** @hidden */
  33628. _getWorldMatrixDeterminant(): number;
  33629. /**
  33630. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  33631. */
  33632. get isAnInstance(): boolean;
  33633. /**
  33634. * Gets a boolean indicating if this mesh has instances
  33635. */
  33636. get hasInstances(): boolean;
  33637. /**
  33638. * Gets a boolean indicating if this mesh has thin instances
  33639. */
  33640. get hasThinInstances(): boolean;
  33641. /**
  33642. * Perform relative position change from the point of view of behind the front of the mesh.
  33643. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33644. * Supports definition of mesh facing forward or backward
  33645. * @param amountRight defines the distance on the right axis
  33646. * @param amountUp defines the distance on the up axis
  33647. * @param amountForward defines the distance on the forward axis
  33648. * @returns the current mesh
  33649. */
  33650. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  33651. /**
  33652. * Calculate relative position change from the point of view of behind the front of the mesh.
  33653. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33654. * Supports definition of mesh facing forward or backward
  33655. * @param amountRight defines the distance on the right axis
  33656. * @param amountUp defines the distance on the up axis
  33657. * @param amountForward defines the distance on the forward axis
  33658. * @returns the new displacement vector
  33659. */
  33660. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  33661. /**
  33662. * Perform relative rotation change from the point of view of behind the front of the mesh.
  33663. * Supports definition of mesh facing forward or backward
  33664. * @param flipBack defines the flip
  33665. * @param twirlClockwise defines the twirl
  33666. * @param tiltRight defines the tilt
  33667. * @returns the current mesh
  33668. */
  33669. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  33670. /**
  33671. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  33672. * Supports definition of mesh facing forward or backward.
  33673. * @param flipBack defines the flip
  33674. * @param twirlClockwise defines the twirl
  33675. * @param tiltRight defines the tilt
  33676. * @returns the new rotation vector
  33677. */
  33678. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  33679. /**
  33680. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33681. * This means the mesh underlying bounding box and sphere are recomputed.
  33682. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33683. * @returns the current mesh
  33684. */
  33685. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  33686. /** @hidden */
  33687. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  33688. /** @hidden */
  33689. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  33690. /** @hidden */
  33691. _updateBoundingInfo(): AbstractMesh;
  33692. /** @hidden */
  33693. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  33694. /** @hidden */
  33695. protected _afterComputeWorldMatrix(): void;
  33696. /** @hidden */
  33697. get _effectiveMesh(): AbstractMesh;
  33698. /**
  33699. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33700. * A mesh is in the frustum if its bounding box intersects the frustum
  33701. * @param frustumPlanes defines the frustum to test
  33702. * @returns true if the mesh is in the frustum planes
  33703. */
  33704. isInFrustum(frustumPlanes: Plane[]): boolean;
  33705. /**
  33706. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  33707. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  33708. * @param frustumPlanes defines the frustum to test
  33709. * @returns true if the mesh is completely in the frustum planes
  33710. */
  33711. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  33712. /**
  33713. * True if the mesh intersects another mesh or a SolidParticle object
  33714. * @param mesh defines a target mesh or SolidParticle to test
  33715. * @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)
  33716. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  33717. * @returns true if there is an intersection
  33718. */
  33719. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  33720. /**
  33721. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  33722. * @param point defines the point to test
  33723. * @returns true if there is an intersection
  33724. */
  33725. intersectsPoint(point: Vector3): boolean;
  33726. /**
  33727. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  33728. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33729. */
  33730. get checkCollisions(): boolean;
  33731. set checkCollisions(collisionEnabled: boolean);
  33732. /**
  33733. * Gets Collider object used to compute collisions (not physics)
  33734. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33735. */
  33736. get collider(): Nullable<Collider>;
  33737. /**
  33738. * Move the mesh using collision engine
  33739. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33740. * @param displacement defines the requested displacement vector
  33741. * @returns the current mesh
  33742. */
  33743. moveWithCollisions(displacement: Vector3): AbstractMesh;
  33744. private _onCollisionPositionChange;
  33745. /** @hidden */
  33746. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  33747. /** @hidden */
  33748. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  33749. /** @hidden */
  33750. _checkCollision(collider: Collider): AbstractMesh;
  33751. /** @hidden */
  33752. _generatePointsArray(): boolean;
  33753. /**
  33754. * Checks if the passed Ray intersects with the mesh
  33755. * @param ray defines the ray to use
  33756. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  33757. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33758. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  33759. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  33760. * @returns the picking info
  33761. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  33762. */
  33763. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  33764. /**
  33765. * Clones the current mesh
  33766. * @param name defines the mesh name
  33767. * @param newParent defines the new mesh parent
  33768. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  33769. * @returns the new mesh
  33770. */
  33771. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  33772. /**
  33773. * Disposes all the submeshes of the current meshnp
  33774. * @returns the current mesh
  33775. */
  33776. releaseSubMeshes(): AbstractMesh;
  33777. /**
  33778. * Releases resources associated with this abstract mesh.
  33779. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33780. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33781. */
  33782. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33783. /**
  33784. * Adds the passed mesh as a child to the current mesh
  33785. * @param mesh defines the child mesh
  33786. * @returns the current mesh
  33787. */
  33788. addChild(mesh: AbstractMesh): AbstractMesh;
  33789. /**
  33790. * Removes the passed mesh from the current mesh children list
  33791. * @param mesh defines the child mesh
  33792. * @returns the current mesh
  33793. */
  33794. removeChild(mesh: AbstractMesh): AbstractMesh;
  33795. /** @hidden */
  33796. private _initFacetData;
  33797. /**
  33798. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  33799. * This method can be called within the render loop.
  33800. * 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
  33801. * @returns the current mesh
  33802. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33803. */
  33804. updateFacetData(): AbstractMesh;
  33805. /**
  33806. * Returns the facetLocalNormals array.
  33807. * The normals are expressed in the mesh local spac
  33808. * @returns an array of Vector3
  33809. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33810. */
  33811. getFacetLocalNormals(): Vector3[];
  33812. /**
  33813. * Returns the facetLocalPositions array.
  33814. * The facet positions are expressed in the mesh local space
  33815. * @returns an array of Vector3
  33816. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33817. */
  33818. getFacetLocalPositions(): Vector3[];
  33819. /**
  33820. * Returns the facetLocalPartioning array
  33821. * @returns an array of array of numbers
  33822. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33823. */
  33824. getFacetLocalPartitioning(): number[][];
  33825. /**
  33826. * Returns the i-th facet position in the world system.
  33827. * This method allocates a new Vector3 per call
  33828. * @param i defines the facet index
  33829. * @returns a new Vector3
  33830. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33831. */
  33832. getFacetPosition(i: number): Vector3;
  33833. /**
  33834. * Sets the reference Vector3 with the i-th facet position in the world system
  33835. * @param i defines the facet index
  33836. * @param ref defines the target vector
  33837. * @returns the current mesh
  33838. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33839. */
  33840. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  33841. /**
  33842. * Returns the i-th facet normal in the world system.
  33843. * This method allocates a new Vector3 per call
  33844. * @param i defines the facet index
  33845. * @returns a new Vector3
  33846. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33847. */
  33848. getFacetNormal(i: number): Vector3;
  33849. /**
  33850. * Sets the reference Vector3 with the i-th facet normal in the world system
  33851. * @param i defines the facet index
  33852. * @param ref defines the target vector
  33853. * @returns the current mesh
  33854. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33855. */
  33856. getFacetNormalToRef(i: number, ref: Vector3): this;
  33857. /**
  33858. * 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)
  33859. * @param x defines x coordinate
  33860. * @param y defines y coordinate
  33861. * @param z defines z coordinate
  33862. * @returns the array of facet indexes
  33863. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33864. */
  33865. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  33866. /**
  33867. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  33868. * @param projected sets as the (x,y,z) world projection on the facet
  33869. * @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
  33870. * @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
  33871. * @param x defines x coordinate
  33872. * @param y defines y coordinate
  33873. * @param z defines z coordinate
  33874. * @returns the face index if found (or null instead)
  33875. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33876. */
  33877. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33878. /**
  33879. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  33880. * @param projected sets as the (x,y,z) local projection on the facet
  33881. * @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
  33882. * @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
  33883. * @param x defines x coordinate
  33884. * @param y defines y coordinate
  33885. * @param z defines z coordinate
  33886. * @returns the face index if found (or null instead)
  33887. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33888. */
  33889. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33890. /**
  33891. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  33892. * @returns the parameters
  33893. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33894. */
  33895. getFacetDataParameters(): any;
  33896. /**
  33897. * Disables the feature FacetData and frees the related memory
  33898. * @returns the current mesh
  33899. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33900. */
  33901. disableFacetData(): AbstractMesh;
  33902. /**
  33903. * Updates the AbstractMesh indices array
  33904. * @param indices defines the data source
  33905. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33906. * @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)
  33907. * @returns the current mesh
  33908. */
  33909. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33910. /**
  33911. * Creates new normals data for the mesh
  33912. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  33913. * @returns the current mesh
  33914. */
  33915. createNormals(updatable: boolean): AbstractMesh;
  33916. /**
  33917. * Align the mesh with a normal
  33918. * @param normal defines the normal to use
  33919. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  33920. * @returns the current mesh
  33921. */
  33922. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  33923. /** @hidden */
  33924. _checkOcclusionQuery(): boolean;
  33925. /**
  33926. * Disables the mesh edge rendering mode
  33927. * @returns the currentAbstractMesh
  33928. */
  33929. disableEdgesRendering(): AbstractMesh;
  33930. /**
  33931. * Enables the edge rendering mode on the mesh.
  33932. * This mode makes the mesh edges visible
  33933. * @param epsilon defines the maximal distance between two angles to detect a face
  33934. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  33935. * @returns the currentAbstractMesh
  33936. * @see https://www.babylonjs-playground.com/#19O9TU#0
  33937. */
  33938. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  33939. /**
  33940. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  33941. * @returns an array of particle systems in the scene that use the mesh as an emitter
  33942. */
  33943. getConnectedParticleSystems(): IParticleSystem[];
  33944. }
  33945. }
  33946. declare module "babylonjs/Actions/actionEvent" {
  33947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33948. import { Nullable } from "babylonjs/types";
  33949. import { Sprite } from "babylonjs/Sprites/sprite";
  33950. import { Scene } from "babylonjs/scene";
  33951. import { Vector2 } from "babylonjs/Maths/math.vector";
  33952. /**
  33953. * Interface used to define ActionEvent
  33954. */
  33955. export interface IActionEvent {
  33956. /** The mesh or sprite that triggered the action */
  33957. source: any;
  33958. /** The X mouse cursor position at the time of the event */
  33959. pointerX: number;
  33960. /** The Y mouse cursor position at the time of the event */
  33961. pointerY: number;
  33962. /** The mesh that is currently pointed at (can be null) */
  33963. meshUnderPointer: Nullable<AbstractMesh>;
  33964. /** the original (browser) event that triggered the ActionEvent */
  33965. sourceEvent?: any;
  33966. /** additional data for the event */
  33967. additionalData?: any;
  33968. }
  33969. /**
  33970. * ActionEvent is the event being sent when an action is triggered.
  33971. */
  33972. export class ActionEvent implements IActionEvent {
  33973. /** The mesh or sprite that triggered the action */
  33974. source: any;
  33975. /** The X mouse cursor position at the time of the event */
  33976. pointerX: number;
  33977. /** The Y mouse cursor position at the time of the event */
  33978. pointerY: number;
  33979. /** The mesh that is currently pointed at (can be null) */
  33980. meshUnderPointer: Nullable<AbstractMesh>;
  33981. /** the original (browser) event that triggered the ActionEvent */
  33982. sourceEvent?: any;
  33983. /** additional data for the event */
  33984. additionalData?: any;
  33985. /**
  33986. * Creates a new ActionEvent
  33987. * @param source The mesh or sprite that triggered the action
  33988. * @param pointerX The X mouse cursor position at the time of the event
  33989. * @param pointerY The Y mouse cursor position at the time of the event
  33990. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  33991. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  33992. * @param additionalData additional data for the event
  33993. */
  33994. constructor(
  33995. /** The mesh or sprite that triggered the action */
  33996. source: any,
  33997. /** The X mouse cursor position at the time of the event */
  33998. pointerX: number,
  33999. /** The Y mouse cursor position at the time of the event */
  34000. pointerY: number,
  34001. /** The mesh that is currently pointed at (can be null) */
  34002. meshUnderPointer: Nullable<AbstractMesh>,
  34003. /** the original (browser) event that triggered the ActionEvent */
  34004. sourceEvent?: any,
  34005. /** additional data for the event */
  34006. additionalData?: any);
  34007. /**
  34008. * Helper function to auto-create an ActionEvent from a source mesh.
  34009. * @param source The source mesh that triggered the event
  34010. * @param evt The original (browser) event
  34011. * @param additionalData additional data for the event
  34012. * @returns the new ActionEvent
  34013. */
  34014. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  34015. /**
  34016. * Helper function to auto-create an ActionEvent from a source sprite
  34017. * @param source The source sprite that triggered the event
  34018. * @param scene Scene associated with the sprite
  34019. * @param evt The original (browser) event
  34020. * @param additionalData additional data for the event
  34021. * @returns the new ActionEvent
  34022. */
  34023. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  34024. /**
  34025. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  34026. * @param scene the scene where the event occurred
  34027. * @param evt The original (browser) event
  34028. * @returns the new ActionEvent
  34029. */
  34030. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  34031. /**
  34032. * Helper function to auto-create an ActionEvent from a primitive
  34033. * @param prim defines the target primitive
  34034. * @param pointerPos defines the pointer position
  34035. * @param evt The original (browser) event
  34036. * @param additionalData additional data for the event
  34037. * @returns the new ActionEvent
  34038. */
  34039. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  34040. }
  34041. }
  34042. declare module "babylonjs/Actions/abstractActionManager" {
  34043. import { IDisposable } from "babylonjs/scene";
  34044. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  34045. import { IAction } from "babylonjs/Actions/action";
  34046. import { Nullable } from "babylonjs/types";
  34047. /**
  34048. * Abstract class used to decouple action Manager from scene and meshes.
  34049. * Do not instantiate.
  34050. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  34051. */
  34052. export abstract class AbstractActionManager implements IDisposable {
  34053. /** Gets the list of active triggers */
  34054. static Triggers: {
  34055. [key: string]: number;
  34056. };
  34057. /** Gets the cursor to use when hovering items */
  34058. hoverCursor: string;
  34059. /** Gets the list of actions */
  34060. actions: IAction[];
  34061. /**
  34062. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  34063. */
  34064. isRecursive: boolean;
  34065. /**
  34066. * Releases all associated resources
  34067. */
  34068. abstract dispose(): void;
  34069. /**
  34070. * Does this action manager has pointer triggers
  34071. */
  34072. abstract get hasPointerTriggers(): boolean;
  34073. /**
  34074. * Does this action manager has pick triggers
  34075. */
  34076. abstract get hasPickTriggers(): boolean;
  34077. /**
  34078. * Process a specific trigger
  34079. * @param trigger defines the trigger to process
  34080. * @param evt defines the event details to be processed
  34081. */
  34082. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  34083. /**
  34084. * Does this action manager handles actions of any of the given triggers
  34085. * @param triggers defines the triggers to be tested
  34086. * @return a boolean indicating whether one (or more) of the triggers is handled
  34087. */
  34088. abstract hasSpecificTriggers(triggers: number[]): boolean;
  34089. /**
  34090. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  34091. * speed.
  34092. * @param triggerA defines the trigger to be tested
  34093. * @param triggerB defines the trigger to be tested
  34094. * @return a boolean indicating whether one (or more) of the triggers is handled
  34095. */
  34096. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  34097. /**
  34098. * Does this action manager handles actions of a given trigger
  34099. * @param trigger defines the trigger to be tested
  34100. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  34101. * @return whether the trigger is handled
  34102. */
  34103. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  34104. /**
  34105. * Serialize this manager to a JSON object
  34106. * @param name defines the property name to store this manager
  34107. * @returns a JSON representation of this manager
  34108. */
  34109. abstract serialize(name: string): any;
  34110. /**
  34111. * Registers an action to this action manager
  34112. * @param action defines the action to be registered
  34113. * @return the action amended (prepared) after registration
  34114. */
  34115. abstract registerAction(action: IAction): Nullable<IAction>;
  34116. /**
  34117. * Unregisters an action to this action manager
  34118. * @param action defines the action to be unregistered
  34119. * @return a boolean indicating whether the action has been unregistered
  34120. */
  34121. abstract unregisterAction(action: IAction): Boolean;
  34122. /**
  34123. * Does exist one action manager with at least one trigger
  34124. **/
  34125. static get HasTriggers(): boolean;
  34126. /**
  34127. * Does exist one action manager with at least one pick trigger
  34128. **/
  34129. static get HasPickTriggers(): boolean;
  34130. /**
  34131. * Does exist one action manager that handles actions of a given trigger
  34132. * @param trigger defines the trigger to be tested
  34133. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  34134. **/
  34135. static HasSpecificTrigger(trigger: number): boolean;
  34136. }
  34137. }
  34138. declare module "babylonjs/node" {
  34139. import { Scene } from "babylonjs/scene";
  34140. import { Nullable } from "babylonjs/types";
  34141. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  34142. import { Engine } from "babylonjs/Engines/engine";
  34143. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  34144. import { Observable } from "babylonjs/Misc/observable";
  34145. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34146. import { IInspectable } from "babylonjs/Misc/iInspectable";
  34147. import { Animatable } from "babylonjs/Animations/animatable";
  34148. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34149. import { Animation } from "babylonjs/Animations/animation";
  34150. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34152. /**
  34153. * Defines how a node can be built from a string name.
  34154. */
  34155. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  34156. /**
  34157. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  34158. */
  34159. export class Node implements IBehaviorAware<Node> {
  34160. /** @hidden */
  34161. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  34162. private static _NodeConstructors;
  34163. /**
  34164. * Add a new node constructor
  34165. * @param type defines the type name of the node to construct
  34166. * @param constructorFunc defines the constructor function
  34167. */
  34168. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  34169. /**
  34170. * Returns a node constructor based on type name
  34171. * @param type defines the type name
  34172. * @param name defines the new node name
  34173. * @param scene defines the hosting scene
  34174. * @param options defines optional options to transmit to constructors
  34175. * @returns the new constructor or null
  34176. */
  34177. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  34178. /**
  34179. * Gets or sets the name of the node
  34180. */
  34181. name: string;
  34182. /**
  34183. * Gets or sets the id of the node
  34184. */
  34185. id: string;
  34186. /**
  34187. * Gets or sets the unique id of the node
  34188. */
  34189. uniqueId: number;
  34190. /**
  34191. * Gets or sets a string used to store user defined state for the node
  34192. */
  34193. state: string;
  34194. /**
  34195. * Gets or sets an object used to store user defined information for the node
  34196. */
  34197. metadata: any;
  34198. /**
  34199. * For internal use only. Please do not use.
  34200. */
  34201. reservedDataStore: any;
  34202. /**
  34203. * List of inspectable custom properties (used by the Inspector)
  34204. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  34205. */
  34206. inspectableCustomProperties: IInspectable[];
  34207. private _doNotSerialize;
  34208. /**
  34209. * Gets or sets a boolean used to define if the node must be serialized
  34210. */
  34211. get doNotSerialize(): boolean;
  34212. set doNotSerialize(value: boolean);
  34213. /** @hidden */
  34214. _isDisposed: boolean;
  34215. /**
  34216. * Gets a list of Animations associated with the node
  34217. */
  34218. animations: import("babylonjs/Animations/animation").Animation[];
  34219. protected _ranges: {
  34220. [name: string]: Nullable<AnimationRange>;
  34221. };
  34222. /**
  34223. * Callback raised when the node is ready to be used
  34224. */
  34225. onReady: Nullable<(node: Node) => void>;
  34226. private _isEnabled;
  34227. private _isParentEnabled;
  34228. private _isReady;
  34229. /** @hidden */
  34230. _currentRenderId: number;
  34231. private _parentUpdateId;
  34232. /** @hidden */
  34233. _childUpdateId: number;
  34234. /** @hidden */
  34235. _waitingParentId: Nullable<string>;
  34236. /** @hidden */
  34237. _scene: Scene;
  34238. /** @hidden */
  34239. _cache: any;
  34240. private _parentNode;
  34241. private _children;
  34242. /** @hidden */
  34243. _worldMatrix: Matrix;
  34244. /** @hidden */
  34245. _worldMatrixDeterminant: number;
  34246. /** @hidden */
  34247. _worldMatrixDeterminantIsDirty: boolean;
  34248. /** @hidden */
  34249. private _sceneRootNodesIndex;
  34250. /**
  34251. * Gets a boolean indicating if the node has been disposed
  34252. * @returns true if the node was disposed
  34253. */
  34254. isDisposed(): boolean;
  34255. /**
  34256. * Gets or sets the parent of the node (without keeping the current position in the scene)
  34257. * @see https://doc.babylonjs.com/how_to/parenting
  34258. */
  34259. set parent(parent: Nullable<Node>);
  34260. get parent(): Nullable<Node>;
  34261. /** @hidden */
  34262. _addToSceneRootNodes(): void;
  34263. /** @hidden */
  34264. _removeFromSceneRootNodes(): void;
  34265. private _animationPropertiesOverride;
  34266. /**
  34267. * Gets or sets the animation properties override
  34268. */
  34269. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34270. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34271. /**
  34272. * Gets a string identifying the name of the class
  34273. * @returns "Node" string
  34274. */
  34275. getClassName(): string;
  34276. /** @hidden */
  34277. readonly _isNode: boolean;
  34278. /**
  34279. * An event triggered when the mesh is disposed
  34280. */
  34281. onDisposeObservable: Observable<Node>;
  34282. private _onDisposeObserver;
  34283. /**
  34284. * Sets a callback that will be raised when the node will be disposed
  34285. */
  34286. set onDispose(callback: () => void);
  34287. /**
  34288. * Creates a new Node
  34289. * @param name the name and id to be given to this node
  34290. * @param scene the scene this node will be added to
  34291. */
  34292. constructor(name: string, scene?: Nullable<Scene>);
  34293. /**
  34294. * Gets the scene of the node
  34295. * @returns a scene
  34296. */
  34297. getScene(): Scene;
  34298. /**
  34299. * Gets the engine of the node
  34300. * @returns a Engine
  34301. */
  34302. getEngine(): Engine;
  34303. private _behaviors;
  34304. /**
  34305. * Attach a behavior to the node
  34306. * @see https://doc.babylonjs.com/features/behaviour
  34307. * @param behavior defines the behavior to attach
  34308. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  34309. * @returns the current Node
  34310. */
  34311. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  34312. /**
  34313. * Remove an attached behavior
  34314. * @see https://doc.babylonjs.com/features/behaviour
  34315. * @param behavior defines the behavior to attach
  34316. * @returns the current Node
  34317. */
  34318. removeBehavior(behavior: Behavior<Node>): Node;
  34319. /**
  34320. * Gets the list of attached behaviors
  34321. * @see https://doc.babylonjs.com/features/behaviour
  34322. */
  34323. get behaviors(): Behavior<Node>[];
  34324. /**
  34325. * Gets an attached behavior by name
  34326. * @param name defines the name of the behavior to look for
  34327. * @see https://doc.babylonjs.com/features/behaviour
  34328. * @returns null if behavior was not found else the requested behavior
  34329. */
  34330. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  34331. /**
  34332. * Returns the latest update of the World matrix
  34333. * @returns a Matrix
  34334. */
  34335. getWorldMatrix(): Matrix;
  34336. /** @hidden */
  34337. _getWorldMatrixDeterminant(): number;
  34338. /**
  34339. * Returns directly the latest state of the mesh World matrix.
  34340. * A Matrix is returned.
  34341. */
  34342. get worldMatrixFromCache(): Matrix;
  34343. /** @hidden */
  34344. _initCache(): void;
  34345. /** @hidden */
  34346. updateCache(force?: boolean): void;
  34347. /** @hidden */
  34348. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  34349. /** @hidden */
  34350. _updateCache(ignoreParentClass?: boolean): void;
  34351. /** @hidden */
  34352. _isSynchronized(): boolean;
  34353. /** @hidden */
  34354. _markSyncedWithParent(): void;
  34355. /** @hidden */
  34356. isSynchronizedWithParent(): boolean;
  34357. /** @hidden */
  34358. isSynchronized(): boolean;
  34359. /**
  34360. * Is this node ready to be used/rendered
  34361. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34362. * @return true if the node is ready
  34363. */
  34364. isReady(completeCheck?: boolean): boolean;
  34365. /**
  34366. * Is this node enabled?
  34367. * 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
  34368. * @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
  34369. * @return whether this node (and its parent) is enabled
  34370. */
  34371. isEnabled(checkAncestors?: boolean): boolean;
  34372. /** @hidden */
  34373. protected _syncParentEnabledState(): void;
  34374. /**
  34375. * Set the enabled state of this node
  34376. * @param value defines the new enabled state
  34377. */
  34378. setEnabled(value: boolean): void;
  34379. /**
  34380. * Is this node a descendant of the given node?
  34381. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  34382. * @param ancestor defines the parent node to inspect
  34383. * @returns a boolean indicating if this node is a descendant of the given node
  34384. */
  34385. isDescendantOf(ancestor: Node): boolean;
  34386. /** @hidden */
  34387. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  34388. /**
  34389. * Will return all nodes that have this node as ascendant
  34390. * @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
  34391. * @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
  34392. * @return all children nodes of all types
  34393. */
  34394. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  34395. /**
  34396. * Get all child-meshes of this node
  34397. * @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)
  34398. * @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
  34399. * @returns an array of AbstractMesh
  34400. */
  34401. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  34402. /**
  34403. * Get all direct children of this node
  34404. * @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
  34405. * @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)
  34406. * @returns an array of Node
  34407. */
  34408. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  34409. /** @hidden */
  34410. _setReady(state: boolean): void;
  34411. /**
  34412. * Get an animation by name
  34413. * @param name defines the name of the animation to look for
  34414. * @returns null if not found else the requested animation
  34415. */
  34416. getAnimationByName(name: string): Nullable<Animation>;
  34417. /**
  34418. * Creates an animation range for this node
  34419. * @param name defines the name of the range
  34420. * @param from defines the starting key
  34421. * @param to defines the end key
  34422. */
  34423. createAnimationRange(name: string, from: number, to: number): void;
  34424. /**
  34425. * Delete a specific animation range
  34426. * @param name defines the name of the range to delete
  34427. * @param deleteFrames defines if animation frames from the range must be deleted as well
  34428. */
  34429. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  34430. /**
  34431. * Get an animation range by name
  34432. * @param name defines the name of the animation range to look for
  34433. * @returns null if not found else the requested animation range
  34434. */
  34435. getAnimationRange(name: string): Nullable<AnimationRange>;
  34436. /**
  34437. * Gets the list of all animation ranges defined on this node
  34438. * @returns an array
  34439. */
  34440. getAnimationRanges(): Nullable<AnimationRange>[];
  34441. /**
  34442. * Will start the animation sequence
  34443. * @param name defines the range frames for animation sequence
  34444. * @param loop defines if the animation should loop (false by default)
  34445. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  34446. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  34447. * @returns the object created for this animation. If range does not exist, it will return null
  34448. */
  34449. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  34450. /**
  34451. * Serialize animation ranges into a JSON compatible object
  34452. * @returns serialization object
  34453. */
  34454. serializeAnimationRanges(): any;
  34455. /**
  34456. * Computes the world matrix of the node
  34457. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  34458. * @returns the world matrix
  34459. */
  34460. computeWorldMatrix(force?: boolean): Matrix;
  34461. /**
  34462. * Releases resources associated with this node.
  34463. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34464. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34465. */
  34466. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34467. /**
  34468. * Parse animation range data from a serialization object and store them into a given node
  34469. * @param node defines where to store the animation ranges
  34470. * @param parsedNode defines the serialization object to read data from
  34471. * @param scene defines the hosting scene
  34472. */
  34473. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  34474. /**
  34475. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  34476. * @param includeDescendants Include bounding info from descendants as well (true by default)
  34477. * @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
  34478. * @returns the new bounding vectors
  34479. */
  34480. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  34481. min: Vector3;
  34482. max: Vector3;
  34483. };
  34484. }
  34485. }
  34486. declare module "babylonjs/Animations/animation" {
  34487. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  34488. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  34489. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  34490. import { Nullable } from "babylonjs/types";
  34491. import { Scene } from "babylonjs/scene";
  34492. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  34493. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34494. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  34495. import { Node } from "babylonjs/node";
  34496. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34497. import { Size } from "babylonjs/Maths/math.size";
  34498. import { Animatable } from "babylonjs/Animations/animatable";
  34499. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  34500. /**
  34501. * @hidden
  34502. */
  34503. export class _IAnimationState {
  34504. key: number;
  34505. repeatCount: number;
  34506. workValue?: any;
  34507. loopMode?: number;
  34508. offsetValue?: any;
  34509. highLimitValue?: any;
  34510. }
  34511. /**
  34512. * Class used to store any kind of animation
  34513. */
  34514. export class Animation {
  34515. /**Name of the animation */
  34516. name: string;
  34517. /**Property to animate */
  34518. targetProperty: string;
  34519. /**The frames per second of the animation */
  34520. framePerSecond: number;
  34521. /**The data type of the animation */
  34522. dataType: number;
  34523. /**The loop mode of the animation */
  34524. loopMode?: number | undefined;
  34525. /**Specifies if blending should be enabled */
  34526. enableBlending?: boolean | undefined;
  34527. /**
  34528. * Use matrix interpolation instead of using direct key value when animating matrices
  34529. */
  34530. static AllowMatricesInterpolation: boolean;
  34531. /**
  34532. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  34533. */
  34534. static AllowMatrixDecomposeForInterpolation: boolean;
  34535. /** Define the Url to load snippets */
  34536. static SnippetUrl: string;
  34537. /** Snippet ID if the animation was created from the snippet server */
  34538. snippetId: string;
  34539. /**
  34540. * Stores the key frames of the animation
  34541. */
  34542. private _keys;
  34543. /**
  34544. * Stores the easing function of the animation
  34545. */
  34546. private _easingFunction;
  34547. /**
  34548. * @hidden Internal use only
  34549. */
  34550. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  34551. /**
  34552. * The set of event that will be linked to this animation
  34553. */
  34554. private _events;
  34555. /**
  34556. * Stores an array of target property paths
  34557. */
  34558. targetPropertyPath: string[];
  34559. /**
  34560. * Stores the blending speed of the animation
  34561. */
  34562. blendingSpeed: number;
  34563. /**
  34564. * Stores the animation ranges for the animation
  34565. */
  34566. private _ranges;
  34567. /**
  34568. * @hidden Internal use
  34569. */
  34570. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  34571. /**
  34572. * Sets up an animation
  34573. * @param property The property to animate
  34574. * @param animationType The animation type to apply
  34575. * @param framePerSecond The frames per second of the animation
  34576. * @param easingFunction The easing function used in the animation
  34577. * @returns The created animation
  34578. */
  34579. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  34580. /**
  34581. * Create and start an animation on a node
  34582. * @param name defines the name of the global animation that will be run on all nodes
  34583. * @param node defines the root node where the animation will take place
  34584. * @param targetProperty defines property to animate
  34585. * @param framePerSecond defines the number of frame per second yo use
  34586. * @param totalFrame defines the number of frames in total
  34587. * @param from defines the initial value
  34588. * @param to defines the final value
  34589. * @param loopMode defines which loop mode you want to use (off by default)
  34590. * @param easingFunction defines the easing function to use (linear by default)
  34591. * @param onAnimationEnd defines the callback to call when animation end
  34592. * @returns the animatable created for this animation
  34593. */
  34594. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34595. /**
  34596. * Create and start an animation on a node and its descendants
  34597. * @param name defines the name of the global animation that will be run on all nodes
  34598. * @param node defines the root node where the animation will take place
  34599. * @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
  34600. * @param targetProperty defines property to animate
  34601. * @param framePerSecond defines the number of frame per second to use
  34602. * @param totalFrame defines the number of frames in total
  34603. * @param from defines the initial value
  34604. * @param to defines the final value
  34605. * @param loopMode defines which loop mode you want to use (off by default)
  34606. * @param easingFunction defines the easing function to use (linear by default)
  34607. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  34608. * @returns the list of animatables created for all nodes
  34609. * @example https://www.babylonjs-playground.com/#MH0VLI
  34610. */
  34611. 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[]>;
  34612. /**
  34613. * Creates a new animation, merges it with the existing animations and starts it
  34614. * @param name Name of the animation
  34615. * @param node Node which contains the scene that begins the animations
  34616. * @param targetProperty Specifies which property to animate
  34617. * @param framePerSecond The frames per second of the animation
  34618. * @param totalFrame The total number of frames
  34619. * @param from The frame at the beginning of the animation
  34620. * @param to The frame at the end of the animation
  34621. * @param loopMode Specifies the loop mode of the animation
  34622. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  34623. * @param onAnimationEnd Callback to run once the animation is complete
  34624. * @returns Nullable animation
  34625. */
  34626. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34627. /**
  34628. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  34629. * @param sourceAnimation defines the Animation containing keyframes to convert
  34630. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  34631. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  34632. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  34633. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  34634. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  34635. */
  34636. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  34637. /**
  34638. * Transition property of an host to the target Value
  34639. * @param property The property to transition
  34640. * @param targetValue The target Value of the property
  34641. * @param host The object where the property to animate belongs
  34642. * @param scene Scene used to run the animation
  34643. * @param frameRate Framerate (in frame/s) to use
  34644. * @param transition The transition type we want to use
  34645. * @param duration The duration of the animation, in milliseconds
  34646. * @param onAnimationEnd Callback trigger at the end of the animation
  34647. * @returns Nullable animation
  34648. */
  34649. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  34650. /**
  34651. * Return the array of runtime animations currently using this animation
  34652. */
  34653. get runtimeAnimations(): RuntimeAnimation[];
  34654. /**
  34655. * Specifies if any of the runtime animations are currently running
  34656. */
  34657. get hasRunningRuntimeAnimations(): boolean;
  34658. /**
  34659. * Initializes the animation
  34660. * @param name Name of the animation
  34661. * @param targetProperty Property to animate
  34662. * @param framePerSecond The frames per second of the animation
  34663. * @param dataType The data type of the animation
  34664. * @param loopMode The loop mode of the animation
  34665. * @param enableBlending Specifies if blending should be enabled
  34666. */
  34667. constructor(
  34668. /**Name of the animation */
  34669. name: string,
  34670. /**Property to animate */
  34671. targetProperty: string,
  34672. /**The frames per second of the animation */
  34673. framePerSecond: number,
  34674. /**The data type of the animation */
  34675. dataType: number,
  34676. /**The loop mode of the animation */
  34677. loopMode?: number | undefined,
  34678. /**Specifies if blending should be enabled */
  34679. enableBlending?: boolean | undefined);
  34680. /**
  34681. * Converts the animation to a string
  34682. * @param fullDetails support for multiple levels of logging within scene loading
  34683. * @returns String form of the animation
  34684. */
  34685. toString(fullDetails?: boolean): string;
  34686. /**
  34687. * Add an event to this animation
  34688. * @param event Event to add
  34689. */
  34690. addEvent(event: AnimationEvent): void;
  34691. /**
  34692. * Remove all events found at the given frame
  34693. * @param frame The frame to remove events from
  34694. */
  34695. removeEvents(frame: number): void;
  34696. /**
  34697. * Retrieves all the events from the animation
  34698. * @returns Events from the animation
  34699. */
  34700. getEvents(): AnimationEvent[];
  34701. /**
  34702. * Creates an animation range
  34703. * @param name Name of the animation range
  34704. * @param from Starting frame of the animation range
  34705. * @param to Ending frame of the animation
  34706. */
  34707. createRange(name: string, from: number, to: number): void;
  34708. /**
  34709. * Deletes an animation range by name
  34710. * @param name Name of the animation range to delete
  34711. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  34712. */
  34713. deleteRange(name: string, deleteFrames?: boolean): void;
  34714. /**
  34715. * Gets the animation range by name, or null if not defined
  34716. * @param name Name of the animation range
  34717. * @returns Nullable animation range
  34718. */
  34719. getRange(name: string): Nullable<AnimationRange>;
  34720. /**
  34721. * Gets the key frames from the animation
  34722. * @returns The key frames of the animation
  34723. */
  34724. getKeys(): Array<IAnimationKey>;
  34725. /**
  34726. * Gets the highest frame rate of the animation
  34727. * @returns Highest frame rate of the animation
  34728. */
  34729. getHighestFrame(): number;
  34730. /**
  34731. * Gets the easing function of the animation
  34732. * @returns Easing function of the animation
  34733. */
  34734. getEasingFunction(): IEasingFunction;
  34735. /**
  34736. * Sets the easing function of the animation
  34737. * @param easingFunction A custom mathematical formula for animation
  34738. */
  34739. setEasingFunction(easingFunction: EasingFunction): void;
  34740. /**
  34741. * Interpolates a scalar linearly
  34742. * @param startValue Start value of the animation curve
  34743. * @param endValue End value of the animation curve
  34744. * @param gradient Scalar amount to interpolate
  34745. * @returns Interpolated scalar value
  34746. */
  34747. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  34748. /**
  34749. * Interpolates a scalar cubically
  34750. * @param startValue Start value of the animation curve
  34751. * @param outTangent End tangent of the animation
  34752. * @param endValue End value of the animation curve
  34753. * @param inTangent Start tangent of the animation curve
  34754. * @param gradient Scalar amount to interpolate
  34755. * @returns Interpolated scalar value
  34756. */
  34757. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  34758. /**
  34759. * Interpolates a quaternion using a spherical linear interpolation
  34760. * @param startValue Start value of the animation curve
  34761. * @param endValue End value of the animation curve
  34762. * @param gradient Scalar amount to interpolate
  34763. * @returns Interpolated quaternion value
  34764. */
  34765. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  34766. /**
  34767. * Interpolates a quaternion cubically
  34768. * @param startValue Start value of the animation curve
  34769. * @param outTangent End tangent of the animation curve
  34770. * @param endValue End value of the animation curve
  34771. * @param inTangent Start tangent of the animation curve
  34772. * @param gradient Scalar amount to interpolate
  34773. * @returns Interpolated quaternion value
  34774. */
  34775. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  34776. /**
  34777. * Interpolates a Vector3 linearl
  34778. * @param startValue Start value of the animation curve
  34779. * @param endValue End value of the animation curve
  34780. * @param gradient Scalar amount to interpolate
  34781. * @returns Interpolated scalar value
  34782. */
  34783. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  34784. /**
  34785. * Interpolates a Vector3 cubically
  34786. * @param startValue Start value of the animation curve
  34787. * @param outTangent End tangent of the animation
  34788. * @param endValue End value of the animation curve
  34789. * @param inTangent Start tangent of the animation curve
  34790. * @param gradient Scalar amount to interpolate
  34791. * @returns InterpolatedVector3 value
  34792. */
  34793. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  34794. /**
  34795. * Interpolates a Vector2 linearly
  34796. * @param startValue Start value of the animation curve
  34797. * @param endValue End value of the animation curve
  34798. * @param gradient Scalar amount to interpolate
  34799. * @returns Interpolated Vector2 value
  34800. */
  34801. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  34802. /**
  34803. * Interpolates a Vector2 cubically
  34804. * @param startValue Start value of the animation curve
  34805. * @param outTangent End tangent of the animation
  34806. * @param endValue End value of the animation curve
  34807. * @param inTangent Start tangent of the animation curve
  34808. * @param gradient Scalar amount to interpolate
  34809. * @returns Interpolated Vector2 value
  34810. */
  34811. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  34812. /**
  34813. * Interpolates a size linearly
  34814. * @param startValue Start value of the animation curve
  34815. * @param endValue End value of the animation curve
  34816. * @param gradient Scalar amount to interpolate
  34817. * @returns Interpolated Size value
  34818. */
  34819. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  34820. /**
  34821. * Interpolates a Color3 linearly
  34822. * @param startValue Start value of the animation curve
  34823. * @param endValue End value of the animation curve
  34824. * @param gradient Scalar amount to interpolate
  34825. * @returns Interpolated Color3 value
  34826. */
  34827. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  34828. /**
  34829. * Interpolates a Color4 linearly
  34830. * @param startValue Start value of the animation curve
  34831. * @param endValue End value of the animation curve
  34832. * @param gradient Scalar amount to interpolate
  34833. * @returns Interpolated Color3 value
  34834. */
  34835. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  34836. /**
  34837. * @hidden Internal use only
  34838. */
  34839. _getKeyValue(value: any): any;
  34840. /**
  34841. * @hidden Internal use only
  34842. */
  34843. _interpolate(currentFrame: number, state: _IAnimationState): any;
  34844. /**
  34845. * Defines the function to use to interpolate matrices
  34846. * @param startValue defines the start matrix
  34847. * @param endValue defines the end matrix
  34848. * @param gradient defines the gradient between both matrices
  34849. * @param result defines an optional target matrix where to store the interpolation
  34850. * @returns the interpolated matrix
  34851. */
  34852. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  34853. /**
  34854. * Makes a copy of the animation
  34855. * @returns Cloned animation
  34856. */
  34857. clone(): Animation;
  34858. /**
  34859. * Sets the key frames of the animation
  34860. * @param values The animation key frames to set
  34861. */
  34862. setKeys(values: Array<IAnimationKey>): void;
  34863. /**
  34864. * Serializes the animation to an object
  34865. * @returns Serialized object
  34866. */
  34867. serialize(): any;
  34868. /**
  34869. * Float animation type
  34870. */
  34871. static readonly ANIMATIONTYPE_FLOAT: number;
  34872. /**
  34873. * Vector3 animation type
  34874. */
  34875. static readonly ANIMATIONTYPE_VECTOR3: number;
  34876. /**
  34877. * Quaternion animation type
  34878. */
  34879. static readonly ANIMATIONTYPE_QUATERNION: number;
  34880. /**
  34881. * Matrix animation type
  34882. */
  34883. static readonly ANIMATIONTYPE_MATRIX: number;
  34884. /**
  34885. * Color3 animation type
  34886. */
  34887. static readonly ANIMATIONTYPE_COLOR3: number;
  34888. /**
  34889. * Color3 animation type
  34890. */
  34891. static readonly ANIMATIONTYPE_COLOR4: number;
  34892. /**
  34893. * Vector2 animation type
  34894. */
  34895. static readonly ANIMATIONTYPE_VECTOR2: number;
  34896. /**
  34897. * Size animation type
  34898. */
  34899. static readonly ANIMATIONTYPE_SIZE: number;
  34900. /**
  34901. * Relative Loop Mode
  34902. */
  34903. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  34904. /**
  34905. * Cycle Loop Mode
  34906. */
  34907. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  34908. /**
  34909. * Constant Loop Mode
  34910. */
  34911. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  34912. /** @hidden */
  34913. static _UniversalLerp(left: any, right: any, amount: number): any;
  34914. /**
  34915. * Parses an animation object and creates an animation
  34916. * @param parsedAnimation Parsed animation object
  34917. * @returns Animation object
  34918. */
  34919. static Parse(parsedAnimation: any): Animation;
  34920. /**
  34921. * Appends the serialized animations from the source animations
  34922. * @param source Source containing the animations
  34923. * @param destination Target to store the animations
  34924. */
  34925. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  34926. /**
  34927. * Creates a new animation or an array of animations from a snippet saved in a remote file
  34928. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  34929. * @param url defines the url to load from
  34930. * @returns a promise that will resolve to the new animation or an array of animations
  34931. */
  34932. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  34933. /**
  34934. * Creates an animation or an array of animations from a snippet saved by the Inspector
  34935. * @param snippetId defines the snippet to load
  34936. * @returns a promise that will resolve to the new animation or a new array of animations
  34937. */
  34938. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  34939. }
  34940. }
  34941. declare module "babylonjs/Animations/animatable.interface" {
  34942. import { Nullable } from "babylonjs/types";
  34943. import { Animation } from "babylonjs/Animations/animation";
  34944. /**
  34945. * Interface containing an array of animations
  34946. */
  34947. export interface IAnimatable {
  34948. /**
  34949. * Array of animations
  34950. */
  34951. animations: Nullable<Array<Animation>>;
  34952. }
  34953. }
  34954. declare module "babylonjs/Misc/decorators" {
  34955. import { Nullable } from "babylonjs/types";
  34956. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34957. import { Scene } from "babylonjs/scene";
  34958. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  34959. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  34960. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  34961. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34962. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  34963. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34964. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34965. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34966. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34967. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34968. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34969. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34970. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34971. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34972. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34973. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34974. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34975. /**
  34976. * Decorator used to define property that can be serialized as reference to a camera
  34977. * @param sourceName defines the name of the property to decorate
  34978. */
  34979. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34980. /**
  34981. * Class used to help serialization objects
  34982. */
  34983. export class SerializationHelper {
  34984. /** @hidden */
  34985. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  34986. /** @hidden */
  34987. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  34988. /** @hidden */
  34989. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  34990. /** @hidden */
  34991. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  34992. /**
  34993. * Appends the serialized animations from the source animations
  34994. * @param source Source containing the animations
  34995. * @param destination Target to store the animations
  34996. */
  34997. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  34998. /**
  34999. * Static function used to serialized a specific entity
  35000. * @param entity defines the entity to serialize
  35001. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  35002. * @returns a JSON compatible object representing the serialization of the entity
  35003. */
  35004. static Serialize<T>(entity: T, serializationObject?: any): any;
  35005. /**
  35006. * Creates a new entity from a serialization data object
  35007. * @param creationFunction defines a function used to instanciated the new entity
  35008. * @param source defines the source serialization data
  35009. * @param scene defines the hosting scene
  35010. * @param rootUrl defines the root url for resources
  35011. * @returns a new entity
  35012. */
  35013. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  35014. /**
  35015. * Clones an object
  35016. * @param creationFunction defines the function used to instanciate the new object
  35017. * @param source defines the source object
  35018. * @returns the cloned object
  35019. */
  35020. static Clone<T>(creationFunction: () => T, source: T): T;
  35021. /**
  35022. * Instanciates a new object based on a source one (some data will be shared between both object)
  35023. * @param creationFunction defines the function used to instanciate the new object
  35024. * @param source defines the source object
  35025. * @returns the new object
  35026. */
  35027. static Instanciate<T>(creationFunction: () => T, source: T): T;
  35028. }
  35029. }
  35030. declare module "babylonjs/Materials/Textures/baseTexture" {
  35031. import { Observable } from "babylonjs/Misc/observable";
  35032. import { Nullable } from "babylonjs/types";
  35033. import { Scene } from "babylonjs/scene";
  35034. import { Matrix } from "babylonjs/Maths/math.vector";
  35035. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35036. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35037. import { ISize } from "babylonjs/Maths/math.size";
  35038. import "babylonjs/Misc/fileTools";
  35039. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35040. /**
  35041. * Base class of all the textures in babylon.
  35042. * It groups all the common properties the materials, post process, lights... might need
  35043. * in order to make a correct use of the texture.
  35044. */
  35045. export class BaseTexture implements IAnimatable {
  35046. /**
  35047. * Default anisotropic filtering level for the application.
  35048. * It is set to 4 as a good tradeoff between perf and quality.
  35049. */
  35050. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  35051. /**
  35052. * Gets or sets the unique id of the texture
  35053. */
  35054. uniqueId: number;
  35055. /**
  35056. * Define the name of the texture.
  35057. */
  35058. name: string;
  35059. /**
  35060. * Gets or sets an object used to store user defined information.
  35061. */
  35062. metadata: any;
  35063. /**
  35064. * For internal use only. Please do not use.
  35065. */
  35066. reservedDataStore: any;
  35067. private _hasAlpha;
  35068. /**
  35069. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  35070. */
  35071. set hasAlpha(value: boolean);
  35072. get hasAlpha(): boolean;
  35073. /**
  35074. * Defines if the alpha value should be determined via the rgb values.
  35075. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  35076. */
  35077. getAlphaFromRGB: boolean;
  35078. /**
  35079. * Intensity or strength of the texture.
  35080. * It is commonly used by materials to fine tune the intensity of the texture
  35081. */
  35082. level: number;
  35083. /**
  35084. * Define the UV chanel to use starting from 0 and defaulting to 0.
  35085. * This is part of the texture as textures usually maps to one uv set.
  35086. */
  35087. coordinatesIndex: number;
  35088. protected _coordinatesMode: number;
  35089. /**
  35090. * How a texture is mapped.
  35091. *
  35092. * | Value | Type | Description |
  35093. * | ----- | ----------------------------------- | ----------- |
  35094. * | 0 | EXPLICIT_MODE | |
  35095. * | 1 | SPHERICAL_MODE | |
  35096. * | 2 | PLANAR_MODE | |
  35097. * | 3 | CUBIC_MODE | |
  35098. * | 4 | PROJECTION_MODE | |
  35099. * | 5 | SKYBOX_MODE | |
  35100. * | 6 | INVCUBIC_MODE | |
  35101. * | 7 | EQUIRECTANGULAR_MODE | |
  35102. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  35103. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  35104. */
  35105. set coordinatesMode(value: number);
  35106. get coordinatesMode(): number;
  35107. private _wrapU;
  35108. /**
  35109. * | Value | Type | Description |
  35110. * | ----- | ------------------ | ----------- |
  35111. * | 0 | CLAMP_ADDRESSMODE | |
  35112. * | 1 | WRAP_ADDRESSMODE | |
  35113. * | 2 | MIRROR_ADDRESSMODE | |
  35114. */
  35115. get wrapU(): number;
  35116. set wrapU(value: number);
  35117. private _wrapV;
  35118. /**
  35119. * | Value | Type | Description |
  35120. * | ----- | ------------------ | ----------- |
  35121. * | 0 | CLAMP_ADDRESSMODE | |
  35122. * | 1 | WRAP_ADDRESSMODE | |
  35123. * | 2 | MIRROR_ADDRESSMODE | |
  35124. */
  35125. get wrapV(): number;
  35126. set wrapV(value: number);
  35127. /**
  35128. * | Value | Type | Description |
  35129. * | ----- | ------------------ | ----------- |
  35130. * | 0 | CLAMP_ADDRESSMODE | |
  35131. * | 1 | WRAP_ADDRESSMODE | |
  35132. * | 2 | MIRROR_ADDRESSMODE | |
  35133. */
  35134. wrapR: number;
  35135. /**
  35136. * With compliant hardware and browser (supporting anisotropic filtering)
  35137. * this defines the level of anisotropic filtering in the texture.
  35138. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  35139. */
  35140. anisotropicFilteringLevel: number;
  35141. /**
  35142. * Define if the texture is a cube texture or if false a 2d texture.
  35143. */
  35144. get isCube(): boolean;
  35145. set isCube(value: boolean);
  35146. /**
  35147. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  35148. */
  35149. get is3D(): boolean;
  35150. set is3D(value: boolean);
  35151. /**
  35152. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  35153. */
  35154. get is2DArray(): boolean;
  35155. set is2DArray(value: boolean);
  35156. private _gammaSpace;
  35157. /**
  35158. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  35159. * HDR texture are usually stored in linear space.
  35160. * This only impacts the PBR and Background materials
  35161. */
  35162. get gammaSpace(): boolean;
  35163. set gammaSpace(gamma: boolean);
  35164. /**
  35165. * Gets or sets whether or not the texture contains RGBD data.
  35166. */
  35167. get isRGBD(): boolean;
  35168. set isRGBD(value: boolean);
  35169. /**
  35170. * Is Z inverted in the texture (useful in a cube texture).
  35171. */
  35172. invertZ: boolean;
  35173. /**
  35174. * Are mip maps generated for this texture or not.
  35175. */
  35176. get noMipmap(): boolean;
  35177. /**
  35178. * @hidden
  35179. */
  35180. lodLevelInAlpha: boolean;
  35181. /**
  35182. * With prefiltered texture, defined the offset used during the prefiltering steps.
  35183. */
  35184. get lodGenerationOffset(): number;
  35185. set lodGenerationOffset(value: number);
  35186. /**
  35187. * With prefiltered texture, defined the scale used during the prefiltering steps.
  35188. */
  35189. get lodGenerationScale(): number;
  35190. set lodGenerationScale(value: number);
  35191. /**
  35192. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  35193. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  35194. * average roughness values.
  35195. */
  35196. get linearSpecularLOD(): boolean;
  35197. set linearSpecularLOD(value: boolean);
  35198. /**
  35199. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  35200. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  35201. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  35202. */
  35203. get irradianceTexture(): Nullable<BaseTexture>;
  35204. set irradianceTexture(value: Nullable<BaseTexture>);
  35205. /**
  35206. * Define if the texture is a render target.
  35207. */
  35208. isRenderTarget: boolean;
  35209. /**
  35210. * Define the unique id of the texture in the scene.
  35211. */
  35212. get uid(): string;
  35213. /** @hidden */
  35214. _prefiltered: boolean;
  35215. /**
  35216. * Return a string representation of the texture.
  35217. * @returns the texture as a string
  35218. */
  35219. toString(): string;
  35220. /**
  35221. * Get the class name of the texture.
  35222. * @returns "BaseTexture"
  35223. */
  35224. getClassName(): string;
  35225. /**
  35226. * Define the list of animation attached to the texture.
  35227. */
  35228. animations: import("babylonjs/Animations/animation").Animation[];
  35229. /**
  35230. * An event triggered when the texture is disposed.
  35231. */
  35232. onDisposeObservable: Observable<BaseTexture>;
  35233. private _onDisposeObserver;
  35234. /**
  35235. * Callback triggered when the texture has been disposed.
  35236. * Kept for back compatibility, you can use the onDisposeObservable instead.
  35237. */
  35238. set onDispose(callback: () => void);
  35239. /**
  35240. * Define the current state of the loading sequence when in delayed load mode.
  35241. */
  35242. delayLoadState: number;
  35243. protected _scene: Nullable<Scene>;
  35244. protected _engine: Nullable<ThinEngine>;
  35245. /** @hidden */
  35246. _texture: Nullable<InternalTexture>;
  35247. private _uid;
  35248. /**
  35249. * Define if the texture is preventinga material to render or not.
  35250. * If not and the texture is not ready, the engine will use a default black texture instead.
  35251. */
  35252. get isBlocking(): boolean;
  35253. /**
  35254. * Instantiates a new BaseTexture.
  35255. * Base class of all the textures in babylon.
  35256. * It groups all the common properties the materials, post process, lights... might need
  35257. * in order to make a correct use of the texture.
  35258. * @param sceneOrEngine Define the scene or engine the texture blongs to
  35259. */
  35260. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  35261. /**
  35262. * Get the scene the texture belongs to.
  35263. * @returns the scene or null if undefined
  35264. */
  35265. getScene(): Nullable<Scene>;
  35266. /** @hidden */
  35267. protected _getEngine(): Nullable<ThinEngine>;
  35268. /**
  35269. * Get the texture transform matrix used to offset tile the texture for istance.
  35270. * @returns the transformation matrix
  35271. */
  35272. getTextureMatrix(): Matrix;
  35273. /**
  35274. * Get the texture reflection matrix used to rotate/transform the reflection.
  35275. * @returns the reflection matrix
  35276. */
  35277. getReflectionTextureMatrix(): Matrix;
  35278. /**
  35279. * Get the underlying lower level texture from Babylon.
  35280. * @returns the insternal texture
  35281. */
  35282. getInternalTexture(): Nullable<InternalTexture>;
  35283. /**
  35284. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  35285. * @returns true if ready or not blocking
  35286. */
  35287. isReadyOrNotBlocking(): boolean;
  35288. /**
  35289. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  35290. * @returns true if fully ready
  35291. */
  35292. isReady(): boolean;
  35293. private _cachedSize;
  35294. /**
  35295. * Get the size of the texture.
  35296. * @returns the texture size.
  35297. */
  35298. getSize(): ISize;
  35299. /**
  35300. * Get the base size of the texture.
  35301. * It can be different from the size if the texture has been resized for POT for instance
  35302. * @returns the base size
  35303. */
  35304. getBaseSize(): ISize;
  35305. /**
  35306. * Update the sampling mode of the texture.
  35307. * Default is Trilinear mode.
  35308. *
  35309. * | Value | Type | Description |
  35310. * | ----- | ------------------ | ----------- |
  35311. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  35312. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  35313. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  35314. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  35315. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  35316. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  35317. * | 7 | NEAREST_LINEAR | |
  35318. * | 8 | NEAREST_NEAREST | |
  35319. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  35320. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  35321. * | 11 | LINEAR_LINEAR | |
  35322. * | 12 | LINEAR_NEAREST | |
  35323. *
  35324. * > _mag_: magnification filter (close to the viewer)
  35325. * > _min_: minification filter (far from the viewer)
  35326. * > _mip_: filter used between mip map levels
  35327. *@param samplingMode Define the new sampling mode of the texture
  35328. */
  35329. updateSamplingMode(samplingMode: number): void;
  35330. /**
  35331. * Scales the texture if is `canRescale()`
  35332. * @param ratio the resize factor we want to use to rescale
  35333. */
  35334. scale(ratio: number): void;
  35335. /**
  35336. * Get if the texture can rescale.
  35337. */
  35338. get canRescale(): boolean;
  35339. /** @hidden */
  35340. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  35341. /** @hidden */
  35342. _rebuild(): void;
  35343. /**
  35344. * Triggers the load sequence in delayed load mode.
  35345. */
  35346. delayLoad(): void;
  35347. /**
  35348. * Clones the texture.
  35349. * @returns the cloned texture
  35350. */
  35351. clone(): Nullable<BaseTexture>;
  35352. /**
  35353. * Get the texture underlying type (INT, FLOAT...)
  35354. */
  35355. get textureType(): number;
  35356. /**
  35357. * Get the texture underlying format (RGB, RGBA...)
  35358. */
  35359. get textureFormat(): number;
  35360. /**
  35361. * Indicates that textures need to be re-calculated for all materials
  35362. */
  35363. protected _markAllSubMeshesAsTexturesDirty(): void;
  35364. /**
  35365. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  35366. * This will returns an RGBA array buffer containing either in values (0-255) or
  35367. * float values (0-1) depending of the underlying buffer type.
  35368. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  35369. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  35370. * @param buffer defines a user defined buffer to fill with data (can be null)
  35371. * @returns The Array buffer containing the pixels data.
  35372. */
  35373. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  35374. /**
  35375. * Release and destroy the underlying lower level texture aka internalTexture.
  35376. */
  35377. releaseInternalTexture(): void;
  35378. /** @hidden */
  35379. get _lodTextureHigh(): Nullable<BaseTexture>;
  35380. /** @hidden */
  35381. get _lodTextureMid(): Nullable<BaseTexture>;
  35382. /** @hidden */
  35383. get _lodTextureLow(): Nullable<BaseTexture>;
  35384. /**
  35385. * Dispose the texture and release its associated resources.
  35386. */
  35387. dispose(): void;
  35388. /**
  35389. * Serialize the texture into a JSON representation that can be parsed later on.
  35390. * @returns the JSON representation of the texture
  35391. */
  35392. serialize(): any;
  35393. /**
  35394. * Helper function to be called back once a list of texture contains only ready textures.
  35395. * @param textures Define the list of textures to wait for
  35396. * @param callback Define the callback triggered once the entire list will be ready
  35397. */
  35398. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  35399. private static _isScene;
  35400. }
  35401. }
  35402. declare module "babylonjs/Materials/effect" {
  35403. import { Observable } from "babylonjs/Misc/observable";
  35404. import { Nullable } from "babylonjs/types";
  35405. import { IDisposable } from "babylonjs/scene";
  35406. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35407. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35408. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  35409. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35410. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35411. import { Engine } from "babylonjs/Engines/engine";
  35412. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35413. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35414. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35415. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35416. /**
  35417. * Options to be used when creating an effect.
  35418. */
  35419. export interface IEffectCreationOptions {
  35420. /**
  35421. * Atrributes that will be used in the shader.
  35422. */
  35423. attributes: string[];
  35424. /**
  35425. * Uniform varible names that will be set in the shader.
  35426. */
  35427. uniformsNames: string[];
  35428. /**
  35429. * Uniform buffer variable names that will be set in the shader.
  35430. */
  35431. uniformBuffersNames: string[];
  35432. /**
  35433. * Sampler texture variable names that will be set in the shader.
  35434. */
  35435. samplers: string[];
  35436. /**
  35437. * Define statements that will be set in the shader.
  35438. */
  35439. defines: any;
  35440. /**
  35441. * Possible fallbacks for this effect to improve performance when needed.
  35442. */
  35443. fallbacks: Nullable<IEffectFallbacks>;
  35444. /**
  35445. * Callback that will be called when the shader is compiled.
  35446. */
  35447. onCompiled: Nullable<(effect: Effect) => void>;
  35448. /**
  35449. * Callback that will be called if an error occurs during shader compilation.
  35450. */
  35451. onError: Nullable<(effect: Effect, errors: string) => void>;
  35452. /**
  35453. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35454. */
  35455. indexParameters?: any;
  35456. /**
  35457. * Max number of lights that can be used in the shader.
  35458. */
  35459. maxSimultaneousLights?: number;
  35460. /**
  35461. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  35462. */
  35463. transformFeedbackVaryings?: Nullable<string[]>;
  35464. /**
  35465. * 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
  35466. */
  35467. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  35468. /**
  35469. * Is this effect rendering to several color attachments ?
  35470. */
  35471. multiTarget?: boolean;
  35472. }
  35473. /**
  35474. * Effect containing vertex and fragment shader that can be executed on an object.
  35475. */
  35476. export class Effect implements IDisposable {
  35477. /**
  35478. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35479. */
  35480. static ShadersRepository: string;
  35481. /**
  35482. * Enable logging of the shader code when a compilation error occurs
  35483. */
  35484. static LogShaderCodeOnCompilationError: boolean;
  35485. /**
  35486. * Name of the effect.
  35487. */
  35488. name: any;
  35489. /**
  35490. * String container all the define statements that should be set on the shader.
  35491. */
  35492. defines: string;
  35493. /**
  35494. * Callback that will be called when the shader is compiled.
  35495. */
  35496. onCompiled: Nullable<(effect: Effect) => void>;
  35497. /**
  35498. * Callback that will be called if an error occurs during shader compilation.
  35499. */
  35500. onError: Nullable<(effect: Effect, errors: string) => void>;
  35501. /**
  35502. * Callback that will be called when effect is bound.
  35503. */
  35504. onBind: Nullable<(effect: Effect) => void>;
  35505. /**
  35506. * Unique ID of the effect.
  35507. */
  35508. uniqueId: number;
  35509. /**
  35510. * Observable that will be called when the shader is compiled.
  35511. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  35512. */
  35513. onCompileObservable: Observable<Effect>;
  35514. /**
  35515. * Observable that will be called if an error occurs during shader compilation.
  35516. */
  35517. onErrorObservable: Observable<Effect>;
  35518. /** @hidden */
  35519. _onBindObservable: Nullable<Observable<Effect>>;
  35520. /**
  35521. * @hidden
  35522. * Specifies if the effect was previously ready
  35523. */
  35524. _wasPreviouslyReady: boolean;
  35525. /**
  35526. * Observable that will be called when effect is bound.
  35527. */
  35528. get onBindObservable(): Observable<Effect>;
  35529. /** @hidden */
  35530. _bonesComputationForcedToCPU: boolean;
  35531. /** @hidden */
  35532. _multiTarget: boolean;
  35533. private static _uniqueIdSeed;
  35534. private _engine;
  35535. private _uniformBuffersNames;
  35536. private _uniformBuffersNamesList;
  35537. private _uniformsNames;
  35538. private _samplerList;
  35539. private _samplers;
  35540. private _isReady;
  35541. private _compilationError;
  35542. private _allFallbacksProcessed;
  35543. private _attributesNames;
  35544. private _attributes;
  35545. private _attributeLocationByName;
  35546. private _uniforms;
  35547. /**
  35548. * Key for the effect.
  35549. * @hidden
  35550. */
  35551. _key: string;
  35552. private _indexParameters;
  35553. private _fallbacks;
  35554. private _vertexSourceCode;
  35555. private _fragmentSourceCode;
  35556. private _vertexSourceCodeOverride;
  35557. private _fragmentSourceCodeOverride;
  35558. private _transformFeedbackVaryings;
  35559. /**
  35560. * Compiled shader to webGL program.
  35561. * @hidden
  35562. */
  35563. _pipelineContext: Nullable<IPipelineContext>;
  35564. private _valueCache;
  35565. private static _baseCache;
  35566. /**
  35567. * Instantiates an effect.
  35568. * An effect can be used to create/manage/execute vertex and fragment shaders.
  35569. * @param baseName Name of the effect.
  35570. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  35571. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  35572. * @param samplers List of sampler variables that will be passed to the shader.
  35573. * @param engine Engine to be used to render the effect
  35574. * @param defines Define statements to be added to the shader.
  35575. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  35576. * @param onCompiled Callback that will be called when the shader is compiled.
  35577. * @param onError Callback that will be called if an error occurs during shader compilation.
  35578. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35579. */
  35580. 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);
  35581. private _useFinalCode;
  35582. /**
  35583. * Unique key for this effect
  35584. */
  35585. get key(): string;
  35586. /**
  35587. * If the effect has been compiled and prepared.
  35588. * @returns if the effect is compiled and prepared.
  35589. */
  35590. isReady(): boolean;
  35591. private _isReadyInternal;
  35592. /**
  35593. * The engine the effect was initialized with.
  35594. * @returns the engine.
  35595. */
  35596. getEngine(): Engine;
  35597. /**
  35598. * The pipeline context for this effect
  35599. * @returns the associated pipeline context
  35600. */
  35601. getPipelineContext(): Nullable<IPipelineContext>;
  35602. /**
  35603. * The set of names of attribute variables for the shader.
  35604. * @returns An array of attribute names.
  35605. */
  35606. getAttributesNames(): string[];
  35607. /**
  35608. * Returns the attribute at the given index.
  35609. * @param index The index of the attribute.
  35610. * @returns The location of the attribute.
  35611. */
  35612. getAttributeLocation(index: number): number;
  35613. /**
  35614. * Returns the attribute based on the name of the variable.
  35615. * @param name of the attribute to look up.
  35616. * @returns the attribute location.
  35617. */
  35618. getAttributeLocationByName(name: string): number;
  35619. /**
  35620. * The number of attributes.
  35621. * @returns the numnber of attributes.
  35622. */
  35623. getAttributesCount(): number;
  35624. /**
  35625. * Gets the index of a uniform variable.
  35626. * @param uniformName of the uniform to look up.
  35627. * @returns the index.
  35628. */
  35629. getUniformIndex(uniformName: string): number;
  35630. /**
  35631. * Returns the attribute based on the name of the variable.
  35632. * @param uniformName of the uniform to look up.
  35633. * @returns the location of the uniform.
  35634. */
  35635. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  35636. /**
  35637. * Returns an array of sampler variable names
  35638. * @returns The array of sampler variable names.
  35639. */
  35640. getSamplers(): string[];
  35641. /**
  35642. * Returns an array of uniform variable names
  35643. * @returns The array of uniform variable names.
  35644. */
  35645. getUniformNames(): string[];
  35646. /**
  35647. * Returns an array of uniform buffer variable names
  35648. * @returns The array of uniform buffer variable names.
  35649. */
  35650. getUniformBuffersNames(): string[];
  35651. /**
  35652. * Returns the index parameters used to create the effect
  35653. * @returns The index parameters object
  35654. */
  35655. getIndexParameters(): any;
  35656. /**
  35657. * The error from the last compilation.
  35658. * @returns the error string.
  35659. */
  35660. getCompilationError(): string;
  35661. /**
  35662. * Gets a boolean indicating that all fallbacks were used during compilation
  35663. * @returns true if all fallbacks were used
  35664. */
  35665. allFallbacksProcessed(): boolean;
  35666. /**
  35667. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  35668. * @param func The callback to be used.
  35669. */
  35670. executeWhenCompiled(func: (effect: Effect) => void): void;
  35671. private _checkIsReady;
  35672. private _loadShader;
  35673. /**
  35674. * Gets the vertex shader source code of this effect
  35675. */
  35676. get vertexSourceCode(): string;
  35677. /**
  35678. * Gets the fragment shader source code of this effect
  35679. */
  35680. get fragmentSourceCode(): string;
  35681. /**
  35682. * Recompiles the webGL program
  35683. * @param vertexSourceCode The source code for the vertex shader.
  35684. * @param fragmentSourceCode The source code for the fragment shader.
  35685. * @param onCompiled Callback called when completed.
  35686. * @param onError Callback called on error.
  35687. * @hidden
  35688. */
  35689. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  35690. /**
  35691. * Prepares the effect
  35692. * @hidden
  35693. */
  35694. _prepareEffect(): void;
  35695. private _getShaderCodeAndErrorLine;
  35696. private _processCompilationErrors;
  35697. /**
  35698. * Checks if the effect is supported. (Must be called after compilation)
  35699. */
  35700. get isSupported(): boolean;
  35701. /**
  35702. * Binds a texture to the engine to be used as output of the shader.
  35703. * @param channel Name of the output variable.
  35704. * @param texture Texture to bind.
  35705. * @hidden
  35706. */
  35707. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  35708. /**
  35709. * Sets a texture on the engine to be used in the shader.
  35710. * @param channel Name of the sampler variable.
  35711. * @param texture Texture to set.
  35712. */
  35713. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  35714. /**
  35715. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  35716. * @param channel Name of the sampler variable.
  35717. * @param texture Texture to set.
  35718. */
  35719. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  35720. /**
  35721. * Sets an array of textures on the engine to be used in the shader.
  35722. * @param channel Name of the variable.
  35723. * @param textures Textures to set.
  35724. */
  35725. setTextureArray(channel: string, textures: BaseTexture[]): void;
  35726. /**
  35727. * 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)
  35728. * @param channel Name of the sampler variable.
  35729. * @param postProcess Post process to get the input texture from.
  35730. */
  35731. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  35732. /**
  35733. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  35734. * 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)
  35735. * @param channel Name of the sampler variable.
  35736. * @param postProcess Post process to get the output texture from.
  35737. */
  35738. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  35739. /** @hidden */
  35740. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  35741. /** @hidden */
  35742. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  35743. /** @hidden */
  35744. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  35745. /** @hidden */
  35746. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  35747. /**
  35748. * Binds a buffer to a uniform.
  35749. * @param buffer Buffer to bind.
  35750. * @param name Name of the uniform variable to bind to.
  35751. */
  35752. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  35753. /**
  35754. * Binds block to a uniform.
  35755. * @param blockName Name of the block to bind.
  35756. * @param index Index to bind.
  35757. */
  35758. bindUniformBlock(blockName: string, index: number): void;
  35759. /**
  35760. * Sets an interger value on a uniform variable.
  35761. * @param uniformName Name of the variable.
  35762. * @param value Value to be set.
  35763. * @returns this effect.
  35764. */
  35765. setInt(uniformName: string, value: number): Effect;
  35766. /**
  35767. * Sets an int array on a uniform variable.
  35768. * @param uniformName Name of the variable.
  35769. * @param array array to be set.
  35770. * @returns this effect.
  35771. */
  35772. setIntArray(uniformName: string, array: Int32Array): Effect;
  35773. /**
  35774. * 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)
  35775. * @param uniformName Name of the variable.
  35776. * @param array array to be set.
  35777. * @returns this effect.
  35778. */
  35779. setIntArray2(uniformName: string, array: Int32Array): Effect;
  35780. /**
  35781. * 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)
  35782. * @param uniformName Name of the variable.
  35783. * @param array array to be set.
  35784. * @returns this effect.
  35785. */
  35786. setIntArray3(uniformName: string, array: Int32Array): Effect;
  35787. /**
  35788. * 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)
  35789. * @param uniformName Name of the variable.
  35790. * @param array array to be set.
  35791. * @returns this effect.
  35792. */
  35793. setIntArray4(uniformName: string, array: Int32Array): Effect;
  35794. /**
  35795. * Sets an float array on a uniform variable.
  35796. * @param uniformName Name of the variable.
  35797. * @param array array to be set.
  35798. * @returns this effect.
  35799. */
  35800. setFloatArray(uniformName: string, array: Float32Array): Effect;
  35801. /**
  35802. * 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)
  35803. * @param uniformName Name of the variable.
  35804. * @param array array to be set.
  35805. * @returns this effect.
  35806. */
  35807. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  35808. /**
  35809. * 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)
  35810. * @param uniformName Name of the variable.
  35811. * @param array array to be set.
  35812. * @returns this effect.
  35813. */
  35814. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  35815. /**
  35816. * 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)
  35817. * @param uniformName Name of the variable.
  35818. * @param array array to be set.
  35819. * @returns this effect.
  35820. */
  35821. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  35822. /**
  35823. * Sets an array on a uniform variable.
  35824. * @param uniformName Name of the variable.
  35825. * @param array array to be set.
  35826. * @returns this effect.
  35827. */
  35828. setArray(uniformName: string, array: number[]): Effect;
  35829. /**
  35830. * 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)
  35831. * @param uniformName Name of the variable.
  35832. * @param array array to be set.
  35833. * @returns this effect.
  35834. */
  35835. setArray2(uniformName: string, array: number[]): Effect;
  35836. /**
  35837. * 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)
  35838. * @param uniformName Name of the variable.
  35839. * @param array array to be set.
  35840. * @returns this effect.
  35841. */
  35842. setArray3(uniformName: string, array: number[]): Effect;
  35843. /**
  35844. * 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)
  35845. * @param uniformName Name of the variable.
  35846. * @param array array to be set.
  35847. * @returns this effect.
  35848. */
  35849. setArray4(uniformName: string, array: number[]): Effect;
  35850. /**
  35851. * Sets matrices on a uniform variable.
  35852. * @param uniformName Name of the variable.
  35853. * @param matrices matrices to be set.
  35854. * @returns this effect.
  35855. */
  35856. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  35857. /**
  35858. * Sets matrix on a uniform variable.
  35859. * @param uniformName Name of the variable.
  35860. * @param matrix matrix to be set.
  35861. * @returns this effect.
  35862. */
  35863. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  35864. /**
  35865. * 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)
  35866. * @param uniformName Name of the variable.
  35867. * @param matrix matrix to be set.
  35868. * @returns this effect.
  35869. */
  35870. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35871. /**
  35872. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  35873. * @param uniformName Name of the variable.
  35874. * @param matrix matrix to be set.
  35875. * @returns this effect.
  35876. */
  35877. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35878. /**
  35879. * Sets a float on a uniform variable.
  35880. * @param uniformName Name of the variable.
  35881. * @param value value to be set.
  35882. * @returns this effect.
  35883. */
  35884. setFloat(uniformName: string, value: number): Effect;
  35885. /**
  35886. * Sets a boolean on a uniform variable.
  35887. * @param uniformName Name of the variable.
  35888. * @param bool value to be set.
  35889. * @returns this effect.
  35890. */
  35891. setBool(uniformName: string, bool: boolean): Effect;
  35892. /**
  35893. * Sets a Vector2 on a uniform variable.
  35894. * @param uniformName Name of the variable.
  35895. * @param vector2 vector2 to be set.
  35896. * @returns this effect.
  35897. */
  35898. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  35899. /**
  35900. * Sets a float2 on a uniform variable.
  35901. * @param uniformName Name of the variable.
  35902. * @param x First float in float2.
  35903. * @param y Second float in float2.
  35904. * @returns this effect.
  35905. */
  35906. setFloat2(uniformName: string, x: number, y: number): Effect;
  35907. /**
  35908. * Sets a Vector3 on a uniform variable.
  35909. * @param uniformName Name of the variable.
  35910. * @param vector3 Value to be set.
  35911. * @returns this effect.
  35912. */
  35913. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  35914. /**
  35915. * Sets a float3 on a uniform variable.
  35916. * @param uniformName Name of the variable.
  35917. * @param x First float in float3.
  35918. * @param y Second float in float3.
  35919. * @param z Third float in float3.
  35920. * @returns this effect.
  35921. */
  35922. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  35923. /**
  35924. * Sets a Vector4 on a uniform variable.
  35925. * @param uniformName Name of the variable.
  35926. * @param vector4 Value to be set.
  35927. * @returns this effect.
  35928. */
  35929. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  35930. /**
  35931. * Sets a float4 on a uniform variable.
  35932. * @param uniformName Name of the variable.
  35933. * @param x First float in float4.
  35934. * @param y Second float in float4.
  35935. * @param z Third float in float4.
  35936. * @param w Fourth float in float4.
  35937. * @returns this effect.
  35938. */
  35939. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  35940. /**
  35941. * Sets a Color3 on a uniform variable.
  35942. * @param uniformName Name of the variable.
  35943. * @param color3 Value to be set.
  35944. * @returns this effect.
  35945. */
  35946. setColor3(uniformName: string, color3: IColor3Like): Effect;
  35947. /**
  35948. * Sets a Color4 on a uniform variable.
  35949. * @param uniformName Name of the variable.
  35950. * @param color3 Value to be set.
  35951. * @param alpha Alpha value to be set.
  35952. * @returns this effect.
  35953. */
  35954. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  35955. /**
  35956. * Sets a Color4 on a uniform variable
  35957. * @param uniformName defines the name of the variable
  35958. * @param color4 defines the value to be set
  35959. * @returns this effect.
  35960. */
  35961. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  35962. /** Release all associated resources */
  35963. dispose(): void;
  35964. /**
  35965. * This function will add a new shader to the shader store
  35966. * @param name the name of the shader
  35967. * @param pixelShader optional pixel shader content
  35968. * @param vertexShader optional vertex shader content
  35969. */
  35970. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  35971. /**
  35972. * Store of each shader (The can be looked up using effect.key)
  35973. */
  35974. static ShadersStore: {
  35975. [key: string]: string;
  35976. };
  35977. /**
  35978. * Store of each included file for a shader (The can be looked up using effect.key)
  35979. */
  35980. static IncludesShadersStore: {
  35981. [key: string]: string;
  35982. };
  35983. /**
  35984. * Resets the cache of effects.
  35985. */
  35986. static ResetCache(): void;
  35987. }
  35988. }
  35989. declare module "babylonjs/Engines/engineCapabilities" {
  35990. /**
  35991. * Interface used to describe the capabilities of the engine relatively to the current browser
  35992. */
  35993. export interface EngineCapabilities {
  35994. /** Maximum textures units per fragment shader */
  35995. maxTexturesImageUnits: number;
  35996. /** Maximum texture units per vertex shader */
  35997. maxVertexTextureImageUnits: number;
  35998. /** Maximum textures units in the entire pipeline */
  35999. maxCombinedTexturesImageUnits: number;
  36000. /** Maximum texture size */
  36001. maxTextureSize: number;
  36002. /** Maximum texture samples */
  36003. maxSamples?: number;
  36004. /** Maximum cube texture size */
  36005. maxCubemapTextureSize: number;
  36006. /** Maximum render texture size */
  36007. maxRenderTextureSize: number;
  36008. /** Maximum number of vertex attributes */
  36009. maxVertexAttribs: number;
  36010. /** Maximum number of varyings */
  36011. maxVaryingVectors: number;
  36012. /** Maximum number of uniforms per vertex shader */
  36013. maxVertexUniformVectors: number;
  36014. /** Maximum number of uniforms per fragment shader */
  36015. maxFragmentUniformVectors: number;
  36016. /** Defines if standard derivates (dx/dy) are supported */
  36017. standardDerivatives: boolean;
  36018. /** Defines if s3tc texture compression is supported */
  36019. s3tc?: WEBGL_compressed_texture_s3tc;
  36020. /** Defines if pvrtc texture compression is supported */
  36021. pvrtc: any;
  36022. /** Defines if etc1 texture compression is supported */
  36023. etc1: any;
  36024. /** Defines if etc2 texture compression is supported */
  36025. etc2: any;
  36026. /** Defines if astc texture compression is supported */
  36027. astc: any;
  36028. /** Defines if bptc texture compression is supported */
  36029. bptc: any;
  36030. /** Defines if float textures are supported */
  36031. textureFloat: boolean;
  36032. /** Defines if vertex array objects are supported */
  36033. vertexArrayObject: boolean;
  36034. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  36035. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  36036. /** Gets the maximum level of anisotropy supported */
  36037. maxAnisotropy: number;
  36038. /** Defines if instancing is supported */
  36039. instancedArrays: boolean;
  36040. /** Defines if 32 bits indices are supported */
  36041. uintIndices: boolean;
  36042. /** Defines if high precision shaders are supported */
  36043. highPrecisionShaderSupported: boolean;
  36044. /** Defines if depth reading in the fragment shader is supported */
  36045. fragmentDepthSupported: boolean;
  36046. /** Defines if float texture linear filtering is supported*/
  36047. textureFloatLinearFiltering: boolean;
  36048. /** Defines if rendering to float textures is supported */
  36049. textureFloatRender: boolean;
  36050. /** Defines if half float textures are supported*/
  36051. textureHalfFloat: boolean;
  36052. /** Defines if half float texture linear filtering is supported*/
  36053. textureHalfFloatLinearFiltering: boolean;
  36054. /** Defines if rendering to half float textures is supported */
  36055. textureHalfFloatRender: boolean;
  36056. /** Defines if textureLOD shader command is supported */
  36057. textureLOD: boolean;
  36058. /** Defines if draw buffers extension is supported */
  36059. drawBuffersExtension: boolean;
  36060. /** Defines if depth textures are supported */
  36061. depthTextureExtension: boolean;
  36062. /** Defines if float color buffer are supported */
  36063. colorBufferFloat: boolean;
  36064. /** Gets disjoint timer query extension (null if not supported) */
  36065. timerQuery?: EXT_disjoint_timer_query;
  36066. /** Defines if timestamp can be used with timer query */
  36067. canUseTimestampForTimerQuery: boolean;
  36068. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  36069. multiview?: any;
  36070. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  36071. oculusMultiview?: any;
  36072. /** Function used to let the system compiles shaders in background */
  36073. parallelShaderCompile?: {
  36074. COMPLETION_STATUS_KHR: number;
  36075. };
  36076. /** Max number of texture samples for MSAA */
  36077. maxMSAASamples: number;
  36078. /** Defines if the blend min max extension is supported */
  36079. blendMinMax: boolean;
  36080. }
  36081. }
  36082. declare module "babylonjs/States/depthCullingState" {
  36083. import { Nullable } from "babylonjs/types";
  36084. /**
  36085. * @hidden
  36086. **/
  36087. export class DepthCullingState {
  36088. private _isDepthTestDirty;
  36089. private _isDepthMaskDirty;
  36090. private _isDepthFuncDirty;
  36091. private _isCullFaceDirty;
  36092. private _isCullDirty;
  36093. private _isZOffsetDirty;
  36094. private _isFrontFaceDirty;
  36095. private _depthTest;
  36096. private _depthMask;
  36097. private _depthFunc;
  36098. private _cull;
  36099. private _cullFace;
  36100. private _zOffset;
  36101. private _frontFace;
  36102. /**
  36103. * Initializes the state.
  36104. */
  36105. constructor();
  36106. get isDirty(): boolean;
  36107. get zOffset(): number;
  36108. set zOffset(value: number);
  36109. get cullFace(): Nullable<number>;
  36110. set cullFace(value: Nullable<number>);
  36111. get cull(): Nullable<boolean>;
  36112. set cull(value: Nullable<boolean>);
  36113. get depthFunc(): Nullable<number>;
  36114. set depthFunc(value: Nullable<number>);
  36115. get depthMask(): boolean;
  36116. set depthMask(value: boolean);
  36117. get depthTest(): boolean;
  36118. set depthTest(value: boolean);
  36119. get frontFace(): Nullable<number>;
  36120. set frontFace(value: Nullable<number>);
  36121. reset(): void;
  36122. apply(gl: WebGLRenderingContext): void;
  36123. }
  36124. }
  36125. declare module "babylonjs/States/stencilState" {
  36126. /**
  36127. * @hidden
  36128. **/
  36129. export class StencilState {
  36130. /** 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 */
  36131. static readonly ALWAYS: number;
  36132. /** Passed to stencilOperation to specify that stencil value must be kept */
  36133. static readonly KEEP: number;
  36134. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36135. static readonly REPLACE: number;
  36136. private _isStencilTestDirty;
  36137. private _isStencilMaskDirty;
  36138. private _isStencilFuncDirty;
  36139. private _isStencilOpDirty;
  36140. private _stencilTest;
  36141. private _stencilMask;
  36142. private _stencilFunc;
  36143. private _stencilFuncRef;
  36144. private _stencilFuncMask;
  36145. private _stencilOpStencilFail;
  36146. private _stencilOpDepthFail;
  36147. private _stencilOpStencilDepthPass;
  36148. get isDirty(): boolean;
  36149. get stencilFunc(): number;
  36150. set stencilFunc(value: number);
  36151. get stencilFuncRef(): number;
  36152. set stencilFuncRef(value: number);
  36153. get stencilFuncMask(): number;
  36154. set stencilFuncMask(value: number);
  36155. get stencilOpStencilFail(): number;
  36156. set stencilOpStencilFail(value: number);
  36157. get stencilOpDepthFail(): number;
  36158. set stencilOpDepthFail(value: number);
  36159. get stencilOpStencilDepthPass(): number;
  36160. set stencilOpStencilDepthPass(value: number);
  36161. get stencilMask(): number;
  36162. set stencilMask(value: number);
  36163. get stencilTest(): boolean;
  36164. set stencilTest(value: boolean);
  36165. constructor();
  36166. reset(): void;
  36167. apply(gl: WebGLRenderingContext): void;
  36168. }
  36169. }
  36170. declare module "babylonjs/States/alphaCullingState" {
  36171. /**
  36172. * @hidden
  36173. **/
  36174. export class AlphaState {
  36175. private _isAlphaBlendDirty;
  36176. private _isBlendFunctionParametersDirty;
  36177. private _isBlendEquationParametersDirty;
  36178. private _isBlendConstantsDirty;
  36179. private _alphaBlend;
  36180. private _blendFunctionParameters;
  36181. private _blendEquationParameters;
  36182. private _blendConstants;
  36183. /**
  36184. * Initializes the state.
  36185. */
  36186. constructor();
  36187. get isDirty(): boolean;
  36188. get alphaBlend(): boolean;
  36189. set alphaBlend(value: boolean);
  36190. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36191. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36192. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36193. reset(): void;
  36194. apply(gl: WebGLRenderingContext): void;
  36195. }
  36196. }
  36197. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  36198. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36199. /** @hidden */
  36200. export class WebGL2ShaderProcessor implements IShaderProcessor {
  36201. attributeProcessor(attribute: string): string;
  36202. varyingProcessor(varying: string, isFragment: boolean): string;
  36203. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  36204. }
  36205. }
  36206. declare module "babylonjs/Engines/instancingAttributeInfo" {
  36207. /**
  36208. * Interface for attribute information associated with buffer instanciation
  36209. */
  36210. export interface InstancingAttributeInfo {
  36211. /**
  36212. * Name of the GLSL attribute
  36213. * if attribute index is not specified, this is used to retrieve the index from the effect
  36214. */
  36215. attributeName: string;
  36216. /**
  36217. * Index/offset of the attribute in the vertex shader
  36218. * if not specified, this will be computes from the name.
  36219. */
  36220. index?: number;
  36221. /**
  36222. * size of the attribute, 1, 2, 3 or 4
  36223. */
  36224. attributeSize: number;
  36225. /**
  36226. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  36227. */
  36228. offset: number;
  36229. /**
  36230. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  36231. * default to 1
  36232. */
  36233. divisor?: number;
  36234. /**
  36235. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  36236. * default is FLOAT
  36237. */
  36238. attributeType?: number;
  36239. /**
  36240. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  36241. */
  36242. normalized?: boolean;
  36243. }
  36244. }
  36245. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  36246. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36247. import { Nullable } from "babylonjs/types";
  36248. module "babylonjs/Engines/thinEngine" {
  36249. interface ThinEngine {
  36250. /**
  36251. * Update a video texture
  36252. * @param texture defines the texture to update
  36253. * @param video defines the video element to use
  36254. * @param invertY defines if data must be stored with Y axis inverted
  36255. */
  36256. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  36257. }
  36258. }
  36259. }
  36260. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  36261. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36262. import { Nullable } from "babylonjs/types";
  36263. module "babylonjs/Engines/thinEngine" {
  36264. interface ThinEngine {
  36265. /**
  36266. * Creates a dynamic texture
  36267. * @param width defines the width of the texture
  36268. * @param height defines the height of the texture
  36269. * @param generateMipMaps defines if the engine should generate the mip levels
  36270. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  36271. * @returns the dynamic texture inside an InternalTexture
  36272. */
  36273. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  36274. /**
  36275. * Update the content of a dynamic texture
  36276. * @param texture defines the texture to update
  36277. * @param canvas defines the canvas containing the source
  36278. * @param invertY defines if data must be stored with Y axis inverted
  36279. * @param premulAlpha defines if alpha is stored as premultiplied
  36280. * @param format defines the format of the data
  36281. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  36282. */
  36283. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  36284. }
  36285. }
  36286. }
  36287. declare module "babylonjs/Materials/Textures/videoTexture" {
  36288. import { Observable } from "babylonjs/Misc/observable";
  36289. import { Nullable } from "babylonjs/types";
  36290. import { Scene } from "babylonjs/scene";
  36291. import { Texture } from "babylonjs/Materials/Textures/texture";
  36292. import "babylonjs/Engines/Extensions/engine.videoTexture";
  36293. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  36294. /**
  36295. * Settings for finer control over video usage
  36296. */
  36297. export interface VideoTextureSettings {
  36298. /**
  36299. * Applies `autoplay` to video, if specified
  36300. */
  36301. autoPlay?: boolean;
  36302. /**
  36303. * Applies `loop` to video, if specified
  36304. */
  36305. loop?: boolean;
  36306. /**
  36307. * Automatically updates internal texture from video at every frame in the render loop
  36308. */
  36309. autoUpdateTexture: boolean;
  36310. /**
  36311. * Image src displayed during the video loading or until the user interacts with the video.
  36312. */
  36313. poster?: string;
  36314. }
  36315. /**
  36316. * If you want to display a video in your scene, this is the special texture for that.
  36317. * This special texture works similar to other textures, with the exception of a few parameters.
  36318. * @see https://doc.babylonjs.com/how_to/video_texture
  36319. */
  36320. export class VideoTexture extends Texture {
  36321. /**
  36322. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  36323. */
  36324. readonly autoUpdateTexture: boolean;
  36325. /**
  36326. * The video instance used by the texture internally
  36327. */
  36328. readonly video: HTMLVideoElement;
  36329. private _onUserActionRequestedObservable;
  36330. /**
  36331. * Event triggerd when a dom action is required by the user to play the video.
  36332. * This happens due to recent changes in browser policies preventing video to auto start.
  36333. */
  36334. get onUserActionRequestedObservable(): Observable<Texture>;
  36335. private _generateMipMaps;
  36336. private _stillImageCaptured;
  36337. private _displayingPosterTexture;
  36338. private _settings;
  36339. private _createInternalTextureOnEvent;
  36340. private _frameId;
  36341. private _currentSrc;
  36342. /**
  36343. * Creates a video texture.
  36344. * If you want to display a video in your scene, this is the special texture for that.
  36345. * This special texture works similar to other textures, with the exception of a few parameters.
  36346. * @see https://doc.babylonjs.com/how_to/video_texture
  36347. * @param name optional name, will detect from video source, if not defined
  36348. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  36349. * @param scene is obviously the current scene.
  36350. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  36351. * @param invertY is false by default but can be used to invert video on Y axis
  36352. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  36353. * @param settings allows finer control over video usage
  36354. */
  36355. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  36356. private _getName;
  36357. private _getVideo;
  36358. private _createInternalTexture;
  36359. private reset;
  36360. /**
  36361. * @hidden Internal method to initiate `update`.
  36362. */
  36363. _rebuild(): void;
  36364. /**
  36365. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  36366. */
  36367. update(): void;
  36368. /**
  36369. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  36370. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  36371. */
  36372. updateTexture(isVisible: boolean): void;
  36373. protected _updateInternalTexture: () => void;
  36374. /**
  36375. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  36376. * @param url New url.
  36377. */
  36378. updateURL(url: string): void;
  36379. /**
  36380. * Clones the texture.
  36381. * @returns the cloned texture
  36382. */
  36383. clone(): VideoTexture;
  36384. /**
  36385. * Dispose the texture and release its associated resources.
  36386. */
  36387. dispose(): void;
  36388. /**
  36389. * Creates a video texture straight from a stream.
  36390. * @param scene Define the scene the texture should be created in
  36391. * @param stream Define the stream the texture should be created from
  36392. * @returns The created video texture as a promise
  36393. */
  36394. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  36395. /**
  36396. * Creates a video texture straight from your WebCam video feed.
  36397. * @param scene Define the scene the texture should be created in
  36398. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36399. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36400. * @returns The created video texture as a promise
  36401. */
  36402. static CreateFromWebCamAsync(scene: Scene, constraints: {
  36403. minWidth: number;
  36404. maxWidth: number;
  36405. minHeight: number;
  36406. maxHeight: number;
  36407. deviceId: string;
  36408. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  36409. /**
  36410. * Creates a video texture straight from your WebCam video feed.
  36411. * @param scene Define the scene the texture should be created in
  36412. * @param onReady Define a callback to triggered once the texture will be ready
  36413. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36414. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36415. */
  36416. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  36417. minWidth: number;
  36418. maxWidth: number;
  36419. minHeight: number;
  36420. maxHeight: number;
  36421. deviceId: string;
  36422. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  36423. }
  36424. }
  36425. declare module "babylonjs/Engines/thinEngine" {
  36426. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  36427. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  36428. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36429. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36430. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  36431. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  36432. import { Observable } from "babylonjs/Misc/observable";
  36433. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  36434. import { StencilState } from "babylonjs/States/stencilState";
  36435. import { AlphaState } from "babylonjs/States/alphaCullingState";
  36436. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36437. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  36438. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  36439. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36440. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  36441. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  36442. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  36443. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  36444. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36445. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36446. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  36447. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  36448. import { WebRequest } from "babylonjs/Misc/webRequest";
  36449. import { LoadFileError } from "babylonjs/Misc/fileTools";
  36450. /**
  36451. * Defines the interface used by objects working like Scene
  36452. * @hidden
  36453. */
  36454. export interface ISceneLike {
  36455. _addPendingData(data: any): void;
  36456. _removePendingData(data: any): void;
  36457. offlineProvider: IOfflineProvider;
  36458. }
  36459. /**
  36460. * Information about the current host
  36461. */
  36462. export interface HostInformation {
  36463. /**
  36464. * Defines if the current host is a mobile
  36465. */
  36466. isMobile: boolean;
  36467. }
  36468. /** Interface defining initialization parameters for Engine class */
  36469. export interface EngineOptions extends WebGLContextAttributes {
  36470. /**
  36471. * Defines if the engine should no exceed a specified device ratio
  36472. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  36473. */
  36474. limitDeviceRatio?: number;
  36475. /**
  36476. * Defines if webvr should be enabled automatically
  36477. * @see https://doc.babylonjs.com/how_to/webvr_camera
  36478. */
  36479. autoEnableWebVR?: boolean;
  36480. /**
  36481. * Defines if webgl2 should be turned off even if supported
  36482. * @see https://doc.babylonjs.com/features/webgl2
  36483. */
  36484. disableWebGL2Support?: boolean;
  36485. /**
  36486. * Defines if webaudio should be initialized as well
  36487. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36488. */
  36489. audioEngine?: boolean;
  36490. /**
  36491. * Defines if animations should run using a deterministic lock step
  36492. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36493. */
  36494. deterministicLockstep?: boolean;
  36495. /** Defines the maximum steps to use with deterministic lock step mode */
  36496. lockstepMaxSteps?: number;
  36497. /** Defines the seconds between each deterministic lock step */
  36498. timeStep?: number;
  36499. /**
  36500. * Defines that engine should ignore context lost events
  36501. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  36502. */
  36503. doNotHandleContextLost?: boolean;
  36504. /**
  36505. * Defines that engine should ignore modifying touch action attribute and style
  36506. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  36507. */
  36508. doNotHandleTouchAction?: boolean;
  36509. /**
  36510. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  36511. */
  36512. useHighPrecisionFloats?: boolean;
  36513. /**
  36514. * Make the canvas XR Compatible for XR sessions
  36515. */
  36516. xrCompatible?: boolean;
  36517. /**
  36518. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  36519. */
  36520. useHighPrecisionMatrix?: boolean;
  36521. }
  36522. /**
  36523. * The base engine class (root of all engines)
  36524. */
  36525. export class ThinEngine {
  36526. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  36527. static ExceptionList: ({
  36528. key: string;
  36529. capture: string;
  36530. captureConstraint: number;
  36531. targets: string[];
  36532. } | {
  36533. key: string;
  36534. capture: null;
  36535. captureConstraint: null;
  36536. targets: string[];
  36537. })[];
  36538. /** @hidden */
  36539. static _TextureLoaders: IInternalTextureLoader[];
  36540. /**
  36541. * Returns the current npm package of the sdk
  36542. */
  36543. static get NpmPackage(): string;
  36544. /**
  36545. * Returns the current version of the framework
  36546. */
  36547. static get Version(): string;
  36548. /**
  36549. * Returns a string describing the current engine
  36550. */
  36551. get description(): string;
  36552. /**
  36553. * Gets or sets the epsilon value used by collision engine
  36554. */
  36555. static CollisionsEpsilon: number;
  36556. /**
  36557. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  36558. */
  36559. static get ShadersRepository(): string;
  36560. static set ShadersRepository(value: string);
  36561. /** @hidden */
  36562. _shaderProcessor: IShaderProcessor;
  36563. /**
  36564. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  36565. */
  36566. forcePOTTextures: boolean;
  36567. /**
  36568. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  36569. */
  36570. isFullscreen: boolean;
  36571. /**
  36572. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  36573. */
  36574. cullBackFaces: boolean;
  36575. /**
  36576. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  36577. */
  36578. renderEvenInBackground: boolean;
  36579. /**
  36580. * Gets or sets a boolean indicating that cache can be kept between frames
  36581. */
  36582. preventCacheWipeBetweenFrames: boolean;
  36583. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  36584. validateShaderPrograms: boolean;
  36585. /**
  36586. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  36587. * This can provide greater z depth for distant objects.
  36588. */
  36589. useReverseDepthBuffer: boolean;
  36590. /**
  36591. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  36592. */
  36593. disableUniformBuffers: boolean;
  36594. /** @hidden */
  36595. _uniformBuffers: UniformBuffer[];
  36596. /**
  36597. * Gets a boolean indicating that the engine supports uniform buffers
  36598. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  36599. */
  36600. get supportsUniformBuffers(): boolean;
  36601. /** @hidden */
  36602. _gl: WebGLRenderingContext;
  36603. /** @hidden */
  36604. _webGLVersion: number;
  36605. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  36606. protected _windowIsBackground: boolean;
  36607. protected _creationOptions: EngineOptions;
  36608. protected _highPrecisionShadersAllowed: boolean;
  36609. /** @hidden */
  36610. get _shouldUseHighPrecisionShader(): boolean;
  36611. /**
  36612. * Gets a boolean indicating that only power of 2 textures are supported
  36613. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  36614. */
  36615. get needPOTTextures(): boolean;
  36616. /** @hidden */
  36617. _badOS: boolean;
  36618. /** @hidden */
  36619. _badDesktopOS: boolean;
  36620. private _hardwareScalingLevel;
  36621. /** @hidden */
  36622. _caps: EngineCapabilities;
  36623. private _isStencilEnable;
  36624. private _glVersion;
  36625. private _glRenderer;
  36626. private _glVendor;
  36627. /** @hidden */
  36628. _videoTextureSupported: boolean;
  36629. protected _renderingQueueLaunched: boolean;
  36630. protected _activeRenderLoops: (() => void)[];
  36631. /**
  36632. * Observable signaled when a context lost event is raised
  36633. */
  36634. onContextLostObservable: Observable<ThinEngine>;
  36635. /**
  36636. * Observable signaled when a context restored event is raised
  36637. */
  36638. onContextRestoredObservable: Observable<ThinEngine>;
  36639. private _onContextLost;
  36640. private _onContextRestored;
  36641. protected _contextWasLost: boolean;
  36642. /** @hidden */
  36643. _doNotHandleContextLost: boolean;
  36644. /**
  36645. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  36646. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  36647. */
  36648. get doNotHandleContextLost(): boolean;
  36649. set doNotHandleContextLost(value: boolean);
  36650. /**
  36651. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  36652. */
  36653. disableVertexArrayObjects: boolean;
  36654. /** @hidden */
  36655. protected _colorWrite: boolean;
  36656. /** @hidden */
  36657. protected _colorWriteChanged: boolean;
  36658. /** @hidden */
  36659. protected _depthCullingState: DepthCullingState;
  36660. /** @hidden */
  36661. protected _stencilState: StencilState;
  36662. /** @hidden */
  36663. _alphaState: AlphaState;
  36664. /** @hidden */
  36665. _alphaMode: number;
  36666. /** @hidden */
  36667. _alphaEquation: number;
  36668. /** @hidden */
  36669. _internalTexturesCache: InternalTexture[];
  36670. /** @hidden */
  36671. protected _activeChannel: number;
  36672. private _currentTextureChannel;
  36673. /** @hidden */
  36674. protected _boundTexturesCache: {
  36675. [key: string]: Nullable<InternalTexture>;
  36676. };
  36677. /** @hidden */
  36678. protected _currentEffect: Nullable<Effect>;
  36679. /** @hidden */
  36680. protected _currentProgram: Nullable<WebGLProgram>;
  36681. private _compiledEffects;
  36682. private _vertexAttribArraysEnabled;
  36683. /** @hidden */
  36684. protected _cachedViewport: Nullable<IViewportLike>;
  36685. private _cachedVertexArrayObject;
  36686. /** @hidden */
  36687. protected _cachedVertexBuffers: any;
  36688. /** @hidden */
  36689. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  36690. /** @hidden */
  36691. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  36692. /** @hidden */
  36693. _currentRenderTarget: Nullable<InternalTexture>;
  36694. private _uintIndicesCurrentlySet;
  36695. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  36696. /** @hidden */
  36697. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  36698. /** @hidden */
  36699. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  36700. private _currentBufferPointers;
  36701. private _currentInstanceLocations;
  36702. private _currentInstanceBuffers;
  36703. private _textureUnits;
  36704. /** @hidden */
  36705. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36706. /** @hidden */
  36707. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36708. /** @hidden */
  36709. _boundRenderFunction: any;
  36710. private _vaoRecordInProgress;
  36711. private _mustWipeVertexAttributes;
  36712. private _emptyTexture;
  36713. private _emptyCubeTexture;
  36714. private _emptyTexture3D;
  36715. private _emptyTexture2DArray;
  36716. /** @hidden */
  36717. _frameHandler: number;
  36718. private _nextFreeTextureSlots;
  36719. private _maxSimultaneousTextures;
  36720. private _activeRequests;
  36721. /** @hidden */
  36722. _transformTextureUrl: Nullable<(url: string) => string>;
  36723. /**
  36724. * Gets information about the current host
  36725. */
  36726. hostInformation: HostInformation;
  36727. protected get _supportsHardwareTextureRescaling(): boolean;
  36728. private _framebufferDimensionsObject;
  36729. /**
  36730. * sets the object from which width and height will be taken from when getting render width and height
  36731. * Will fallback to the gl object
  36732. * @param dimensions the framebuffer width and height that will be used.
  36733. */
  36734. set framebufferDimensionsObject(dimensions: Nullable<{
  36735. framebufferWidth: number;
  36736. framebufferHeight: number;
  36737. }>);
  36738. /**
  36739. * Gets the current viewport
  36740. */
  36741. get currentViewport(): Nullable<IViewportLike>;
  36742. /**
  36743. * Gets the default empty texture
  36744. */
  36745. get emptyTexture(): InternalTexture;
  36746. /**
  36747. * Gets the default empty 3D texture
  36748. */
  36749. get emptyTexture3D(): InternalTexture;
  36750. /**
  36751. * Gets the default empty 2D array texture
  36752. */
  36753. get emptyTexture2DArray(): InternalTexture;
  36754. /**
  36755. * Gets the default empty cube texture
  36756. */
  36757. get emptyCubeTexture(): InternalTexture;
  36758. /**
  36759. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  36760. */
  36761. readonly premultipliedAlpha: boolean;
  36762. /**
  36763. * Observable event triggered before each texture is initialized
  36764. */
  36765. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  36766. /**
  36767. * Creates a new engine
  36768. * @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
  36769. * @param antialias defines enable antialiasing (default: false)
  36770. * @param options defines further options to be sent to the getContext() function
  36771. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36772. */
  36773. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36774. private _rebuildInternalTextures;
  36775. private _rebuildEffects;
  36776. /**
  36777. * Gets a boolean indicating if all created effects are ready
  36778. * @returns true if all effects are ready
  36779. */
  36780. areAllEffectsReady(): boolean;
  36781. protected _rebuildBuffers(): void;
  36782. protected _initGLContext(): void;
  36783. /**
  36784. * Gets version of the current webGL context
  36785. */
  36786. get webGLVersion(): number;
  36787. /**
  36788. * Gets a string identifying the name of the class
  36789. * @returns "Engine" string
  36790. */
  36791. getClassName(): string;
  36792. /**
  36793. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  36794. */
  36795. get isStencilEnable(): boolean;
  36796. /** @hidden */
  36797. _prepareWorkingCanvas(): void;
  36798. /**
  36799. * Reset the texture cache to empty state
  36800. */
  36801. resetTextureCache(): void;
  36802. /**
  36803. * Gets an object containing information about the current webGL context
  36804. * @returns an object containing the vender, the renderer and the version of the current webGL context
  36805. */
  36806. getGlInfo(): {
  36807. vendor: string;
  36808. renderer: string;
  36809. version: string;
  36810. };
  36811. /**
  36812. * Defines the hardware scaling level.
  36813. * By default the hardware scaling level is computed from the window device ratio.
  36814. * 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.
  36815. * @param level defines the level to use
  36816. */
  36817. setHardwareScalingLevel(level: number): void;
  36818. /**
  36819. * Gets the current hardware scaling level.
  36820. * By default the hardware scaling level is computed from the window device ratio.
  36821. * 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.
  36822. * @returns a number indicating the current hardware scaling level
  36823. */
  36824. getHardwareScalingLevel(): number;
  36825. /**
  36826. * Gets the list of loaded textures
  36827. * @returns an array containing all loaded textures
  36828. */
  36829. getLoadedTexturesCache(): InternalTexture[];
  36830. /**
  36831. * Gets the object containing all engine capabilities
  36832. * @returns the EngineCapabilities object
  36833. */
  36834. getCaps(): EngineCapabilities;
  36835. /**
  36836. * stop executing a render loop function and remove it from the execution array
  36837. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  36838. */
  36839. stopRenderLoop(renderFunction?: () => void): void;
  36840. /** @hidden */
  36841. _renderLoop(): void;
  36842. /**
  36843. * Gets the HTML canvas attached with the current webGL context
  36844. * @returns a HTML canvas
  36845. */
  36846. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  36847. /**
  36848. * Gets host window
  36849. * @returns the host window object
  36850. */
  36851. getHostWindow(): Nullable<Window>;
  36852. /**
  36853. * Gets the current render width
  36854. * @param useScreen defines if screen size must be used (or the current render target if any)
  36855. * @returns a number defining the current render width
  36856. */
  36857. getRenderWidth(useScreen?: boolean): number;
  36858. /**
  36859. * Gets the current render height
  36860. * @param useScreen defines if screen size must be used (or the current render target if any)
  36861. * @returns a number defining the current render height
  36862. */
  36863. getRenderHeight(useScreen?: boolean): number;
  36864. /**
  36865. * Can be used to override the current requestAnimationFrame requester.
  36866. * @hidden
  36867. */
  36868. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  36869. /**
  36870. * Register and execute a render loop. The engine can have more than one render function
  36871. * @param renderFunction defines the function to continuously execute
  36872. */
  36873. runRenderLoop(renderFunction: () => void): void;
  36874. /**
  36875. * Clear the current render buffer or the current render target (if any is set up)
  36876. * @param color defines the color to use
  36877. * @param backBuffer defines if the back buffer must be cleared
  36878. * @param depth defines if the depth buffer must be cleared
  36879. * @param stencil defines if the stencil buffer must be cleared
  36880. */
  36881. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  36882. private _viewportCached;
  36883. /** @hidden */
  36884. _viewport(x: number, y: number, width: number, height: number): void;
  36885. /**
  36886. * Set the WebGL's viewport
  36887. * @param viewport defines the viewport element to be used
  36888. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  36889. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  36890. */
  36891. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  36892. /**
  36893. * Begin a new frame
  36894. */
  36895. beginFrame(): void;
  36896. /**
  36897. * Enf the current frame
  36898. */
  36899. endFrame(): void;
  36900. /**
  36901. * Resize the view according to the canvas' size
  36902. */
  36903. resize(): void;
  36904. /**
  36905. * Force a specific size of the canvas
  36906. * @param width defines the new canvas' width
  36907. * @param height defines the new canvas' height
  36908. * @returns true if the size was changed
  36909. */
  36910. setSize(width: number, height: number): boolean;
  36911. /**
  36912. * Binds the frame buffer to the specified texture.
  36913. * @param texture The texture to render to or null for the default canvas
  36914. * @param faceIndex The face of the texture to render to in case of cube texture
  36915. * @param requiredWidth The width of the target to render to
  36916. * @param requiredHeight The height of the target to render to
  36917. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  36918. * @param lodLevel defines the lod level to bind to the frame buffer
  36919. * @param layer defines the 2d array index to bind to frame buffer to
  36920. */
  36921. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  36922. /** @hidden */
  36923. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  36924. /**
  36925. * Unbind the current render target texture from the webGL context
  36926. * @param texture defines the render target texture to unbind
  36927. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  36928. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  36929. */
  36930. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  36931. /**
  36932. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  36933. */
  36934. flushFramebuffer(): void;
  36935. /**
  36936. * Unbind the current render target and bind the default framebuffer
  36937. */
  36938. restoreDefaultFramebuffer(): void;
  36939. /** @hidden */
  36940. protected _resetVertexBufferBinding(): void;
  36941. /**
  36942. * Creates a vertex buffer
  36943. * @param data the data for the vertex buffer
  36944. * @returns the new WebGL static buffer
  36945. */
  36946. createVertexBuffer(data: DataArray): DataBuffer;
  36947. private _createVertexBuffer;
  36948. /**
  36949. * Creates a dynamic vertex buffer
  36950. * @param data the data for the dynamic vertex buffer
  36951. * @returns the new WebGL dynamic buffer
  36952. */
  36953. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  36954. protected _resetIndexBufferBinding(): void;
  36955. /**
  36956. * Creates a new index buffer
  36957. * @param indices defines the content of the index buffer
  36958. * @param updatable defines if the index buffer must be updatable
  36959. * @returns a new webGL buffer
  36960. */
  36961. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  36962. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  36963. /**
  36964. * Bind a webGL buffer to the webGL context
  36965. * @param buffer defines the buffer to bind
  36966. */
  36967. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  36968. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  36969. private bindBuffer;
  36970. /**
  36971. * update the bound buffer with the given data
  36972. * @param data defines the data to update
  36973. */
  36974. updateArrayBuffer(data: Float32Array): void;
  36975. private _vertexAttribPointer;
  36976. /** @hidden */
  36977. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  36978. private _bindVertexBuffersAttributes;
  36979. /**
  36980. * Records a vertex array object
  36981. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  36982. * @param vertexBuffers defines the list of vertex buffers to store
  36983. * @param indexBuffer defines the index buffer to store
  36984. * @param effect defines the effect to store
  36985. * @returns the new vertex array object
  36986. */
  36987. recordVertexArrayObject(vertexBuffers: {
  36988. [key: string]: VertexBuffer;
  36989. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  36990. /**
  36991. * Bind a specific vertex array object
  36992. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  36993. * @param vertexArrayObject defines the vertex array object to bind
  36994. * @param indexBuffer defines the index buffer to bind
  36995. */
  36996. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  36997. /**
  36998. * Bind webGl buffers directly to the webGL context
  36999. * @param vertexBuffer defines the vertex buffer to bind
  37000. * @param indexBuffer defines the index buffer to bind
  37001. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  37002. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  37003. * @param effect defines the effect associated with the vertex buffer
  37004. */
  37005. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  37006. private _unbindVertexArrayObject;
  37007. /**
  37008. * Bind a list of vertex buffers to the webGL context
  37009. * @param vertexBuffers defines the list of vertex buffers to bind
  37010. * @param indexBuffer defines the index buffer to bind
  37011. * @param effect defines the effect associated with the vertex buffers
  37012. */
  37013. bindBuffers(vertexBuffers: {
  37014. [key: string]: Nullable<VertexBuffer>;
  37015. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  37016. /**
  37017. * Unbind all instance attributes
  37018. */
  37019. unbindInstanceAttributes(): void;
  37020. /**
  37021. * Release and free the memory of a vertex array object
  37022. * @param vao defines the vertex array object to delete
  37023. */
  37024. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  37025. /** @hidden */
  37026. _releaseBuffer(buffer: DataBuffer): boolean;
  37027. protected _deleteBuffer(buffer: DataBuffer): void;
  37028. /**
  37029. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  37030. * @param instancesBuffer defines the webGL buffer to update and bind
  37031. * @param data defines the data to store in the buffer
  37032. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  37033. */
  37034. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  37035. /**
  37036. * Bind the content of a webGL buffer used with instantiation
  37037. * @param instancesBuffer defines the webGL buffer to bind
  37038. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  37039. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  37040. */
  37041. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  37042. /**
  37043. * Disable the instance attribute corresponding to the name in parameter
  37044. * @param name defines the name of the attribute to disable
  37045. */
  37046. disableInstanceAttributeByName(name: string): void;
  37047. /**
  37048. * Disable the instance attribute corresponding to the location in parameter
  37049. * @param attributeLocation defines the attribute location of the attribute to disable
  37050. */
  37051. disableInstanceAttribute(attributeLocation: number): void;
  37052. /**
  37053. * Disable the attribute corresponding to the location in parameter
  37054. * @param attributeLocation defines the attribute location of the attribute to disable
  37055. */
  37056. disableAttributeByIndex(attributeLocation: number): void;
  37057. /**
  37058. * Send a draw order
  37059. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37060. * @param indexStart defines the starting index
  37061. * @param indexCount defines the number of index to draw
  37062. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37063. */
  37064. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  37065. /**
  37066. * Draw a list of points
  37067. * @param verticesStart defines the index of first vertex to draw
  37068. * @param verticesCount defines the count of vertices to draw
  37069. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37070. */
  37071. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37072. /**
  37073. * Draw a list of unindexed primitives
  37074. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37075. * @param verticesStart defines the index of first vertex to draw
  37076. * @param verticesCount defines the count of vertices to draw
  37077. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37078. */
  37079. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37080. /**
  37081. * Draw a list of indexed primitives
  37082. * @param fillMode defines the primitive to use
  37083. * @param indexStart defines the starting index
  37084. * @param indexCount defines the number of index to draw
  37085. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37086. */
  37087. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  37088. /**
  37089. * Draw a list of unindexed primitives
  37090. * @param fillMode defines the primitive to use
  37091. * @param verticesStart defines the index of first vertex to draw
  37092. * @param verticesCount defines the count of vertices to draw
  37093. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37094. */
  37095. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37096. private _drawMode;
  37097. /** @hidden */
  37098. protected _reportDrawCall(): void;
  37099. /** @hidden */
  37100. _releaseEffect(effect: Effect): void;
  37101. /** @hidden */
  37102. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37103. /**
  37104. * Create a new effect (used to store vertex/fragment shaders)
  37105. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  37106. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  37107. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  37108. * @param samplers defines an array of string used to represent textures
  37109. * @param defines defines the string containing the defines to use to compile the shaders
  37110. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  37111. * @param onCompiled defines a function to call when the effect creation is successful
  37112. * @param onError defines a function to call when the effect creation has failed
  37113. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  37114. * @returns the new Effect
  37115. */
  37116. 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;
  37117. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  37118. private _compileShader;
  37119. private _compileRawShader;
  37120. /** @hidden */
  37121. _getShaderSource(shader: WebGLShader): Nullable<string>;
  37122. /**
  37123. * Directly creates a webGL program
  37124. * @param pipelineContext defines the pipeline context to attach to
  37125. * @param vertexCode defines the vertex shader code to use
  37126. * @param fragmentCode defines the fragment shader code to use
  37127. * @param context defines the webGL context to use (if not set, the current one will be used)
  37128. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37129. * @returns the new webGL program
  37130. */
  37131. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37132. /**
  37133. * Creates a webGL program
  37134. * @param pipelineContext defines the pipeline context to attach to
  37135. * @param vertexCode defines the vertex shader code to use
  37136. * @param fragmentCode defines the fragment shader code to use
  37137. * @param defines defines the string containing the defines to use to compile the shaders
  37138. * @param context defines the webGL context to use (if not set, the current one will be used)
  37139. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37140. * @returns the new webGL program
  37141. */
  37142. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37143. /**
  37144. * Creates a new pipeline context
  37145. * @returns the new pipeline
  37146. */
  37147. createPipelineContext(): IPipelineContext;
  37148. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37149. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  37150. /** @hidden */
  37151. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  37152. /** @hidden */
  37153. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  37154. /** @hidden */
  37155. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  37156. /**
  37157. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  37158. * @param pipelineContext defines the pipeline context to use
  37159. * @param uniformsNames defines the list of uniform names
  37160. * @returns an array of webGL uniform locations
  37161. */
  37162. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  37163. /**
  37164. * Gets the lsit of active attributes for a given webGL program
  37165. * @param pipelineContext defines the pipeline context to use
  37166. * @param attributesNames defines the list of attribute names to get
  37167. * @returns an array of indices indicating the offset of each attribute
  37168. */
  37169. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  37170. /**
  37171. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  37172. * @param effect defines the effect to activate
  37173. */
  37174. enableEffect(effect: Nullable<Effect>): void;
  37175. /**
  37176. * Set the value of an uniform to a number (int)
  37177. * @param uniform defines the webGL uniform location where to store the value
  37178. * @param value defines the int number to store
  37179. */
  37180. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  37181. /**
  37182. * Set the value of an uniform to an array of int32
  37183. * @param uniform defines the webGL uniform location where to store the value
  37184. * @param array defines the array of int32 to store
  37185. */
  37186. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37187. /**
  37188. * Set the value of an uniform to an array of int32 (stored as vec2)
  37189. * @param uniform defines the webGL uniform location where to store the value
  37190. * @param array defines the array of int32 to store
  37191. */
  37192. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37193. /**
  37194. * Set the value of an uniform to an array of int32 (stored as vec3)
  37195. * @param uniform defines the webGL uniform location where to store the value
  37196. * @param array defines the array of int32 to store
  37197. */
  37198. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37199. /**
  37200. * Set the value of an uniform to an array of int32 (stored as vec4)
  37201. * @param uniform defines the webGL uniform location where to store the value
  37202. * @param array defines the array of int32 to store
  37203. */
  37204. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  37205. /**
  37206. * Set the value of an uniform to an array of number
  37207. * @param uniform defines the webGL uniform location where to store the value
  37208. * @param array defines the array of number to store
  37209. */
  37210. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37211. /**
  37212. * Set the value of an uniform to an array of number (stored as vec2)
  37213. * @param uniform defines the webGL uniform location where to store the value
  37214. * @param array defines the array of number to store
  37215. */
  37216. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37217. /**
  37218. * Set the value of an uniform to an array of number (stored as vec3)
  37219. * @param uniform defines the webGL uniform location where to store the value
  37220. * @param array defines the array of number to store
  37221. */
  37222. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37223. /**
  37224. * Set the value of an uniform to an array of number (stored as vec4)
  37225. * @param uniform defines the webGL uniform location where to store the value
  37226. * @param array defines the array of number to store
  37227. */
  37228. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  37229. /**
  37230. * Set the value of an uniform to an array of float32 (stored as matrices)
  37231. * @param uniform defines the webGL uniform location where to store the value
  37232. * @param matrices defines the array of float32 to store
  37233. */
  37234. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  37235. /**
  37236. * Set the value of an uniform to a matrix (3x3)
  37237. * @param uniform defines the webGL uniform location where to store the value
  37238. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  37239. */
  37240. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  37241. /**
  37242. * Set the value of an uniform to a matrix (2x2)
  37243. * @param uniform defines the webGL uniform location where to store the value
  37244. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  37245. */
  37246. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  37247. /**
  37248. * Set the value of an uniform to a number (float)
  37249. * @param uniform defines the webGL uniform location where to store the value
  37250. * @param value defines the float number to store
  37251. */
  37252. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  37253. /**
  37254. * Set the value of an uniform to a vec2
  37255. * @param uniform defines the webGL uniform location where to store the value
  37256. * @param x defines the 1st component of the value
  37257. * @param y defines the 2nd component of the value
  37258. */
  37259. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  37260. /**
  37261. * Set the value of an uniform to a vec3
  37262. * @param uniform defines the webGL uniform location where to store the value
  37263. * @param x defines the 1st component of the value
  37264. * @param y defines the 2nd component of the value
  37265. * @param z defines the 3rd component of the value
  37266. */
  37267. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  37268. /**
  37269. * Set the value of an uniform to a vec4
  37270. * @param uniform defines the webGL uniform location where to store the value
  37271. * @param x defines the 1st component of the value
  37272. * @param y defines the 2nd component of the value
  37273. * @param z defines the 3rd component of the value
  37274. * @param w defines the 4th component of the value
  37275. */
  37276. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  37277. /**
  37278. * Apply all cached states (depth, culling, stencil and alpha)
  37279. */
  37280. applyStates(): void;
  37281. /**
  37282. * Enable or disable color writing
  37283. * @param enable defines the state to set
  37284. */
  37285. setColorWrite(enable: boolean): void;
  37286. /**
  37287. * Gets a boolean indicating if color writing is enabled
  37288. * @returns the current color writing state
  37289. */
  37290. getColorWrite(): boolean;
  37291. /**
  37292. * Gets the depth culling state manager
  37293. */
  37294. get depthCullingState(): DepthCullingState;
  37295. /**
  37296. * Gets the alpha state manager
  37297. */
  37298. get alphaState(): AlphaState;
  37299. /**
  37300. * Gets the stencil state manager
  37301. */
  37302. get stencilState(): StencilState;
  37303. /**
  37304. * Clears the list of texture accessible through engine.
  37305. * This can help preventing texture load conflict due to name collision.
  37306. */
  37307. clearInternalTexturesCache(): void;
  37308. /**
  37309. * Force the entire cache to be cleared
  37310. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  37311. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  37312. */
  37313. wipeCaches(bruteForce?: boolean): void;
  37314. /** @hidden */
  37315. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  37316. min: number;
  37317. mag: number;
  37318. };
  37319. /** @hidden */
  37320. _createTexture(): WebGLTexture;
  37321. /**
  37322. * Usually called from Texture.ts.
  37323. * Passed information to create a WebGLTexture
  37324. * @param url defines a value which contains one of the following:
  37325. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  37326. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  37327. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  37328. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  37329. * @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)
  37330. * @param scene needed for loading to the correct scene
  37331. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  37332. * @param onLoad optional callback to be called upon successful completion
  37333. * @param onError optional callback to be called upon failure
  37334. * @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
  37335. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  37336. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  37337. * @param forcedExtension defines the extension to use to pick the right loader
  37338. * @param mimeType defines an optional mime type
  37339. * @returns a InternalTexture for assignment back into BABYLON.Texture
  37340. */
  37341. 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;
  37342. /**
  37343. * Loads an image as an HTMLImageElement.
  37344. * @param input url string, ArrayBuffer, or Blob to load
  37345. * @param onLoad callback called when the image successfully loads
  37346. * @param onError callback called when the image fails to load
  37347. * @param offlineProvider offline provider for caching
  37348. * @param mimeType optional mime type
  37349. * @returns the HTMLImageElement of the loaded image
  37350. * @hidden
  37351. */
  37352. 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>;
  37353. /**
  37354. * @hidden
  37355. */
  37356. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37357. private _unpackFlipYCached;
  37358. /**
  37359. * In case you are sharing the context with other applications, it might
  37360. * be interested to not cache the unpack flip y state to ensure a consistent
  37361. * value would be set.
  37362. */
  37363. enableUnpackFlipYCached: boolean;
  37364. /** @hidden */
  37365. _unpackFlipY(value: boolean): void;
  37366. /** @hidden */
  37367. _getUnpackAlignement(): number;
  37368. private _getTextureTarget;
  37369. /**
  37370. * Update the sampling mode of a given texture
  37371. * @param samplingMode defines the required sampling mode
  37372. * @param texture defines the texture to update
  37373. * @param generateMipMaps defines whether to generate mipmaps for the texture
  37374. */
  37375. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  37376. /**
  37377. * Update the sampling mode of a given texture
  37378. * @param texture defines the texture to update
  37379. * @param wrapU defines the texture wrap mode of the u coordinates
  37380. * @param wrapV defines the texture wrap mode of the v coordinates
  37381. * @param wrapR defines the texture wrap mode of the r coordinates
  37382. */
  37383. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  37384. /** @hidden */
  37385. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  37386. width: number;
  37387. height: number;
  37388. layers?: number;
  37389. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  37390. /** @hidden */
  37391. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37392. /** @hidden */
  37393. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  37394. /**
  37395. * Update a portion of an internal texture
  37396. * @param texture defines the texture to update
  37397. * @param imageData defines the data to store into the texture
  37398. * @param xOffset defines the x coordinates of the update rectangle
  37399. * @param yOffset defines the y coordinates of the update rectangle
  37400. * @param width defines the width of the update rectangle
  37401. * @param height defines the height of the update rectangle
  37402. * @param faceIndex defines the face index if texture is a cube (0 by default)
  37403. * @param lod defines the lod level to update (0 by default)
  37404. */
  37405. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  37406. /** @hidden */
  37407. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37408. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  37409. private _prepareWebGLTexture;
  37410. /** @hidden */
  37411. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  37412. private _getDepthStencilBuffer;
  37413. /** @hidden */
  37414. _releaseFramebufferObjects(texture: InternalTexture): void;
  37415. /** @hidden */
  37416. _releaseTexture(texture: InternalTexture): void;
  37417. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  37418. protected _setProgram(program: WebGLProgram): void;
  37419. protected _boundUniforms: {
  37420. [key: number]: WebGLUniformLocation;
  37421. };
  37422. /**
  37423. * Binds an effect to the webGL context
  37424. * @param effect defines the effect to bind
  37425. */
  37426. bindSamplers(effect: Effect): void;
  37427. private _activateCurrentTexture;
  37428. /** @hidden */
  37429. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  37430. /** @hidden */
  37431. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  37432. /**
  37433. * Unbind all textures from the webGL context
  37434. */
  37435. unbindAllTextures(): void;
  37436. /**
  37437. * Sets a texture to the according uniform.
  37438. * @param channel The texture channel
  37439. * @param uniform The uniform to set
  37440. * @param texture The texture to apply
  37441. */
  37442. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  37443. private _bindSamplerUniformToChannel;
  37444. private _getTextureWrapMode;
  37445. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  37446. /**
  37447. * Sets an array of texture to the webGL context
  37448. * @param channel defines the channel where the texture array must be set
  37449. * @param uniform defines the associated uniform location
  37450. * @param textures defines the array of textures to bind
  37451. */
  37452. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  37453. /** @hidden */
  37454. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  37455. private _setTextureParameterFloat;
  37456. private _setTextureParameterInteger;
  37457. /**
  37458. * Unbind all vertex attributes from the webGL context
  37459. */
  37460. unbindAllAttributes(): void;
  37461. /**
  37462. * 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
  37463. */
  37464. releaseEffects(): void;
  37465. /**
  37466. * Dispose and release all associated resources
  37467. */
  37468. dispose(): void;
  37469. /**
  37470. * Attach a new callback raised when context lost event is fired
  37471. * @param callback defines the callback to call
  37472. */
  37473. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37474. /**
  37475. * Attach a new callback raised when context restored event is fired
  37476. * @param callback defines the callback to call
  37477. */
  37478. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37479. /**
  37480. * Get the current error code of the webGL context
  37481. * @returns the error code
  37482. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  37483. */
  37484. getError(): number;
  37485. private _canRenderToFloatFramebuffer;
  37486. private _canRenderToHalfFloatFramebuffer;
  37487. private _canRenderToFramebuffer;
  37488. /** @hidden */
  37489. _getWebGLTextureType(type: number): number;
  37490. /** @hidden */
  37491. _getInternalFormat(format: number): number;
  37492. /** @hidden */
  37493. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  37494. /** @hidden */
  37495. _getRGBAMultiSampleBufferFormat(type: number): number;
  37496. /** @hidden */
  37497. _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;
  37498. /**
  37499. * Loads a file from a url
  37500. * @param url url to load
  37501. * @param onSuccess callback called when the file successfully loads
  37502. * @param onProgress callback called while file is loading (if the server supports this mode)
  37503. * @param offlineProvider defines the offline provider for caching
  37504. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37505. * @param onError callback called when the file fails to load
  37506. * @returns a file request object
  37507. * @hidden
  37508. */
  37509. 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;
  37510. /**
  37511. * Reads pixels from the current frame buffer. Please note that this function can be slow
  37512. * @param x defines the x coordinate of the rectangle where pixels must be read
  37513. * @param y defines the y coordinate of the rectangle where pixels must be read
  37514. * @param width defines the width of the rectangle where pixels must be read
  37515. * @param height defines the height of the rectangle where pixels must be read
  37516. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  37517. * @returns a Uint8Array containing RGBA colors
  37518. */
  37519. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  37520. private static _isSupported;
  37521. /**
  37522. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  37523. * @returns true if the engine can be created
  37524. * @ignorenaming
  37525. */
  37526. static isSupported(): boolean;
  37527. /**
  37528. * Find the next highest power of two.
  37529. * @param x Number to start search from.
  37530. * @return Next highest power of two.
  37531. */
  37532. static CeilingPOT(x: number): number;
  37533. /**
  37534. * Find the next lowest power of two.
  37535. * @param x Number to start search from.
  37536. * @return Next lowest power of two.
  37537. */
  37538. static FloorPOT(x: number): number;
  37539. /**
  37540. * Find the nearest power of two.
  37541. * @param x Number to start search from.
  37542. * @return Next nearest power of two.
  37543. */
  37544. static NearestPOT(x: number): number;
  37545. /**
  37546. * Get the closest exponent of two
  37547. * @param value defines the value to approximate
  37548. * @param max defines the maximum value to return
  37549. * @param mode defines how to define the closest value
  37550. * @returns closest exponent of two of the given value
  37551. */
  37552. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  37553. /**
  37554. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  37555. * @param func - the function to be called
  37556. * @param requester - the object that will request the next frame. Falls back to window.
  37557. * @returns frame number
  37558. */
  37559. static QueueNewFrame(func: () => void, requester?: any): number;
  37560. /**
  37561. * Gets host document
  37562. * @returns the host document object
  37563. */
  37564. getHostDocument(): Nullable<Document>;
  37565. }
  37566. }
  37567. declare module "babylonjs/Maths/sphericalPolynomial" {
  37568. import { Vector3 } from "babylonjs/Maths/math.vector";
  37569. import { Color3 } from "babylonjs/Maths/math.color";
  37570. /**
  37571. * Class representing spherical harmonics coefficients to the 3rd degree
  37572. */
  37573. export class SphericalHarmonics {
  37574. /**
  37575. * Defines whether or not the harmonics have been prescaled for rendering.
  37576. */
  37577. preScaled: boolean;
  37578. /**
  37579. * The l0,0 coefficients of the spherical harmonics
  37580. */
  37581. l00: Vector3;
  37582. /**
  37583. * The l1,-1 coefficients of the spherical harmonics
  37584. */
  37585. l1_1: Vector3;
  37586. /**
  37587. * The l1,0 coefficients of the spherical harmonics
  37588. */
  37589. l10: Vector3;
  37590. /**
  37591. * The l1,1 coefficients of the spherical harmonics
  37592. */
  37593. l11: Vector3;
  37594. /**
  37595. * The l2,-2 coefficients of the spherical harmonics
  37596. */
  37597. l2_2: Vector3;
  37598. /**
  37599. * The l2,-1 coefficients of the spherical harmonics
  37600. */
  37601. l2_1: Vector3;
  37602. /**
  37603. * The l2,0 coefficients of the spherical harmonics
  37604. */
  37605. l20: Vector3;
  37606. /**
  37607. * The l2,1 coefficients of the spherical harmonics
  37608. */
  37609. l21: Vector3;
  37610. /**
  37611. * The l2,2 coefficients of the spherical harmonics
  37612. */
  37613. l22: Vector3;
  37614. /**
  37615. * Adds a light to the spherical harmonics
  37616. * @param direction the direction of the light
  37617. * @param color the color of the light
  37618. * @param deltaSolidAngle the delta solid angle of the light
  37619. */
  37620. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  37621. /**
  37622. * Scales the spherical harmonics by the given amount
  37623. * @param scale the amount to scale
  37624. */
  37625. scaleInPlace(scale: number): void;
  37626. /**
  37627. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  37628. *
  37629. * ```
  37630. * E_lm = A_l * L_lm
  37631. * ```
  37632. *
  37633. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  37634. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  37635. * the scaling factors are given in equation 9.
  37636. */
  37637. convertIncidentRadianceToIrradiance(): void;
  37638. /**
  37639. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  37640. *
  37641. * ```
  37642. * L = (1/pi) * E * rho
  37643. * ```
  37644. *
  37645. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  37646. */
  37647. convertIrradianceToLambertianRadiance(): void;
  37648. /**
  37649. * Integrates the reconstruction coefficients directly in to the SH preventing further
  37650. * required operations at run time.
  37651. *
  37652. * This is simply done by scaling back the SH with Ylm constants parameter.
  37653. * The trigonometric part being applied by the shader at run time.
  37654. */
  37655. preScaleForRendering(): void;
  37656. /**
  37657. * Constructs a spherical harmonics from an array.
  37658. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  37659. * @returns the spherical harmonics
  37660. */
  37661. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  37662. /**
  37663. * Gets the spherical harmonics from polynomial
  37664. * @param polynomial the spherical polynomial
  37665. * @returns the spherical harmonics
  37666. */
  37667. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  37668. }
  37669. /**
  37670. * Class representing spherical polynomial coefficients to the 3rd degree
  37671. */
  37672. export class SphericalPolynomial {
  37673. private _harmonics;
  37674. /**
  37675. * The spherical harmonics used to create the polynomials.
  37676. */
  37677. get preScaledHarmonics(): SphericalHarmonics;
  37678. /**
  37679. * The x coefficients of the spherical polynomial
  37680. */
  37681. x: Vector3;
  37682. /**
  37683. * The y coefficients of the spherical polynomial
  37684. */
  37685. y: Vector3;
  37686. /**
  37687. * The z coefficients of the spherical polynomial
  37688. */
  37689. z: Vector3;
  37690. /**
  37691. * The xx coefficients of the spherical polynomial
  37692. */
  37693. xx: Vector3;
  37694. /**
  37695. * The yy coefficients of the spherical polynomial
  37696. */
  37697. yy: Vector3;
  37698. /**
  37699. * The zz coefficients of the spherical polynomial
  37700. */
  37701. zz: Vector3;
  37702. /**
  37703. * The xy coefficients of the spherical polynomial
  37704. */
  37705. xy: Vector3;
  37706. /**
  37707. * The yz coefficients of the spherical polynomial
  37708. */
  37709. yz: Vector3;
  37710. /**
  37711. * The zx coefficients of the spherical polynomial
  37712. */
  37713. zx: Vector3;
  37714. /**
  37715. * Adds an ambient color to the spherical polynomial
  37716. * @param color the color to add
  37717. */
  37718. addAmbient(color: Color3): void;
  37719. /**
  37720. * Scales the spherical polynomial by the given amount
  37721. * @param scale the amount to scale
  37722. */
  37723. scaleInPlace(scale: number): void;
  37724. /**
  37725. * Gets the spherical polynomial from harmonics
  37726. * @param harmonics the spherical harmonics
  37727. * @returns the spherical polynomial
  37728. */
  37729. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  37730. /**
  37731. * Constructs a spherical polynomial from an array.
  37732. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  37733. * @returns the spherical polynomial
  37734. */
  37735. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  37736. }
  37737. }
  37738. declare module "babylonjs/Materials/Textures/internalTexture" {
  37739. import { Observable } from "babylonjs/Misc/observable";
  37740. import { Nullable, int } from "babylonjs/types";
  37741. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  37742. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37743. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  37744. /**
  37745. * Defines the source of the internal texture
  37746. */
  37747. export enum InternalTextureSource {
  37748. /**
  37749. * The source of the texture data is unknown
  37750. */
  37751. Unknown = 0,
  37752. /**
  37753. * Texture data comes from an URL
  37754. */
  37755. Url = 1,
  37756. /**
  37757. * Texture data is only used for temporary storage
  37758. */
  37759. Temp = 2,
  37760. /**
  37761. * Texture data comes from raw data (ArrayBuffer)
  37762. */
  37763. Raw = 3,
  37764. /**
  37765. * Texture content is dynamic (video or dynamic texture)
  37766. */
  37767. Dynamic = 4,
  37768. /**
  37769. * Texture content is generated by rendering to it
  37770. */
  37771. RenderTarget = 5,
  37772. /**
  37773. * Texture content is part of a multi render target process
  37774. */
  37775. MultiRenderTarget = 6,
  37776. /**
  37777. * Texture data comes from a cube data file
  37778. */
  37779. Cube = 7,
  37780. /**
  37781. * Texture data comes from a raw cube data
  37782. */
  37783. CubeRaw = 8,
  37784. /**
  37785. * Texture data come from a prefiltered cube data file
  37786. */
  37787. CubePrefiltered = 9,
  37788. /**
  37789. * Texture content is raw 3D data
  37790. */
  37791. Raw3D = 10,
  37792. /**
  37793. * Texture content is raw 2D array data
  37794. */
  37795. Raw2DArray = 11,
  37796. /**
  37797. * Texture content is a depth texture
  37798. */
  37799. Depth = 12,
  37800. /**
  37801. * Texture data comes from a raw cube data encoded with RGBD
  37802. */
  37803. CubeRawRGBD = 13
  37804. }
  37805. /**
  37806. * Class used to store data associated with WebGL texture data for the engine
  37807. * This class should not be used directly
  37808. */
  37809. export class InternalTexture {
  37810. /** @hidden */
  37811. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  37812. /**
  37813. * Defines if the texture is ready
  37814. */
  37815. isReady: boolean;
  37816. /**
  37817. * Defines if the texture is a cube texture
  37818. */
  37819. isCube: boolean;
  37820. /**
  37821. * Defines if the texture contains 3D data
  37822. */
  37823. is3D: boolean;
  37824. /**
  37825. * Defines if the texture contains 2D array data
  37826. */
  37827. is2DArray: boolean;
  37828. /**
  37829. * Defines if the texture contains multiview data
  37830. */
  37831. isMultiview: boolean;
  37832. /**
  37833. * Gets the URL used to load this texture
  37834. */
  37835. url: string;
  37836. /**
  37837. * Gets the sampling mode of the texture
  37838. */
  37839. samplingMode: number;
  37840. /**
  37841. * Gets a boolean indicating if the texture needs mipmaps generation
  37842. */
  37843. generateMipMaps: boolean;
  37844. /**
  37845. * Gets the number of samples used by the texture (WebGL2+ only)
  37846. */
  37847. samples: number;
  37848. /**
  37849. * Gets the type of the texture (int, float...)
  37850. */
  37851. type: number;
  37852. /**
  37853. * Gets the format of the texture (RGB, RGBA...)
  37854. */
  37855. format: number;
  37856. /**
  37857. * Observable called when the texture is loaded
  37858. */
  37859. onLoadedObservable: Observable<InternalTexture>;
  37860. /**
  37861. * Gets the width of the texture
  37862. */
  37863. width: number;
  37864. /**
  37865. * Gets the height of the texture
  37866. */
  37867. height: number;
  37868. /**
  37869. * Gets the depth of the texture
  37870. */
  37871. depth: number;
  37872. /**
  37873. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  37874. */
  37875. baseWidth: number;
  37876. /**
  37877. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  37878. */
  37879. baseHeight: number;
  37880. /**
  37881. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  37882. */
  37883. baseDepth: number;
  37884. /**
  37885. * Gets a boolean indicating if the texture is inverted on Y axis
  37886. */
  37887. invertY: boolean;
  37888. /** @hidden */
  37889. _invertVScale: boolean;
  37890. /** @hidden */
  37891. _associatedChannel: number;
  37892. /** @hidden */
  37893. _source: InternalTextureSource;
  37894. /** @hidden */
  37895. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  37896. /** @hidden */
  37897. _bufferView: Nullable<ArrayBufferView>;
  37898. /** @hidden */
  37899. _bufferViewArray: Nullable<ArrayBufferView[]>;
  37900. /** @hidden */
  37901. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  37902. /** @hidden */
  37903. _size: number;
  37904. /** @hidden */
  37905. _extension: string;
  37906. /** @hidden */
  37907. _files: Nullable<string[]>;
  37908. /** @hidden */
  37909. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  37910. /** @hidden */
  37911. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  37912. /** @hidden */
  37913. _framebuffer: Nullable<WebGLFramebuffer>;
  37914. /** @hidden */
  37915. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  37916. /** @hidden */
  37917. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  37918. /** @hidden */
  37919. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  37920. /** @hidden */
  37921. _attachments: Nullable<number[]>;
  37922. /** @hidden */
  37923. _textureArray: Nullable<InternalTexture[]>;
  37924. /** @hidden */
  37925. _cachedCoordinatesMode: Nullable<number>;
  37926. /** @hidden */
  37927. _cachedWrapU: Nullable<number>;
  37928. /** @hidden */
  37929. _cachedWrapV: Nullable<number>;
  37930. /** @hidden */
  37931. _cachedWrapR: Nullable<number>;
  37932. /** @hidden */
  37933. _cachedAnisotropicFilteringLevel: Nullable<number>;
  37934. /** @hidden */
  37935. _isDisabled: boolean;
  37936. /** @hidden */
  37937. _compression: Nullable<string>;
  37938. /** @hidden */
  37939. _generateStencilBuffer: boolean;
  37940. /** @hidden */
  37941. _generateDepthBuffer: boolean;
  37942. /** @hidden */
  37943. _comparisonFunction: number;
  37944. /** @hidden */
  37945. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  37946. /** @hidden */
  37947. _lodGenerationScale: number;
  37948. /** @hidden */
  37949. _lodGenerationOffset: number;
  37950. /** @hidden */
  37951. _depthStencilTexture: Nullable<InternalTexture>;
  37952. /** @hidden */
  37953. _colorTextureArray: Nullable<WebGLTexture>;
  37954. /** @hidden */
  37955. _depthStencilTextureArray: Nullable<WebGLTexture>;
  37956. /** @hidden */
  37957. _lodTextureHigh: Nullable<BaseTexture>;
  37958. /** @hidden */
  37959. _lodTextureMid: Nullable<BaseTexture>;
  37960. /** @hidden */
  37961. _lodTextureLow: Nullable<BaseTexture>;
  37962. /** @hidden */
  37963. _isRGBD: boolean;
  37964. /** @hidden */
  37965. _linearSpecularLOD: boolean;
  37966. /** @hidden */
  37967. _irradianceTexture: Nullable<BaseTexture>;
  37968. /** @hidden */
  37969. _webGLTexture: Nullable<WebGLTexture>;
  37970. /** @hidden */
  37971. _references: number;
  37972. /** @hidden */
  37973. _gammaSpace: Nullable<boolean>;
  37974. private _engine;
  37975. /**
  37976. * Gets the Engine the texture belongs to.
  37977. * @returns The babylon engine
  37978. */
  37979. getEngine(): ThinEngine;
  37980. /**
  37981. * Gets the data source type of the texture
  37982. */
  37983. get source(): InternalTextureSource;
  37984. /**
  37985. * Creates a new InternalTexture
  37986. * @param engine defines the engine to use
  37987. * @param source defines the type of data that will be used
  37988. * @param delayAllocation if the texture allocation should be delayed (default: false)
  37989. */
  37990. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  37991. /**
  37992. * Increments the number of references (ie. the number of Texture that point to it)
  37993. */
  37994. incrementReferences(): void;
  37995. /**
  37996. * Change the size of the texture (not the size of the content)
  37997. * @param width defines the new width
  37998. * @param height defines the new height
  37999. * @param depth defines the new depth (1 by default)
  38000. */
  38001. updateSize(width: int, height: int, depth?: int): void;
  38002. /** @hidden */
  38003. _rebuild(): void;
  38004. /** @hidden */
  38005. _swapAndDie(target: InternalTexture): void;
  38006. /**
  38007. * Dispose the current allocated resources
  38008. */
  38009. dispose(): void;
  38010. }
  38011. }
  38012. declare module "babylonjs/Audio/analyser" {
  38013. import { Scene } from "babylonjs/scene";
  38014. /**
  38015. * Class used to work with sound analyzer using fast fourier transform (FFT)
  38016. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38017. */
  38018. export class Analyser {
  38019. /**
  38020. * Gets or sets the smoothing
  38021. * @ignorenaming
  38022. */
  38023. SMOOTHING: number;
  38024. /**
  38025. * Gets or sets the FFT table size
  38026. * @ignorenaming
  38027. */
  38028. FFT_SIZE: number;
  38029. /**
  38030. * Gets or sets the bar graph amplitude
  38031. * @ignorenaming
  38032. */
  38033. BARGRAPHAMPLITUDE: number;
  38034. /**
  38035. * Gets or sets the position of the debug canvas
  38036. * @ignorenaming
  38037. */
  38038. DEBUGCANVASPOS: {
  38039. x: number;
  38040. y: number;
  38041. };
  38042. /**
  38043. * Gets or sets the debug canvas size
  38044. * @ignorenaming
  38045. */
  38046. DEBUGCANVASSIZE: {
  38047. width: number;
  38048. height: number;
  38049. };
  38050. private _byteFreqs;
  38051. private _byteTime;
  38052. private _floatFreqs;
  38053. private _webAudioAnalyser;
  38054. private _debugCanvas;
  38055. private _debugCanvasContext;
  38056. private _scene;
  38057. private _registerFunc;
  38058. private _audioEngine;
  38059. /**
  38060. * Creates a new analyser
  38061. * @param scene defines hosting scene
  38062. */
  38063. constructor(scene: Scene);
  38064. /**
  38065. * Get the number of data values you will have to play with for the visualization
  38066. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  38067. * @returns a number
  38068. */
  38069. getFrequencyBinCount(): number;
  38070. /**
  38071. * Gets the current frequency data as a byte array
  38072. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38073. * @returns a Uint8Array
  38074. */
  38075. getByteFrequencyData(): Uint8Array;
  38076. /**
  38077. * Gets the current waveform as a byte array
  38078. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  38079. * @returns a Uint8Array
  38080. */
  38081. getByteTimeDomainData(): Uint8Array;
  38082. /**
  38083. * Gets the current frequency data as a float array
  38084. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38085. * @returns a Float32Array
  38086. */
  38087. getFloatFrequencyData(): Float32Array;
  38088. /**
  38089. * Renders the debug canvas
  38090. */
  38091. drawDebugCanvas(): void;
  38092. /**
  38093. * Stops rendering the debug canvas and removes it
  38094. */
  38095. stopDebugCanvas(): void;
  38096. /**
  38097. * Connects two audio nodes
  38098. * @param inputAudioNode defines first node to connect
  38099. * @param outputAudioNode defines second node to connect
  38100. */
  38101. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  38102. /**
  38103. * Releases all associated resources
  38104. */
  38105. dispose(): void;
  38106. }
  38107. }
  38108. declare module "babylonjs/Audio/audioEngine" {
  38109. import { IDisposable } from "babylonjs/scene";
  38110. import { Analyser } from "babylonjs/Audio/analyser";
  38111. import { Nullable } from "babylonjs/types";
  38112. import { Observable } from "babylonjs/Misc/observable";
  38113. /**
  38114. * This represents an audio engine and it is responsible
  38115. * to play, synchronize and analyse sounds throughout the application.
  38116. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38117. */
  38118. export interface IAudioEngine extends IDisposable {
  38119. /**
  38120. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38121. */
  38122. readonly canUseWebAudio: boolean;
  38123. /**
  38124. * Gets the current AudioContext if available.
  38125. */
  38126. readonly audioContext: Nullable<AudioContext>;
  38127. /**
  38128. * The master gain node defines the global audio volume of your audio engine.
  38129. */
  38130. readonly masterGain: GainNode;
  38131. /**
  38132. * Gets whether or not mp3 are supported by your browser.
  38133. */
  38134. readonly isMP3supported: boolean;
  38135. /**
  38136. * Gets whether or not ogg are supported by your browser.
  38137. */
  38138. readonly isOGGsupported: boolean;
  38139. /**
  38140. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38141. * @ignoreNaming
  38142. */
  38143. WarnedWebAudioUnsupported: boolean;
  38144. /**
  38145. * Defines if the audio engine relies on a custom unlocked button.
  38146. * In this case, the embedded button will not be displayed.
  38147. */
  38148. useCustomUnlockedButton: boolean;
  38149. /**
  38150. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  38151. */
  38152. readonly unlocked: boolean;
  38153. /**
  38154. * Event raised when audio has been unlocked on the browser.
  38155. */
  38156. onAudioUnlockedObservable: Observable<AudioEngine>;
  38157. /**
  38158. * Event raised when audio has been locked on the browser.
  38159. */
  38160. onAudioLockedObservable: Observable<AudioEngine>;
  38161. /**
  38162. * Flags the audio engine in Locked state.
  38163. * This happens due to new browser policies preventing audio to autoplay.
  38164. */
  38165. lock(): void;
  38166. /**
  38167. * Unlocks the audio engine once a user action has been done on the dom.
  38168. * This is helpful to resume play once browser policies have been satisfied.
  38169. */
  38170. unlock(): void;
  38171. /**
  38172. * Gets the global volume sets on the master gain.
  38173. * @returns the global volume if set or -1 otherwise
  38174. */
  38175. getGlobalVolume(): number;
  38176. /**
  38177. * Sets the global volume of your experience (sets on the master gain).
  38178. * @param newVolume Defines the new global volume of the application
  38179. */
  38180. setGlobalVolume(newVolume: number): void;
  38181. /**
  38182. * Connect the audio engine to an audio analyser allowing some amazing
  38183. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38184. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38185. * @param analyser The analyser to connect to the engine
  38186. */
  38187. connectToAnalyser(analyser: Analyser): void;
  38188. }
  38189. /**
  38190. * This represents the default audio engine used in babylon.
  38191. * It is responsible to play, synchronize and analyse sounds throughout the application.
  38192. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38193. */
  38194. export class AudioEngine implements IAudioEngine {
  38195. private _audioContext;
  38196. private _audioContextInitialized;
  38197. private _muteButton;
  38198. private _hostElement;
  38199. /**
  38200. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38201. */
  38202. canUseWebAudio: boolean;
  38203. /**
  38204. * The master gain node defines the global audio volume of your audio engine.
  38205. */
  38206. masterGain: GainNode;
  38207. /**
  38208. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38209. * @ignoreNaming
  38210. */
  38211. WarnedWebAudioUnsupported: boolean;
  38212. /**
  38213. * Gets whether or not mp3 are supported by your browser.
  38214. */
  38215. isMP3supported: boolean;
  38216. /**
  38217. * Gets whether or not ogg are supported by your browser.
  38218. */
  38219. isOGGsupported: boolean;
  38220. /**
  38221. * Gets whether audio has been unlocked on the device.
  38222. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  38223. * a user interaction has happened.
  38224. */
  38225. unlocked: boolean;
  38226. /**
  38227. * Defines if the audio engine relies on a custom unlocked button.
  38228. * In this case, the embedded button will not be displayed.
  38229. */
  38230. useCustomUnlockedButton: boolean;
  38231. /**
  38232. * Event raised when audio has been unlocked on the browser.
  38233. */
  38234. onAudioUnlockedObservable: Observable<AudioEngine>;
  38235. /**
  38236. * Event raised when audio has been locked on the browser.
  38237. */
  38238. onAudioLockedObservable: Observable<AudioEngine>;
  38239. /**
  38240. * Gets the current AudioContext if available.
  38241. */
  38242. get audioContext(): Nullable<AudioContext>;
  38243. private _connectedAnalyser;
  38244. /**
  38245. * Instantiates a new audio engine.
  38246. *
  38247. * There should be only one per page as some browsers restrict the number
  38248. * of audio contexts you can create.
  38249. * @param hostElement defines the host element where to display the mute icon if necessary
  38250. */
  38251. constructor(hostElement?: Nullable<HTMLElement>);
  38252. /**
  38253. * Flags the audio engine in Locked state.
  38254. * This happens due to new browser policies preventing audio to autoplay.
  38255. */
  38256. lock(): void;
  38257. /**
  38258. * Unlocks the audio engine once a user action has been done on the dom.
  38259. * This is helpful to resume play once browser policies have been satisfied.
  38260. */
  38261. unlock(): void;
  38262. private _resumeAudioContext;
  38263. private _initializeAudioContext;
  38264. private _tryToRun;
  38265. private _triggerRunningState;
  38266. private _triggerSuspendedState;
  38267. private _displayMuteButton;
  38268. private _moveButtonToTopLeft;
  38269. private _onResize;
  38270. private _hideMuteButton;
  38271. /**
  38272. * Destroy and release the resources associated with the audio ccontext.
  38273. */
  38274. dispose(): void;
  38275. /**
  38276. * Gets the global volume sets on the master gain.
  38277. * @returns the global volume if set or -1 otherwise
  38278. */
  38279. getGlobalVolume(): number;
  38280. /**
  38281. * Sets the global volume of your experience (sets on the master gain).
  38282. * @param newVolume Defines the new global volume of the application
  38283. */
  38284. setGlobalVolume(newVolume: number): void;
  38285. /**
  38286. * Connect the audio engine to an audio analyser allowing some amazing
  38287. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38288. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38289. * @param analyser The analyser to connect to the engine
  38290. */
  38291. connectToAnalyser(analyser: Analyser): void;
  38292. }
  38293. }
  38294. declare module "babylonjs/Loading/loadingScreen" {
  38295. /**
  38296. * Interface used to present a loading screen while loading a scene
  38297. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38298. */
  38299. export interface ILoadingScreen {
  38300. /**
  38301. * Function called to display the loading screen
  38302. */
  38303. displayLoadingUI: () => void;
  38304. /**
  38305. * Function called to hide the loading screen
  38306. */
  38307. hideLoadingUI: () => void;
  38308. /**
  38309. * Gets or sets the color to use for the background
  38310. */
  38311. loadingUIBackgroundColor: string;
  38312. /**
  38313. * Gets or sets the text to display while loading
  38314. */
  38315. loadingUIText: string;
  38316. }
  38317. /**
  38318. * Class used for the default loading screen
  38319. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38320. */
  38321. export class DefaultLoadingScreen implements ILoadingScreen {
  38322. private _renderingCanvas;
  38323. private _loadingText;
  38324. private _loadingDivBackgroundColor;
  38325. private _loadingDiv;
  38326. private _loadingTextDiv;
  38327. /** Gets or sets the logo url to use for the default loading screen */
  38328. static DefaultLogoUrl: string;
  38329. /** Gets or sets the spinner url to use for the default loading screen */
  38330. static DefaultSpinnerUrl: string;
  38331. /**
  38332. * Creates a new default loading screen
  38333. * @param _renderingCanvas defines the canvas used to render the scene
  38334. * @param _loadingText defines the default text to display
  38335. * @param _loadingDivBackgroundColor defines the default background color
  38336. */
  38337. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  38338. /**
  38339. * Function called to display the loading screen
  38340. */
  38341. displayLoadingUI(): void;
  38342. /**
  38343. * Function called to hide the loading screen
  38344. */
  38345. hideLoadingUI(): void;
  38346. /**
  38347. * Gets or sets the text to display while loading
  38348. */
  38349. set loadingUIText(text: string);
  38350. get loadingUIText(): string;
  38351. /**
  38352. * Gets or sets the color to use for the background
  38353. */
  38354. get loadingUIBackgroundColor(): string;
  38355. set loadingUIBackgroundColor(color: string);
  38356. private _resizeLoadingUI;
  38357. }
  38358. }
  38359. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  38360. /**
  38361. * Interface for any object that can request an animation frame
  38362. */
  38363. export interface ICustomAnimationFrameRequester {
  38364. /**
  38365. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  38366. */
  38367. renderFunction?: Function;
  38368. /**
  38369. * Called to request the next frame to render to
  38370. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  38371. */
  38372. requestAnimationFrame: Function;
  38373. /**
  38374. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  38375. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  38376. */
  38377. requestID?: number;
  38378. }
  38379. }
  38380. declare module "babylonjs/Misc/performanceMonitor" {
  38381. /**
  38382. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38383. */
  38384. export class PerformanceMonitor {
  38385. private _enabled;
  38386. private _rollingFrameTime;
  38387. private _lastFrameTimeMs;
  38388. /**
  38389. * constructor
  38390. * @param frameSampleSize The number of samples required to saturate the sliding window
  38391. */
  38392. constructor(frameSampleSize?: number);
  38393. /**
  38394. * Samples current frame
  38395. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38396. */
  38397. sampleFrame(timeMs?: number): void;
  38398. /**
  38399. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38400. */
  38401. get averageFrameTime(): number;
  38402. /**
  38403. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38404. */
  38405. get averageFrameTimeVariance(): number;
  38406. /**
  38407. * Returns the frame time of the most recent frame
  38408. */
  38409. get instantaneousFrameTime(): number;
  38410. /**
  38411. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38412. */
  38413. get averageFPS(): number;
  38414. /**
  38415. * Returns the average framerate in frames per second using the most recent frame time
  38416. */
  38417. get instantaneousFPS(): number;
  38418. /**
  38419. * Returns true if enough samples have been taken to completely fill the sliding window
  38420. */
  38421. get isSaturated(): boolean;
  38422. /**
  38423. * Enables contributions to the sliding window sample set
  38424. */
  38425. enable(): void;
  38426. /**
  38427. * Disables contributions to the sliding window sample set
  38428. * Samples will not be interpolated over the disabled period
  38429. */
  38430. disable(): void;
  38431. /**
  38432. * Returns true if sampling is enabled
  38433. */
  38434. get isEnabled(): boolean;
  38435. /**
  38436. * Resets performance monitor
  38437. */
  38438. reset(): void;
  38439. }
  38440. /**
  38441. * RollingAverage
  38442. *
  38443. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38444. */
  38445. export class RollingAverage {
  38446. /**
  38447. * Current average
  38448. */
  38449. average: number;
  38450. /**
  38451. * Current variance
  38452. */
  38453. variance: number;
  38454. protected _samples: Array<number>;
  38455. protected _sampleCount: number;
  38456. protected _pos: number;
  38457. protected _m2: number;
  38458. /**
  38459. * constructor
  38460. * @param length The number of samples required to saturate the sliding window
  38461. */
  38462. constructor(length: number);
  38463. /**
  38464. * Adds a sample to the sample set
  38465. * @param v The sample value
  38466. */
  38467. add(v: number): void;
  38468. /**
  38469. * Returns previously added values or null if outside of history or outside the sliding window domain
  38470. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38471. * @return Value previously recorded with add() or null if outside of range
  38472. */
  38473. history(i: number): number;
  38474. /**
  38475. * Returns true if enough samples have been taken to completely fill the sliding window
  38476. * @return true if sample-set saturated
  38477. */
  38478. isSaturated(): boolean;
  38479. /**
  38480. * Resets the rolling average (equivalent to 0 samples taken so far)
  38481. */
  38482. reset(): void;
  38483. /**
  38484. * Wraps a value around the sample range boundaries
  38485. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38486. * @return Wrapped position in sample range
  38487. */
  38488. protected _wrapPosition(i: number): number;
  38489. }
  38490. }
  38491. declare module "babylonjs/Misc/perfCounter" {
  38492. /**
  38493. * This class is used to track a performance counter which is number based.
  38494. * The user has access to many properties which give statistics of different nature.
  38495. *
  38496. * The implementer can track two kinds of Performance Counter: time and count.
  38497. * 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.
  38498. * 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.
  38499. */
  38500. export class PerfCounter {
  38501. /**
  38502. * Gets or sets a global boolean to turn on and off all the counters
  38503. */
  38504. static Enabled: boolean;
  38505. /**
  38506. * Returns the smallest value ever
  38507. */
  38508. get min(): number;
  38509. /**
  38510. * Returns the biggest value ever
  38511. */
  38512. get max(): number;
  38513. /**
  38514. * Returns the average value since the performance counter is running
  38515. */
  38516. get average(): number;
  38517. /**
  38518. * Returns the average value of the last second the counter was monitored
  38519. */
  38520. get lastSecAverage(): number;
  38521. /**
  38522. * Returns the current value
  38523. */
  38524. get current(): number;
  38525. /**
  38526. * Gets the accumulated total
  38527. */
  38528. get total(): number;
  38529. /**
  38530. * Gets the total value count
  38531. */
  38532. get count(): number;
  38533. /**
  38534. * Creates a new counter
  38535. */
  38536. constructor();
  38537. /**
  38538. * Call this method to start monitoring a new frame.
  38539. * 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.
  38540. */
  38541. fetchNewFrame(): void;
  38542. /**
  38543. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  38544. * @param newCount the count value to add to the monitored count
  38545. * @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.
  38546. */
  38547. addCount(newCount: number, fetchResult: boolean): void;
  38548. /**
  38549. * Start monitoring this performance counter
  38550. */
  38551. beginMonitoring(): void;
  38552. /**
  38553. * Compute the time lapsed since the previous beginMonitoring() call.
  38554. * @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
  38555. */
  38556. endMonitoring(newFrame?: boolean): void;
  38557. private _fetchResult;
  38558. private _startMonitoringTime;
  38559. private _min;
  38560. private _max;
  38561. private _average;
  38562. private _current;
  38563. private _totalValueCount;
  38564. private _totalAccumulated;
  38565. private _lastSecAverage;
  38566. private _lastSecAccumulated;
  38567. private _lastSecTime;
  38568. private _lastSecValueCount;
  38569. }
  38570. }
  38571. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  38572. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38573. import { Nullable } from "babylonjs/types";
  38574. module "babylonjs/Engines/thinEngine" {
  38575. interface ThinEngine {
  38576. /** @hidden */
  38577. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  38578. }
  38579. }
  38580. }
  38581. declare module "babylonjs/Engines/engine" {
  38582. import { Observable } from "babylonjs/Misc/observable";
  38583. import { Nullable } from "babylonjs/types";
  38584. import { Scene } from "babylonjs/scene";
  38585. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38586. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  38587. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38588. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  38589. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  38590. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38591. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  38592. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  38593. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  38594. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38595. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  38596. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38597. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  38598. import "babylonjs/Engines/Extensions/engine.alpha";
  38599. import "babylonjs/Engines/Extensions/engine.readTexture";
  38600. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  38601. import { Material } from "babylonjs/Materials/material";
  38602. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38603. /**
  38604. * Defines the interface used by display changed events
  38605. */
  38606. export interface IDisplayChangedEventArgs {
  38607. /** Gets the vrDisplay object (if any) */
  38608. vrDisplay: Nullable<any>;
  38609. /** Gets a boolean indicating if webVR is supported */
  38610. vrSupported: boolean;
  38611. }
  38612. /**
  38613. * Defines the interface used by objects containing a viewport (like a camera)
  38614. */
  38615. interface IViewportOwnerLike {
  38616. /**
  38617. * Gets or sets the viewport
  38618. */
  38619. viewport: IViewportLike;
  38620. }
  38621. /**
  38622. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  38623. */
  38624. export class Engine extends ThinEngine {
  38625. /** Defines that alpha blending is disabled */
  38626. static readonly ALPHA_DISABLE: number;
  38627. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  38628. static readonly ALPHA_ADD: number;
  38629. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  38630. static readonly ALPHA_COMBINE: number;
  38631. /** Defines that alpha blending to DEST - SRC * DEST */
  38632. static readonly ALPHA_SUBTRACT: number;
  38633. /** Defines that alpha blending to SRC * DEST */
  38634. static readonly ALPHA_MULTIPLY: number;
  38635. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  38636. static readonly ALPHA_MAXIMIZED: number;
  38637. /** Defines that alpha blending to SRC + DEST */
  38638. static readonly ALPHA_ONEONE: number;
  38639. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  38640. static readonly ALPHA_PREMULTIPLIED: number;
  38641. /**
  38642. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  38643. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  38644. */
  38645. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  38646. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  38647. static readonly ALPHA_INTERPOLATE: number;
  38648. /**
  38649. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  38650. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  38651. */
  38652. static readonly ALPHA_SCREENMODE: number;
  38653. /** Defines that the ressource is not delayed*/
  38654. static readonly DELAYLOADSTATE_NONE: number;
  38655. /** Defines that the ressource was successfully delay loaded */
  38656. static readonly DELAYLOADSTATE_LOADED: number;
  38657. /** Defines that the ressource is currently delay loading */
  38658. static readonly DELAYLOADSTATE_LOADING: number;
  38659. /** Defines that the ressource is delayed and has not started loading */
  38660. static readonly DELAYLOADSTATE_NOTLOADED: number;
  38661. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  38662. static readonly NEVER: number;
  38663. /** 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 */
  38664. static readonly ALWAYS: number;
  38665. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  38666. static readonly LESS: number;
  38667. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  38668. static readonly EQUAL: number;
  38669. /** 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 */
  38670. static readonly LEQUAL: number;
  38671. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  38672. static readonly GREATER: number;
  38673. /** 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 */
  38674. static readonly GEQUAL: number;
  38675. /** 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 */
  38676. static readonly NOTEQUAL: number;
  38677. /** Passed to stencilOperation to specify that stencil value must be kept */
  38678. static readonly KEEP: number;
  38679. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38680. static readonly REPLACE: number;
  38681. /** Passed to stencilOperation to specify that stencil value must be incremented */
  38682. static readonly INCR: number;
  38683. /** Passed to stencilOperation to specify that stencil value must be decremented */
  38684. static readonly DECR: number;
  38685. /** Passed to stencilOperation to specify that stencil value must be inverted */
  38686. static readonly INVERT: number;
  38687. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  38688. static readonly INCR_WRAP: number;
  38689. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  38690. static readonly DECR_WRAP: number;
  38691. /** Texture is not repeating outside of 0..1 UVs */
  38692. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  38693. /** Texture is repeating outside of 0..1 UVs */
  38694. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  38695. /** Texture is repeating and mirrored */
  38696. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  38697. /** ALPHA */
  38698. static readonly TEXTUREFORMAT_ALPHA: number;
  38699. /** LUMINANCE */
  38700. static readonly TEXTUREFORMAT_LUMINANCE: number;
  38701. /** LUMINANCE_ALPHA */
  38702. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  38703. /** RGB */
  38704. static readonly TEXTUREFORMAT_RGB: number;
  38705. /** RGBA */
  38706. static readonly TEXTUREFORMAT_RGBA: number;
  38707. /** RED */
  38708. static readonly TEXTUREFORMAT_RED: number;
  38709. /** RED (2nd reference) */
  38710. static readonly TEXTUREFORMAT_R: number;
  38711. /** RG */
  38712. static readonly TEXTUREFORMAT_RG: number;
  38713. /** RED_INTEGER */
  38714. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  38715. /** RED_INTEGER (2nd reference) */
  38716. static readonly TEXTUREFORMAT_R_INTEGER: number;
  38717. /** RG_INTEGER */
  38718. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  38719. /** RGB_INTEGER */
  38720. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  38721. /** RGBA_INTEGER */
  38722. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  38723. /** UNSIGNED_BYTE */
  38724. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  38725. /** UNSIGNED_BYTE (2nd reference) */
  38726. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  38727. /** FLOAT */
  38728. static readonly TEXTURETYPE_FLOAT: number;
  38729. /** HALF_FLOAT */
  38730. static readonly TEXTURETYPE_HALF_FLOAT: number;
  38731. /** BYTE */
  38732. static readonly TEXTURETYPE_BYTE: number;
  38733. /** SHORT */
  38734. static readonly TEXTURETYPE_SHORT: number;
  38735. /** UNSIGNED_SHORT */
  38736. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  38737. /** INT */
  38738. static readonly TEXTURETYPE_INT: number;
  38739. /** UNSIGNED_INT */
  38740. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  38741. /** UNSIGNED_SHORT_4_4_4_4 */
  38742. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  38743. /** UNSIGNED_SHORT_5_5_5_1 */
  38744. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  38745. /** UNSIGNED_SHORT_5_6_5 */
  38746. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  38747. /** UNSIGNED_INT_2_10_10_10_REV */
  38748. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  38749. /** UNSIGNED_INT_24_8 */
  38750. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  38751. /** UNSIGNED_INT_10F_11F_11F_REV */
  38752. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  38753. /** UNSIGNED_INT_5_9_9_9_REV */
  38754. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  38755. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  38756. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  38757. /** nearest is mag = nearest and min = nearest and mip = linear */
  38758. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  38759. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38760. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  38761. /** Trilinear is mag = linear and min = linear and mip = linear */
  38762. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  38763. /** nearest is mag = nearest and min = nearest and mip = linear */
  38764. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  38765. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38766. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  38767. /** Trilinear is mag = linear and min = linear and mip = linear */
  38768. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  38769. /** mag = nearest and min = nearest and mip = nearest */
  38770. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  38771. /** mag = nearest and min = linear and mip = nearest */
  38772. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  38773. /** mag = nearest and min = linear and mip = linear */
  38774. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  38775. /** mag = nearest and min = linear and mip = none */
  38776. static readonly TEXTURE_NEAREST_LINEAR: number;
  38777. /** mag = nearest and min = nearest and mip = none */
  38778. static readonly TEXTURE_NEAREST_NEAREST: number;
  38779. /** mag = linear and min = nearest and mip = nearest */
  38780. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  38781. /** mag = linear and min = nearest and mip = linear */
  38782. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  38783. /** mag = linear and min = linear and mip = none */
  38784. static readonly TEXTURE_LINEAR_LINEAR: number;
  38785. /** mag = linear and min = nearest and mip = none */
  38786. static readonly TEXTURE_LINEAR_NEAREST: number;
  38787. /** Explicit coordinates mode */
  38788. static readonly TEXTURE_EXPLICIT_MODE: number;
  38789. /** Spherical coordinates mode */
  38790. static readonly TEXTURE_SPHERICAL_MODE: number;
  38791. /** Planar coordinates mode */
  38792. static readonly TEXTURE_PLANAR_MODE: number;
  38793. /** Cubic coordinates mode */
  38794. static readonly TEXTURE_CUBIC_MODE: number;
  38795. /** Projection coordinates mode */
  38796. static readonly TEXTURE_PROJECTION_MODE: number;
  38797. /** Skybox coordinates mode */
  38798. static readonly TEXTURE_SKYBOX_MODE: number;
  38799. /** Inverse Cubic coordinates mode */
  38800. static readonly TEXTURE_INVCUBIC_MODE: number;
  38801. /** Equirectangular coordinates mode */
  38802. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  38803. /** Equirectangular Fixed coordinates mode */
  38804. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  38805. /** Equirectangular Fixed Mirrored coordinates mode */
  38806. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  38807. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  38808. static readonly SCALEMODE_FLOOR: number;
  38809. /** Defines that texture rescaling will look for the nearest power of 2 size */
  38810. static readonly SCALEMODE_NEAREST: number;
  38811. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  38812. static readonly SCALEMODE_CEILING: number;
  38813. /**
  38814. * Returns the current npm package of the sdk
  38815. */
  38816. static get NpmPackage(): string;
  38817. /**
  38818. * Returns the current version of the framework
  38819. */
  38820. static get Version(): string;
  38821. /** Gets the list of created engines */
  38822. static get Instances(): Engine[];
  38823. /**
  38824. * Gets the latest created engine
  38825. */
  38826. static get LastCreatedEngine(): Nullable<Engine>;
  38827. /**
  38828. * Gets the latest created scene
  38829. */
  38830. static get LastCreatedScene(): Nullable<Scene>;
  38831. /**
  38832. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  38833. * @param flag defines which part of the materials must be marked as dirty
  38834. * @param predicate defines a predicate used to filter which materials should be affected
  38835. */
  38836. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38837. /**
  38838. * Method called to create the default loading screen.
  38839. * This can be overriden in your own app.
  38840. * @param canvas The rendering canvas element
  38841. * @returns The loading screen
  38842. */
  38843. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  38844. /**
  38845. * Method called to create the default rescale post process on each engine.
  38846. */
  38847. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  38848. /**
  38849. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  38850. **/
  38851. enableOfflineSupport: boolean;
  38852. /**
  38853. * 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)
  38854. **/
  38855. disableManifestCheck: boolean;
  38856. /**
  38857. * Gets the list of created scenes
  38858. */
  38859. scenes: Scene[];
  38860. /**
  38861. * Event raised when a new scene is created
  38862. */
  38863. onNewSceneAddedObservable: Observable<Scene>;
  38864. /**
  38865. * Gets the list of created postprocesses
  38866. */
  38867. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  38868. /**
  38869. * Gets a boolean indicating if the pointer is currently locked
  38870. */
  38871. isPointerLock: boolean;
  38872. /**
  38873. * Observable event triggered each time the rendering canvas is resized
  38874. */
  38875. onResizeObservable: Observable<Engine>;
  38876. /**
  38877. * Observable event triggered each time the canvas loses focus
  38878. */
  38879. onCanvasBlurObservable: Observable<Engine>;
  38880. /**
  38881. * Observable event triggered each time the canvas gains focus
  38882. */
  38883. onCanvasFocusObservable: Observable<Engine>;
  38884. /**
  38885. * Observable event triggered each time the canvas receives pointerout event
  38886. */
  38887. onCanvasPointerOutObservable: Observable<PointerEvent>;
  38888. /**
  38889. * Observable raised when the engine begins a new frame
  38890. */
  38891. onBeginFrameObservable: Observable<Engine>;
  38892. /**
  38893. * If set, will be used to request the next animation frame for the render loop
  38894. */
  38895. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  38896. /**
  38897. * Observable raised when the engine ends the current frame
  38898. */
  38899. onEndFrameObservable: Observable<Engine>;
  38900. /**
  38901. * Observable raised when the engine is about to compile a shader
  38902. */
  38903. onBeforeShaderCompilationObservable: Observable<Engine>;
  38904. /**
  38905. * Observable raised when the engine has jsut compiled a shader
  38906. */
  38907. onAfterShaderCompilationObservable: Observable<Engine>;
  38908. /**
  38909. * Gets the audio engine
  38910. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38911. * @ignorenaming
  38912. */
  38913. static audioEngine: IAudioEngine;
  38914. /**
  38915. * Default AudioEngine factory responsible of creating the Audio Engine.
  38916. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  38917. */
  38918. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  38919. /**
  38920. * Default offline support factory responsible of creating a tool used to store data locally.
  38921. * By default, this will create a Database object if the workload has been embedded.
  38922. */
  38923. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  38924. private _loadingScreen;
  38925. private _pointerLockRequested;
  38926. private _rescalePostProcess;
  38927. private _deterministicLockstep;
  38928. private _lockstepMaxSteps;
  38929. private _timeStep;
  38930. protected get _supportsHardwareTextureRescaling(): boolean;
  38931. private _fps;
  38932. private _deltaTime;
  38933. /** @hidden */
  38934. _drawCalls: PerfCounter;
  38935. /** 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 */
  38936. canvasTabIndex: number;
  38937. /**
  38938. * Turn this value on if you want to pause FPS computation when in background
  38939. */
  38940. disablePerformanceMonitorInBackground: boolean;
  38941. private _performanceMonitor;
  38942. /**
  38943. * Gets the performance monitor attached to this engine
  38944. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  38945. */
  38946. get performanceMonitor(): PerformanceMonitor;
  38947. private _onFocus;
  38948. private _onBlur;
  38949. private _onCanvasPointerOut;
  38950. private _onCanvasBlur;
  38951. private _onCanvasFocus;
  38952. private _onFullscreenChange;
  38953. private _onPointerLockChange;
  38954. /**
  38955. * Gets the HTML element used to attach event listeners
  38956. * @returns a HTML element
  38957. */
  38958. getInputElement(): Nullable<HTMLElement>;
  38959. /**
  38960. * Creates a new engine
  38961. * @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
  38962. * @param antialias defines enable antialiasing (default: false)
  38963. * @param options defines further options to be sent to the getContext() function
  38964. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  38965. */
  38966. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  38967. /**
  38968. * Gets current aspect ratio
  38969. * @param viewportOwner defines the camera to use to get the aspect ratio
  38970. * @param useScreen defines if screen size must be used (or the current render target if any)
  38971. * @returns a number defining the aspect ratio
  38972. */
  38973. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  38974. /**
  38975. * Gets current screen aspect ratio
  38976. * @returns a number defining the aspect ratio
  38977. */
  38978. getScreenAspectRatio(): number;
  38979. /**
  38980. * Gets the client rect of the HTML canvas attached with the current webGL context
  38981. * @returns a client rectanglee
  38982. */
  38983. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  38984. /**
  38985. * Gets the client rect of the HTML element used for events
  38986. * @returns a client rectanglee
  38987. */
  38988. getInputElementClientRect(): Nullable<ClientRect>;
  38989. /**
  38990. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  38991. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38992. * @returns true if engine is in deterministic lock step mode
  38993. */
  38994. isDeterministicLockStep(): boolean;
  38995. /**
  38996. * Gets the max steps when engine is running in deterministic lock step
  38997. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38998. * @returns the max steps
  38999. */
  39000. getLockstepMaxSteps(): number;
  39001. /**
  39002. * Returns the time in ms between steps when using deterministic lock step.
  39003. * @returns time step in (ms)
  39004. */
  39005. getTimeStep(): number;
  39006. /**
  39007. * Force the mipmap generation for the given render target texture
  39008. * @param texture defines the render target texture to use
  39009. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  39010. */
  39011. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  39012. /** States */
  39013. /**
  39014. * Set various states to the webGL context
  39015. * @param culling defines backface culling state
  39016. * @param zOffset defines the value to apply to zOffset (0 by default)
  39017. * @param force defines if states must be applied even if cache is up to date
  39018. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  39019. */
  39020. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  39021. /**
  39022. * Set the z offset to apply to current rendering
  39023. * @param value defines the offset to apply
  39024. */
  39025. setZOffset(value: number): void;
  39026. /**
  39027. * Gets the current value of the zOffset
  39028. * @returns the current zOffset state
  39029. */
  39030. getZOffset(): number;
  39031. /**
  39032. * Enable or disable depth buffering
  39033. * @param enable defines the state to set
  39034. */
  39035. setDepthBuffer(enable: boolean): void;
  39036. /**
  39037. * Gets a boolean indicating if depth writing is enabled
  39038. * @returns the current depth writing state
  39039. */
  39040. getDepthWrite(): boolean;
  39041. /**
  39042. * Enable or disable depth writing
  39043. * @param enable defines the state to set
  39044. */
  39045. setDepthWrite(enable: boolean): void;
  39046. /**
  39047. * Gets a boolean indicating if stencil buffer is enabled
  39048. * @returns the current stencil buffer state
  39049. */
  39050. getStencilBuffer(): boolean;
  39051. /**
  39052. * Enable or disable the stencil buffer
  39053. * @param enable defines if the stencil buffer must be enabled or disabled
  39054. */
  39055. setStencilBuffer(enable: boolean): void;
  39056. /**
  39057. * Gets the current stencil mask
  39058. * @returns a number defining the new stencil mask to use
  39059. */
  39060. getStencilMask(): number;
  39061. /**
  39062. * Sets the current stencil mask
  39063. * @param mask defines the new stencil mask to use
  39064. */
  39065. setStencilMask(mask: number): void;
  39066. /**
  39067. * Gets the current stencil function
  39068. * @returns a number defining the stencil function to use
  39069. */
  39070. getStencilFunction(): number;
  39071. /**
  39072. * Gets the current stencil reference value
  39073. * @returns a number defining the stencil reference value to use
  39074. */
  39075. getStencilFunctionReference(): number;
  39076. /**
  39077. * Gets the current stencil mask
  39078. * @returns a number defining the stencil mask to use
  39079. */
  39080. getStencilFunctionMask(): number;
  39081. /**
  39082. * Sets the current stencil function
  39083. * @param stencilFunc defines the new stencil function to use
  39084. */
  39085. setStencilFunction(stencilFunc: number): void;
  39086. /**
  39087. * Sets the current stencil reference
  39088. * @param reference defines the new stencil reference to use
  39089. */
  39090. setStencilFunctionReference(reference: number): void;
  39091. /**
  39092. * Sets the current stencil mask
  39093. * @param mask defines the new stencil mask to use
  39094. */
  39095. setStencilFunctionMask(mask: number): void;
  39096. /**
  39097. * Gets the current stencil operation when stencil fails
  39098. * @returns a number defining stencil operation to use when stencil fails
  39099. */
  39100. getStencilOperationFail(): number;
  39101. /**
  39102. * Gets the current stencil operation when depth fails
  39103. * @returns a number defining stencil operation to use when depth fails
  39104. */
  39105. getStencilOperationDepthFail(): number;
  39106. /**
  39107. * Gets the current stencil operation when stencil passes
  39108. * @returns a number defining stencil operation to use when stencil passes
  39109. */
  39110. getStencilOperationPass(): number;
  39111. /**
  39112. * Sets the stencil operation to use when stencil fails
  39113. * @param operation defines the stencil operation to use when stencil fails
  39114. */
  39115. setStencilOperationFail(operation: number): void;
  39116. /**
  39117. * Sets the stencil operation to use when depth fails
  39118. * @param operation defines the stencil operation to use when depth fails
  39119. */
  39120. setStencilOperationDepthFail(operation: number): void;
  39121. /**
  39122. * Sets the stencil operation to use when stencil passes
  39123. * @param operation defines the stencil operation to use when stencil passes
  39124. */
  39125. setStencilOperationPass(operation: number): void;
  39126. /**
  39127. * Sets a boolean indicating if the dithering state is enabled or disabled
  39128. * @param value defines the dithering state
  39129. */
  39130. setDitheringState(value: boolean): void;
  39131. /**
  39132. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  39133. * @param value defines the rasterizer state
  39134. */
  39135. setRasterizerState(value: boolean): void;
  39136. /**
  39137. * Gets the current depth function
  39138. * @returns a number defining the depth function
  39139. */
  39140. getDepthFunction(): Nullable<number>;
  39141. /**
  39142. * Sets the current depth function
  39143. * @param depthFunc defines the function to use
  39144. */
  39145. setDepthFunction(depthFunc: number): void;
  39146. /**
  39147. * Sets the current depth function to GREATER
  39148. */
  39149. setDepthFunctionToGreater(): void;
  39150. /**
  39151. * Sets the current depth function to GEQUAL
  39152. */
  39153. setDepthFunctionToGreaterOrEqual(): void;
  39154. /**
  39155. * Sets the current depth function to LESS
  39156. */
  39157. setDepthFunctionToLess(): void;
  39158. /**
  39159. * Sets the current depth function to LEQUAL
  39160. */
  39161. setDepthFunctionToLessOrEqual(): void;
  39162. private _cachedStencilBuffer;
  39163. private _cachedStencilFunction;
  39164. private _cachedStencilMask;
  39165. private _cachedStencilOperationPass;
  39166. private _cachedStencilOperationFail;
  39167. private _cachedStencilOperationDepthFail;
  39168. private _cachedStencilReference;
  39169. /**
  39170. * Caches the the state of the stencil buffer
  39171. */
  39172. cacheStencilState(): void;
  39173. /**
  39174. * Restores the state of the stencil buffer
  39175. */
  39176. restoreStencilState(): void;
  39177. /**
  39178. * Directly set the WebGL Viewport
  39179. * @param x defines the x coordinate of the viewport (in screen space)
  39180. * @param y defines the y coordinate of the viewport (in screen space)
  39181. * @param width defines the width of the viewport (in screen space)
  39182. * @param height defines the height of the viewport (in screen space)
  39183. * @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
  39184. */
  39185. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  39186. /**
  39187. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  39188. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39189. * @param y defines the y-coordinate of the corner of the clear rectangle
  39190. * @param width defines the width of the clear rectangle
  39191. * @param height defines the height of the clear rectangle
  39192. * @param clearColor defines the clear color
  39193. */
  39194. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  39195. /**
  39196. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  39197. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39198. * @param y defines the y-coordinate of the corner of the clear rectangle
  39199. * @param width defines the width of the clear rectangle
  39200. * @param height defines the height of the clear rectangle
  39201. */
  39202. enableScissor(x: number, y: number, width: number, height: number): void;
  39203. /**
  39204. * Disable previously set scissor test rectangle
  39205. */
  39206. disableScissor(): void;
  39207. protected _reportDrawCall(): void;
  39208. /**
  39209. * Initializes a webVR display and starts listening to display change events
  39210. * The onVRDisplayChangedObservable will be notified upon these changes
  39211. * @returns The onVRDisplayChangedObservable
  39212. */
  39213. initWebVR(): Observable<IDisplayChangedEventArgs>;
  39214. /** @hidden */
  39215. _prepareVRComponent(): void;
  39216. /** @hidden */
  39217. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  39218. /** @hidden */
  39219. _submitVRFrame(): void;
  39220. /**
  39221. * Call this function to leave webVR mode
  39222. * Will do nothing if webVR is not supported or if there is no webVR device
  39223. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39224. */
  39225. disableVR(): void;
  39226. /**
  39227. * Gets a boolean indicating that the system is in VR mode and is presenting
  39228. * @returns true if VR mode is engaged
  39229. */
  39230. isVRPresenting(): boolean;
  39231. /** @hidden */
  39232. _requestVRFrame(): void;
  39233. /** @hidden */
  39234. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39235. /**
  39236. * Gets the source code of the vertex shader associated with a specific webGL program
  39237. * @param program defines the program to use
  39238. * @returns a string containing the source code of the vertex shader associated with the program
  39239. */
  39240. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  39241. /**
  39242. * Gets the source code of the fragment shader associated with a specific webGL program
  39243. * @param program defines the program to use
  39244. * @returns a string containing the source code of the fragment shader associated with the program
  39245. */
  39246. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  39247. /**
  39248. * Sets a depth stencil texture from a render target to the according uniform.
  39249. * @param channel The texture channel
  39250. * @param uniform The uniform to set
  39251. * @param texture The render target texture containing the depth stencil texture to apply
  39252. */
  39253. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  39254. /**
  39255. * Sets a texture to the webGL context from a postprocess
  39256. * @param channel defines the channel to use
  39257. * @param postProcess defines the source postprocess
  39258. */
  39259. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  39260. /**
  39261. * Binds the output of the passed in post process to the texture channel specified
  39262. * @param channel The channel the texture should be bound to
  39263. * @param postProcess The post process which's output should be bound
  39264. */
  39265. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  39266. protected _rebuildBuffers(): void;
  39267. /** @hidden */
  39268. _renderFrame(): void;
  39269. _renderLoop(): void;
  39270. /** @hidden */
  39271. _renderViews(): boolean;
  39272. /**
  39273. * Toggle full screen mode
  39274. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39275. */
  39276. switchFullscreen(requestPointerLock: boolean): void;
  39277. /**
  39278. * Enters full screen mode
  39279. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39280. */
  39281. enterFullscreen(requestPointerLock: boolean): void;
  39282. /**
  39283. * Exits full screen mode
  39284. */
  39285. exitFullscreen(): void;
  39286. /**
  39287. * Enters Pointerlock mode
  39288. */
  39289. enterPointerlock(): void;
  39290. /**
  39291. * Exits Pointerlock mode
  39292. */
  39293. exitPointerlock(): void;
  39294. /**
  39295. * Begin a new frame
  39296. */
  39297. beginFrame(): void;
  39298. /**
  39299. * Enf the current frame
  39300. */
  39301. endFrame(): void;
  39302. resize(): void;
  39303. /**
  39304. * Force a specific size of the canvas
  39305. * @param width defines the new canvas' width
  39306. * @param height defines the new canvas' height
  39307. * @returns true if the size was changed
  39308. */
  39309. setSize(width: number, height: number): boolean;
  39310. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39311. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39312. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39313. _releaseTexture(texture: InternalTexture): void;
  39314. /**
  39315. * @hidden
  39316. * Rescales a texture
  39317. * @param source input texutre
  39318. * @param destination destination texture
  39319. * @param scene scene to use to render the resize
  39320. * @param internalFormat format to use when resizing
  39321. * @param onComplete callback to be called when resize has completed
  39322. */
  39323. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39324. /**
  39325. * Gets the current framerate
  39326. * @returns a number representing the framerate
  39327. */
  39328. getFps(): number;
  39329. /**
  39330. * Gets the time spent between current and previous frame
  39331. * @returns a number representing the delta time in ms
  39332. */
  39333. getDeltaTime(): number;
  39334. private _measureFps;
  39335. /** @hidden */
  39336. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  39337. /**
  39338. * Updates the sample count of a render target texture
  39339. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  39340. * @param texture defines the texture to update
  39341. * @param samples defines the sample count to set
  39342. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  39343. */
  39344. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  39345. /**
  39346. * Updates a depth texture Comparison Mode and Function.
  39347. * If the comparison Function is equal to 0, the mode will be set to none.
  39348. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  39349. * @param texture The texture to set the comparison function for
  39350. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  39351. */
  39352. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  39353. /**
  39354. * Creates a webGL buffer to use with instanciation
  39355. * @param capacity defines the size of the buffer
  39356. * @returns the webGL buffer
  39357. */
  39358. createInstancesBuffer(capacity: number): DataBuffer;
  39359. /**
  39360. * Delete a webGL buffer used with instanciation
  39361. * @param buffer defines the webGL buffer to delete
  39362. */
  39363. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  39364. private _clientWaitAsync;
  39365. /** @hidden */
  39366. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  39367. dispose(): void;
  39368. private _disableTouchAction;
  39369. /**
  39370. * Display the loading screen
  39371. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39372. */
  39373. displayLoadingUI(): void;
  39374. /**
  39375. * Hide the loading screen
  39376. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39377. */
  39378. hideLoadingUI(): void;
  39379. /**
  39380. * Gets the current loading screen object
  39381. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39382. */
  39383. get loadingScreen(): ILoadingScreen;
  39384. /**
  39385. * Sets the current loading screen object
  39386. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39387. */
  39388. set loadingScreen(loadingScreen: ILoadingScreen);
  39389. /**
  39390. * Sets the current loading screen text
  39391. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39392. */
  39393. set loadingUIText(text: string);
  39394. /**
  39395. * Sets the current loading screen background color
  39396. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39397. */
  39398. set loadingUIBackgroundColor(color: string);
  39399. /** Pointerlock and fullscreen */
  39400. /**
  39401. * Ask the browser to promote the current element to pointerlock mode
  39402. * @param element defines the DOM element to promote
  39403. */
  39404. static _RequestPointerlock(element: HTMLElement): void;
  39405. /**
  39406. * Asks the browser to exit pointerlock mode
  39407. */
  39408. static _ExitPointerlock(): void;
  39409. /**
  39410. * Ask the browser to promote the current element to fullscreen rendering mode
  39411. * @param element defines the DOM element to promote
  39412. */
  39413. static _RequestFullscreen(element: HTMLElement): void;
  39414. /**
  39415. * Asks the browser to exit fullscreen mode
  39416. */
  39417. static _ExitFullscreen(): void;
  39418. }
  39419. }
  39420. declare module "babylonjs/Engines/engineStore" {
  39421. import { Nullable } from "babylonjs/types";
  39422. import { Engine } from "babylonjs/Engines/engine";
  39423. import { Scene } from "babylonjs/scene";
  39424. /**
  39425. * The engine store class is responsible to hold all the instances of Engine and Scene created
  39426. * during the life time of the application.
  39427. */
  39428. export class EngineStore {
  39429. /** Gets the list of created engines */
  39430. static Instances: import("babylonjs/Engines/engine").Engine[];
  39431. /** @hidden */
  39432. static _LastCreatedScene: Nullable<Scene>;
  39433. /**
  39434. * Gets the latest created engine
  39435. */
  39436. static get LastCreatedEngine(): Nullable<Engine>;
  39437. /**
  39438. * Gets the latest created scene
  39439. */
  39440. static get LastCreatedScene(): Nullable<Scene>;
  39441. /**
  39442. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39443. * @ignorenaming
  39444. */
  39445. static UseFallbackTexture: boolean;
  39446. /**
  39447. * Texture content used if a texture cannot loaded
  39448. * @ignorenaming
  39449. */
  39450. static FallbackTexture: string;
  39451. }
  39452. }
  39453. declare module "babylonjs/Misc/promise" {
  39454. /**
  39455. * Helper class that provides a small promise polyfill
  39456. */
  39457. export class PromisePolyfill {
  39458. /**
  39459. * Static function used to check if the polyfill is required
  39460. * If this is the case then the function will inject the polyfill to window.Promise
  39461. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  39462. */
  39463. static Apply(force?: boolean): void;
  39464. }
  39465. }
  39466. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  39467. /**
  39468. * Interface for screenshot methods with describe argument called `size` as object with options
  39469. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  39470. */
  39471. export interface IScreenshotSize {
  39472. /**
  39473. * number in pixels for canvas height
  39474. */
  39475. height?: number;
  39476. /**
  39477. * multiplier allowing render at a higher or lower resolution
  39478. * If value is defined then height and width will be ignored and taken from camera
  39479. */
  39480. precision?: number;
  39481. /**
  39482. * number in pixels for canvas width
  39483. */
  39484. width?: number;
  39485. }
  39486. }
  39487. declare module "babylonjs/Misc/tools" {
  39488. import { Nullable, float } from "babylonjs/types";
  39489. import { DomManagement } from "babylonjs/Misc/domManagement";
  39490. import { WebRequest } from "babylonjs/Misc/webRequest";
  39491. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39492. import { ReadFileError } from "babylonjs/Misc/fileTools";
  39493. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39494. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  39495. import { Camera } from "babylonjs/Cameras/camera";
  39496. import { Engine } from "babylonjs/Engines/engine";
  39497. interface IColor4Like {
  39498. r: float;
  39499. g: float;
  39500. b: float;
  39501. a: float;
  39502. }
  39503. /**
  39504. * Class containing a set of static utilities functions
  39505. */
  39506. export class Tools {
  39507. /**
  39508. * Gets or sets the base URL to use to load assets
  39509. */
  39510. static get BaseUrl(): string;
  39511. static set BaseUrl(value: string);
  39512. /**
  39513. * Enable/Disable Custom HTTP Request Headers globally.
  39514. * default = false
  39515. * @see CustomRequestHeaders
  39516. */
  39517. static UseCustomRequestHeaders: boolean;
  39518. /**
  39519. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39520. * i.e. when loading files, where the server/service expects an Authorization header
  39521. */
  39522. static CustomRequestHeaders: {
  39523. [key: string]: string;
  39524. };
  39525. /**
  39526. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39527. */
  39528. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  39529. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  39530. /**
  39531. * Default behaviour for cors in the application.
  39532. * It can be a string if the expected behavior is identical in the entire app.
  39533. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39534. */
  39535. static get CorsBehavior(): string | ((url: string | string[]) => string);
  39536. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  39537. /**
  39538. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39539. * @ignorenaming
  39540. */
  39541. static get UseFallbackTexture(): boolean;
  39542. static set UseFallbackTexture(value: boolean);
  39543. /**
  39544. * Use this object to register external classes like custom textures or material
  39545. * to allow the laoders to instantiate them
  39546. */
  39547. static get RegisteredExternalClasses(): {
  39548. [key: string]: Object;
  39549. };
  39550. static set RegisteredExternalClasses(classes: {
  39551. [key: string]: Object;
  39552. });
  39553. /**
  39554. * Texture content used if a texture cannot loaded
  39555. * @ignorenaming
  39556. */
  39557. static get fallbackTexture(): string;
  39558. static set fallbackTexture(value: string);
  39559. /**
  39560. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39561. * @param u defines the coordinate on X axis
  39562. * @param v defines the coordinate on Y axis
  39563. * @param width defines the width of the source data
  39564. * @param height defines the height of the source data
  39565. * @param pixels defines the source byte array
  39566. * @param color defines the output color
  39567. */
  39568. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  39569. /**
  39570. * Interpolates between a and b via alpha
  39571. * @param a The lower value (returned when alpha = 0)
  39572. * @param b The upper value (returned when alpha = 1)
  39573. * @param alpha The interpolation-factor
  39574. * @return The mixed value
  39575. */
  39576. static Mix(a: number, b: number, alpha: number): number;
  39577. /**
  39578. * Tries to instantiate a new object from a given class name
  39579. * @param className defines the class name to instantiate
  39580. * @returns the new object or null if the system was not able to do the instantiation
  39581. */
  39582. static Instantiate(className: string): any;
  39583. /**
  39584. * Provides a slice function that will work even on IE
  39585. * @param data defines the array to slice
  39586. * @param start defines the start of the data (optional)
  39587. * @param end defines the end of the data (optional)
  39588. * @returns the new sliced array
  39589. */
  39590. static Slice<T>(data: T, start?: number, end?: number): T;
  39591. /**
  39592. * Polyfill for setImmediate
  39593. * @param action defines the action to execute after the current execution block
  39594. */
  39595. static SetImmediate(action: () => void): void;
  39596. /**
  39597. * Function indicating if a number is an exponent of 2
  39598. * @param value defines the value to test
  39599. * @returns true if the value is an exponent of 2
  39600. */
  39601. static IsExponentOfTwo(value: number): boolean;
  39602. private static _tmpFloatArray;
  39603. /**
  39604. * Returns the nearest 32-bit single precision float representation of a Number
  39605. * @param value A Number. If the parameter is of a different type, it will get converted
  39606. * to a number or to NaN if it cannot be converted
  39607. * @returns number
  39608. */
  39609. static FloatRound(value: number): number;
  39610. /**
  39611. * Extracts the filename from a path
  39612. * @param path defines the path to use
  39613. * @returns the filename
  39614. */
  39615. static GetFilename(path: string): string;
  39616. /**
  39617. * Extracts the "folder" part of a path (everything before the filename).
  39618. * @param uri The URI to extract the info from
  39619. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39620. * @returns The "folder" part of the path
  39621. */
  39622. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39623. /**
  39624. * Extracts text content from a DOM element hierarchy
  39625. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  39626. */
  39627. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  39628. /**
  39629. * Convert an angle in radians to degrees
  39630. * @param angle defines the angle to convert
  39631. * @returns the angle in degrees
  39632. */
  39633. static ToDegrees(angle: number): number;
  39634. /**
  39635. * Convert an angle in degrees to radians
  39636. * @param angle defines the angle to convert
  39637. * @returns the angle in radians
  39638. */
  39639. static ToRadians(angle: number): number;
  39640. /**
  39641. * Returns an array if obj is not an array
  39642. * @param obj defines the object to evaluate as an array
  39643. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39644. * @returns either obj directly if obj is an array or a new array containing obj
  39645. */
  39646. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39647. /**
  39648. * Gets the pointer prefix to use
  39649. * @param engine defines the engine we are finding the prefix for
  39650. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39651. */
  39652. static GetPointerPrefix(engine: Engine): string;
  39653. /**
  39654. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39655. * @param url define the url we are trying
  39656. * @param element define the dom element where to configure the cors policy
  39657. */
  39658. static SetCorsBehavior(url: string | string[], element: {
  39659. crossOrigin: string | null;
  39660. }): void;
  39661. /**
  39662. * Removes unwanted characters from an url
  39663. * @param url defines the url to clean
  39664. * @returns the cleaned url
  39665. */
  39666. static CleanUrl(url: string): string;
  39667. /**
  39668. * Gets or sets a function used to pre-process url before using them to load assets
  39669. */
  39670. static get PreprocessUrl(): (url: string) => string;
  39671. static set PreprocessUrl(processor: (url: string) => string);
  39672. /**
  39673. * Loads an image as an HTMLImageElement.
  39674. * @param input url string, ArrayBuffer, or Blob to load
  39675. * @param onLoad callback called when the image successfully loads
  39676. * @param onError callback called when the image fails to load
  39677. * @param offlineProvider offline provider for caching
  39678. * @param mimeType optional mime type
  39679. * @returns the HTMLImageElement of the loaded image
  39680. */
  39681. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  39682. /**
  39683. * Loads a file from a url
  39684. * @param url url string, ArrayBuffer, or Blob to load
  39685. * @param onSuccess callback called when the file successfully loads
  39686. * @param onProgress callback called while file is loading (if the server supports this mode)
  39687. * @param offlineProvider defines the offline provider for caching
  39688. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39689. * @param onError callback called when the file fails to load
  39690. * @returns a file request object
  39691. */
  39692. 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;
  39693. /**
  39694. * Loads a file from a url
  39695. * @param url the file url to load
  39696. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39697. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  39698. */
  39699. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  39700. /**
  39701. * Load a script (identified by an url). When the url returns, the
  39702. * content of this file is added into a new script element, attached to the DOM (body element)
  39703. * @param scriptUrl defines the url of the script to laod
  39704. * @param onSuccess defines the callback called when the script is loaded
  39705. * @param onError defines the callback to call if an error occurs
  39706. * @param scriptId defines the id of the script element
  39707. */
  39708. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  39709. /**
  39710. * Load an asynchronous script (identified by an url). When the url returns, the
  39711. * content of this file is added into a new script element, attached to the DOM (body element)
  39712. * @param scriptUrl defines the url of the script to laod
  39713. * @param scriptId defines the id of the script element
  39714. * @returns a promise request object
  39715. */
  39716. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  39717. /**
  39718. * Loads a file from a blob
  39719. * @param fileToLoad defines the blob to use
  39720. * @param callback defines the callback to call when data is loaded
  39721. * @param progressCallback defines the callback to call during loading process
  39722. * @returns a file request object
  39723. */
  39724. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39725. /**
  39726. * Reads a file from a File object
  39727. * @param file defines the file to load
  39728. * @param onSuccess defines the callback to call when data is loaded
  39729. * @param onProgress defines the callback to call during loading process
  39730. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39731. * @param onError defines the callback to call when an error occurs
  39732. * @returns a file request object
  39733. */
  39734. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39735. /**
  39736. * Creates a data url from a given string content
  39737. * @param content defines the content to convert
  39738. * @returns the new data url link
  39739. */
  39740. static FileAsURL(content: string): string;
  39741. /**
  39742. * Format the given number to a specific decimal format
  39743. * @param value defines the number to format
  39744. * @param decimals defines the number of decimals to use
  39745. * @returns the formatted string
  39746. */
  39747. static Format(value: number, decimals?: number): string;
  39748. /**
  39749. * Tries to copy an object by duplicating every property
  39750. * @param source defines the source object
  39751. * @param destination defines the target object
  39752. * @param doNotCopyList defines a list of properties to avoid
  39753. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39754. */
  39755. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39756. /**
  39757. * Gets a boolean indicating if the given object has no own property
  39758. * @param obj defines the object to test
  39759. * @returns true if object has no own property
  39760. */
  39761. static IsEmpty(obj: any): boolean;
  39762. /**
  39763. * Function used to register events at window level
  39764. * @param windowElement defines the Window object to use
  39765. * @param events defines the events to register
  39766. */
  39767. static RegisterTopRootEvents(windowElement: Window, events: {
  39768. name: string;
  39769. handler: Nullable<(e: FocusEvent) => any>;
  39770. }[]): void;
  39771. /**
  39772. * Function used to unregister events from window level
  39773. * @param windowElement defines the Window object to use
  39774. * @param events defines the events to unregister
  39775. */
  39776. static UnregisterTopRootEvents(windowElement: Window, events: {
  39777. name: string;
  39778. handler: Nullable<(e: FocusEvent) => any>;
  39779. }[]): void;
  39780. /**
  39781. * @ignore
  39782. */
  39783. static _ScreenshotCanvas: HTMLCanvasElement;
  39784. /**
  39785. * Dumps the current bound framebuffer
  39786. * @param width defines the rendering width
  39787. * @param height defines the rendering height
  39788. * @param engine defines the hosting engine
  39789. * @param successCallback defines the callback triggered once the data are available
  39790. * @param mimeType defines the mime type of the result
  39791. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39792. */
  39793. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39794. /**
  39795. * Converts the canvas data to blob.
  39796. * This acts as a polyfill for browsers not supporting the to blob function.
  39797. * @param canvas Defines the canvas to extract the data from
  39798. * @param successCallback Defines the callback triggered once the data are available
  39799. * @param mimeType Defines the mime type of the result
  39800. */
  39801. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39802. /**
  39803. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39804. * @param successCallback defines the callback triggered once the data are available
  39805. * @param mimeType defines the mime type of the result
  39806. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39807. */
  39808. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39809. /**
  39810. * Downloads a blob in the browser
  39811. * @param blob defines the blob to download
  39812. * @param fileName defines the name of the downloaded file
  39813. */
  39814. static Download(blob: Blob, fileName: string): void;
  39815. /**
  39816. * Captures a screenshot of the current rendering
  39817. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39818. * @param engine defines the rendering engine
  39819. * @param camera defines the source camera
  39820. * @param size This parameter can be set to a single number or to an object with the
  39821. * following (optional) properties: precision, width, height. If a single number is passed,
  39822. * it will be used for both width and height. If an object is passed, the screenshot size
  39823. * will be derived from the parameters. The precision property is a multiplier allowing
  39824. * rendering at a higher or lower resolution
  39825. * @param successCallback defines the callback receives a single parameter which contains the
  39826. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39827. * src parameter of an <img> to display it
  39828. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39829. * Check your browser for supported MIME types
  39830. */
  39831. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  39832. /**
  39833. * Captures a screenshot of the current rendering
  39834. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39835. * @param engine defines the rendering engine
  39836. * @param camera defines the source camera
  39837. * @param size This parameter can be set to a single number or to an object with the
  39838. * following (optional) properties: precision, width, height. If a single number is passed,
  39839. * it will be used for both width and height. If an object is passed, the screenshot size
  39840. * will be derived from the parameters. The precision property is a multiplier allowing
  39841. * rendering at a higher or lower resolution
  39842. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39843. * Check your browser for supported MIME types
  39844. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39845. * to the src parameter of an <img> to display it
  39846. */
  39847. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  39848. /**
  39849. * Generates an image screenshot from the specified camera.
  39850. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39851. * @param engine The engine to use for rendering
  39852. * @param camera The camera to use for rendering
  39853. * @param size This parameter can be set to a single number or to an object with the
  39854. * following (optional) properties: precision, width, height. If a single number is passed,
  39855. * it will be used for both width and height. If an object is passed, the screenshot size
  39856. * will be derived from the parameters. The precision property is a multiplier allowing
  39857. * rendering at a higher or lower resolution
  39858. * @param successCallback The callback receives a single parameter which contains the
  39859. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39860. * src parameter of an <img> to display it
  39861. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39862. * Check your browser for supported MIME types
  39863. * @param samples Texture samples (default: 1)
  39864. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39865. * @param fileName A name for for the downloaded file.
  39866. */
  39867. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39868. /**
  39869. * Generates an image screenshot from the specified camera.
  39870. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39871. * @param engine The engine to use for rendering
  39872. * @param camera The camera to use for rendering
  39873. * @param size This parameter can be set to a single number or to an object with the
  39874. * following (optional) properties: precision, width, height. If a single number is passed,
  39875. * it will be used for both width and height. If an object is passed, the screenshot size
  39876. * will be derived from the parameters. The precision property is a multiplier allowing
  39877. * rendering at a higher or lower resolution
  39878. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39879. * Check your browser for supported MIME types
  39880. * @param samples Texture samples (default: 1)
  39881. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39882. * @param fileName A name for for the downloaded file.
  39883. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39884. * to the src parameter of an <img> to display it
  39885. */
  39886. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  39887. /**
  39888. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39889. * Be aware Math.random() could cause collisions, but:
  39890. * "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"
  39891. * @returns a pseudo random id
  39892. */
  39893. static RandomId(): string;
  39894. /**
  39895. * Test if the given uri is a base64 string
  39896. * @param uri The uri to test
  39897. * @return True if the uri is a base64 string or false otherwise
  39898. */
  39899. static IsBase64(uri: string): boolean;
  39900. /**
  39901. * Decode the given base64 uri.
  39902. * @param uri The uri to decode
  39903. * @return The decoded base64 data.
  39904. */
  39905. static DecodeBase64(uri: string): ArrayBuffer;
  39906. /**
  39907. * Gets the absolute url.
  39908. * @param url the input url
  39909. * @return the absolute url
  39910. */
  39911. static GetAbsoluteUrl(url: string): string;
  39912. /**
  39913. * No log
  39914. */
  39915. static readonly NoneLogLevel: number;
  39916. /**
  39917. * Only message logs
  39918. */
  39919. static readonly MessageLogLevel: number;
  39920. /**
  39921. * Only warning logs
  39922. */
  39923. static readonly WarningLogLevel: number;
  39924. /**
  39925. * Only error logs
  39926. */
  39927. static readonly ErrorLogLevel: number;
  39928. /**
  39929. * All logs
  39930. */
  39931. static readonly AllLogLevel: number;
  39932. /**
  39933. * Gets a value indicating the number of loading errors
  39934. * @ignorenaming
  39935. */
  39936. static get errorsCount(): number;
  39937. /**
  39938. * Callback called when a new log is added
  39939. */
  39940. static OnNewCacheEntry: (entry: string) => void;
  39941. /**
  39942. * Log a message to the console
  39943. * @param message defines the message to log
  39944. */
  39945. static Log(message: string): void;
  39946. /**
  39947. * Write a warning message to the console
  39948. * @param message defines the message to log
  39949. */
  39950. static Warn(message: string): void;
  39951. /**
  39952. * Write an error message to the console
  39953. * @param message defines the message to log
  39954. */
  39955. static Error(message: string): void;
  39956. /**
  39957. * Gets current log cache (list of logs)
  39958. */
  39959. static get LogCache(): string;
  39960. /**
  39961. * Clears the log cache
  39962. */
  39963. static ClearLogCache(): void;
  39964. /**
  39965. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  39966. */
  39967. static set LogLevels(level: number);
  39968. /**
  39969. * Checks if the window object exists
  39970. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  39971. */
  39972. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  39973. /**
  39974. * No performance log
  39975. */
  39976. static readonly PerformanceNoneLogLevel: number;
  39977. /**
  39978. * Use user marks to log performance
  39979. */
  39980. static readonly PerformanceUserMarkLogLevel: number;
  39981. /**
  39982. * Log performance to the console
  39983. */
  39984. static readonly PerformanceConsoleLogLevel: number;
  39985. private static _performance;
  39986. /**
  39987. * Sets the current performance log level
  39988. */
  39989. static set PerformanceLogLevel(level: number);
  39990. private static _StartPerformanceCounterDisabled;
  39991. private static _EndPerformanceCounterDisabled;
  39992. private static _StartUserMark;
  39993. private static _EndUserMark;
  39994. private static _StartPerformanceConsole;
  39995. private static _EndPerformanceConsole;
  39996. /**
  39997. * Starts a performance counter
  39998. */
  39999. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40000. /**
  40001. * Ends a specific performance coutner
  40002. */
  40003. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40004. /**
  40005. * Gets either window.performance.now() if supported or Date.now() else
  40006. */
  40007. static get Now(): number;
  40008. /**
  40009. * This method will return the name of the class used to create the instance of the given object.
  40010. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  40011. * @param object the object to get the class name from
  40012. * @param isType defines if the object is actually a type
  40013. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  40014. */
  40015. static GetClassName(object: any, isType?: boolean): string;
  40016. /**
  40017. * Gets the first element of an array satisfying a given predicate
  40018. * @param array defines the array to browse
  40019. * @param predicate defines the predicate to use
  40020. * @returns null if not found or the element
  40021. */
  40022. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  40023. /**
  40024. * This method will return the name of the full name of the class, including its owning module (if any).
  40025. * 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).
  40026. * @param object the object to get the class name from
  40027. * @param isType defines if the object is actually a type
  40028. * @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.
  40029. * @ignorenaming
  40030. */
  40031. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  40032. /**
  40033. * Returns a promise that resolves after the given amount of time.
  40034. * @param delay Number of milliseconds to delay
  40035. * @returns Promise that resolves after the given amount of time
  40036. */
  40037. static DelayAsync(delay: number): Promise<void>;
  40038. /**
  40039. * Utility function to detect if the current user agent is Safari
  40040. * @returns whether or not the current user agent is safari
  40041. */
  40042. static IsSafari(): boolean;
  40043. }
  40044. /**
  40045. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40046. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40047. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40048. * @param name The name of the class, case should be preserved
  40049. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40050. */
  40051. export function className(name: string, module?: string): (target: Object) => void;
  40052. /**
  40053. * An implementation of a loop for asynchronous functions.
  40054. */
  40055. export class AsyncLoop {
  40056. /**
  40057. * Defines the number of iterations for the loop
  40058. */
  40059. iterations: number;
  40060. /**
  40061. * Defines the current index of the loop.
  40062. */
  40063. index: number;
  40064. private _done;
  40065. private _fn;
  40066. private _successCallback;
  40067. /**
  40068. * Constructor.
  40069. * @param iterations the number of iterations.
  40070. * @param func the function to run each iteration
  40071. * @param successCallback the callback that will be called upon succesful execution
  40072. * @param offset starting offset.
  40073. */
  40074. constructor(
  40075. /**
  40076. * Defines the number of iterations for the loop
  40077. */
  40078. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40079. /**
  40080. * Execute the next iteration. Must be called after the last iteration was finished.
  40081. */
  40082. executeNext(): void;
  40083. /**
  40084. * Break the loop and run the success callback.
  40085. */
  40086. breakLoop(): void;
  40087. /**
  40088. * Create and run an async loop.
  40089. * @param iterations the number of iterations.
  40090. * @param fn the function to run each iteration
  40091. * @param successCallback the callback that will be called upon succesful execution
  40092. * @param offset starting offset.
  40093. * @returns the created async loop object
  40094. */
  40095. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40096. /**
  40097. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40098. * @param iterations total number of iterations
  40099. * @param syncedIterations number of synchronous iterations in each async iteration.
  40100. * @param fn the function to call each iteration.
  40101. * @param callback a success call back that will be called when iterating stops.
  40102. * @param breakFunction a break condition (optional)
  40103. * @param timeout timeout settings for the setTimeout function. default - 0.
  40104. * @returns the created async loop object
  40105. */
  40106. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40107. }
  40108. }
  40109. declare module "babylonjs/Misc/stringDictionary" {
  40110. import { Nullable } from "babylonjs/types";
  40111. /**
  40112. * This class implement a typical dictionary using a string as key and the generic type T as value.
  40113. * The underlying implementation relies on an associative array to ensure the best performances.
  40114. * The value can be anything including 'null' but except 'undefined'
  40115. */
  40116. export class StringDictionary<T> {
  40117. /**
  40118. * This will clear this dictionary and copy the content from the 'source' one.
  40119. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  40120. * @param source the dictionary to take the content from and copy to this dictionary
  40121. */
  40122. copyFrom(source: StringDictionary<T>): void;
  40123. /**
  40124. * Get a value based from its key
  40125. * @param key the given key to get the matching value from
  40126. * @return the value if found, otherwise undefined is returned
  40127. */
  40128. get(key: string): T | undefined;
  40129. /**
  40130. * Get a value from its key or add it if it doesn't exist.
  40131. * This method will ensure you that a given key/data will be present in the dictionary.
  40132. * @param key the given key to get the matching value from
  40133. * @param factory the factory that will create the value if the key is not present in the dictionary.
  40134. * The factory will only be invoked if there's no data for the given key.
  40135. * @return the value corresponding to the key.
  40136. */
  40137. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  40138. /**
  40139. * Get a value from its key if present in the dictionary otherwise add it
  40140. * @param key the key to get the value from
  40141. * @param val if there's no such key/value pair in the dictionary add it with this value
  40142. * @return the value corresponding to the key
  40143. */
  40144. getOrAdd(key: string, val: T): T;
  40145. /**
  40146. * Check if there's a given key in the dictionary
  40147. * @param key the key to check for
  40148. * @return true if the key is present, false otherwise
  40149. */
  40150. contains(key: string): boolean;
  40151. /**
  40152. * Add a new key and its corresponding value
  40153. * @param key the key to add
  40154. * @param value the value corresponding to the key
  40155. * @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
  40156. */
  40157. add(key: string, value: T): boolean;
  40158. /**
  40159. * Update a specific value associated to a key
  40160. * @param key defines the key to use
  40161. * @param value defines the value to store
  40162. * @returns true if the value was updated (or false if the key was not found)
  40163. */
  40164. set(key: string, value: T): boolean;
  40165. /**
  40166. * Get the element of the given key and remove it from the dictionary
  40167. * @param key defines the key to search
  40168. * @returns the value associated with the key or null if not found
  40169. */
  40170. getAndRemove(key: string): Nullable<T>;
  40171. /**
  40172. * Remove a key/value from the dictionary.
  40173. * @param key the key to remove
  40174. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  40175. */
  40176. remove(key: string): boolean;
  40177. /**
  40178. * Clear the whole content of the dictionary
  40179. */
  40180. clear(): void;
  40181. /**
  40182. * Gets the current count
  40183. */
  40184. get count(): number;
  40185. /**
  40186. * Execute a callback on each key/val of the dictionary.
  40187. * Note that you can remove any element in this dictionary in the callback implementation
  40188. * @param callback the callback to execute on a given key/value pair
  40189. */
  40190. forEach(callback: (key: string, val: T) => void): void;
  40191. /**
  40192. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  40193. * If the callback returns null or undefined the method will iterate to the next key/value pair
  40194. * Note that you can remove any element in this dictionary in the callback implementation
  40195. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  40196. * @returns the first item
  40197. */
  40198. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  40199. private _count;
  40200. private _data;
  40201. }
  40202. }
  40203. declare module "babylonjs/Collisions/collisionCoordinator" {
  40204. import { Nullable } from "babylonjs/types";
  40205. import { Scene } from "babylonjs/scene";
  40206. import { Vector3 } from "babylonjs/Maths/math.vector";
  40207. import { Collider } from "babylonjs/Collisions/collider";
  40208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40209. /** @hidden */
  40210. export interface ICollisionCoordinator {
  40211. createCollider(): Collider;
  40212. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40213. init(scene: Scene): void;
  40214. }
  40215. /** @hidden */
  40216. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  40217. private _scene;
  40218. private _scaledPosition;
  40219. private _scaledVelocity;
  40220. private _finalPosition;
  40221. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40222. createCollider(): Collider;
  40223. init(scene: Scene): void;
  40224. private _collideWithWorld;
  40225. }
  40226. }
  40227. declare module "babylonjs/Inputs/scene.inputManager" {
  40228. import { Nullable } from "babylonjs/types";
  40229. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40230. import { Vector2 } from "babylonjs/Maths/math.vector";
  40231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40232. import { Scene } from "babylonjs/scene";
  40233. /**
  40234. * Class used to manage all inputs for the scene.
  40235. */
  40236. export class InputManager {
  40237. /** The distance in pixel that you have to move to prevent some events */
  40238. static DragMovementThreshold: number;
  40239. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  40240. static LongPressDelay: number;
  40241. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  40242. static DoubleClickDelay: number;
  40243. /** If you need to check double click without raising a single click at first click, enable this flag */
  40244. static ExclusiveDoubleClickMode: boolean;
  40245. /** 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. */
  40246. private _alreadyAttached;
  40247. private _wheelEventName;
  40248. private _onPointerMove;
  40249. private _onPointerDown;
  40250. private _onPointerUp;
  40251. private _initClickEvent;
  40252. private _initActionManager;
  40253. private _delayedSimpleClick;
  40254. private _delayedSimpleClickTimeout;
  40255. private _previousDelayedSimpleClickTimeout;
  40256. private _meshPickProceed;
  40257. private _previousButtonPressed;
  40258. private _currentPickResult;
  40259. private _previousPickResult;
  40260. private _totalPointersPressed;
  40261. private _doubleClickOccured;
  40262. private _pointerOverMesh;
  40263. private _pickedDownMesh;
  40264. private _pickedUpMesh;
  40265. private _pointerX;
  40266. private _pointerY;
  40267. private _unTranslatedPointerX;
  40268. private _unTranslatedPointerY;
  40269. private _startingPointerPosition;
  40270. private _previousStartingPointerPosition;
  40271. private _startingPointerTime;
  40272. private _previousStartingPointerTime;
  40273. private _pointerCaptures;
  40274. private _meshUnderPointerId;
  40275. private _onKeyDown;
  40276. private _onKeyUp;
  40277. private _onCanvasFocusObserver;
  40278. private _onCanvasBlurObserver;
  40279. private _scene;
  40280. /**
  40281. * Creates a new InputManager
  40282. * @param scene defines the hosting scene
  40283. */
  40284. constructor(scene: Scene);
  40285. /**
  40286. * Gets the mesh that is currently under the pointer
  40287. */
  40288. get meshUnderPointer(): Nullable<AbstractMesh>;
  40289. /**
  40290. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  40291. * @param pointerId the pointer id to use
  40292. * @returns The mesh under this pointer id or null if not found
  40293. */
  40294. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  40295. /**
  40296. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  40297. */
  40298. get unTranslatedPointer(): Vector2;
  40299. /**
  40300. * Gets or sets the current on-screen X position of the pointer
  40301. */
  40302. get pointerX(): number;
  40303. set pointerX(value: number);
  40304. /**
  40305. * Gets or sets the current on-screen Y position of the pointer
  40306. */
  40307. get pointerY(): number;
  40308. set pointerY(value: number);
  40309. private _updatePointerPosition;
  40310. private _processPointerMove;
  40311. private _setRayOnPointerInfo;
  40312. private _checkPrePointerObservable;
  40313. /**
  40314. * Use this method to simulate a pointer move on a mesh
  40315. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40316. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40317. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40318. */
  40319. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40320. /**
  40321. * Use this method to simulate a pointer down on a mesh
  40322. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40323. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40324. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40325. */
  40326. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40327. private _processPointerDown;
  40328. /** @hidden */
  40329. _isPointerSwiping(): boolean;
  40330. /**
  40331. * Use this method to simulate a pointer up on a mesh
  40332. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40333. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40334. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40335. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40336. */
  40337. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  40338. private _processPointerUp;
  40339. /**
  40340. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40341. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40342. * @returns true if the pointer was captured
  40343. */
  40344. isPointerCaptured(pointerId?: number): boolean;
  40345. /**
  40346. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40347. * @param attachUp defines if you want to attach events to pointerup
  40348. * @param attachDown defines if you want to attach events to pointerdown
  40349. * @param attachMove defines if you want to attach events to pointermove
  40350. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  40351. */
  40352. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  40353. /**
  40354. * Detaches all event handlers
  40355. */
  40356. detachControl(): void;
  40357. /**
  40358. * Force the value of meshUnderPointer
  40359. * @param mesh defines the mesh to use
  40360. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  40361. */
  40362. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  40363. /**
  40364. * Gets the mesh under the pointer
  40365. * @returns a Mesh or null if no mesh is under the pointer
  40366. */
  40367. getPointerOverMesh(): Nullable<AbstractMesh>;
  40368. }
  40369. }
  40370. declare module "babylonjs/Animations/animationGroup" {
  40371. import { Animatable } from "babylonjs/Animations/animatable";
  40372. import { Animation } from "babylonjs/Animations/animation";
  40373. import { Scene, IDisposable } from "babylonjs/scene";
  40374. import { Observable } from "babylonjs/Misc/observable";
  40375. import { Nullable } from "babylonjs/types";
  40376. import "babylonjs/Animations/animatable";
  40377. /**
  40378. * This class defines the direct association between an animation and a target
  40379. */
  40380. export class TargetedAnimation {
  40381. /**
  40382. * Animation to perform
  40383. */
  40384. animation: Animation;
  40385. /**
  40386. * Target to animate
  40387. */
  40388. target: any;
  40389. /**
  40390. * Returns the string "TargetedAnimation"
  40391. * @returns "TargetedAnimation"
  40392. */
  40393. getClassName(): string;
  40394. /**
  40395. * Serialize the object
  40396. * @returns the JSON object representing the current entity
  40397. */
  40398. serialize(): any;
  40399. }
  40400. /**
  40401. * Use this class to create coordinated animations on multiple targets
  40402. */
  40403. export class AnimationGroup implements IDisposable {
  40404. /** The name of the animation group */
  40405. name: string;
  40406. private _scene;
  40407. private _targetedAnimations;
  40408. private _animatables;
  40409. private _from;
  40410. private _to;
  40411. private _isStarted;
  40412. private _isPaused;
  40413. private _speedRatio;
  40414. private _loopAnimation;
  40415. private _isAdditive;
  40416. /**
  40417. * Gets or sets the unique id of the node
  40418. */
  40419. uniqueId: number;
  40420. /**
  40421. * This observable will notify when one animation have ended
  40422. */
  40423. onAnimationEndObservable: Observable<TargetedAnimation>;
  40424. /**
  40425. * Observer raised when one animation loops
  40426. */
  40427. onAnimationLoopObservable: Observable<TargetedAnimation>;
  40428. /**
  40429. * Observer raised when all animations have looped
  40430. */
  40431. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  40432. /**
  40433. * This observable will notify when all animations have ended.
  40434. */
  40435. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  40436. /**
  40437. * This observable will notify when all animations have paused.
  40438. */
  40439. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  40440. /**
  40441. * This observable will notify when all animations are playing.
  40442. */
  40443. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  40444. /**
  40445. * Gets the first frame
  40446. */
  40447. get from(): number;
  40448. /**
  40449. * Gets the last frame
  40450. */
  40451. get to(): number;
  40452. /**
  40453. * Define if the animations are started
  40454. */
  40455. get isStarted(): boolean;
  40456. /**
  40457. * Gets a value indicating that the current group is playing
  40458. */
  40459. get isPlaying(): boolean;
  40460. /**
  40461. * Gets or sets the speed ratio to use for all animations
  40462. */
  40463. get speedRatio(): number;
  40464. /**
  40465. * Gets or sets the speed ratio to use for all animations
  40466. */
  40467. set speedRatio(value: number);
  40468. /**
  40469. * Gets or sets if all animations should loop or not
  40470. */
  40471. get loopAnimation(): boolean;
  40472. set loopAnimation(value: boolean);
  40473. /**
  40474. * Gets or sets if all animations should be evaluated additively
  40475. */
  40476. get isAdditive(): boolean;
  40477. set isAdditive(value: boolean);
  40478. /**
  40479. * Gets the targeted animations for this animation group
  40480. */
  40481. get targetedAnimations(): Array<TargetedAnimation>;
  40482. /**
  40483. * returning the list of animatables controlled by this animation group.
  40484. */
  40485. get animatables(): Array<Animatable>;
  40486. /**
  40487. * Gets the list of target animations
  40488. */
  40489. get children(): TargetedAnimation[];
  40490. /**
  40491. * Instantiates a new Animation Group.
  40492. * This helps managing several animations at once.
  40493. * @see https://doc.babylonjs.com/how_to/group
  40494. * @param name Defines the name of the group
  40495. * @param scene Defines the scene the group belongs to
  40496. */
  40497. constructor(
  40498. /** The name of the animation group */
  40499. name: string, scene?: Nullable<Scene>);
  40500. /**
  40501. * Add an animation (with its target) in the group
  40502. * @param animation defines the animation we want to add
  40503. * @param target defines the target of the animation
  40504. * @returns the TargetedAnimation object
  40505. */
  40506. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  40507. /**
  40508. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  40509. * It can add constant keys at begin or end
  40510. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  40511. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  40512. * @returns the animation group
  40513. */
  40514. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  40515. private _animationLoopCount;
  40516. private _animationLoopFlags;
  40517. private _processLoop;
  40518. /**
  40519. * Start all animations on given targets
  40520. * @param loop defines if animations must loop
  40521. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  40522. * @param from defines the from key (optional)
  40523. * @param to defines the to key (optional)
  40524. * @param isAdditive defines the additive state for the resulting animatables (optional)
  40525. * @returns the current animation group
  40526. */
  40527. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  40528. /**
  40529. * Pause all animations
  40530. * @returns the animation group
  40531. */
  40532. pause(): AnimationGroup;
  40533. /**
  40534. * Play all animations to initial state
  40535. * This function will start() the animations if they were not started or will restart() them if they were paused
  40536. * @param loop defines if animations must loop
  40537. * @returns the animation group
  40538. */
  40539. play(loop?: boolean): AnimationGroup;
  40540. /**
  40541. * Reset all animations to initial state
  40542. * @returns the animation group
  40543. */
  40544. reset(): AnimationGroup;
  40545. /**
  40546. * Restart animations from key 0
  40547. * @returns the animation group
  40548. */
  40549. restart(): AnimationGroup;
  40550. /**
  40551. * Stop all animations
  40552. * @returns the animation group
  40553. */
  40554. stop(): AnimationGroup;
  40555. /**
  40556. * Set animation weight for all animatables
  40557. * @param weight defines the weight to use
  40558. * @return the animationGroup
  40559. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40560. */
  40561. setWeightForAllAnimatables(weight: number): AnimationGroup;
  40562. /**
  40563. * Synchronize and normalize all animatables with a source animatable
  40564. * @param root defines the root animatable to synchronize with
  40565. * @return the animationGroup
  40566. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40567. */
  40568. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  40569. /**
  40570. * Goes to a specific frame in this animation group
  40571. * @param frame the frame number to go to
  40572. * @return the animationGroup
  40573. */
  40574. goToFrame(frame: number): AnimationGroup;
  40575. /**
  40576. * Dispose all associated resources
  40577. */
  40578. dispose(): void;
  40579. private _checkAnimationGroupEnded;
  40580. /**
  40581. * Clone the current animation group and returns a copy
  40582. * @param newName defines the name of the new group
  40583. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  40584. * @returns the new aniamtion group
  40585. */
  40586. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  40587. /**
  40588. * Serializes the animationGroup to an object
  40589. * @returns Serialized object
  40590. */
  40591. serialize(): any;
  40592. /**
  40593. * Returns a new AnimationGroup object parsed from the source provided.
  40594. * @param parsedAnimationGroup defines the source
  40595. * @param scene defines the scene that will receive the animationGroup
  40596. * @returns a new AnimationGroup
  40597. */
  40598. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  40599. /**
  40600. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  40601. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  40602. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  40603. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  40604. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  40605. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  40606. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  40607. */
  40608. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  40609. /**
  40610. * Returns the string "AnimationGroup"
  40611. * @returns "AnimationGroup"
  40612. */
  40613. getClassName(): string;
  40614. /**
  40615. * Creates a detailled string about the object
  40616. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  40617. * @returns a string representing the object
  40618. */
  40619. toString(fullDetails?: boolean): string;
  40620. }
  40621. }
  40622. declare module "babylonjs/scene" {
  40623. import { Nullable } from "babylonjs/types";
  40624. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40625. import { Observable } from "babylonjs/Misc/observable";
  40626. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40627. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  40628. import { Geometry } from "babylonjs/Meshes/geometry";
  40629. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40630. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40632. import { Mesh } from "babylonjs/Meshes/mesh";
  40633. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  40634. import { Bone } from "babylonjs/Bones/bone";
  40635. import { Skeleton } from "babylonjs/Bones/skeleton";
  40636. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  40637. import { Camera } from "babylonjs/Cameras/camera";
  40638. import { AbstractScene } from "babylonjs/abstractScene";
  40639. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40640. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40641. import { Material } from "babylonjs/Materials/material";
  40642. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40643. import { Effect } from "babylonjs/Materials/effect";
  40644. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40645. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  40646. import { Light } from "babylonjs/Lights/light";
  40647. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40648. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  40649. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  40650. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  40651. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  40652. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40653. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  40654. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  40655. import { Engine } from "babylonjs/Engines/engine";
  40656. import { Node } from "babylonjs/node";
  40657. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  40658. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  40659. import { WebRequest } from "babylonjs/Misc/webRequest";
  40660. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  40661. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  40662. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40663. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  40664. import { Plane } from "babylonjs/Maths/math.plane";
  40665. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  40666. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  40667. import { Ray } from "babylonjs/Culling/ray";
  40668. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  40669. import { Animation } from "babylonjs/Animations/animation";
  40670. import { Animatable } from "babylonjs/Animations/animatable";
  40671. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  40672. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  40673. import { Collider } from "babylonjs/Collisions/collider";
  40674. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40675. /**
  40676. * Define an interface for all classes that will hold resources
  40677. */
  40678. export interface IDisposable {
  40679. /**
  40680. * Releases all held resources
  40681. */
  40682. dispose(): void;
  40683. }
  40684. /** Interface defining initialization parameters for Scene class */
  40685. export interface SceneOptions {
  40686. /**
  40687. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  40688. * It will improve performance when the number of geometries becomes important.
  40689. */
  40690. useGeometryUniqueIdsMap?: boolean;
  40691. /**
  40692. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  40693. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40694. */
  40695. useMaterialMeshMap?: boolean;
  40696. /**
  40697. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  40698. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40699. */
  40700. useClonedMeshMap?: boolean;
  40701. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  40702. virtual?: boolean;
  40703. }
  40704. /**
  40705. * Represents a scene to be rendered by the engine.
  40706. * @see https://doc.babylonjs.com/features/scene
  40707. */
  40708. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  40709. /** The fog is deactivated */
  40710. static readonly FOGMODE_NONE: number;
  40711. /** The fog density is following an exponential function */
  40712. static readonly FOGMODE_EXP: number;
  40713. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  40714. static readonly FOGMODE_EXP2: number;
  40715. /** The fog density is following a linear function. */
  40716. static readonly FOGMODE_LINEAR: number;
  40717. /**
  40718. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  40719. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40720. */
  40721. static MinDeltaTime: number;
  40722. /**
  40723. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  40724. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40725. */
  40726. static MaxDeltaTime: number;
  40727. /**
  40728. * Factory used to create the default material.
  40729. * @param name The name of the material to create
  40730. * @param scene The scene to create the material for
  40731. * @returns The default material
  40732. */
  40733. static DefaultMaterialFactory(scene: Scene): Material;
  40734. /**
  40735. * Factory used to create the a collision coordinator.
  40736. * @returns The collision coordinator
  40737. */
  40738. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  40739. /** @hidden */
  40740. _inputManager: InputManager;
  40741. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  40742. cameraToUseForPointers: Nullable<Camera>;
  40743. /** @hidden */
  40744. readonly _isScene: boolean;
  40745. /** @hidden */
  40746. _blockEntityCollection: boolean;
  40747. /**
  40748. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  40749. */
  40750. autoClear: boolean;
  40751. /**
  40752. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  40753. */
  40754. autoClearDepthAndStencil: boolean;
  40755. /**
  40756. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  40757. */
  40758. clearColor: Color4;
  40759. /**
  40760. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  40761. */
  40762. ambientColor: Color3;
  40763. /**
  40764. * This is use to store the default BRDF lookup for PBR materials in your scene.
  40765. * It should only be one of the following (if not the default embedded one):
  40766. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  40767. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  40768. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  40769. * The material properties need to be setup according to the type of texture in use.
  40770. */
  40771. environmentBRDFTexture: BaseTexture;
  40772. /**
  40773. * Texture used in all pbr material as the reflection texture.
  40774. * As in the majority of the scene they are the same (exception for multi room and so on),
  40775. * this is easier to reference from here than from all the materials.
  40776. */
  40777. get environmentTexture(): Nullable<BaseTexture>;
  40778. /**
  40779. * Texture used in all pbr material as the reflection texture.
  40780. * As in the majority of the scene they are the same (exception for multi room and so on),
  40781. * this is easier to set here than in all the materials.
  40782. */
  40783. set environmentTexture(value: Nullable<BaseTexture>);
  40784. /** @hidden */
  40785. protected _environmentIntensity: number;
  40786. /**
  40787. * Intensity of the environment in all pbr material.
  40788. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40789. * As in the majority of the scene they are the same (exception for multi room and so on),
  40790. * this is easier to reference from here than from all the materials.
  40791. */
  40792. get environmentIntensity(): number;
  40793. /**
  40794. * Intensity of the environment in all pbr material.
  40795. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40796. * As in the majority of the scene they are the same (exception for multi room and so on),
  40797. * this is easier to set here than in all the materials.
  40798. */
  40799. set environmentIntensity(value: number);
  40800. /** @hidden */
  40801. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40802. /**
  40803. * Default image processing configuration used either in the rendering
  40804. * Forward main pass or through the imageProcessingPostProcess if present.
  40805. * As in the majority of the scene they are the same (exception for multi camera),
  40806. * this is easier to reference from here than from all the materials and post process.
  40807. *
  40808. * No setter as we it is a shared configuration, you can set the values instead.
  40809. */
  40810. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  40811. private _forceWireframe;
  40812. /**
  40813. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  40814. */
  40815. set forceWireframe(value: boolean);
  40816. get forceWireframe(): boolean;
  40817. private _skipFrustumClipping;
  40818. /**
  40819. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  40820. */
  40821. set skipFrustumClipping(value: boolean);
  40822. get skipFrustumClipping(): boolean;
  40823. private _forcePointsCloud;
  40824. /**
  40825. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  40826. */
  40827. set forcePointsCloud(value: boolean);
  40828. get forcePointsCloud(): boolean;
  40829. /**
  40830. * Gets or sets the active clipplane 1
  40831. */
  40832. clipPlane: Nullable<Plane>;
  40833. /**
  40834. * Gets or sets the active clipplane 2
  40835. */
  40836. clipPlane2: Nullable<Plane>;
  40837. /**
  40838. * Gets or sets the active clipplane 3
  40839. */
  40840. clipPlane3: Nullable<Plane>;
  40841. /**
  40842. * Gets or sets the active clipplane 4
  40843. */
  40844. clipPlane4: Nullable<Plane>;
  40845. /**
  40846. * Gets or sets the active clipplane 5
  40847. */
  40848. clipPlane5: Nullable<Plane>;
  40849. /**
  40850. * Gets or sets the active clipplane 6
  40851. */
  40852. clipPlane6: Nullable<Plane>;
  40853. /**
  40854. * Gets or sets a boolean indicating if animations are enabled
  40855. */
  40856. animationsEnabled: boolean;
  40857. private _animationPropertiesOverride;
  40858. /**
  40859. * Gets or sets the animation properties override
  40860. */
  40861. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  40862. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  40863. /**
  40864. * Gets or sets a boolean indicating if a constant deltatime has to be used
  40865. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  40866. */
  40867. useConstantAnimationDeltaTime: boolean;
  40868. /**
  40869. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  40870. * Please note that it requires to run a ray cast through the scene on every frame
  40871. */
  40872. constantlyUpdateMeshUnderPointer: boolean;
  40873. /**
  40874. * Defines the HTML cursor to use when hovering over interactive elements
  40875. */
  40876. hoverCursor: string;
  40877. /**
  40878. * Defines the HTML default cursor to use (empty by default)
  40879. */
  40880. defaultCursor: string;
  40881. /**
  40882. * Defines whether cursors are handled by the scene.
  40883. */
  40884. doNotHandleCursors: boolean;
  40885. /**
  40886. * This is used to call preventDefault() on pointer down
  40887. * in order to block unwanted artifacts like system double clicks
  40888. */
  40889. preventDefaultOnPointerDown: boolean;
  40890. /**
  40891. * This is used to call preventDefault() on pointer up
  40892. * in order to block unwanted artifacts like system double clicks
  40893. */
  40894. preventDefaultOnPointerUp: boolean;
  40895. /**
  40896. * Gets or sets user defined metadata
  40897. */
  40898. metadata: any;
  40899. /**
  40900. * For internal use only. Please do not use.
  40901. */
  40902. reservedDataStore: any;
  40903. /**
  40904. * Gets the name of the plugin used to load this scene (null by default)
  40905. */
  40906. loadingPluginName: string;
  40907. /**
  40908. * Use this array to add regular expressions used to disable offline support for specific urls
  40909. */
  40910. disableOfflineSupportExceptionRules: RegExp[];
  40911. /**
  40912. * An event triggered when the scene is disposed.
  40913. */
  40914. onDisposeObservable: Observable<Scene>;
  40915. private _onDisposeObserver;
  40916. /** Sets a function to be executed when this scene is disposed. */
  40917. set onDispose(callback: () => void);
  40918. /**
  40919. * An event triggered before rendering the scene (right after animations and physics)
  40920. */
  40921. onBeforeRenderObservable: Observable<Scene>;
  40922. private _onBeforeRenderObserver;
  40923. /** Sets a function to be executed before rendering this scene */
  40924. set beforeRender(callback: Nullable<() => void>);
  40925. /**
  40926. * An event triggered after rendering the scene
  40927. */
  40928. onAfterRenderObservable: Observable<Scene>;
  40929. /**
  40930. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  40931. */
  40932. onAfterRenderCameraObservable: Observable<Camera>;
  40933. private _onAfterRenderObserver;
  40934. /** Sets a function to be executed after rendering this scene */
  40935. set afterRender(callback: Nullable<() => void>);
  40936. /**
  40937. * An event triggered before animating the scene
  40938. */
  40939. onBeforeAnimationsObservable: Observable<Scene>;
  40940. /**
  40941. * An event triggered after animations processing
  40942. */
  40943. onAfterAnimationsObservable: Observable<Scene>;
  40944. /**
  40945. * An event triggered before draw calls are ready to be sent
  40946. */
  40947. onBeforeDrawPhaseObservable: Observable<Scene>;
  40948. /**
  40949. * An event triggered after draw calls have been sent
  40950. */
  40951. onAfterDrawPhaseObservable: Observable<Scene>;
  40952. /**
  40953. * An event triggered when the scene is ready
  40954. */
  40955. onReadyObservable: Observable<Scene>;
  40956. /**
  40957. * An event triggered before rendering a camera
  40958. */
  40959. onBeforeCameraRenderObservable: Observable<Camera>;
  40960. private _onBeforeCameraRenderObserver;
  40961. /** Sets a function to be executed before rendering a camera*/
  40962. set beforeCameraRender(callback: () => void);
  40963. /**
  40964. * An event triggered after rendering a camera
  40965. */
  40966. onAfterCameraRenderObservable: Observable<Camera>;
  40967. private _onAfterCameraRenderObserver;
  40968. /** Sets a function to be executed after rendering a camera*/
  40969. set afterCameraRender(callback: () => void);
  40970. /**
  40971. * An event triggered when active meshes evaluation is about to start
  40972. */
  40973. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  40974. /**
  40975. * An event triggered when active meshes evaluation is done
  40976. */
  40977. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  40978. /**
  40979. * An event triggered when particles rendering is about to start
  40980. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  40981. */
  40982. onBeforeParticlesRenderingObservable: Observable<Scene>;
  40983. /**
  40984. * An event triggered when particles rendering is done
  40985. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  40986. */
  40987. onAfterParticlesRenderingObservable: Observable<Scene>;
  40988. /**
  40989. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  40990. */
  40991. onDataLoadedObservable: Observable<Scene>;
  40992. /**
  40993. * An event triggered when a camera is created
  40994. */
  40995. onNewCameraAddedObservable: Observable<Camera>;
  40996. /**
  40997. * An event triggered when a camera is removed
  40998. */
  40999. onCameraRemovedObservable: Observable<Camera>;
  41000. /**
  41001. * An event triggered when a light is created
  41002. */
  41003. onNewLightAddedObservable: Observable<Light>;
  41004. /**
  41005. * An event triggered when a light is removed
  41006. */
  41007. onLightRemovedObservable: Observable<Light>;
  41008. /**
  41009. * An event triggered when a geometry is created
  41010. */
  41011. onNewGeometryAddedObservable: Observable<Geometry>;
  41012. /**
  41013. * An event triggered when a geometry is removed
  41014. */
  41015. onGeometryRemovedObservable: Observable<Geometry>;
  41016. /**
  41017. * An event triggered when a transform node is created
  41018. */
  41019. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  41020. /**
  41021. * An event triggered when a transform node is removed
  41022. */
  41023. onTransformNodeRemovedObservable: Observable<TransformNode>;
  41024. /**
  41025. * An event triggered when a mesh is created
  41026. */
  41027. onNewMeshAddedObservable: Observable<AbstractMesh>;
  41028. /**
  41029. * An event triggered when a mesh is removed
  41030. */
  41031. onMeshRemovedObservable: Observable<AbstractMesh>;
  41032. /**
  41033. * An event triggered when a skeleton is created
  41034. */
  41035. onNewSkeletonAddedObservable: Observable<Skeleton>;
  41036. /**
  41037. * An event triggered when a skeleton is removed
  41038. */
  41039. onSkeletonRemovedObservable: Observable<Skeleton>;
  41040. /**
  41041. * An event triggered when a material is created
  41042. */
  41043. onNewMaterialAddedObservable: Observable<Material>;
  41044. /**
  41045. * An event triggered when a material is removed
  41046. */
  41047. onMaterialRemovedObservable: Observable<Material>;
  41048. /**
  41049. * An event triggered when a texture is created
  41050. */
  41051. onNewTextureAddedObservable: Observable<BaseTexture>;
  41052. /**
  41053. * An event triggered when a texture is removed
  41054. */
  41055. onTextureRemovedObservable: Observable<BaseTexture>;
  41056. /**
  41057. * An event triggered when render targets are about to be rendered
  41058. * Can happen multiple times per frame.
  41059. */
  41060. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  41061. /**
  41062. * An event triggered when render targets were rendered.
  41063. * Can happen multiple times per frame.
  41064. */
  41065. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  41066. /**
  41067. * An event triggered before calculating deterministic simulation step
  41068. */
  41069. onBeforeStepObservable: Observable<Scene>;
  41070. /**
  41071. * An event triggered after calculating deterministic simulation step
  41072. */
  41073. onAfterStepObservable: Observable<Scene>;
  41074. /**
  41075. * An event triggered when the activeCamera property is updated
  41076. */
  41077. onActiveCameraChanged: Observable<Scene>;
  41078. /**
  41079. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  41080. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41081. * 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)
  41082. */
  41083. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41084. /**
  41085. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  41086. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41087. * 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)
  41088. */
  41089. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41090. /**
  41091. * This Observable will when a mesh has been imported into the scene.
  41092. */
  41093. onMeshImportedObservable: Observable<AbstractMesh>;
  41094. /**
  41095. * This Observable will when an animation file has been imported into the scene.
  41096. */
  41097. onAnimationFileImportedObservable: Observable<Scene>;
  41098. /**
  41099. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  41100. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  41101. */
  41102. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  41103. /** @hidden */
  41104. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  41105. /**
  41106. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  41107. */
  41108. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  41109. /**
  41110. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  41111. */
  41112. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  41113. /**
  41114. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  41115. */
  41116. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  41117. /** Callback called when a pointer move is detected */
  41118. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41119. /** Callback called when a pointer down is detected */
  41120. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41121. /** Callback called when a pointer up is detected */
  41122. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  41123. /** Callback called when a pointer pick is detected */
  41124. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  41125. /**
  41126. * 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).
  41127. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  41128. */
  41129. onPrePointerObservable: Observable<PointerInfoPre>;
  41130. /**
  41131. * Observable event triggered each time an input event is received from the rendering canvas
  41132. */
  41133. onPointerObservable: Observable<PointerInfo>;
  41134. /**
  41135. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  41136. */
  41137. get unTranslatedPointer(): Vector2;
  41138. /**
  41139. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  41140. */
  41141. static get DragMovementThreshold(): number;
  41142. static set DragMovementThreshold(value: number);
  41143. /**
  41144. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  41145. */
  41146. static get LongPressDelay(): number;
  41147. static set LongPressDelay(value: number);
  41148. /**
  41149. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  41150. */
  41151. static get DoubleClickDelay(): number;
  41152. static set DoubleClickDelay(value: number);
  41153. /** If you need to check double click without raising a single click at first click, enable this flag */
  41154. static get ExclusiveDoubleClickMode(): boolean;
  41155. static set ExclusiveDoubleClickMode(value: boolean);
  41156. /** @hidden */
  41157. _mirroredCameraPosition: Nullable<Vector3>;
  41158. /**
  41159. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  41160. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  41161. */
  41162. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  41163. /**
  41164. * Observable event triggered each time an keyboard event is received from the hosting window
  41165. */
  41166. onKeyboardObservable: Observable<KeyboardInfo>;
  41167. private _useRightHandedSystem;
  41168. /**
  41169. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  41170. */
  41171. set useRightHandedSystem(value: boolean);
  41172. get useRightHandedSystem(): boolean;
  41173. private _timeAccumulator;
  41174. private _currentStepId;
  41175. private _currentInternalStep;
  41176. /**
  41177. * Sets the step Id used by deterministic lock step
  41178. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41179. * @param newStepId defines the step Id
  41180. */
  41181. setStepId(newStepId: number): void;
  41182. /**
  41183. * Gets the step Id used by deterministic lock step
  41184. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41185. * @returns the step Id
  41186. */
  41187. getStepId(): number;
  41188. /**
  41189. * Gets the internal step used by deterministic lock step
  41190. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41191. * @returns the internal step
  41192. */
  41193. getInternalStep(): number;
  41194. private _fogEnabled;
  41195. /**
  41196. * Gets or sets a boolean indicating if fog is enabled on this scene
  41197. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41198. * (Default is true)
  41199. */
  41200. set fogEnabled(value: boolean);
  41201. get fogEnabled(): boolean;
  41202. private _fogMode;
  41203. /**
  41204. * Gets or sets the fog mode to use
  41205. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41206. * | mode | value |
  41207. * | --- | --- |
  41208. * | FOGMODE_NONE | 0 |
  41209. * | FOGMODE_EXP | 1 |
  41210. * | FOGMODE_EXP2 | 2 |
  41211. * | FOGMODE_LINEAR | 3 |
  41212. */
  41213. set fogMode(value: number);
  41214. get fogMode(): number;
  41215. /**
  41216. * Gets or sets the fog color to use
  41217. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41218. * (Default is Color3(0.2, 0.2, 0.3))
  41219. */
  41220. fogColor: Color3;
  41221. /**
  41222. * Gets or sets the fog density to use
  41223. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41224. * (Default is 0.1)
  41225. */
  41226. fogDensity: number;
  41227. /**
  41228. * Gets or sets the fog start distance to use
  41229. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41230. * (Default is 0)
  41231. */
  41232. fogStart: number;
  41233. /**
  41234. * Gets or sets the fog end distance to use
  41235. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41236. * (Default is 1000)
  41237. */
  41238. fogEnd: number;
  41239. /**
  41240. * Flag indicating that the frame buffer binding is handled by another component
  41241. */
  41242. prePass: boolean;
  41243. private _shadowsEnabled;
  41244. /**
  41245. * Gets or sets a boolean indicating if shadows are enabled on this scene
  41246. */
  41247. set shadowsEnabled(value: boolean);
  41248. get shadowsEnabled(): boolean;
  41249. private _lightsEnabled;
  41250. /**
  41251. * Gets or sets a boolean indicating if lights are enabled on this scene
  41252. */
  41253. set lightsEnabled(value: boolean);
  41254. get lightsEnabled(): boolean;
  41255. /** All of the active cameras added to this scene. */
  41256. activeCameras: Camera[];
  41257. /** @hidden */
  41258. _activeCamera: Nullable<Camera>;
  41259. /** Gets or sets the current active camera */
  41260. get activeCamera(): Nullable<Camera>;
  41261. set activeCamera(value: Nullable<Camera>);
  41262. private _defaultMaterial;
  41263. /** The default material used on meshes when no material is affected */
  41264. get defaultMaterial(): Material;
  41265. /** The default material used on meshes when no material is affected */
  41266. set defaultMaterial(value: Material);
  41267. private _texturesEnabled;
  41268. /**
  41269. * Gets or sets a boolean indicating if textures are enabled on this scene
  41270. */
  41271. set texturesEnabled(value: boolean);
  41272. get texturesEnabled(): boolean;
  41273. /**
  41274. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  41275. */
  41276. physicsEnabled: boolean;
  41277. /**
  41278. * Gets or sets a boolean indicating if particles are enabled on this scene
  41279. */
  41280. particlesEnabled: boolean;
  41281. /**
  41282. * Gets or sets a boolean indicating if sprites are enabled on this scene
  41283. */
  41284. spritesEnabled: boolean;
  41285. private _skeletonsEnabled;
  41286. /**
  41287. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  41288. */
  41289. set skeletonsEnabled(value: boolean);
  41290. get skeletonsEnabled(): boolean;
  41291. /**
  41292. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  41293. */
  41294. lensFlaresEnabled: boolean;
  41295. /**
  41296. * Gets or sets a boolean indicating if collisions are enabled on this scene
  41297. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41298. */
  41299. collisionsEnabled: boolean;
  41300. private _collisionCoordinator;
  41301. /** @hidden */
  41302. get collisionCoordinator(): ICollisionCoordinator;
  41303. /**
  41304. * Defines the gravity applied to this scene (used only for collisions)
  41305. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41306. */
  41307. gravity: Vector3;
  41308. /**
  41309. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  41310. */
  41311. postProcessesEnabled: boolean;
  41312. /**
  41313. * Gets the current postprocess manager
  41314. */
  41315. postProcessManager: PostProcessManager;
  41316. /**
  41317. * Gets or sets a boolean indicating if render targets are enabled on this scene
  41318. */
  41319. renderTargetsEnabled: boolean;
  41320. /**
  41321. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  41322. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  41323. */
  41324. dumpNextRenderTargets: boolean;
  41325. /**
  41326. * The list of user defined render targets added to the scene
  41327. */
  41328. customRenderTargets: RenderTargetTexture[];
  41329. /**
  41330. * Defines if texture loading must be delayed
  41331. * If true, textures will only be loaded when they need to be rendered
  41332. */
  41333. useDelayedTextureLoading: boolean;
  41334. /**
  41335. * Gets the list of meshes imported to the scene through SceneLoader
  41336. */
  41337. importedMeshesFiles: String[];
  41338. /**
  41339. * Gets or sets a boolean indicating if probes are enabled on this scene
  41340. */
  41341. probesEnabled: boolean;
  41342. /**
  41343. * Gets or sets the current offline provider to use to store scene data
  41344. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  41345. */
  41346. offlineProvider: IOfflineProvider;
  41347. /**
  41348. * Gets or sets the action manager associated with the scene
  41349. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41350. */
  41351. actionManager: AbstractActionManager;
  41352. private _meshesForIntersections;
  41353. /**
  41354. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  41355. */
  41356. proceduralTexturesEnabled: boolean;
  41357. private _engine;
  41358. private _totalVertices;
  41359. /** @hidden */
  41360. _activeIndices: PerfCounter;
  41361. /** @hidden */
  41362. _activeParticles: PerfCounter;
  41363. /** @hidden */
  41364. _activeBones: PerfCounter;
  41365. private _animationRatio;
  41366. /** @hidden */
  41367. _animationTimeLast: number;
  41368. /** @hidden */
  41369. _animationTime: number;
  41370. /**
  41371. * Gets or sets a general scale for animation speed
  41372. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  41373. */
  41374. animationTimeScale: number;
  41375. /** @hidden */
  41376. _cachedMaterial: Nullable<Material>;
  41377. /** @hidden */
  41378. _cachedEffect: Nullable<Effect>;
  41379. /** @hidden */
  41380. _cachedVisibility: Nullable<number>;
  41381. private _renderId;
  41382. private _frameId;
  41383. private _executeWhenReadyTimeoutId;
  41384. private _intermediateRendering;
  41385. private _viewUpdateFlag;
  41386. private _projectionUpdateFlag;
  41387. /** @hidden */
  41388. _toBeDisposed: Nullable<IDisposable>[];
  41389. private _activeRequests;
  41390. /** @hidden */
  41391. _pendingData: any[];
  41392. private _isDisposed;
  41393. /**
  41394. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  41395. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  41396. */
  41397. dispatchAllSubMeshesOfActiveMeshes: boolean;
  41398. private _activeMeshes;
  41399. private _processedMaterials;
  41400. private _renderTargets;
  41401. /** @hidden */
  41402. _activeParticleSystems: SmartArray<IParticleSystem>;
  41403. private _activeSkeletons;
  41404. private _softwareSkinnedMeshes;
  41405. private _renderingManager;
  41406. /** @hidden */
  41407. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  41408. private _transformMatrix;
  41409. private _sceneUbo;
  41410. /** @hidden */
  41411. _viewMatrix: Matrix;
  41412. private _projectionMatrix;
  41413. /** @hidden */
  41414. _forcedViewPosition: Nullable<Vector3>;
  41415. /** @hidden */
  41416. _frustumPlanes: Plane[];
  41417. /**
  41418. * Gets the list of frustum planes (built from the active camera)
  41419. */
  41420. get frustumPlanes(): Plane[];
  41421. /**
  41422. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  41423. * This is useful if there are more lights that the maximum simulteanous authorized
  41424. */
  41425. requireLightSorting: boolean;
  41426. /** @hidden */
  41427. readonly useMaterialMeshMap: boolean;
  41428. /** @hidden */
  41429. readonly useClonedMeshMap: boolean;
  41430. private _externalData;
  41431. private _uid;
  41432. /**
  41433. * @hidden
  41434. * Backing store of defined scene components.
  41435. */
  41436. _components: ISceneComponent[];
  41437. /**
  41438. * @hidden
  41439. * Backing store of defined scene components.
  41440. */
  41441. _serializableComponents: ISceneSerializableComponent[];
  41442. /**
  41443. * List of components to register on the next registration step.
  41444. */
  41445. private _transientComponents;
  41446. /**
  41447. * Registers the transient components if needed.
  41448. */
  41449. private _registerTransientComponents;
  41450. /**
  41451. * @hidden
  41452. * Add a component to the scene.
  41453. * Note that the ccomponent could be registered on th next frame if this is called after
  41454. * the register component stage.
  41455. * @param component Defines the component to add to the scene
  41456. */
  41457. _addComponent(component: ISceneComponent): void;
  41458. /**
  41459. * @hidden
  41460. * Gets a component from the scene.
  41461. * @param name defines the name of the component to retrieve
  41462. * @returns the component or null if not present
  41463. */
  41464. _getComponent(name: string): Nullable<ISceneComponent>;
  41465. /**
  41466. * @hidden
  41467. * Defines the actions happening before camera updates.
  41468. */
  41469. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  41470. /**
  41471. * @hidden
  41472. * Defines the actions happening before clear the canvas.
  41473. */
  41474. _beforeClearStage: Stage<SimpleStageAction>;
  41475. /**
  41476. * @hidden
  41477. * Defines the actions when collecting render targets for the frame.
  41478. */
  41479. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41480. /**
  41481. * @hidden
  41482. * Defines the actions happening for one camera in the frame.
  41483. */
  41484. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41485. /**
  41486. * @hidden
  41487. * Defines the actions happening during the per mesh ready checks.
  41488. */
  41489. _isReadyForMeshStage: Stage<MeshStageAction>;
  41490. /**
  41491. * @hidden
  41492. * Defines the actions happening before evaluate active mesh checks.
  41493. */
  41494. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  41495. /**
  41496. * @hidden
  41497. * Defines the actions happening during the evaluate sub mesh checks.
  41498. */
  41499. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  41500. /**
  41501. * @hidden
  41502. * Defines the actions happening during the active mesh stage.
  41503. */
  41504. _activeMeshStage: Stage<ActiveMeshStageAction>;
  41505. /**
  41506. * @hidden
  41507. * Defines the actions happening during the per camera render target step.
  41508. */
  41509. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  41510. /**
  41511. * @hidden
  41512. * Defines the actions happening just before the active camera is drawing.
  41513. */
  41514. _beforeCameraDrawStage: Stage<CameraStageAction>;
  41515. /**
  41516. * @hidden
  41517. * Defines the actions happening just before a render target is drawing.
  41518. */
  41519. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41520. /**
  41521. * @hidden
  41522. * Defines the actions happening just before a rendering group is drawing.
  41523. */
  41524. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41525. /**
  41526. * @hidden
  41527. * Defines the actions happening just before a mesh is drawing.
  41528. */
  41529. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41530. /**
  41531. * @hidden
  41532. * Defines the actions happening just after a mesh has been drawn.
  41533. */
  41534. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41535. /**
  41536. * @hidden
  41537. * Defines the actions happening just after a rendering group has been drawn.
  41538. */
  41539. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41540. /**
  41541. * @hidden
  41542. * Defines the actions happening just after the active camera has been drawn.
  41543. */
  41544. _afterCameraDrawStage: Stage<CameraStageAction>;
  41545. /**
  41546. * @hidden
  41547. * Defines the actions happening just after a render target has been drawn.
  41548. */
  41549. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41550. /**
  41551. * @hidden
  41552. * Defines the actions happening just after rendering all cameras and computing intersections.
  41553. */
  41554. _afterRenderStage: Stage<SimpleStageAction>;
  41555. /**
  41556. * @hidden
  41557. * Defines the actions happening when a pointer move event happens.
  41558. */
  41559. _pointerMoveStage: Stage<PointerMoveStageAction>;
  41560. /**
  41561. * @hidden
  41562. * Defines the actions happening when a pointer down event happens.
  41563. */
  41564. _pointerDownStage: Stage<PointerUpDownStageAction>;
  41565. /**
  41566. * @hidden
  41567. * Defines the actions happening when a pointer up event happens.
  41568. */
  41569. _pointerUpStage: Stage<PointerUpDownStageAction>;
  41570. /**
  41571. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  41572. */
  41573. private geometriesByUniqueId;
  41574. /**
  41575. * Creates a new Scene
  41576. * @param engine defines the engine to use to render this scene
  41577. * @param options defines the scene options
  41578. */
  41579. constructor(engine: Engine, options?: SceneOptions);
  41580. /**
  41581. * Gets a string identifying the name of the class
  41582. * @returns "Scene" string
  41583. */
  41584. getClassName(): string;
  41585. private _defaultMeshCandidates;
  41586. /**
  41587. * @hidden
  41588. */
  41589. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41590. private _defaultSubMeshCandidates;
  41591. /**
  41592. * @hidden
  41593. */
  41594. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41595. /**
  41596. * Sets the default candidate providers for the scene.
  41597. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  41598. * and getCollidingSubMeshCandidates to their default function
  41599. */
  41600. setDefaultCandidateProviders(): void;
  41601. /**
  41602. * Gets the mesh that is currently under the pointer
  41603. */
  41604. get meshUnderPointer(): Nullable<AbstractMesh>;
  41605. /**
  41606. * Gets or sets the current on-screen X position of the pointer
  41607. */
  41608. get pointerX(): number;
  41609. set pointerX(value: number);
  41610. /**
  41611. * Gets or sets the current on-screen Y position of the pointer
  41612. */
  41613. get pointerY(): number;
  41614. set pointerY(value: number);
  41615. /**
  41616. * Gets the cached material (ie. the latest rendered one)
  41617. * @returns the cached material
  41618. */
  41619. getCachedMaterial(): Nullable<Material>;
  41620. /**
  41621. * Gets the cached effect (ie. the latest rendered one)
  41622. * @returns the cached effect
  41623. */
  41624. getCachedEffect(): Nullable<Effect>;
  41625. /**
  41626. * Gets the cached visibility state (ie. the latest rendered one)
  41627. * @returns the cached visibility state
  41628. */
  41629. getCachedVisibility(): Nullable<number>;
  41630. /**
  41631. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  41632. * @param material defines the current material
  41633. * @param effect defines the current effect
  41634. * @param visibility defines the current visibility state
  41635. * @returns true if one parameter is not cached
  41636. */
  41637. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  41638. /**
  41639. * Gets the engine associated with the scene
  41640. * @returns an Engine
  41641. */
  41642. getEngine(): Engine;
  41643. /**
  41644. * Gets the total number of vertices rendered per frame
  41645. * @returns the total number of vertices rendered per frame
  41646. */
  41647. getTotalVertices(): number;
  41648. /**
  41649. * Gets the performance counter for total vertices
  41650. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41651. */
  41652. get totalVerticesPerfCounter(): PerfCounter;
  41653. /**
  41654. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  41655. * @returns the total number of active indices rendered per frame
  41656. */
  41657. getActiveIndices(): number;
  41658. /**
  41659. * Gets the performance counter for active indices
  41660. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41661. */
  41662. get totalActiveIndicesPerfCounter(): PerfCounter;
  41663. /**
  41664. * Gets the total number of active particles rendered per frame
  41665. * @returns the total number of active particles rendered per frame
  41666. */
  41667. getActiveParticles(): number;
  41668. /**
  41669. * Gets the performance counter for active particles
  41670. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41671. */
  41672. get activeParticlesPerfCounter(): PerfCounter;
  41673. /**
  41674. * Gets the total number of active bones rendered per frame
  41675. * @returns the total number of active bones rendered per frame
  41676. */
  41677. getActiveBones(): number;
  41678. /**
  41679. * Gets the performance counter for active bones
  41680. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41681. */
  41682. get activeBonesPerfCounter(): PerfCounter;
  41683. /**
  41684. * Gets the array of active meshes
  41685. * @returns an array of AbstractMesh
  41686. */
  41687. getActiveMeshes(): SmartArray<AbstractMesh>;
  41688. /**
  41689. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  41690. * @returns a number
  41691. */
  41692. getAnimationRatio(): number;
  41693. /**
  41694. * Gets an unique Id for the current render phase
  41695. * @returns a number
  41696. */
  41697. getRenderId(): number;
  41698. /**
  41699. * Gets an unique Id for the current frame
  41700. * @returns a number
  41701. */
  41702. getFrameId(): number;
  41703. /** Call this function if you want to manually increment the render Id*/
  41704. incrementRenderId(): void;
  41705. private _createUbo;
  41706. /**
  41707. * Use this method to simulate a pointer move on a mesh
  41708. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41709. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41710. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41711. * @returns the current scene
  41712. */
  41713. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41714. /**
  41715. * Use this method to simulate a pointer down on a mesh
  41716. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41717. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41718. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41719. * @returns the current scene
  41720. */
  41721. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41722. /**
  41723. * Use this method to simulate a pointer up on a mesh
  41724. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41725. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41726. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41727. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  41728. * @returns the current scene
  41729. */
  41730. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  41731. /**
  41732. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  41733. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  41734. * @returns true if the pointer was captured
  41735. */
  41736. isPointerCaptured(pointerId?: number): boolean;
  41737. /**
  41738. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  41739. * @param attachUp defines if you want to attach events to pointerup
  41740. * @param attachDown defines if you want to attach events to pointerdown
  41741. * @param attachMove defines if you want to attach events to pointermove
  41742. */
  41743. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  41744. /** Detaches all event handlers*/
  41745. detachControl(): void;
  41746. /**
  41747. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  41748. * Delay loaded resources are not taking in account
  41749. * @return true if all required resources are ready
  41750. */
  41751. isReady(): boolean;
  41752. /** Resets all cached information relative to material (including effect and visibility) */
  41753. resetCachedMaterial(): void;
  41754. /**
  41755. * Registers a function to be called before every frame render
  41756. * @param func defines the function to register
  41757. */
  41758. registerBeforeRender(func: () => void): void;
  41759. /**
  41760. * Unregisters a function called before every frame render
  41761. * @param func defines the function to unregister
  41762. */
  41763. unregisterBeforeRender(func: () => void): void;
  41764. /**
  41765. * Registers a function to be called after every frame render
  41766. * @param func defines the function to register
  41767. */
  41768. registerAfterRender(func: () => void): void;
  41769. /**
  41770. * Unregisters a function called after every frame render
  41771. * @param func defines the function to unregister
  41772. */
  41773. unregisterAfterRender(func: () => void): void;
  41774. private _executeOnceBeforeRender;
  41775. /**
  41776. * The provided function will run before render once and will be disposed afterwards.
  41777. * A timeout delay can be provided so that the function will be executed in N ms.
  41778. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  41779. * @param func The function to be executed.
  41780. * @param timeout optional delay in ms
  41781. */
  41782. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  41783. /** @hidden */
  41784. _addPendingData(data: any): void;
  41785. /** @hidden */
  41786. _removePendingData(data: any): void;
  41787. /**
  41788. * Returns the number of items waiting to be loaded
  41789. * @returns the number of items waiting to be loaded
  41790. */
  41791. getWaitingItemsCount(): number;
  41792. /**
  41793. * Returns a boolean indicating if the scene is still loading data
  41794. */
  41795. get isLoading(): boolean;
  41796. /**
  41797. * Registers a function to be executed when the scene is ready
  41798. * @param {Function} func - the function to be executed
  41799. */
  41800. executeWhenReady(func: () => void): void;
  41801. /**
  41802. * Returns a promise that resolves when the scene is ready
  41803. * @returns A promise that resolves when the scene is ready
  41804. */
  41805. whenReadyAsync(): Promise<void>;
  41806. /** @hidden */
  41807. _checkIsReady(): void;
  41808. /**
  41809. * Gets all animatable attached to the scene
  41810. */
  41811. get animatables(): Animatable[];
  41812. /**
  41813. * Resets the last animation time frame.
  41814. * Useful to override when animations start running when loading a scene for the first time.
  41815. */
  41816. resetLastAnimationTimeFrame(): void;
  41817. /**
  41818. * Gets the current view matrix
  41819. * @returns a Matrix
  41820. */
  41821. getViewMatrix(): Matrix;
  41822. /**
  41823. * Gets the current projection matrix
  41824. * @returns a Matrix
  41825. */
  41826. getProjectionMatrix(): Matrix;
  41827. /**
  41828. * Gets the current transform matrix
  41829. * @returns a Matrix made of View * Projection
  41830. */
  41831. getTransformMatrix(): Matrix;
  41832. /**
  41833. * Sets the current transform matrix
  41834. * @param viewL defines the View matrix to use
  41835. * @param projectionL defines the Projection matrix to use
  41836. * @param viewR defines the right View matrix to use (if provided)
  41837. * @param projectionR defines the right Projection matrix to use (if provided)
  41838. */
  41839. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  41840. /**
  41841. * Gets the uniform buffer used to store scene data
  41842. * @returns a UniformBuffer
  41843. */
  41844. getSceneUniformBuffer(): UniformBuffer;
  41845. /**
  41846. * Gets an unique (relatively to the current scene) Id
  41847. * @returns an unique number for the scene
  41848. */
  41849. getUniqueId(): number;
  41850. /**
  41851. * Add a mesh to the list of scene's meshes
  41852. * @param newMesh defines the mesh to add
  41853. * @param recursive if all child meshes should also be added to the scene
  41854. */
  41855. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  41856. /**
  41857. * Remove a mesh for the list of scene's meshes
  41858. * @param toRemove defines the mesh to remove
  41859. * @param recursive if all child meshes should also be removed from the scene
  41860. * @returns the index where the mesh was in the mesh list
  41861. */
  41862. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  41863. /**
  41864. * Add a transform node to the list of scene's transform nodes
  41865. * @param newTransformNode defines the transform node to add
  41866. */
  41867. addTransformNode(newTransformNode: TransformNode): void;
  41868. /**
  41869. * Remove a transform node for the list of scene's transform nodes
  41870. * @param toRemove defines the transform node to remove
  41871. * @returns the index where the transform node was in the transform node list
  41872. */
  41873. removeTransformNode(toRemove: TransformNode): number;
  41874. /**
  41875. * Remove a skeleton for the list of scene's skeletons
  41876. * @param toRemove defines the skeleton to remove
  41877. * @returns the index where the skeleton was in the skeleton list
  41878. */
  41879. removeSkeleton(toRemove: Skeleton): number;
  41880. /**
  41881. * Remove a morph target for the list of scene's morph targets
  41882. * @param toRemove defines the morph target to remove
  41883. * @returns the index where the morph target was in the morph target list
  41884. */
  41885. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  41886. /**
  41887. * Remove a light for the list of scene's lights
  41888. * @param toRemove defines the light to remove
  41889. * @returns the index where the light was in the light list
  41890. */
  41891. removeLight(toRemove: Light): number;
  41892. /**
  41893. * Remove a camera for the list of scene's cameras
  41894. * @param toRemove defines the camera to remove
  41895. * @returns the index where the camera was in the camera list
  41896. */
  41897. removeCamera(toRemove: Camera): number;
  41898. /**
  41899. * Remove a particle system for the list of scene's particle systems
  41900. * @param toRemove defines the particle system to remove
  41901. * @returns the index where the particle system was in the particle system list
  41902. */
  41903. removeParticleSystem(toRemove: IParticleSystem): number;
  41904. /**
  41905. * Remove a animation for the list of scene's animations
  41906. * @param toRemove defines the animation to remove
  41907. * @returns the index where the animation was in the animation list
  41908. */
  41909. removeAnimation(toRemove: Animation): number;
  41910. /**
  41911. * Will stop the animation of the given target
  41912. * @param target - the target
  41913. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  41914. * @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)
  41915. */
  41916. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  41917. /**
  41918. * Removes the given animation group from this scene.
  41919. * @param toRemove The animation group to remove
  41920. * @returns The index of the removed animation group
  41921. */
  41922. removeAnimationGroup(toRemove: AnimationGroup): number;
  41923. /**
  41924. * Removes the given multi-material from this scene.
  41925. * @param toRemove The multi-material to remove
  41926. * @returns The index of the removed multi-material
  41927. */
  41928. removeMultiMaterial(toRemove: MultiMaterial): number;
  41929. /**
  41930. * Removes the given material from this scene.
  41931. * @param toRemove The material to remove
  41932. * @returns The index of the removed material
  41933. */
  41934. removeMaterial(toRemove: Material): number;
  41935. /**
  41936. * Removes the given action manager from this scene.
  41937. * @param toRemove The action manager to remove
  41938. * @returns The index of the removed action manager
  41939. */
  41940. removeActionManager(toRemove: AbstractActionManager): number;
  41941. /**
  41942. * Removes the given texture from this scene.
  41943. * @param toRemove The texture to remove
  41944. * @returns The index of the removed texture
  41945. */
  41946. removeTexture(toRemove: BaseTexture): number;
  41947. /**
  41948. * Adds the given light to this scene
  41949. * @param newLight The light to add
  41950. */
  41951. addLight(newLight: Light): void;
  41952. /**
  41953. * Sorts the list list based on light priorities
  41954. */
  41955. sortLightsByPriority(): void;
  41956. /**
  41957. * Adds the given camera to this scene
  41958. * @param newCamera The camera to add
  41959. */
  41960. addCamera(newCamera: Camera): void;
  41961. /**
  41962. * Adds the given skeleton to this scene
  41963. * @param newSkeleton The skeleton to add
  41964. */
  41965. addSkeleton(newSkeleton: Skeleton): void;
  41966. /**
  41967. * Adds the given particle system to this scene
  41968. * @param newParticleSystem The particle system to add
  41969. */
  41970. addParticleSystem(newParticleSystem: IParticleSystem): void;
  41971. /**
  41972. * Adds the given animation to this scene
  41973. * @param newAnimation The animation to add
  41974. */
  41975. addAnimation(newAnimation: Animation): void;
  41976. /**
  41977. * Adds the given animation group to this scene.
  41978. * @param newAnimationGroup The animation group to add
  41979. */
  41980. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  41981. /**
  41982. * Adds the given multi-material to this scene
  41983. * @param newMultiMaterial The multi-material to add
  41984. */
  41985. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  41986. /**
  41987. * Adds the given material to this scene
  41988. * @param newMaterial The material to add
  41989. */
  41990. addMaterial(newMaterial: Material): void;
  41991. /**
  41992. * Adds the given morph target to this scene
  41993. * @param newMorphTargetManager The morph target to add
  41994. */
  41995. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  41996. /**
  41997. * Adds the given geometry to this scene
  41998. * @param newGeometry The geometry to add
  41999. */
  42000. addGeometry(newGeometry: Geometry): void;
  42001. /**
  42002. * Adds the given action manager to this scene
  42003. * @param newActionManager The action manager to add
  42004. */
  42005. addActionManager(newActionManager: AbstractActionManager): void;
  42006. /**
  42007. * Adds the given texture to this scene.
  42008. * @param newTexture The texture to add
  42009. */
  42010. addTexture(newTexture: BaseTexture): void;
  42011. /**
  42012. * Switch active camera
  42013. * @param newCamera defines the new active camera
  42014. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  42015. */
  42016. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  42017. /**
  42018. * sets the active camera of the scene using its ID
  42019. * @param id defines the camera's ID
  42020. * @return the new active camera or null if none found.
  42021. */
  42022. setActiveCameraByID(id: string): Nullable<Camera>;
  42023. /**
  42024. * sets the active camera of the scene using its name
  42025. * @param name defines the camera's name
  42026. * @returns the new active camera or null if none found.
  42027. */
  42028. setActiveCameraByName(name: string): Nullable<Camera>;
  42029. /**
  42030. * get an animation group using its name
  42031. * @param name defines the material's name
  42032. * @return the animation group or null if none found.
  42033. */
  42034. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  42035. /**
  42036. * Get a material using its unique id
  42037. * @param uniqueId defines the material's unique id
  42038. * @return the material or null if none found.
  42039. */
  42040. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  42041. /**
  42042. * get a material using its id
  42043. * @param id defines the material's ID
  42044. * @return the material or null if none found.
  42045. */
  42046. getMaterialByID(id: string): Nullable<Material>;
  42047. /**
  42048. * Gets a the last added material using a given id
  42049. * @param id defines the material's ID
  42050. * @return the last material with the given id or null if none found.
  42051. */
  42052. getLastMaterialByID(id: string): Nullable<Material>;
  42053. /**
  42054. * Gets a material using its name
  42055. * @param name defines the material's name
  42056. * @return the material or null if none found.
  42057. */
  42058. getMaterialByName(name: string): Nullable<Material>;
  42059. /**
  42060. * Get a texture using its unique id
  42061. * @param uniqueId defines the texture's unique id
  42062. * @return the texture or null if none found.
  42063. */
  42064. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  42065. /**
  42066. * Gets a camera using its id
  42067. * @param id defines the id to look for
  42068. * @returns the camera or null if not found
  42069. */
  42070. getCameraByID(id: string): Nullable<Camera>;
  42071. /**
  42072. * Gets a camera using its unique id
  42073. * @param uniqueId defines the unique id to look for
  42074. * @returns the camera or null if not found
  42075. */
  42076. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  42077. /**
  42078. * Gets a camera using its name
  42079. * @param name defines the camera's name
  42080. * @return the camera or null if none found.
  42081. */
  42082. getCameraByName(name: string): Nullable<Camera>;
  42083. /**
  42084. * Gets a bone using its id
  42085. * @param id defines the bone's id
  42086. * @return the bone or null if not found
  42087. */
  42088. getBoneByID(id: string): Nullable<Bone>;
  42089. /**
  42090. * Gets a bone using its id
  42091. * @param name defines the bone's name
  42092. * @return the bone or null if not found
  42093. */
  42094. getBoneByName(name: string): Nullable<Bone>;
  42095. /**
  42096. * Gets a light node using its name
  42097. * @param name defines the the light's name
  42098. * @return the light or null if none found.
  42099. */
  42100. getLightByName(name: string): Nullable<Light>;
  42101. /**
  42102. * Gets a light node using its id
  42103. * @param id defines the light's id
  42104. * @return the light or null if none found.
  42105. */
  42106. getLightByID(id: string): Nullable<Light>;
  42107. /**
  42108. * Gets a light node using its scene-generated unique ID
  42109. * @param uniqueId defines the light's unique id
  42110. * @return the light or null if none found.
  42111. */
  42112. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  42113. /**
  42114. * Gets a particle system by id
  42115. * @param id defines the particle system id
  42116. * @return the corresponding system or null if none found
  42117. */
  42118. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  42119. /**
  42120. * Gets a geometry using its ID
  42121. * @param id defines the geometry's id
  42122. * @return the geometry or null if none found.
  42123. */
  42124. getGeometryByID(id: string): Nullable<Geometry>;
  42125. private _getGeometryByUniqueID;
  42126. /**
  42127. * Add a new geometry to this scene
  42128. * @param geometry defines the geometry to be added to the scene.
  42129. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  42130. * @return a boolean defining if the geometry was added or not
  42131. */
  42132. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  42133. /**
  42134. * Removes an existing geometry
  42135. * @param geometry defines the geometry to be removed from the scene
  42136. * @return a boolean defining if the geometry was removed or not
  42137. */
  42138. removeGeometry(geometry: Geometry): boolean;
  42139. /**
  42140. * Gets the list of geometries attached to the scene
  42141. * @returns an array of Geometry
  42142. */
  42143. getGeometries(): Geometry[];
  42144. /**
  42145. * Gets the first added mesh found of a given ID
  42146. * @param id defines the id to search for
  42147. * @return the mesh found or null if not found at all
  42148. */
  42149. getMeshByID(id: string): Nullable<AbstractMesh>;
  42150. /**
  42151. * Gets a list of meshes using their id
  42152. * @param id defines the id to search for
  42153. * @returns a list of meshes
  42154. */
  42155. getMeshesByID(id: string): Array<AbstractMesh>;
  42156. /**
  42157. * Gets the first added transform node found of a given ID
  42158. * @param id defines the id to search for
  42159. * @return the found transform node or null if not found at all.
  42160. */
  42161. getTransformNodeByID(id: string): Nullable<TransformNode>;
  42162. /**
  42163. * Gets a transform node with its auto-generated unique id
  42164. * @param uniqueId efines the unique id to search for
  42165. * @return the found transform node or null if not found at all.
  42166. */
  42167. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  42168. /**
  42169. * Gets a list of transform nodes using their id
  42170. * @param id defines the id to search for
  42171. * @returns a list of transform nodes
  42172. */
  42173. getTransformNodesByID(id: string): Array<TransformNode>;
  42174. /**
  42175. * Gets a mesh with its auto-generated unique id
  42176. * @param uniqueId defines the unique id to search for
  42177. * @return the found mesh or null if not found at all.
  42178. */
  42179. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  42180. /**
  42181. * Gets a the last added mesh using a given id
  42182. * @param id defines the id to search for
  42183. * @return the found mesh or null if not found at all.
  42184. */
  42185. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  42186. /**
  42187. * Gets a the last added node (Mesh, Camera, Light) using a given id
  42188. * @param id defines the id to search for
  42189. * @return the found node or null if not found at all
  42190. */
  42191. getLastEntryByID(id: string): Nullable<Node>;
  42192. /**
  42193. * Gets a node (Mesh, Camera, Light) using a given id
  42194. * @param id defines the id to search for
  42195. * @return the found node or null if not found at all
  42196. */
  42197. getNodeByID(id: string): Nullable<Node>;
  42198. /**
  42199. * Gets a node (Mesh, Camera, Light) using a given name
  42200. * @param name defines the name to search for
  42201. * @return the found node or null if not found at all.
  42202. */
  42203. getNodeByName(name: string): Nullable<Node>;
  42204. /**
  42205. * Gets a mesh using a given name
  42206. * @param name defines the name to search for
  42207. * @return the found mesh or null if not found at all.
  42208. */
  42209. getMeshByName(name: string): Nullable<AbstractMesh>;
  42210. /**
  42211. * Gets a transform node using a given name
  42212. * @param name defines the name to search for
  42213. * @return the found transform node or null if not found at all.
  42214. */
  42215. getTransformNodeByName(name: string): Nullable<TransformNode>;
  42216. /**
  42217. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  42218. * @param id defines the id to search for
  42219. * @return the found skeleton or null if not found at all.
  42220. */
  42221. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  42222. /**
  42223. * Gets a skeleton using a given auto generated unique id
  42224. * @param uniqueId defines the unique id to search for
  42225. * @return the found skeleton or null if not found at all.
  42226. */
  42227. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  42228. /**
  42229. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  42230. * @param id defines the id to search for
  42231. * @return the found skeleton or null if not found at all.
  42232. */
  42233. getSkeletonById(id: string): Nullable<Skeleton>;
  42234. /**
  42235. * Gets a skeleton using a given name
  42236. * @param name defines the name to search for
  42237. * @return the found skeleton or null if not found at all.
  42238. */
  42239. getSkeletonByName(name: string): Nullable<Skeleton>;
  42240. /**
  42241. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  42242. * @param id defines the id to search for
  42243. * @return the found morph target manager or null if not found at all.
  42244. */
  42245. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  42246. /**
  42247. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  42248. * @param id defines the id to search for
  42249. * @return the found morph target or null if not found at all.
  42250. */
  42251. getMorphTargetById(id: string): Nullable<MorphTarget>;
  42252. /**
  42253. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  42254. * @param name defines the name to search for
  42255. * @return the found morph target or null if not found at all.
  42256. */
  42257. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  42258. /**
  42259. * Gets a post process using a given name (if many are found, this function will pick the first one)
  42260. * @param name defines the name to search for
  42261. * @return the found post process or null if not found at all.
  42262. */
  42263. getPostProcessByName(name: string): Nullable<PostProcess>;
  42264. /**
  42265. * Gets a boolean indicating if the given mesh is active
  42266. * @param mesh defines the mesh to look for
  42267. * @returns true if the mesh is in the active list
  42268. */
  42269. isActiveMesh(mesh: AbstractMesh): boolean;
  42270. /**
  42271. * Return a unique id as a string which can serve as an identifier for the scene
  42272. */
  42273. get uid(): string;
  42274. /**
  42275. * Add an externaly attached data from its key.
  42276. * This method call will fail and return false, if such key already exists.
  42277. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  42278. * @param key the unique key that identifies the data
  42279. * @param data the data object to associate to the key for this Engine instance
  42280. * @return true if no such key were already present and the data was added successfully, false otherwise
  42281. */
  42282. addExternalData<T>(key: string, data: T): boolean;
  42283. /**
  42284. * Get an externaly attached data from its key
  42285. * @param key the unique key that identifies the data
  42286. * @return the associated data, if present (can be null), or undefined if not present
  42287. */
  42288. getExternalData<T>(key: string): Nullable<T>;
  42289. /**
  42290. * Get an externaly attached data from its key, create it using a factory if it's not already present
  42291. * @param key the unique key that identifies the data
  42292. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  42293. * @return the associated data, can be null if the factory returned null.
  42294. */
  42295. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  42296. /**
  42297. * Remove an externaly attached data from the Engine instance
  42298. * @param key the unique key that identifies the data
  42299. * @return true if the data was successfully removed, false if it doesn't exist
  42300. */
  42301. removeExternalData(key: string): boolean;
  42302. private _evaluateSubMesh;
  42303. /**
  42304. * Clear the processed materials smart array preventing retention point in material dispose.
  42305. */
  42306. freeProcessedMaterials(): void;
  42307. private _preventFreeActiveMeshesAndRenderingGroups;
  42308. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  42309. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  42310. * when disposing several meshes in a row or a hierarchy of meshes.
  42311. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  42312. */
  42313. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  42314. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  42315. /**
  42316. * Clear the active meshes smart array preventing retention point in mesh dispose.
  42317. */
  42318. freeActiveMeshes(): void;
  42319. /**
  42320. * Clear the info related to rendering groups preventing retention points during dispose.
  42321. */
  42322. freeRenderingGroups(): void;
  42323. /** @hidden */
  42324. _isInIntermediateRendering(): boolean;
  42325. /**
  42326. * Lambda returning the list of potentially active meshes.
  42327. */
  42328. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  42329. /**
  42330. * Lambda returning the list of potentially active sub meshes.
  42331. */
  42332. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  42333. /**
  42334. * Lambda returning the list of potentially intersecting sub meshes.
  42335. */
  42336. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  42337. /**
  42338. * Lambda returning the list of potentially colliding sub meshes.
  42339. */
  42340. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  42341. private _activeMeshesFrozen;
  42342. private _skipEvaluateActiveMeshesCompletely;
  42343. /**
  42344. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  42345. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  42346. * @returns the current scene
  42347. */
  42348. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  42349. /**
  42350. * Use this function to restart evaluating active meshes on every frame
  42351. * @returns the current scene
  42352. */
  42353. unfreezeActiveMeshes(): Scene;
  42354. private _evaluateActiveMeshes;
  42355. private _activeMesh;
  42356. /**
  42357. * Update the transform matrix to update from the current active camera
  42358. * @param force defines a boolean used to force the update even if cache is up to date
  42359. */
  42360. updateTransformMatrix(force?: boolean): void;
  42361. private _bindFrameBuffer;
  42362. /** @hidden */
  42363. _allowPostProcessClearColor: boolean;
  42364. /** @hidden */
  42365. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  42366. private _processSubCameras;
  42367. private _checkIntersections;
  42368. /** @hidden */
  42369. _advancePhysicsEngineStep(step: number): void;
  42370. /**
  42371. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  42372. */
  42373. getDeterministicFrameTime: () => number;
  42374. /** @hidden */
  42375. _animate(): void;
  42376. /** Execute all animations (for a frame) */
  42377. animate(): void;
  42378. /**
  42379. * Render the scene
  42380. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  42381. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  42382. */
  42383. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  42384. /**
  42385. * Freeze all materials
  42386. * A frozen material will not be updatable but should be faster to render
  42387. */
  42388. freezeMaterials(): void;
  42389. /**
  42390. * Unfreeze all materials
  42391. * A frozen material will not be updatable but should be faster to render
  42392. */
  42393. unfreezeMaterials(): void;
  42394. /**
  42395. * Releases all held ressources
  42396. */
  42397. dispose(): void;
  42398. /**
  42399. * Gets if the scene is already disposed
  42400. */
  42401. get isDisposed(): boolean;
  42402. /**
  42403. * Call this function to reduce memory footprint of the scene.
  42404. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  42405. */
  42406. clearCachedVertexData(): void;
  42407. /**
  42408. * This function will remove the local cached buffer data from texture.
  42409. * It will save memory but will prevent the texture from being rebuilt
  42410. */
  42411. cleanCachedTextureBuffer(): void;
  42412. /**
  42413. * Get the world extend vectors with an optional filter
  42414. *
  42415. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  42416. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  42417. */
  42418. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  42419. min: Vector3;
  42420. max: Vector3;
  42421. };
  42422. /**
  42423. * Creates a ray that can be used to pick in the scene
  42424. * @param x defines the x coordinate of the origin (on-screen)
  42425. * @param y defines the y coordinate of the origin (on-screen)
  42426. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42427. * @param camera defines the camera to use for the picking
  42428. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42429. * @returns a Ray
  42430. */
  42431. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  42432. /**
  42433. * Creates a ray that can be used to pick in the scene
  42434. * @param x defines the x coordinate of the origin (on-screen)
  42435. * @param y defines the y coordinate of the origin (on-screen)
  42436. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42437. * @param result defines the ray where to store the picking ray
  42438. * @param camera defines the camera to use for the picking
  42439. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42440. * @returns the current scene
  42441. */
  42442. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  42443. /**
  42444. * Creates a ray that can be used to pick in the scene
  42445. * @param x defines the x coordinate of the origin (on-screen)
  42446. * @param y defines the y coordinate of the origin (on-screen)
  42447. * @param camera defines the camera to use for the picking
  42448. * @returns a Ray
  42449. */
  42450. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  42451. /**
  42452. * Creates a ray that can be used to pick in the scene
  42453. * @param x defines the x coordinate of the origin (on-screen)
  42454. * @param y defines the y coordinate of the origin (on-screen)
  42455. * @param result defines the ray where to store the picking ray
  42456. * @param camera defines the camera to use for the picking
  42457. * @returns the current scene
  42458. */
  42459. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  42460. /** Launch a ray to try to pick a mesh in the scene
  42461. * @param x position on screen
  42462. * @param y position on screen
  42463. * @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
  42464. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42465. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42466. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42467. * @returns a PickingInfo
  42468. */
  42469. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42470. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  42471. * @param x position on screen
  42472. * @param y position on screen
  42473. * @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
  42474. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42475. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42476. * @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)
  42477. */
  42478. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  42479. /** Use the given ray to pick a mesh in the scene
  42480. * @param ray The ray to use to pick meshes
  42481. * @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
  42482. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42483. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42484. * @returns a PickingInfo
  42485. */
  42486. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42487. /**
  42488. * Launch a ray to try to pick a mesh in the scene
  42489. * @param x X position on screen
  42490. * @param y Y position on screen
  42491. * @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
  42492. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42493. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42494. * @returns an array of PickingInfo
  42495. */
  42496. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42497. /**
  42498. * Launch a ray to try to pick a mesh in the scene
  42499. * @param ray Ray to use
  42500. * @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
  42501. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42502. * @returns an array of PickingInfo
  42503. */
  42504. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42505. /**
  42506. * Force the value of meshUnderPointer
  42507. * @param mesh defines the mesh to use
  42508. * @param pointerId optional pointer id when using more than one pointer
  42509. */
  42510. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42511. /**
  42512. * Gets the mesh under the pointer
  42513. * @returns a Mesh or null if no mesh is under the pointer
  42514. */
  42515. getPointerOverMesh(): Nullable<AbstractMesh>;
  42516. /** @hidden */
  42517. _rebuildGeometries(): void;
  42518. /** @hidden */
  42519. _rebuildTextures(): void;
  42520. private _getByTags;
  42521. /**
  42522. * Get a list of meshes by tags
  42523. * @param tagsQuery defines the tags query to use
  42524. * @param forEach defines a predicate used to filter results
  42525. * @returns an array of Mesh
  42526. */
  42527. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  42528. /**
  42529. * Get a list of cameras by tags
  42530. * @param tagsQuery defines the tags query to use
  42531. * @param forEach defines a predicate used to filter results
  42532. * @returns an array of Camera
  42533. */
  42534. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  42535. /**
  42536. * Get a list of lights by tags
  42537. * @param tagsQuery defines the tags query to use
  42538. * @param forEach defines a predicate used to filter results
  42539. * @returns an array of Light
  42540. */
  42541. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  42542. /**
  42543. * Get a list of materials by tags
  42544. * @param tagsQuery defines the tags query to use
  42545. * @param forEach defines a predicate used to filter results
  42546. * @returns an array of Material
  42547. */
  42548. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  42549. /**
  42550. * Get a list of transform nodes by tags
  42551. * @param tagsQuery defines the tags query to use
  42552. * @param forEach defines a predicate used to filter results
  42553. * @returns an array of TransformNode
  42554. */
  42555. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  42556. /**
  42557. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  42558. * This allowed control for front to back rendering or reversly depending of the special needs.
  42559. *
  42560. * @param renderingGroupId The rendering group id corresponding to its index
  42561. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  42562. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  42563. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  42564. */
  42565. 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;
  42566. /**
  42567. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  42568. *
  42569. * @param renderingGroupId The rendering group id corresponding to its index
  42570. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  42571. * @param depth Automatically clears depth between groups if true and autoClear is true.
  42572. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  42573. */
  42574. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  42575. /**
  42576. * Gets the current auto clear configuration for one rendering group of the rendering
  42577. * manager.
  42578. * @param index the rendering group index to get the information for
  42579. * @returns The auto clear setup for the requested rendering group
  42580. */
  42581. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  42582. private _blockMaterialDirtyMechanism;
  42583. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  42584. get blockMaterialDirtyMechanism(): boolean;
  42585. set blockMaterialDirtyMechanism(value: boolean);
  42586. /**
  42587. * Will flag all materials as dirty to trigger new shader compilation
  42588. * @param flag defines the flag used to specify which material part must be marked as dirty
  42589. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  42590. */
  42591. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42592. /** @hidden */
  42593. _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;
  42594. /** @hidden */
  42595. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42596. /** @hidden */
  42597. _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;
  42598. /** @hidden */
  42599. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  42600. /** @hidden */
  42601. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42602. /** @hidden */
  42603. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42604. }
  42605. }
  42606. declare module "babylonjs/assetContainer" {
  42607. import { AbstractScene } from "babylonjs/abstractScene";
  42608. import { Scene } from "babylonjs/scene";
  42609. import { Mesh } from "babylonjs/Meshes/mesh";
  42610. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42611. import { Skeleton } from "babylonjs/Bones/skeleton";
  42612. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42613. import { Animatable } from "babylonjs/Animations/animatable";
  42614. import { Nullable } from "babylonjs/types";
  42615. import { Node } from "babylonjs/node";
  42616. /**
  42617. * Set of assets to keep when moving a scene into an asset container.
  42618. */
  42619. export class KeepAssets extends AbstractScene {
  42620. }
  42621. /**
  42622. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  42623. */
  42624. export class InstantiatedEntries {
  42625. /**
  42626. * List of new root nodes (eg. nodes with no parent)
  42627. */
  42628. rootNodes: TransformNode[];
  42629. /**
  42630. * List of new skeletons
  42631. */
  42632. skeletons: Skeleton[];
  42633. /**
  42634. * List of new animation groups
  42635. */
  42636. animationGroups: AnimationGroup[];
  42637. }
  42638. /**
  42639. * Container with a set of assets that can be added or removed from a scene.
  42640. */
  42641. export class AssetContainer extends AbstractScene {
  42642. private _wasAddedToScene;
  42643. /**
  42644. * The scene the AssetContainer belongs to.
  42645. */
  42646. scene: Scene;
  42647. /**
  42648. * Instantiates an AssetContainer.
  42649. * @param scene The scene the AssetContainer belongs to.
  42650. */
  42651. constructor(scene: Scene);
  42652. /**
  42653. * Instantiate or clone all meshes and add the new ones to the scene.
  42654. * Skeletons and animation groups will all be cloned
  42655. * @param nameFunction defines an optional function used to get new names for clones
  42656. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  42657. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  42658. */
  42659. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  42660. /**
  42661. * Adds all the assets from the container to the scene.
  42662. */
  42663. addAllToScene(): void;
  42664. /**
  42665. * Removes all the assets in the container from the scene
  42666. */
  42667. removeAllFromScene(): void;
  42668. /**
  42669. * Disposes all the assets in the container
  42670. */
  42671. dispose(): void;
  42672. private _moveAssets;
  42673. /**
  42674. * Removes all the assets contained in the scene and adds them to the container.
  42675. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  42676. */
  42677. moveAllFromScene(keepAssets?: KeepAssets): void;
  42678. /**
  42679. * 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.
  42680. * @returns the root mesh
  42681. */
  42682. createRootMesh(): Mesh;
  42683. /**
  42684. * Merge animations (direct and animation groups) from this asset container into a scene
  42685. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42686. * @param animatables set of animatables to retarget to a node from the scene
  42687. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  42688. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  42689. */
  42690. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  42691. }
  42692. }
  42693. declare module "babylonjs/abstractScene" {
  42694. import { Scene } from "babylonjs/scene";
  42695. import { Nullable } from "babylonjs/types";
  42696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42697. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42698. import { Geometry } from "babylonjs/Meshes/geometry";
  42699. import { Skeleton } from "babylonjs/Bones/skeleton";
  42700. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  42701. import { AssetContainer } from "babylonjs/assetContainer";
  42702. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42703. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42704. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42705. import { Material } from "babylonjs/Materials/material";
  42706. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  42707. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  42708. import { Camera } from "babylonjs/Cameras/camera";
  42709. import { Light } from "babylonjs/Lights/light";
  42710. import { Node } from "babylonjs/node";
  42711. import { Animation } from "babylonjs/Animations/animation";
  42712. /**
  42713. * Defines how the parser contract is defined.
  42714. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  42715. */
  42716. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  42717. /**
  42718. * Defines how the individual parser contract is defined.
  42719. * These parser can parse an individual asset
  42720. */
  42721. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  42722. /**
  42723. * Base class of the scene acting as a container for the different elements composing a scene.
  42724. * This class is dynamically extended by the different components of the scene increasing
  42725. * flexibility and reducing coupling
  42726. */
  42727. export abstract class AbstractScene {
  42728. /**
  42729. * Stores the list of available parsers in the application.
  42730. */
  42731. private static _BabylonFileParsers;
  42732. /**
  42733. * Stores the list of available individual parsers in the application.
  42734. */
  42735. private static _IndividualBabylonFileParsers;
  42736. /**
  42737. * Adds a parser in the list of available ones
  42738. * @param name Defines the name of the parser
  42739. * @param parser Defines the parser to add
  42740. */
  42741. static AddParser(name: string, parser: BabylonFileParser): void;
  42742. /**
  42743. * Gets a general parser from the list of avaialble ones
  42744. * @param name Defines the name of the parser
  42745. * @returns the requested parser or null
  42746. */
  42747. static GetParser(name: string): Nullable<BabylonFileParser>;
  42748. /**
  42749. * Adds n individual parser in the list of available ones
  42750. * @param name Defines the name of the parser
  42751. * @param parser Defines the parser to add
  42752. */
  42753. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  42754. /**
  42755. * Gets an individual parser from the list of avaialble ones
  42756. * @param name Defines the name of the parser
  42757. * @returns the requested parser or null
  42758. */
  42759. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  42760. /**
  42761. * Parser json data and populate both a scene and its associated container object
  42762. * @param jsonData Defines the data to parse
  42763. * @param scene Defines the scene to parse the data for
  42764. * @param container Defines the container attached to the parsing sequence
  42765. * @param rootUrl Defines the root url of the data
  42766. */
  42767. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  42768. /**
  42769. * Gets the list of root nodes (ie. nodes with no parent)
  42770. */
  42771. rootNodes: Node[];
  42772. /** All of the cameras added to this scene
  42773. * @see https://doc.babylonjs.com/babylon101/cameras
  42774. */
  42775. cameras: Camera[];
  42776. /**
  42777. * All of the lights added to this scene
  42778. * @see https://doc.babylonjs.com/babylon101/lights
  42779. */
  42780. lights: Light[];
  42781. /**
  42782. * All of the (abstract) meshes added to this scene
  42783. */
  42784. meshes: AbstractMesh[];
  42785. /**
  42786. * The list of skeletons added to the scene
  42787. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  42788. */
  42789. skeletons: Skeleton[];
  42790. /**
  42791. * All of the particle systems added to this scene
  42792. * @see https://doc.babylonjs.com/babylon101/particles
  42793. */
  42794. particleSystems: IParticleSystem[];
  42795. /**
  42796. * Gets a list of Animations associated with the scene
  42797. */
  42798. animations: Animation[];
  42799. /**
  42800. * All of the animation groups added to this scene
  42801. * @see https://doc.babylonjs.com/how_to/group
  42802. */
  42803. animationGroups: AnimationGroup[];
  42804. /**
  42805. * All of the multi-materials added to this scene
  42806. * @see https://doc.babylonjs.com/how_to/multi_materials
  42807. */
  42808. multiMaterials: MultiMaterial[];
  42809. /**
  42810. * All of the materials added to this scene
  42811. * In the context of a Scene, it is not supposed to be modified manually.
  42812. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  42813. * Note also that the order of the Material within the array is not significant and might change.
  42814. * @see https://doc.babylonjs.com/babylon101/materials
  42815. */
  42816. materials: Material[];
  42817. /**
  42818. * The list of morph target managers added to the scene
  42819. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  42820. */
  42821. morphTargetManagers: MorphTargetManager[];
  42822. /**
  42823. * The list of geometries used in the scene.
  42824. */
  42825. geometries: Geometry[];
  42826. /**
  42827. * All of the tranform nodes added to this scene
  42828. * In the context of a Scene, it is not supposed to be modified manually.
  42829. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  42830. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  42831. * @see https://doc.babylonjs.com/how_to/transformnode
  42832. */
  42833. transformNodes: TransformNode[];
  42834. /**
  42835. * ActionManagers available on the scene.
  42836. */
  42837. actionManagers: AbstractActionManager[];
  42838. /**
  42839. * Textures to keep.
  42840. */
  42841. textures: BaseTexture[];
  42842. /** @hidden */
  42843. protected _environmentTexture: Nullable<BaseTexture>;
  42844. /**
  42845. * Texture used in all pbr material as the reflection texture.
  42846. * As in the majority of the scene they are the same (exception for multi room and so on),
  42847. * this is easier to reference from here than from all the materials.
  42848. */
  42849. get environmentTexture(): Nullable<BaseTexture>;
  42850. set environmentTexture(value: Nullable<BaseTexture>);
  42851. /**
  42852. * The list of postprocesses added to the scene
  42853. */
  42854. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42855. /**
  42856. * @returns all meshes, lights, cameras, transformNodes and bones
  42857. */
  42858. getNodes(): Array<Node>;
  42859. }
  42860. }
  42861. declare module "babylonjs/Audio/sound" {
  42862. import { Observable } from "babylonjs/Misc/observable";
  42863. import { Vector3 } from "babylonjs/Maths/math.vector";
  42864. import { Nullable } from "babylonjs/types";
  42865. import { Scene } from "babylonjs/scene";
  42866. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42867. /**
  42868. * Interface used to define options for Sound class
  42869. */
  42870. export interface ISoundOptions {
  42871. /**
  42872. * Does the sound autoplay once loaded.
  42873. */
  42874. autoplay?: boolean;
  42875. /**
  42876. * Does the sound loop after it finishes playing once.
  42877. */
  42878. loop?: boolean;
  42879. /**
  42880. * Sound's volume
  42881. */
  42882. volume?: number;
  42883. /**
  42884. * Is it a spatial sound?
  42885. */
  42886. spatialSound?: boolean;
  42887. /**
  42888. * Maximum distance to hear that sound
  42889. */
  42890. maxDistance?: number;
  42891. /**
  42892. * Uses user defined attenuation function
  42893. */
  42894. useCustomAttenuation?: boolean;
  42895. /**
  42896. * Define the roll off factor of spatial sounds.
  42897. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42898. */
  42899. rolloffFactor?: number;
  42900. /**
  42901. * Define the reference distance the sound should be heard perfectly.
  42902. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42903. */
  42904. refDistance?: number;
  42905. /**
  42906. * Define the distance attenuation model the sound will follow.
  42907. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42908. */
  42909. distanceModel?: string;
  42910. /**
  42911. * Defines the playback speed (1 by default)
  42912. */
  42913. playbackRate?: number;
  42914. /**
  42915. * Defines if the sound is from a streaming source
  42916. */
  42917. streaming?: boolean;
  42918. /**
  42919. * Defines an optional length (in seconds) inside the sound file
  42920. */
  42921. length?: number;
  42922. /**
  42923. * Defines an optional offset (in seconds) inside the sound file
  42924. */
  42925. offset?: number;
  42926. /**
  42927. * If true, URLs will not be required to state the audio file codec to use.
  42928. */
  42929. skipCodecCheck?: boolean;
  42930. }
  42931. /**
  42932. * Defines a sound that can be played in the application.
  42933. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  42934. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42935. */
  42936. export class Sound {
  42937. /**
  42938. * The name of the sound in the scene.
  42939. */
  42940. name: string;
  42941. /**
  42942. * Does the sound autoplay once loaded.
  42943. */
  42944. autoplay: boolean;
  42945. /**
  42946. * Does the sound loop after it finishes playing once.
  42947. */
  42948. loop: boolean;
  42949. /**
  42950. * Does the sound use a custom attenuation curve to simulate the falloff
  42951. * happening when the source gets further away from the camera.
  42952. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  42953. */
  42954. useCustomAttenuation: boolean;
  42955. /**
  42956. * The sound track id this sound belongs to.
  42957. */
  42958. soundTrackId: number;
  42959. /**
  42960. * Is this sound currently played.
  42961. */
  42962. isPlaying: boolean;
  42963. /**
  42964. * Is this sound currently paused.
  42965. */
  42966. isPaused: boolean;
  42967. /**
  42968. * Does this sound enables spatial sound.
  42969. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42970. */
  42971. spatialSound: boolean;
  42972. /**
  42973. * Define the reference distance the sound should be heard perfectly.
  42974. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42975. */
  42976. refDistance: number;
  42977. /**
  42978. * Define the roll off factor of spatial sounds.
  42979. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42980. */
  42981. rolloffFactor: number;
  42982. /**
  42983. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  42984. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42985. */
  42986. maxDistance: number;
  42987. /**
  42988. * Define the distance attenuation model the sound will follow.
  42989. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42990. */
  42991. distanceModel: string;
  42992. /**
  42993. * @hidden
  42994. * Back Compat
  42995. **/
  42996. onended: () => any;
  42997. /**
  42998. * Gets or sets an object used to store user defined information for the sound.
  42999. */
  43000. metadata: any;
  43001. /**
  43002. * Observable event when the current playing sound finishes.
  43003. */
  43004. onEndedObservable: Observable<Sound>;
  43005. private _panningModel;
  43006. private _playbackRate;
  43007. private _streaming;
  43008. private _startTime;
  43009. private _startOffset;
  43010. private _position;
  43011. /** @hidden */
  43012. _positionInEmitterSpace: boolean;
  43013. private _localDirection;
  43014. private _volume;
  43015. private _isReadyToPlay;
  43016. private _isDirectional;
  43017. private _readyToPlayCallback;
  43018. private _audioBuffer;
  43019. private _soundSource;
  43020. private _streamingSource;
  43021. private _soundPanner;
  43022. private _soundGain;
  43023. private _inputAudioNode;
  43024. private _outputAudioNode;
  43025. private _coneInnerAngle;
  43026. private _coneOuterAngle;
  43027. private _coneOuterGain;
  43028. private _scene;
  43029. private _connectedTransformNode;
  43030. private _customAttenuationFunction;
  43031. private _registerFunc;
  43032. private _isOutputConnected;
  43033. private _htmlAudioElement;
  43034. private _urlType;
  43035. private _length?;
  43036. private _offset?;
  43037. /** @hidden */
  43038. static _SceneComponentInitialization: (scene: Scene) => void;
  43039. /**
  43040. * Create a sound and attach it to a scene
  43041. * @param name Name of your sound
  43042. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  43043. * @param scene defines the scene the sound belongs to
  43044. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  43045. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  43046. */
  43047. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  43048. /**
  43049. * Release the sound and its associated resources
  43050. */
  43051. dispose(): void;
  43052. /**
  43053. * Gets if the sounds is ready to be played or not.
  43054. * @returns true if ready, otherwise false
  43055. */
  43056. isReady(): boolean;
  43057. private _soundLoaded;
  43058. /**
  43059. * Sets the data of the sound from an audiobuffer
  43060. * @param audioBuffer The audioBuffer containing the data
  43061. */
  43062. setAudioBuffer(audioBuffer: AudioBuffer): void;
  43063. /**
  43064. * Updates the current sounds options such as maxdistance, loop...
  43065. * @param options A JSON object containing values named as the object properties
  43066. */
  43067. updateOptions(options: ISoundOptions): void;
  43068. private _createSpatialParameters;
  43069. private _updateSpatialParameters;
  43070. /**
  43071. * Switch the panning model to HRTF:
  43072. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43073. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43074. */
  43075. switchPanningModelToHRTF(): void;
  43076. /**
  43077. * Switch the panning model to Equal Power:
  43078. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43079. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43080. */
  43081. switchPanningModelToEqualPower(): void;
  43082. private _switchPanningModel;
  43083. /**
  43084. * Connect this sound to a sound track audio node like gain...
  43085. * @param soundTrackAudioNode the sound track audio node to connect to
  43086. */
  43087. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  43088. /**
  43089. * Transform this sound into a directional source
  43090. * @param coneInnerAngle Size of the inner cone in degree
  43091. * @param coneOuterAngle Size of the outer cone in degree
  43092. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  43093. */
  43094. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  43095. /**
  43096. * Gets or sets the inner angle for the directional cone.
  43097. */
  43098. get directionalConeInnerAngle(): number;
  43099. /**
  43100. * Gets or sets the inner angle for the directional cone.
  43101. */
  43102. set directionalConeInnerAngle(value: number);
  43103. /**
  43104. * Gets or sets the outer angle for the directional cone.
  43105. */
  43106. get directionalConeOuterAngle(): number;
  43107. /**
  43108. * Gets or sets the outer angle for the directional cone.
  43109. */
  43110. set directionalConeOuterAngle(value: number);
  43111. /**
  43112. * Sets the position of the emitter if spatial sound is enabled
  43113. * @param newPosition Defines the new posisiton
  43114. */
  43115. setPosition(newPosition: Vector3): void;
  43116. /**
  43117. * Sets the local direction of the emitter if spatial sound is enabled
  43118. * @param newLocalDirection Defines the new local direction
  43119. */
  43120. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  43121. private _updateDirection;
  43122. /** @hidden */
  43123. updateDistanceFromListener(): void;
  43124. /**
  43125. * Sets a new custom attenuation function for the sound.
  43126. * @param callback Defines the function used for the attenuation
  43127. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43128. */
  43129. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  43130. /**
  43131. * Play the sound
  43132. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  43133. * @param offset (optional) Start the sound at a specific time in seconds
  43134. * @param length (optional) Sound duration (in seconds)
  43135. */
  43136. play(time?: number, offset?: number, length?: number): void;
  43137. private _onended;
  43138. /**
  43139. * Stop the sound
  43140. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  43141. */
  43142. stop(time?: number): void;
  43143. /**
  43144. * Put the sound in pause
  43145. */
  43146. pause(): void;
  43147. /**
  43148. * Sets a dedicated volume for this sounds
  43149. * @param newVolume Define the new volume of the sound
  43150. * @param time Define time for gradual change to new volume
  43151. */
  43152. setVolume(newVolume: number, time?: number): void;
  43153. /**
  43154. * Set the sound play back rate
  43155. * @param newPlaybackRate Define the playback rate the sound should be played at
  43156. */
  43157. setPlaybackRate(newPlaybackRate: number): void;
  43158. /**
  43159. * Gets the volume of the sound.
  43160. * @returns the volume of the sound
  43161. */
  43162. getVolume(): number;
  43163. /**
  43164. * Attach the sound to a dedicated mesh
  43165. * @param transformNode The transform node to connect the sound with
  43166. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43167. */
  43168. attachToMesh(transformNode: TransformNode): void;
  43169. /**
  43170. * Detach the sound from the previously attached mesh
  43171. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43172. */
  43173. detachFromMesh(): void;
  43174. private _onRegisterAfterWorldMatrixUpdate;
  43175. /**
  43176. * Clone the current sound in the scene.
  43177. * @returns the new sound clone
  43178. */
  43179. clone(): Nullable<Sound>;
  43180. /**
  43181. * Gets the current underlying audio buffer containing the data
  43182. * @returns the audio buffer
  43183. */
  43184. getAudioBuffer(): Nullable<AudioBuffer>;
  43185. /**
  43186. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  43187. * @returns the source node
  43188. */
  43189. getSoundSource(): Nullable<AudioBufferSourceNode>;
  43190. /**
  43191. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  43192. * @returns the gain node
  43193. */
  43194. getSoundGain(): Nullable<GainNode>;
  43195. /**
  43196. * Serializes the Sound in a JSON representation
  43197. * @returns the JSON representation of the sound
  43198. */
  43199. serialize(): any;
  43200. /**
  43201. * Parse a JSON representation of a sound to innstantiate in a given scene
  43202. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  43203. * @param scene Define the scene the new parsed sound should be created in
  43204. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  43205. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  43206. * @returns the newly parsed sound
  43207. */
  43208. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  43209. }
  43210. }
  43211. declare module "babylonjs/Actions/directAudioActions" {
  43212. import { Action } from "babylonjs/Actions/action";
  43213. import { Condition } from "babylonjs/Actions/condition";
  43214. import { Sound } from "babylonjs/Audio/sound";
  43215. /**
  43216. * This defines an action helpful to play a defined sound on a triggered action.
  43217. */
  43218. export class PlaySoundAction extends Action {
  43219. private _sound;
  43220. /**
  43221. * Instantiate the action
  43222. * @param triggerOptions defines the trigger options
  43223. * @param sound defines the sound to play
  43224. * @param condition defines the trigger related conditions
  43225. */
  43226. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43227. /** @hidden */
  43228. _prepare(): void;
  43229. /**
  43230. * Execute the action and play the sound.
  43231. */
  43232. execute(): void;
  43233. /**
  43234. * Serializes the actions and its related information.
  43235. * @param parent defines the object to serialize in
  43236. * @returns the serialized object
  43237. */
  43238. serialize(parent: any): any;
  43239. }
  43240. /**
  43241. * This defines an action helpful to stop a defined sound on a triggered action.
  43242. */
  43243. export class StopSoundAction extends Action {
  43244. private _sound;
  43245. /**
  43246. * Instantiate the action
  43247. * @param triggerOptions defines the trigger options
  43248. * @param sound defines the sound to stop
  43249. * @param condition defines the trigger related conditions
  43250. */
  43251. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43252. /** @hidden */
  43253. _prepare(): void;
  43254. /**
  43255. * Execute the action and stop the sound.
  43256. */
  43257. execute(): void;
  43258. /**
  43259. * Serializes the actions and its related information.
  43260. * @param parent defines the object to serialize in
  43261. * @returns the serialized object
  43262. */
  43263. serialize(parent: any): any;
  43264. }
  43265. }
  43266. declare module "babylonjs/Actions/interpolateValueAction" {
  43267. import { Action } from "babylonjs/Actions/action";
  43268. import { Condition } from "babylonjs/Actions/condition";
  43269. import { Observable } from "babylonjs/Misc/observable";
  43270. /**
  43271. * This defines an action responsible to change the value of a property
  43272. * by interpolating between its current value and the newly set one once triggered.
  43273. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43274. */
  43275. export class InterpolateValueAction extends Action {
  43276. /**
  43277. * Defines the path of the property where the value should be interpolated
  43278. */
  43279. propertyPath: string;
  43280. /**
  43281. * Defines the target value at the end of the interpolation.
  43282. */
  43283. value: any;
  43284. /**
  43285. * Defines the time it will take for the property to interpolate to the value.
  43286. */
  43287. duration: number;
  43288. /**
  43289. * Defines if the other scene animations should be stopped when the action has been triggered
  43290. */
  43291. stopOtherAnimations?: boolean;
  43292. /**
  43293. * Defines a callback raised once the interpolation animation has been done.
  43294. */
  43295. onInterpolationDone?: () => void;
  43296. /**
  43297. * Observable triggered once the interpolation animation has been done.
  43298. */
  43299. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  43300. private _target;
  43301. private _effectiveTarget;
  43302. private _property;
  43303. /**
  43304. * Instantiate the action
  43305. * @param triggerOptions defines the trigger options
  43306. * @param target defines the object containing the value to interpolate
  43307. * @param propertyPath defines the path to the property in the target object
  43308. * @param value defines the target value at the end of the interpolation
  43309. * @param duration deines the time it will take for the property to interpolate to the value.
  43310. * @param condition defines the trigger related conditions
  43311. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  43312. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  43313. */
  43314. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  43315. /** @hidden */
  43316. _prepare(): void;
  43317. /**
  43318. * Execute the action starts the value interpolation.
  43319. */
  43320. execute(): void;
  43321. /**
  43322. * Serializes the actions and its related information.
  43323. * @param parent defines the object to serialize in
  43324. * @returns the serialized object
  43325. */
  43326. serialize(parent: any): any;
  43327. }
  43328. }
  43329. declare module "babylonjs/Actions/index" {
  43330. export * from "babylonjs/Actions/abstractActionManager";
  43331. export * from "babylonjs/Actions/action";
  43332. export * from "babylonjs/Actions/actionEvent";
  43333. export * from "babylonjs/Actions/actionManager";
  43334. export * from "babylonjs/Actions/condition";
  43335. export * from "babylonjs/Actions/directActions";
  43336. export * from "babylonjs/Actions/directAudioActions";
  43337. export * from "babylonjs/Actions/interpolateValueAction";
  43338. }
  43339. declare module "babylonjs/Animations/index" {
  43340. export * from "babylonjs/Animations/animatable";
  43341. export * from "babylonjs/Animations/animation";
  43342. export * from "babylonjs/Animations/animationGroup";
  43343. export * from "babylonjs/Animations/animationPropertiesOverride";
  43344. export * from "babylonjs/Animations/easing";
  43345. export * from "babylonjs/Animations/runtimeAnimation";
  43346. export * from "babylonjs/Animations/animationEvent";
  43347. export * from "babylonjs/Animations/animationGroup";
  43348. export * from "babylonjs/Animations/animationKey";
  43349. export * from "babylonjs/Animations/animationRange";
  43350. export * from "babylonjs/Animations/animatable.interface";
  43351. }
  43352. declare module "babylonjs/Audio/soundTrack" {
  43353. import { Sound } from "babylonjs/Audio/sound";
  43354. import { Analyser } from "babylonjs/Audio/analyser";
  43355. import { Scene } from "babylonjs/scene";
  43356. /**
  43357. * Options allowed during the creation of a sound track.
  43358. */
  43359. export interface ISoundTrackOptions {
  43360. /**
  43361. * The volume the sound track should take during creation
  43362. */
  43363. volume?: number;
  43364. /**
  43365. * Define if the sound track is the main sound track of the scene
  43366. */
  43367. mainTrack?: boolean;
  43368. }
  43369. /**
  43370. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  43371. * It will be also used in a future release to apply effects on a specific track.
  43372. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43373. */
  43374. export class SoundTrack {
  43375. /**
  43376. * The unique identifier of the sound track in the scene.
  43377. */
  43378. id: number;
  43379. /**
  43380. * The list of sounds included in the sound track.
  43381. */
  43382. soundCollection: Array<Sound>;
  43383. private _outputAudioNode;
  43384. private _scene;
  43385. private _connectedAnalyser;
  43386. private _options;
  43387. private _isInitialized;
  43388. /**
  43389. * Creates a new sound track.
  43390. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43391. * @param scene Define the scene the sound track belongs to
  43392. * @param options
  43393. */
  43394. constructor(scene: Scene, options?: ISoundTrackOptions);
  43395. private _initializeSoundTrackAudioGraph;
  43396. /**
  43397. * Release the sound track and its associated resources
  43398. */
  43399. dispose(): void;
  43400. /**
  43401. * Adds a sound to this sound track
  43402. * @param sound define the cound to add
  43403. * @ignoreNaming
  43404. */
  43405. AddSound(sound: Sound): void;
  43406. /**
  43407. * Removes a sound to this sound track
  43408. * @param sound define the cound to remove
  43409. * @ignoreNaming
  43410. */
  43411. RemoveSound(sound: Sound): void;
  43412. /**
  43413. * Set a global volume for the full sound track.
  43414. * @param newVolume Define the new volume of the sound track
  43415. */
  43416. setVolume(newVolume: number): void;
  43417. /**
  43418. * Switch the panning model to HRTF:
  43419. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43420. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43421. */
  43422. switchPanningModelToHRTF(): void;
  43423. /**
  43424. * Switch the panning model to Equal Power:
  43425. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43426. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43427. */
  43428. switchPanningModelToEqualPower(): void;
  43429. /**
  43430. * Connect the sound track to an audio analyser allowing some amazing
  43431. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  43432. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43433. * @param analyser The analyser to connect to the engine
  43434. */
  43435. connectToAnalyser(analyser: Analyser): void;
  43436. }
  43437. }
  43438. declare module "babylonjs/Audio/audioSceneComponent" {
  43439. import { Sound } from "babylonjs/Audio/sound";
  43440. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  43441. import { Nullable } from "babylonjs/types";
  43442. import { Vector3 } from "babylonjs/Maths/math.vector";
  43443. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  43444. import { Scene } from "babylonjs/scene";
  43445. import { AbstractScene } from "babylonjs/abstractScene";
  43446. import "babylonjs/Audio/audioEngine";
  43447. module "babylonjs/abstractScene" {
  43448. interface AbstractScene {
  43449. /**
  43450. * The list of sounds used in the scene.
  43451. */
  43452. sounds: Nullable<Array<Sound>>;
  43453. }
  43454. }
  43455. module "babylonjs/scene" {
  43456. interface Scene {
  43457. /**
  43458. * @hidden
  43459. * Backing field
  43460. */
  43461. _mainSoundTrack: SoundTrack;
  43462. /**
  43463. * The main sound track played by the scene.
  43464. * It cotains your primary collection of sounds.
  43465. */
  43466. mainSoundTrack: SoundTrack;
  43467. /**
  43468. * The list of sound tracks added to the scene
  43469. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43470. */
  43471. soundTracks: Nullable<Array<SoundTrack>>;
  43472. /**
  43473. * Gets a sound using a given name
  43474. * @param name defines the name to search for
  43475. * @return the found sound or null if not found at all.
  43476. */
  43477. getSoundByName(name: string): Nullable<Sound>;
  43478. /**
  43479. * Gets or sets if audio support is enabled
  43480. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43481. */
  43482. audioEnabled: boolean;
  43483. /**
  43484. * Gets or sets if audio will be output to headphones
  43485. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43486. */
  43487. headphone: boolean;
  43488. /**
  43489. * Gets or sets custom audio listener position provider
  43490. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43491. */
  43492. audioListenerPositionProvider: Nullable<() => Vector3>;
  43493. /**
  43494. * Gets or sets a refresh rate when using 3D audio positioning
  43495. */
  43496. audioPositioningRefreshRate: number;
  43497. }
  43498. }
  43499. /**
  43500. * Defines the sound scene component responsible to manage any sounds
  43501. * in a given scene.
  43502. */
  43503. export class AudioSceneComponent implements ISceneSerializableComponent {
  43504. private static _CameraDirectionLH;
  43505. private static _CameraDirectionRH;
  43506. /**
  43507. * The component name helpfull to identify the component in the list of scene components.
  43508. */
  43509. readonly name: string;
  43510. /**
  43511. * The scene the component belongs to.
  43512. */
  43513. scene: Scene;
  43514. private _audioEnabled;
  43515. /**
  43516. * Gets whether audio is enabled or not.
  43517. * Please use related enable/disable method to switch state.
  43518. */
  43519. get audioEnabled(): boolean;
  43520. private _headphone;
  43521. /**
  43522. * Gets whether audio is outputing to headphone or not.
  43523. * Please use the according Switch methods to change output.
  43524. */
  43525. get headphone(): boolean;
  43526. /**
  43527. * Gets or sets a refresh rate when using 3D audio positioning
  43528. */
  43529. audioPositioningRefreshRate: number;
  43530. private _audioListenerPositionProvider;
  43531. /**
  43532. * Gets the current audio listener position provider
  43533. */
  43534. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  43535. /**
  43536. * Sets a custom listener position for all sounds in the scene
  43537. * By default, this is the position of the first active camera
  43538. */
  43539. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  43540. /**
  43541. * Creates a new instance of the component for the given scene
  43542. * @param scene Defines the scene to register the component in
  43543. */
  43544. constructor(scene: Scene);
  43545. /**
  43546. * Registers the component in a given scene
  43547. */
  43548. register(): void;
  43549. /**
  43550. * Rebuilds the elements related to this component in case of
  43551. * context lost for instance.
  43552. */
  43553. rebuild(): void;
  43554. /**
  43555. * Serializes the component data to the specified json object
  43556. * @param serializationObject The object to serialize to
  43557. */
  43558. serialize(serializationObject: any): void;
  43559. /**
  43560. * Adds all the elements from the container to the scene
  43561. * @param container the container holding the elements
  43562. */
  43563. addFromContainer(container: AbstractScene): void;
  43564. /**
  43565. * Removes all the elements in the container from the scene
  43566. * @param container contains the elements to remove
  43567. * @param dispose if the removed element should be disposed (default: false)
  43568. */
  43569. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  43570. /**
  43571. * Disposes the component and the associated ressources.
  43572. */
  43573. dispose(): void;
  43574. /**
  43575. * Disables audio in the associated scene.
  43576. */
  43577. disableAudio(): void;
  43578. /**
  43579. * Enables audio in the associated scene.
  43580. */
  43581. enableAudio(): void;
  43582. /**
  43583. * Switch audio to headphone output.
  43584. */
  43585. switchAudioModeForHeadphones(): void;
  43586. /**
  43587. * Switch audio to normal speakers.
  43588. */
  43589. switchAudioModeForNormalSpeakers(): void;
  43590. private _cachedCameraDirection;
  43591. private _cachedCameraPosition;
  43592. private _lastCheck;
  43593. private _afterRender;
  43594. }
  43595. }
  43596. declare module "babylonjs/Audio/weightedsound" {
  43597. import { Sound } from "babylonjs/Audio/sound";
  43598. /**
  43599. * Wraps one or more Sound objects and selects one with random weight for playback.
  43600. */
  43601. export class WeightedSound {
  43602. /** When true a Sound will be selected and played when the current playing Sound completes. */
  43603. loop: boolean;
  43604. private _coneInnerAngle;
  43605. private _coneOuterAngle;
  43606. private _volume;
  43607. /** A Sound is currently playing. */
  43608. isPlaying: boolean;
  43609. /** A Sound is currently paused. */
  43610. isPaused: boolean;
  43611. private _sounds;
  43612. private _weights;
  43613. private _currentIndex?;
  43614. /**
  43615. * Creates a new WeightedSound from the list of sounds given.
  43616. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  43617. * @param sounds Array of Sounds that will be selected from.
  43618. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  43619. */
  43620. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  43621. /**
  43622. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  43623. */
  43624. get directionalConeInnerAngle(): number;
  43625. /**
  43626. * The size of cone in degress for a directional sound in which there will be no attenuation.
  43627. */
  43628. set directionalConeInnerAngle(value: number);
  43629. /**
  43630. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43631. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43632. */
  43633. get directionalConeOuterAngle(): number;
  43634. /**
  43635. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43636. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43637. */
  43638. set directionalConeOuterAngle(value: number);
  43639. /**
  43640. * Playback volume.
  43641. */
  43642. get volume(): number;
  43643. /**
  43644. * Playback volume.
  43645. */
  43646. set volume(value: number);
  43647. private _onended;
  43648. /**
  43649. * Suspend playback
  43650. */
  43651. pause(): void;
  43652. /**
  43653. * Stop playback
  43654. */
  43655. stop(): void;
  43656. /**
  43657. * Start playback.
  43658. * @param startOffset Position the clip head at a specific time in seconds.
  43659. */
  43660. play(startOffset?: number): void;
  43661. }
  43662. }
  43663. declare module "babylonjs/Audio/index" {
  43664. export * from "babylonjs/Audio/analyser";
  43665. export * from "babylonjs/Audio/audioEngine";
  43666. export * from "babylonjs/Audio/audioSceneComponent";
  43667. export * from "babylonjs/Audio/sound";
  43668. export * from "babylonjs/Audio/soundTrack";
  43669. export * from "babylonjs/Audio/weightedsound";
  43670. }
  43671. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  43672. import { Behavior } from "babylonjs/Behaviors/behavior";
  43673. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43674. import { BackEase } from "babylonjs/Animations/easing";
  43675. /**
  43676. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  43677. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43678. */
  43679. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  43680. /**
  43681. * Gets the name of the behavior.
  43682. */
  43683. get name(): string;
  43684. /**
  43685. * The easing function used by animations
  43686. */
  43687. static EasingFunction: BackEase;
  43688. /**
  43689. * The easing mode used by animations
  43690. */
  43691. static EasingMode: number;
  43692. /**
  43693. * The duration of the animation, in milliseconds
  43694. */
  43695. transitionDuration: number;
  43696. /**
  43697. * Length of the distance animated by the transition when lower radius is reached
  43698. */
  43699. lowerRadiusTransitionRange: number;
  43700. /**
  43701. * Length of the distance animated by the transition when upper radius is reached
  43702. */
  43703. upperRadiusTransitionRange: number;
  43704. private _autoTransitionRange;
  43705. /**
  43706. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43707. */
  43708. get autoTransitionRange(): boolean;
  43709. /**
  43710. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43711. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  43712. */
  43713. set autoTransitionRange(value: boolean);
  43714. private _attachedCamera;
  43715. private _onAfterCheckInputsObserver;
  43716. private _onMeshTargetChangedObserver;
  43717. /**
  43718. * Initializes the behavior.
  43719. */
  43720. init(): void;
  43721. /**
  43722. * Attaches the behavior to its arc rotate camera.
  43723. * @param camera Defines the camera to attach the behavior to
  43724. */
  43725. attach(camera: ArcRotateCamera): void;
  43726. /**
  43727. * Detaches the behavior from its current arc rotate camera.
  43728. */
  43729. detach(): void;
  43730. private _radiusIsAnimating;
  43731. private _radiusBounceTransition;
  43732. private _animatables;
  43733. private _cachedWheelPrecision;
  43734. /**
  43735. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  43736. * @param radiusLimit The limit to check against.
  43737. * @return Bool to indicate if at limit.
  43738. */
  43739. private _isRadiusAtLimit;
  43740. /**
  43741. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  43742. * @param radiusDelta The delta by which to animate to. Can be negative.
  43743. */
  43744. private _applyBoundRadiusAnimation;
  43745. /**
  43746. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  43747. */
  43748. protected _clearAnimationLocks(): void;
  43749. /**
  43750. * Stops and removes all animations that have been applied to the camera
  43751. */
  43752. stopAllAnimations(): void;
  43753. }
  43754. }
  43755. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  43756. import { Behavior } from "babylonjs/Behaviors/behavior";
  43757. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43758. import { ExponentialEase } from "babylonjs/Animations/easing";
  43759. import { Nullable } from "babylonjs/types";
  43760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43761. import { Vector3 } from "babylonjs/Maths/math.vector";
  43762. /**
  43763. * 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.
  43764. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43765. */
  43766. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  43767. /**
  43768. * Gets the name of the behavior.
  43769. */
  43770. get name(): string;
  43771. private _mode;
  43772. private _radiusScale;
  43773. private _positionScale;
  43774. private _defaultElevation;
  43775. private _elevationReturnTime;
  43776. private _elevationReturnWaitTime;
  43777. private _zoomStopsAnimation;
  43778. private _framingTime;
  43779. /**
  43780. * The easing function used by animations
  43781. */
  43782. static EasingFunction: ExponentialEase;
  43783. /**
  43784. * The easing mode used by animations
  43785. */
  43786. static EasingMode: number;
  43787. /**
  43788. * Sets the current mode used by the behavior
  43789. */
  43790. set mode(mode: number);
  43791. /**
  43792. * Gets current mode used by the behavior.
  43793. */
  43794. get mode(): number;
  43795. /**
  43796. * Sets the scale applied to the radius (1 by default)
  43797. */
  43798. set radiusScale(radius: number);
  43799. /**
  43800. * Gets the scale applied to the radius
  43801. */
  43802. get radiusScale(): number;
  43803. /**
  43804. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43805. */
  43806. set positionScale(scale: number);
  43807. /**
  43808. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43809. */
  43810. get positionScale(): number;
  43811. /**
  43812. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43813. * behaviour is triggered, in radians.
  43814. */
  43815. set defaultElevation(elevation: number);
  43816. /**
  43817. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43818. * behaviour is triggered, in radians.
  43819. */
  43820. get defaultElevation(): number;
  43821. /**
  43822. * Sets the time (in milliseconds) taken to return to the default beta position.
  43823. * Negative value indicates camera should not return to default.
  43824. */
  43825. set elevationReturnTime(speed: number);
  43826. /**
  43827. * Gets the time (in milliseconds) taken to return to the default beta position.
  43828. * Negative value indicates camera should not return to default.
  43829. */
  43830. get elevationReturnTime(): number;
  43831. /**
  43832. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43833. */
  43834. set elevationReturnWaitTime(time: number);
  43835. /**
  43836. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43837. */
  43838. get elevationReturnWaitTime(): number;
  43839. /**
  43840. * Sets the flag that indicates if user zooming should stop animation.
  43841. */
  43842. set zoomStopsAnimation(flag: boolean);
  43843. /**
  43844. * Gets the flag that indicates if user zooming should stop animation.
  43845. */
  43846. get zoomStopsAnimation(): boolean;
  43847. /**
  43848. * Sets the transition time when framing the mesh, in milliseconds
  43849. */
  43850. set framingTime(time: number);
  43851. /**
  43852. * Gets the transition time when framing the mesh, in milliseconds
  43853. */
  43854. get framingTime(): number;
  43855. /**
  43856. * Define if the behavior should automatically change the configured
  43857. * camera limits and sensibilities.
  43858. */
  43859. autoCorrectCameraLimitsAndSensibility: boolean;
  43860. private _onPrePointerObservableObserver;
  43861. private _onAfterCheckInputsObserver;
  43862. private _onMeshTargetChangedObserver;
  43863. private _attachedCamera;
  43864. private _isPointerDown;
  43865. private _lastInteractionTime;
  43866. /**
  43867. * Initializes the behavior.
  43868. */
  43869. init(): void;
  43870. /**
  43871. * Attaches the behavior to its arc rotate camera.
  43872. * @param camera Defines the camera to attach the behavior to
  43873. */
  43874. attach(camera: ArcRotateCamera): void;
  43875. /**
  43876. * Detaches the behavior from its current arc rotate camera.
  43877. */
  43878. detach(): void;
  43879. private _animatables;
  43880. private _betaIsAnimating;
  43881. private _betaTransition;
  43882. private _radiusTransition;
  43883. private _vectorTransition;
  43884. /**
  43885. * Targets the given mesh and updates zoom level accordingly.
  43886. * @param mesh The mesh to target.
  43887. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43888. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43889. */
  43890. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43891. /**
  43892. * Targets the given mesh with its children and updates zoom level accordingly.
  43893. * @param mesh The mesh to target.
  43894. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43895. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43896. */
  43897. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43898. /**
  43899. * Targets the given meshes with their children and updates zoom level accordingly.
  43900. * @param meshes The mesh to target.
  43901. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43902. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43903. */
  43904. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43905. /**
  43906. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  43907. * @param minimumWorld Determines the smaller position of the bounding box extend
  43908. * @param maximumWorld Determines the bigger position of the bounding box extend
  43909. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43910. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43911. */
  43912. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43913. /**
  43914. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  43915. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  43916. * frustum width.
  43917. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  43918. * to fully enclose the mesh in the viewing frustum.
  43919. */
  43920. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  43921. /**
  43922. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  43923. * is automatically returned to its default position (expected to be above ground plane).
  43924. */
  43925. private _maintainCameraAboveGround;
  43926. /**
  43927. * Returns the frustum slope based on the canvas ratio and camera FOV
  43928. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  43929. */
  43930. private _getFrustumSlope;
  43931. /**
  43932. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  43933. */
  43934. private _clearAnimationLocks;
  43935. /**
  43936. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43937. */
  43938. private _applyUserInteraction;
  43939. /**
  43940. * Stops and removes all animations that have been applied to the camera
  43941. */
  43942. stopAllAnimations(): void;
  43943. /**
  43944. * Gets a value indicating if the user is moving the camera
  43945. */
  43946. get isUserIsMoving(): boolean;
  43947. /**
  43948. * The camera can move all the way towards the mesh.
  43949. */
  43950. static IgnoreBoundsSizeMode: number;
  43951. /**
  43952. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  43953. */
  43954. static FitFrustumSidesMode: number;
  43955. }
  43956. }
  43957. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  43958. import { Nullable } from "babylonjs/types";
  43959. import { Camera } from "babylonjs/Cameras/camera";
  43960. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43961. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43962. /**
  43963. * Base class for Camera Pointer Inputs.
  43964. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  43965. * for example usage.
  43966. */
  43967. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  43968. /**
  43969. * Defines the camera the input is attached to.
  43970. */
  43971. abstract camera: Camera;
  43972. /**
  43973. * Whether keyboard modifier keys are pressed at time of last mouse event.
  43974. */
  43975. protected _altKey: boolean;
  43976. protected _ctrlKey: boolean;
  43977. protected _metaKey: boolean;
  43978. protected _shiftKey: boolean;
  43979. /**
  43980. * Which mouse buttons were pressed at time of last mouse event.
  43981. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  43982. */
  43983. protected _buttonsPressed: number;
  43984. /**
  43985. * Defines the buttons associated with the input to handle camera move.
  43986. */
  43987. buttons: number[];
  43988. /**
  43989. * Attach the input controls to a specific dom element to get the input from.
  43990. * @param element Defines the element the controls should be listened from
  43991. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43992. */
  43993. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43994. /**
  43995. * Detach the current controls from the specified dom element.
  43996. * @param element Defines the element to stop listening the inputs from
  43997. */
  43998. detachControl(element: Nullable<HTMLElement>): void;
  43999. /**
  44000. * Gets the class name of the current input.
  44001. * @returns the class name
  44002. */
  44003. getClassName(): string;
  44004. /**
  44005. * Get the friendly name associated with the input class.
  44006. * @returns the input friendly name
  44007. */
  44008. getSimpleName(): string;
  44009. /**
  44010. * Called on pointer POINTERDOUBLETAP event.
  44011. * Override this method to provide functionality on POINTERDOUBLETAP event.
  44012. */
  44013. protected onDoubleTap(type: string): void;
  44014. /**
  44015. * Called on pointer POINTERMOVE event if only a single touch is active.
  44016. * Override this method to provide functionality.
  44017. */
  44018. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44019. /**
  44020. * Called on pointer POINTERMOVE event if multiple touches are active.
  44021. * Override this method to provide functionality.
  44022. */
  44023. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44024. /**
  44025. * Called on JS contextmenu event.
  44026. * Override this method to provide functionality.
  44027. */
  44028. protected onContextMenu(evt: PointerEvent): void;
  44029. /**
  44030. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44031. * press.
  44032. * Override this method to provide functionality.
  44033. */
  44034. protected onButtonDown(evt: PointerEvent): void;
  44035. /**
  44036. * Called each time a new POINTERUP event occurs. Ie, for each button
  44037. * release.
  44038. * Override this method to provide functionality.
  44039. */
  44040. protected onButtonUp(evt: PointerEvent): void;
  44041. /**
  44042. * Called when window becomes inactive.
  44043. * Override this method to provide functionality.
  44044. */
  44045. protected onLostFocus(): void;
  44046. private _pointerInput;
  44047. private _observer;
  44048. private _onLostFocus;
  44049. private pointA;
  44050. private pointB;
  44051. }
  44052. }
  44053. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  44054. import { Nullable } from "babylonjs/types";
  44055. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44056. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  44057. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44058. /**
  44059. * Manage the pointers inputs to control an arc rotate camera.
  44060. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44061. */
  44062. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  44063. /**
  44064. * Defines the camera the input is attached to.
  44065. */
  44066. camera: ArcRotateCamera;
  44067. /**
  44068. * Gets the class name of the current input.
  44069. * @returns the class name
  44070. */
  44071. getClassName(): string;
  44072. /**
  44073. * Defines the buttons associated with the input to handle camera move.
  44074. */
  44075. buttons: number[];
  44076. /**
  44077. * Defines the pointer angular sensibility along the X axis or how fast is
  44078. * the camera rotating.
  44079. */
  44080. angularSensibilityX: number;
  44081. /**
  44082. * Defines the pointer angular sensibility along the Y axis or how fast is
  44083. * the camera rotating.
  44084. */
  44085. angularSensibilityY: number;
  44086. /**
  44087. * Defines the pointer pinch precision or how fast is the camera zooming.
  44088. */
  44089. pinchPrecision: number;
  44090. /**
  44091. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44092. * from 0.
  44093. * It defines the percentage of current camera.radius to use as delta when
  44094. * pinch zoom is used.
  44095. */
  44096. pinchDeltaPercentage: number;
  44097. /**
  44098. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44099. * that any object in the plane at the camera's target point will scale
  44100. * perfectly with finger motion.
  44101. * Overrides pinchDeltaPercentage and pinchPrecision.
  44102. */
  44103. useNaturalPinchZoom: boolean;
  44104. /**
  44105. * Defines the pointer panning sensibility or how fast is the camera moving.
  44106. */
  44107. panningSensibility: number;
  44108. /**
  44109. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  44110. */
  44111. multiTouchPanning: boolean;
  44112. /**
  44113. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  44114. * zoom (pinch) through multitouch.
  44115. */
  44116. multiTouchPanAndZoom: boolean;
  44117. /**
  44118. * Revers pinch action direction.
  44119. */
  44120. pinchInwards: boolean;
  44121. private _isPanClick;
  44122. private _twoFingerActivityCount;
  44123. private _isPinching;
  44124. /**
  44125. * Called on pointer POINTERMOVE event if only a single touch is active.
  44126. */
  44127. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44128. /**
  44129. * Called on pointer POINTERDOUBLETAP event.
  44130. */
  44131. protected onDoubleTap(type: string): void;
  44132. /**
  44133. * Called on pointer POINTERMOVE event if multiple touches are active.
  44134. */
  44135. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44136. /**
  44137. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44138. * press.
  44139. */
  44140. protected onButtonDown(evt: PointerEvent): void;
  44141. /**
  44142. * Called each time a new POINTERUP event occurs. Ie, for each button
  44143. * release.
  44144. */
  44145. protected onButtonUp(evt: PointerEvent): void;
  44146. /**
  44147. * Called when window becomes inactive.
  44148. */
  44149. protected onLostFocus(): void;
  44150. }
  44151. }
  44152. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  44153. import { Nullable } from "babylonjs/types";
  44154. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44155. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44156. /**
  44157. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  44158. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44159. */
  44160. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  44161. /**
  44162. * Defines the camera the input is attached to.
  44163. */
  44164. camera: ArcRotateCamera;
  44165. /**
  44166. * Defines the list of key codes associated with the up action (increase alpha)
  44167. */
  44168. keysUp: number[];
  44169. /**
  44170. * Defines the list of key codes associated with the down action (decrease alpha)
  44171. */
  44172. keysDown: number[];
  44173. /**
  44174. * Defines the list of key codes associated with the left action (increase beta)
  44175. */
  44176. keysLeft: number[];
  44177. /**
  44178. * Defines the list of key codes associated with the right action (decrease beta)
  44179. */
  44180. keysRight: number[];
  44181. /**
  44182. * Defines the list of key codes associated with the reset action.
  44183. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  44184. */
  44185. keysReset: number[];
  44186. /**
  44187. * Defines the panning sensibility of the inputs.
  44188. * (How fast is the camera panning)
  44189. */
  44190. panningSensibility: number;
  44191. /**
  44192. * Defines the zooming sensibility of the inputs.
  44193. * (How fast is the camera zooming)
  44194. */
  44195. zoomingSensibility: number;
  44196. /**
  44197. * Defines whether maintaining the alt key down switch the movement mode from
  44198. * orientation to zoom.
  44199. */
  44200. useAltToZoom: boolean;
  44201. /**
  44202. * Rotation speed of the camera
  44203. */
  44204. angularSpeed: number;
  44205. private _keys;
  44206. private _ctrlPressed;
  44207. private _altPressed;
  44208. private _onCanvasBlurObserver;
  44209. private _onKeyboardObserver;
  44210. private _engine;
  44211. private _scene;
  44212. /**
  44213. * Attach the input controls to a specific dom element to get the input from.
  44214. * @param element Defines the element the controls should be listened from
  44215. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44216. */
  44217. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44218. /**
  44219. * Detach the current controls from the specified dom element.
  44220. * @param element Defines the element to stop listening the inputs from
  44221. */
  44222. detachControl(element: Nullable<HTMLElement>): void;
  44223. /**
  44224. * Update the current camera state depending on the inputs that have been used this frame.
  44225. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44226. */
  44227. checkInputs(): void;
  44228. /**
  44229. * Gets the class name of the current intput.
  44230. * @returns the class name
  44231. */
  44232. getClassName(): string;
  44233. /**
  44234. * Get the friendly name associated with the input class.
  44235. * @returns the input friendly name
  44236. */
  44237. getSimpleName(): string;
  44238. }
  44239. }
  44240. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  44241. import { Nullable } from "babylonjs/types";
  44242. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44243. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44244. /**
  44245. * Manage the mouse wheel inputs to control an arc rotate camera.
  44246. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44247. */
  44248. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  44249. /**
  44250. * Defines the camera the input is attached to.
  44251. */
  44252. camera: ArcRotateCamera;
  44253. /**
  44254. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44255. */
  44256. wheelPrecision: number;
  44257. /**
  44258. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44259. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44260. */
  44261. wheelDeltaPercentage: number;
  44262. private _wheel;
  44263. private _observer;
  44264. private computeDeltaFromMouseWheelLegacyEvent;
  44265. /**
  44266. * Attach the input controls to a specific dom element to get the input from.
  44267. * @param element Defines the element the controls should be listened from
  44268. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44269. */
  44270. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44271. /**
  44272. * Detach the current controls from the specified dom element.
  44273. * @param element Defines the element to stop listening the inputs from
  44274. */
  44275. detachControl(element: Nullable<HTMLElement>): void;
  44276. /**
  44277. * Gets the class name of the current intput.
  44278. * @returns the class name
  44279. */
  44280. getClassName(): string;
  44281. /**
  44282. * Get the friendly name associated with the input class.
  44283. * @returns the input friendly name
  44284. */
  44285. getSimpleName(): string;
  44286. }
  44287. }
  44288. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44289. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44290. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44291. /**
  44292. * Default Inputs manager for the ArcRotateCamera.
  44293. * It groups all the default supported inputs for ease of use.
  44294. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44295. */
  44296. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  44297. /**
  44298. * Instantiates a new ArcRotateCameraInputsManager.
  44299. * @param camera Defines the camera the inputs belong to
  44300. */
  44301. constructor(camera: ArcRotateCamera);
  44302. /**
  44303. * Add mouse wheel input support to the input manager.
  44304. * @returns the current input manager
  44305. */
  44306. addMouseWheel(): ArcRotateCameraInputsManager;
  44307. /**
  44308. * Add pointers input support to the input manager.
  44309. * @returns the current input manager
  44310. */
  44311. addPointers(): ArcRotateCameraInputsManager;
  44312. /**
  44313. * Add keyboard input support to the input manager.
  44314. * @returns the current input manager
  44315. */
  44316. addKeyboard(): ArcRotateCameraInputsManager;
  44317. }
  44318. }
  44319. declare module "babylonjs/Cameras/arcRotateCamera" {
  44320. import { Observable } from "babylonjs/Misc/observable";
  44321. import { Nullable } from "babylonjs/types";
  44322. import { Scene } from "babylonjs/scene";
  44323. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  44324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44325. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44326. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44327. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  44328. import { Camera } from "babylonjs/Cameras/camera";
  44329. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44330. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44331. import { Collider } from "babylonjs/Collisions/collider";
  44332. /**
  44333. * This represents an orbital type of camera.
  44334. *
  44335. * 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.
  44336. * 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.
  44337. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  44338. */
  44339. export class ArcRotateCamera extends TargetCamera {
  44340. /**
  44341. * Defines the rotation angle of the camera along the longitudinal axis.
  44342. */
  44343. alpha: number;
  44344. /**
  44345. * Defines the rotation angle of the camera along the latitudinal axis.
  44346. */
  44347. beta: number;
  44348. /**
  44349. * Defines the radius of the camera from it s target point.
  44350. */
  44351. radius: number;
  44352. protected _target: Vector3;
  44353. protected _targetHost: Nullable<AbstractMesh>;
  44354. /**
  44355. * Defines the target point of the camera.
  44356. * The camera looks towards it form the radius distance.
  44357. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  44358. */
  44359. get target(): Vector3;
  44360. set target(value: Vector3);
  44361. /**
  44362. * Define the current local position of the camera in the scene
  44363. */
  44364. get position(): Vector3;
  44365. set position(newPosition: Vector3);
  44366. protected _upToYMatrix: Matrix;
  44367. protected _YToUpMatrix: Matrix;
  44368. /**
  44369. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  44370. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  44371. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  44372. */
  44373. set upVector(vec: Vector3);
  44374. get upVector(): Vector3;
  44375. /**
  44376. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  44377. */
  44378. setMatUp(): void;
  44379. /**
  44380. * Current inertia value on the longitudinal axis.
  44381. * The bigger this number the longer it will take for the camera to stop.
  44382. */
  44383. inertialAlphaOffset: number;
  44384. /**
  44385. * Current inertia value on the latitudinal axis.
  44386. * The bigger this number the longer it will take for the camera to stop.
  44387. */
  44388. inertialBetaOffset: number;
  44389. /**
  44390. * Current inertia value on the radius axis.
  44391. * The bigger this number the longer it will take for the camera to stop.
  44392. */
  44393. inertialRadiusOffset: number;
  44394. /**
  44395. * Minimum allowed angle on the longitudinal axis.
  44396. * This can help limiting how the Camera is able to move in the scene.
  44397. */
  44398. lowerAlphaLimit: Nullable<number>;
  44399. /**
  44400. * Maximum allowed angle on the longitudinal axis.
  44401. * This can help limiting how the Camera is able to move in the scene.
  44402. */
  44403. upperAlphaLimit: Nullable<number>;
  44404. /**
  44405. * Minimum allowed angle on the latitudinal axis.
  44406. * This can help limiting how the Camera is able to move in the scene.
  44407. */
  44408. lowerBetaLimit: number;
  44409. /**
  44410. * Maximum allowed angle on the latitudinal axis.
  44411. * This can help limiting how the Camera is able to move in the scene.
  44412. */
  44413. upperBetaLimit: number;
  44414. /**
  44415. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  44416. * This can help limiting how the Camera is able to move in the scene.
  44417. */
  44418. lowerRadiusLimit: Nullable<number>;
  44419. /**
  44420. * Maximum allowed distance of the camera to the target (The camera can not get further).
  44421. * This can help limiting how the Camera is able to move in the scene.
  44422. */
  44423. upperRadiusLimit: Nullable<number>;
  44424. /**
  44425. * Defines the current inertia value used during panning of the camera along the X axis.
  44426. */
  44427. inertialPanningX: number;
  44428. /**
  44429. * Defines the current inertia value used during panning of the camera along the Y axis.
  44430. */
  44431. inertialPanningY: number;
  44432. /**
  44433. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  44434. * Basically if your fingers moves away from more than this distance you will be considered
  44435. * in pinch mode.
  44436. */
  44437. pinchToPanMaxDistance: number;
  44438. /**
  44439. * Defines the maximum distance the camera can pan.
  44440. * This could help keeping the cammera always in your scene.
  44441. */
  44442. panningDistanceLimit: Nullable<number>;
  44443. /**
  44444. * Defines the target of the camera before paning.
  44445. */
  44446. panningOriginTarget: Vector3;
  44447. /**
  44448. * Defines the value of the inertia used during panning.
  44449. * 0 would mean stop inertia and one would mean no decelleration at all.
  44450. */
  44451. panningInertia: number;
  44452. /**
  44453. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  44454. */
  44455. get angularSensibilityX(): number;
  44456. set angularSensibilityX(value: number);
  44457. /**
  44458. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  44459. */
  44460. get angularSensibilityY(): number;
  44461. set angularSensibilityY(value: number);
  44462. /**
  44463. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  44464. */
  44465. get pinchPrecision(): number;
  44466. set pinchPrecision(value: number);
  44467. /**
  44468. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  44469. * It will be used instead of pinchDeltaPrecision if different from 0.
  44470. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44471. */
  44472. get pinchDeltaPercentage(): number;
  44473. set pinchDeltaPercentage(value: number);
  44474. /**
  44475. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  44476. * and pinch delta percentage.
  44477. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44478. * that any object in the plane at the camera's target point will scale
  44479. * perfectly with finger motion.
  44480. */
  44481. get useNaturalPinchZoom(): boolean;
  44482. set useNaturalPinchZoom(value: boolean);
  44483. /**
  44484. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  44485. */
  44486. get panningSensibility(): number;
  44487. set panningSensibility(value: number);
  44488. /**
  44489. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  44490. */
  44491. get keysUp(): number[];
  44492. set keysUp(value: number[]);
  44493. /**
  44494. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  44495. */
  44496. get keysDown(): number[];
  44497. set keysDown(value: number[]);
  44498. /**
  44499. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  44500. */
  44501. get keysLeft(): number[];
  44502. set keysLeft(value: number[]);
  44503. /**
  44504. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  44505. */
  44506. get keysRight(): number[];
  44507. set keysRight(value: number[]);
  44508. /**
  44509. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44510. */
  44511. get wheelPrecision(): number;
  44512. set wheelPrecision(value: number);
  44513. /**
  44514. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  44515. * It will be used instead of pinchDeltaPrecision if different from 0.
  44516. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44517. */
  44518. get wheelDeltaPercentage(): number;
  44519. set wheelDeltaPercentage(value: number);
  44520. /**
  44521. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  44522. */
  44523. zoomOnFactor: number;
  44524. /**
  44525. * Defines a screen offset for the camera position.
  44526. */
  44527. targetScreenOffset: Vector2;
  44528. /**
  44529. * Allows the camera to be completely reversed.
  44530. * If false the camera can not arrive upside down.
  44531. */
  44532. allowUpsideDown: boolean;
  44533. /**
  44534. * Define if double tap/click is used to restore the previously saved state of the camera.
  44535. */
  44536. useInputToRestoreState: boolean;
  44537. /** @hidden */
  44538. _viewMatrix: Matrix;
  44539. /** @hidden */
  44540. _useCtrlForPanning: boolean;
  44541. /** @hidden */
  44542. _panningMouseButton: number;
  44543. /**
  44544. * Defines the input associated to the camera.
  44545. */
  44546. inputs: ArcRotateCameraInputsManager;
  44547. /** @hidden */
  44548. _reset: () => void;
  44549. /**
  44550. * Defines the allowed panning axis.
  44551. */
  44552. panningAxis: Vector3;
  44553. protected _localDirection: Vector3;
  44554. protected _transformedDirection: Vector3;
  44555. private _bouncingBehavior;
  44556. /**
  44557. * Gets the bouncing behavior of the camera if it has been enabled.
  44558. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44559. */
  44560. get bouncingBehavior(): Nullable<BouncingBehavior>;
  44561. /**
  44562. * Defines if the bouncing behavior of the camera is enabled on the camera.
  44563. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44564. */
  44565. get useBouncingBehavior(): boolean;
  44566. set useBouncingBehavior(value: boolean);
  44567. private _framingBehavior;
  44568. /**
  44569. * Gets the framing behavior of the camera if it has been enabled.
  44570. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44571. */
  44572. get framingBehavior(): Nullable<FramingBehavior>;
  44573. /**
  44574. * Defines if the framing behavior of the camera is enabled on the camera.
  44575. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44576. */
  44577. get useFramingBehavior(): boolean;
  44578. set useFramingBehavior(value: boolean);
  44579. private _autoRotationBehavior;
  44580. /**
  44581. * Gets the auto rotation behavior of the camera if it has been enabled.
  44582. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44583. */
  44584. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  44585. /**
  44586. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  44587. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44588. */
  44589. get useAutoRotationBehavior(): boolean;
  44590. set useAutoRotationBehavior(value: boolean);
  44591. /**
  44592. * Observable triggered when the mesh target has been changed on the camera.
  44593. */
  44594. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  44595. /**
  44596. * Event raised when the camera is colliding with a mesh.
  44597. */
  44598. onCollide: (collidedMesh: AbstractMesh) => void;
  44599. /**
  44600. * Defines whether the camera should check collision with the objects oh the scene.
  44601. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  44602. */
  44603. checkCollisions: boolean;
  44604. /**
  44605. * Defines the collision radius of the camera.
  44606. * This simulates a sphere around the camera.
  44607. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44608. */
  44609. collisionRadius: Vector3;
  44610. protected _collider: Collider;
  44611. protected _previousPosition: Vector3;
  44612. protected _collisionVelocity: Vector3;
  44613. protected _newPosition: Vector3;
  44614. protected _previousAlpha: number;
  44615. protected _previousBeta: number;
  44616. protected _previousRadius: number;
  44617. protected _collisionTriggered: boolean;
  44618. protected _targetBoundingCenter: Nullable<Vector3>;
  44619. private _computationVector;
  44620. /**
  44621. * Instantiates a new ArcRotateCamera in a given scene
  44622. * @param name Defines the name of the camera
  44623. * @param alpha Defines the camera rotation along the logitudinal axis
  44624. * @param beta Defines the camera rotation along the latitudinal axis
  44625. * @param radius Defines the camera distance from its target
  44626. * @param target Defines the camera target
  44627. * @param scene Defines the scene the camera belongs to
  44628. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  44629. */
  44630. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44631. /** @hidden */
  44632. _initCache(): void;
  44633. /** @hidden */
  44634. _updateCache(ignoreParentClass?: boolean): void;
  44635. protected _getTargetPosition(): Vector3;
  44636. private _storedAlpha;
  44637. private _storedBeta;
  44638. private _storedRadius;
  44639. private _storedTarget;
  44640. private _storedTargetScreenOffset;
  44641. /**
  44642. * Stores the current state of the camera (alpha, beta, radius and target)
  44643. * @returns the camera itself
  44644. */
  44645. storeState(): Camera;
  44646. /**
  44647. * @hidden
  44648. * Restored camera state. You must call storeState() first
  44649. */
  44650. _restoreStateValues(): boolean;
  44651. /** @hidden */
  44652. _isSynchronizedViewMatrix(): boolean;
  44653. /**
  44654. * Attached controls to the current camera.
  44655. * @param element Defines the element the controls should be listened from
  44656. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44657. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  44658. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  44659. */
  44660. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  44661. /**
  44662. * Detach the current controls from the camera.
  44663. * The camera will stop reacting to inputs.
  44664. * @param element Defines the element to stop listening the inputs from
  44665. */
  44666. detachControl(element: HTMLElement): void;
  44667. /** @hidden */
  44668. _checkInputs(): void;
  44669. protected _checkLimits(): void;
  44670. /**
  44671. * Rebuilds angles (alpha, beta) and radius from the give position and target
  44672. */
  44673. rebuildAnglesAndRadius(): void;
  44674. /**
  44675. * Use a position to define the current camera related information like alpha, beta and radius
  44676. * @param position Defines the position to set the camera at
  44677. */
  44678. setPosition(position: Vector3): void;
  44679. /**
  44680. * Defines the target the camera should look at.
  44681. * This will automatically adapt alpha beta and radius to fit within the new target.
  44682. * @param target Defines the new target as a Vector or a mesh
  44683. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  44684. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  44685. */
  44686. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  44687. /** @hidden */
  44688. _getViewMatrix(): Matrix;
  44689. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  44690. /**
  44691. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  44692. * @param meshes Defines the mesh to zoom on
  44693. * @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)
  44694. */
  44695. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  44696. /**
  44697. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  44698. * The target will be changed but the radius
  44699. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  44700. * @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)
  44701. */
  44702. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  44703. min: Vector3;
  44704. max: Vector3;
  44705. distance: number;
  44706. }, doNotUpdateMaxZ?: boolean): void;
  44707. /**
  44708. * @override
  44709. * Override Camera.createRigCamera
  44710. */
  44711. createRigCamera(name: string, cameraIndex: number): Camera;
  44712. /**
  44713. * @hidden
  44714. * @override
  44715. * Override Camera._updateRigCameras
  44716. */
  44717. _updateRigCameras(): void;
  44718. /**
  44719. * Destroy the camera and release the current resources hold by it.
  44720. */
  44721. dispose(): void;
  44722. /**
  44723. * Gets the current object class name.
  44724. * @return the class name
  44725. */
  44726. getClassName(): string;
  44727. }
  44728. }
  44729. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  44730. import { Behavior } from "babylonjs/Behaviors/behavior";
  44731. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44732. /**
  44733. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  44734. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44735. */
  44736. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  44737. /**
  44738. * Gets the name of the behavior.
  44739. */
  44740. get name(): string;
  44741. private _zoomStopsAnimation;
  44742. private _idleRotationSpeed;
  44743. private _idleRotationWaitTime;
  44744. private _idleRotationSpinupTime;
  44745. /**
  44746. * Sets the flag that indicates if user zooming should stop animation.
  44747. */
  44748. set zoomStopsAnimation(flag: boolean);
  44749. /**
  44750. * Gets the flag that indicates if user zooming should stop animation.
  44751. */
  44752. get zoomStopsAnimation(): boolean;
  44753. /**
  44754. * Sets the default speed at which the camera rotates around the model.
  44755. */
  44756. set idleRotationSpeed(speed: number);
  44757. /**
  44758. * Gets the default speed at which the camera rotates around the model.
  44759. */
  44760. get idleRotationSpeed(): number;
  44761. /**
  44762. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  44763. */
  44764. set idleRotationWaitTime(time: number);
  44765. /**
  44766. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  44767. */
  44768. get idleRotationWaitTime(): number;
  44769. /**
  44770. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44771. */
  44772. set idleRotationSpinupTime(time: number);
  44773. /**
  44774. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44775. */
  44776. get idleRotationSpinupTime(): number;
  44777. /**
  44778. * Gets a value indicating if the camera is currently rotating because of this behavior
  44779. */
  44780. get rotationInProgress(): boolean;
  44781. private _onPrePointerObservableObserver;
  44782. private _onAfterCheckInputsObserver;
  44783. private _attachedCamera;
  44784. private _isPointerDown;
  44785. private _lastFrameTime;
  44786. private _lastInteractionTime;
  44787. private _cameraRotationSpeed;
  44788. /**
  44789. * Initializes the behavior.
  44790. */
  44791. init(): void;
  44792. /**
  44793. * Attaches the behavior to its arc rotate camera.
  44794. * @param camera Defines the camera to attach the behavior to
  44795. */
  44796. attach(camera: ArcRotateCamera): void;
  44797. /**
  44798. * Detaches the behavior from its current arc rotate camera.
  44799. */
  44800. detach(): void;
  44801. /**
  44802. * Returns true if user is scrolling.
  44803. * @return true if user is scrolling.
  44804. */
  44805. private _userIsZooming;
  44806. private _lastFrameRadius;
  44807. private _shouldAnimationStopForInteraction;
  44808. /**
  44809. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44810. */
  44811. private _applyUserInteraction;
  44812. private _userIsMoving;
  44813. }
  44814. }
  44815. declare module "babylonjs/Behaviors/Cameras/index" {
  44816. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44817. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44818. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  44819. }
  44820. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  44821. import { Mesh } from "babylonjs/Meshes/mesh";
  44822. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44823. import { Behavior } from "babylonjs/Behaviors/behavior";
  44824. /**
  44825. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  44826. */
  44827. export class AttachToBoxBehavior implements Behavior<Mesh> {
  44828. private ui;
  44829. /**
  44830. * The name of the behavior
  44831. */
  44832. name: string;
  44833. /**
  44834. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  44835. */
  44836. distanceAwayFromFace: number;
  44837. /**
  44838. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  44839. */
  44840. distanceAwayFromBottomOfFace: number;
  44841. private _faceVectors;
  44842. private _target;
  44843. private _scene;
  44844. private _onRenderObserver;
  44845. private _tmpMatrix;
  44846. private _tmpVector;
  44847. /**
  44848. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  44849. * @param ui The transform node that should be attched to the mesh
  44850. */
  44851. constructor(ui: TransformNode);
  44852. /**
  44853. * Initializes the behavior
  44854. */
  44855. init(): void;
  44856. private _closestFace;
  44857. private _zeroVector;
  44858. private _lookAtTmpMatrix;
  44859. private _lookAtToRef;
  44860. /**
  44861. * Attaches the AttachToBoxBehavior to the passed in mesh
  44862. * @param target The mesh that the specified node will be attached to
  44863. */
  44864. attach(target: Mesh): void;
  44865. /**
  44866. * Detaches the behavior from the mesh
  44867. */
  44868. detach(): void;
  44869. }
  44870. }
  44871. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  44872. import { Behavior } from "babylonjs/Behaviors/behavior";
  44873. import { Mesh } from "babylonjs/Meshes/mesh";
  44874. /**
  44875. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  44876. */
  44877. export class FadeInOutBehavior implements Behavior<Mesh> {
  44878. /**
  44879. * Time in milliseconds to delay before fading in (Default: 0)
  44880. */
  44881. delay: number;
  44882. /**
  44883. * Time in milliseconds for the mesh to fade in (Default: 300)
  44884. */
  44885. fadeInTime: number;
  44886. private _millisecondsPerFrame;
  44887. private _hovered;
  44888. private _hoverValue;
  44889. private _ownerNode;
  44890. /**
  44891. * Instatiates the FadeInOutBehavior
  44892. */
  44893. constructor();
  44894. /**
  44895. * The name of the behavior
  44896. */
  44897. get name(): string;
  44898. /**
  44899. * Initializes the behavior
  44900. */
  44901. init(): void;
  44902. /**
  44903. * Attaches the fade behavior on the passed in mesh
  44904. * @param ownerNode The mesh that will be faded in/out once attached
  44905. */
  44906. attach(ownerNode: Mesh): void;
  44907. /**
  44908. * Detaches the behavior from the mesh
  44909. */
  44910. detach(): void;
  44911. /**
  44912. * Triggers the mesh to begin fading in or out
  44913. * @param value if the object should fade in or out (true to fade in)
  44914. */
  44915. fadeIn(value: boolean): void;
  44916. private _update;
  44917. private _setAllVisibility;
  44918. }
  44919. }
  44920. declare module "babylonjs/Misc/pivotTools" {
  44921. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44922. /**
  44923. * Class containing a set of static utilities functions for managing Pivots
  44924. * @hidden
  44925. */
  44926. export class PivotTools {
  44927. private static _PivotCached;
  44928. private static _OldPivotPoint;
  44929. private static _PivotTranslation;
  44930. private static _PivotTmpVector;
  44931. private static _PivotPostMultiplyPivotMatrix;
  44932. /** @hidden */
  44933. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  44934. /** @hidden */
  44935. static _RestorePivotPoint(mesh: AbstractMesh): void;
  44936. }
  44937. }
  44938. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  44939. import { Scene } from "babylonjs/scene";
  44940. import { Vector4 } from "babylonjs/Maths/math.vector";
  44941. import { Mesh } from "babylonjs/Meshes/mesh";
  44942. import { Nullable } from "babylonjs/types";
  44943. import { Plane } from "babylonjs/Maths/math.plane";
  44944. /**
  44945. * Class containing static functions to help procedurally build meshes
  44946. */
  44947. export class PlaneBuilder {
  44948. /**
  44949. * Creates a plane mesh
  44950. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  44951. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  44952. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  44953. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44954. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44956. * @param name defines the name of the mesh
  44957. * @param options defines the options used to create the mesh
  44958. * @param scene defines the hosting scene
  44959. * @returns the plane mesh
  44960. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  44961. */
  44962. static CreatePlane(name: string, options: {
  44963. size?: number;
  44964. width?: number;
  44965. height?: number;
  44966. sideOrientation?: number;
  44967. frontUVs?: Vector4;
  44968. backUVs?: Vector4;
  44969. updatable?: boolean;
  44970. sourcePlane?: Plane;
  44971. }, scene?: Nullable<Scene>): Mesh;
  44972. }
  44973. }
  44974. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  44975. import { Behavior } from "babylonjs/Behaviors/behavior";
  44976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44977. import { Observable } from "babylonjs/Misc/observable";
  44978. import { Vector3 } from "babylonjs/Maths/math.vector";
  44979. import { Ray } from "babylonjs/Culling/ray";
  44980. import "babylonjs/Meshes/Builders/planeBuilder";
  44981. /**
  44982. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  44983. */
  44984. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  44985. private static _AnyMouseID;
  44986. /**
  44987. * Abstract mesh the behavior is set on
  44988. */
  44989. attachedNode: AbstractMesh;
  44990. private _dragPlane;
  44991. private _scene;
  44992. private _pointerObserver;
  44993. private _beforeRenderObserver;
  44994. private static _planeScene;
  44995. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  44996. /**
  44997. * 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)
  44998. */
  44999. maxDragAngle: number;
  45000. /**
  45001. * @hidden
  45002. */
  45003. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  45004. /**
  45005. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45006. */
  45007. currentDraggingPointerID: number;
  45008. /**
  45009. * The last position where the pointer hit the drag plane in world space
  45010. */
  45011. lastDragPosition: Vector3;
  45012. /**
  45013. * If the behavior is currently in a dragging state
  45014. */
  45015. dragging: boolean;
  45016. /**
  45017. * 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)
  45018. */
  45019. dragDeltaRatio: number;
  45020. /**
  45021. * If the drag plane orientation should be updated during the dragging (Default: true)
  45022. */
  45023. updateDragPlane: boolean;
  45024. private _debugMode;
  45025. private _moving;
  45026. /**
  45027. * Fires each time the attached mesh is dragged with the pointer
  45028. * * delta between last drag position and current drag position in world space
  45029. * * dragDistance along the drag axis
  45030. * * dragPlaneNormal normal of the current drag plane used during the drag
  45031. * * dragPlanePoint in world space where the drag intersects the drag plane
  45032. */
  45033. onDragObservable: Observable<{
  45034. delta: Vector3;
  45035. dragPlanePoint: Vector3;
  45036. dragPlaneNormal: Vector3;
  45037. dragDistance: number;
  45038. pointerId: number;
  45039. }>;
  45040. /**
  45041. * Fires each time a drag begins (eg. mouse down on mesh)
  45042. */
  45043. onDragStartObservable: Observable<{
  45044. dragPlanePoint: Vector3;
  45045. pointerId: number;
  45046. }>;
  45047. /**
  45048. * Fires each time a drag ends (eg. mouse release after drag)
  45049. */
  45050. onDragEndObservable: Observable<{
  45051. dragPlanePoint: Vector3;
  45052. pointerId: number;
  45053. }>;
  45054. /**
  45055. * If the attached mesh should be moved when dragged
  45056. */
  45057. moveAttached: boolean;
  45058. /**
  45059. * If the drag behavior will react to drag events (Default: true)
  45060. */
  45061. enabled: boolean;
  45062. /**
  45063. * If pointer events should start and release the drag (Default: true)
  45064. */
  45065. startAndReleaseDragOnPointerEvents: boolean;
  45066. /**
  45067. * If camera controls should be detached during the drag
  45068. */
  45069. detachCameraControls: boolean;
  45070. /**
  45071. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  45072. */
  45073. useObjectOrientationForDragging: boolean;
  45074. private _options;
  45075. /**
  45076. * Gets the options used by the behavior
  45077. */
  45078. get options(): {
  45079. dragAxis?: Vector3;
  45080. dragPlaneNormal?: Vector3;
  45081. };
  45082. /**
  45083. * Sets the options used by the behavior
  45084. */
  45085. set options(options: {
  45086. dragAxis?: Vector3;
  45087. dragPlaneNormal?: Vector3;
  45088. });
  45089. /**
  45090. * Creates a pointer drag behavior that can be attached to a mesh
  45091. * @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)
  45092. */
  45093. constructor(options?: {
  45094. dragAxis?: Vector3;
  45095. dragPlaneNormal?: Vector3;
  45096. });
  45097. /**
  45098. * Predicate to determine if it is valid to move the object to a new position when it is moved
  45099. */
  45100. validateDrag: (targetPosition: Vector3) => boolean;
  45101. /**
  45102. * The name of the behavior
  45103. */
  45104. get name(): string;
  45105. /**
  45106. * Initializes the behavior
  45107. */
  45108. init(): void;
  45109. private _tmpVector;
  45110. private _alternatePickedPoint;
  45111. private _worldDragAxis;
  45112. private _targetPosition;
  45113. private _attachedElement;
  45114. /**
  45115. * Attaches the drag behavior the passed in mesh
  45116. * @param ownerNode The mesh that will be dragged around once attached
  45117. * @param predicate Predicate to use for pick filtering
  45118. */
  45119. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  45120. /**
  45121. * Force relase the drag action by code.
  45122. */
  45123. releaseDrag(): void;
  45124. private _startDragRay;
  45125. private _lastPointerRay;
  45126. /**
  45127. * Simulates the start of a pointer drag event on the behavior
  45128. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  45129. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  45130. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  45131. */
  45132. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45133. private _startDrag;
  45134. private _dragDelta;
  45135. private _moveDrag;
  45136. private _pickWithRayOnDragPlane;
  45137. private _pointA;
  45138. private _pointC;
  45139. private _localAxis;
  45140. private _lookAt;
  45141. private _updateDragPlanePosition;
  45142. /**
  45143. * Detaches the behavior from the mesh
  45144. */
  45145. detach(): void;
  45146. }
  45147. }
  45148. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  45149. import { Mesh } from "babylonjs/Meshes/mesh";
  45150. import { Behavior } from "babylonjs/Behaviors/behavior";
  45151. /**
  45152. * A behavior that when attached to a mesh will allow the mesh to be scaled
  45153. */
  45154. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  45155. private _dragBehaviorA;
  45156. private _dragBehaviorB;
  45157. private _startDistance;
  45158. private _initialScale;
  45159. private _targetScale;
  45160. private _ownerNode;
  45161. private _sceneRenderObserver;
  45162. /**
  45163. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  45164. */
  45165. constructor();
  45166. /**
  45167. * The name of the behavior
  45168. */
  45169. get name(): string;
  45170. /**
  45171. * Initializes the behavior
  45172. */
  45173. init(): void;
  45174. private _getCurrentDistance;
  45175. /**
  45176. * Attaches the scale behavior the passed in mesh
  45177. * @param ownerNode The mesh that will be scaled around once attached
  45178. */
  45179. attach(ownerNode: Mesh): void;
  45180. /**
  45181. * Detaches the behavior from the mesh
  45182. */
  45183. detach(): void;
  45184. }
  45185. }
  45186. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  45187. import { Behavior } from "babylonjs/Behaviors/behavior";
  45188. import { Mesh } from "babylonjs/Meshes/mesh";
  45189. import { Observable } from "babylonjs/Misc/observable";
  45190. /**
  45191. * 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
  45192. */
  45193. export class SixDofDragBehavior implements Behavior<Mesh> {
  45194. private static _virtualScene;
  45195. private _ownerNode;
  45196. private _sceneRenderObserver;
  45197. private _scene;
  45198. private _targetPosition;
  45199. private _virtualOriginMesh;
  45200. private _virtualDragMesh;
  45201. private _pointerObserver;
  45202. private _moving;
  45203. private _startingOrientation;
  45204. private _attachedElement;
  45205. /**
  45206. * 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)
  45207. */
  45208. private zDragFactor;
  45209. /**
  45210. * If the object should rotate to face the drag origin
  45211. */
  45212. rotateDraggedObject: boolean;
  45213. /**
  45214. * If the behavior is currently in a dragging state
  45215. */
  45216. dragging: boolean;
  45217. /**
  45218. * 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)
  45219. */
  45220. dragDeltaRatio: number;
  45221. /**
  45222. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45223. */
  45224. currentDraggingPointerID: number;
  45225. /**
  45226. * If camera controls should be detached during the drag
  45227. */
  45228. detachCameraControls: boolean;
  45229. /**
  45230. * Fires each time a drag starts
  45231. */
  45232. onDragStartObservable: Observable<{}>;
  45233. /**
  45234. * Fires each time a drag ends (eg. mouse release after drag)
  45235. */
  45236. onDragEndObservable: Observable<{}>;
  45237. /**
  45238. * 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
  45239. */
  45240. constructor();
  45241. /**
  45242. * The name of the behavior
  45243. */
  45244. get name(): string;
  45245. /**
  45246. * Initializes the behavior
  45247. */
  45248. init(): void;
  45249. /**
  45250. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  45251. */
  45252. private get _pointerCamera();
  45253. /**
  45254. * Attaches the scale behavior the passed in mesh
  45255. * @param ownerNode The mesh that will be scaled around once attached
  45256. */
  45257. attach(ownerNode: Mesh): void;
  45258. /**
  45259. * Detaches the behavior from the mesh
  45260. */
  45261. detach(): void;
  45262. }
  45263. }
  45264. declare module "babylonjs/Behaviors/Meshes/index" {
  45265. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  45266. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  45267. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  45268. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45269. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45270. }
  45271. declare module "babylonjs/Behaviors/index" {
  45272. export * from "babylonjs/Behaviors/behavior";
  45273. export * from "babylonjs/Behaviors/Cameras/index";
  45274. export * from "babylonjs/Behaviors/Meshes/index";
  45275. }
  45276. declare module "babylonjs/Bones/boneIKController" {
  45277. import { Bone } from "babylonjs/Bones/bone";
  45278. import { Vector3 } from "babylonjs/Maths/math.vector";
  45279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45280. import { Nullable } from "babylonjs/types";
  45281. /**
  45282. * Class used to apply inverse kinematics to bones
  45283. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  45284. */
  45285. export class BoneIKController {
  45286. private static _tmpVecs;
  45287. private static _tmpQuat;
  45288. private static _tmpMats;
  45289. /**
  45290. * Gets or sets the target mesh
  45291. */
  45292. targetMesh: AbstractMesh;
  45293. /** Gets or sets the mesh used as pole */
  45294. poleTargetMesh: AbstractMesh;
  45295. /**
  45296. * Gets or sets the bone used as pole
  45297. */
  45298. poleTargetBone: Nullable<Bone>;
  45299. /**
  45300. * Gets or sets the target position
  45301. */
  45302. targetPosition: Vector3;
  45303. /**
  45304. * Gets or sets the pole target position
  45305. */
  45306. poleTargetPosition: Vector3;
  45307. /**
  45308. * Gets or sets the pole target local offset
  45309. */
  45310. poleTargetLocalOffset: Vector3;
  45311. /**
  45312. * Gets or sets the pole angle
  45313. */
  45314. poleAngle: number;
  45315. /**
  45316. * Gets or sets the mesh associated with the controller
  45317. */
  45318. mesh: AbstractMesh;
  45319. /**
  45320. * 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)
  45321. */
  45322. slerpAmount: number;
  45323. private _bone1Quat;
  45324. private _bone1Mat;
  45325. private _bone2Ang;
  45326. private _bone1;
  45327. private _bone2;
  45328. private _bone1Length;
  45329. private _bone2Length;
  45330. private _maxAngle;
  45331. private _maxReach;
  45332. private _rightHandedSystem;
  45333. private _bendAxis;
  45334. private _slerping;
  45335. private _adjustRoll;
  45336. /**
  45337. * Gets or sets maximum allowed angle
  45338. */
  45339. get maxAngle(): number;
  45340. set maxAngle(value: number);
  45341. /**
  45342. * Creates a new BoneIKController
  45343. * @param mesh defines the mesh to control
  45344. * @param bone defines the bone to control
  45345. * @param options defines options to set up the controller
  45346. */
  45347. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  45348. targetMesh?: AbstractMesh;
  45349. poleTargetMesh?: AbstractMesh;
  45350. poleTargetBone?: Bone;
  45351. poleTargetLocalOffset?: Vector3;
  45352. poleAngle?: number;
  45353. bendAxis?: Vector3;
  45354. maxAngle?: number;
  45355. slerpAmount?: number;
  45356. });
  45357. private _setMaxAngle;
  45358. /**
  45359. * Force the controller to update the bones
  45360. */
  45361. update(): void;
  45362. }
  45363. }
  45364. declare module "babylonjs/Bones/boneLookController" {
  45365. import { Vector3 } from "babylonjs/Maths/math.vector";
  45366. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45367. import { Bone } from "babylonjs/Bones/bone";
  45368. import { Space } from "babylonjs/Maths/math.axis";
  45369. /**
  45370. * Class used to make a bone look toward a point in space
  45371. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  45372. */
  45373. export class BoneLookController {
  45374. private static _tmpVecs;
  45375. private static _tmpQuat;
  45376. private static _tmpMats;
  45377. /**
  45378. * The target Vector3 that the bone will look at
  45379. */
  45380. target: Vector3;
  45381. /**
  45382. * The mesh that the bone is attached to
  45383. */
  45384. mesh: AbstractMesh;
  45385. /**
  45386. * The bone that will be looking to the target
  45387. */
  45388. bone: Bone;
  45389. /**
  45390. * The up axis of the coordinate system that is used when the bone is rotated
  45391. */
  45392. upAxis: Vector3;
  45393. /**
  45394. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  45395. */
  45396. upAxisSpace: Space;
  45397. /**
  45398. * Used to make an adjustment to the yaw of the bone
  45399. */
  45400. adjustYaw: number;
  45401. /**
  45402. * Used to make an adjustment to the pitch of the bone
  45403. */
  45404. adjustPitch: number;
  45405. /**
  45406. * Used to make an adjustment to the roll of the bone
  45407. */
  45408. adjustRoll: number;
  45409. /**
  45410. * 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)
  45411. */
  45412. slerpAmount: number;
  45413. private _minYaw;
  45414. private _maxYaw;
  45415. private _minPitch;
  45416. private _maxPitch;
  45417. private _minYawSin;
  45418. private _minYawCos;
  45419. private _maxYawSin;
  45420. private _maxYawCos;
  45421. private _midYawConstraint;
  45422. private _minPitchTan;
  45423. private _maxPitchTan;
  45424. private _boneQuat;
  45425. private _slerping;
  45426. private _transformYawPitch;
  45427. private _transformYawPitchInv;
  45428. private _firstFrameSkipped;
  45429. private _yawRange;
  45430. private _fowardAxis;
  45431. /**
  45432. * Gets or sets the minimum yaw angle that the bone can look to
  45433. */
  45434. get minYaw(): number;
  45435. set minYaw(value: number);
  45436. /**
  45437. * Gets or sets the maximum yaw angle that the bone can look to
  45438. */
  45439. get maxYaw(): number;
  45440. set maxYaw(value: number);
  45441. /**
  45442. * Gets or sets the minimum pitch angle that the bone can look to
  45443. */
  45444. get minPitch(): number;
  45445. set minPitch(value: number);
  45446. /**
  45447. * Gets or sets the maximum pitch angle that the bone can look to
  45448. */
  45449. get maxPitch(): number;
  45450. set maxPitch(value: number);
  45451. /**
  45452. * Create a BoneLookController
  45453. * @param mesh the mesh that the bone belongs to
  45454. * @param bone the bone that will be looking to the target
  45455. * @param target the target Vector3 to look at
  45456. * @param options optional settings:
  45457. * * maxYaw: the maximum angle the bone will yaw to
  45458. * * minYaw: the minimum angle the bone will yaw to
  45459. * * maxPitch: the maximum angle the bone will pitch to
  45460. * * minPitch: the minimum angle the bone will yaw to
  45461. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  45462. * * upAxis: the up axis of the coordinate system
  45463. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  45464. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  45465. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  45466. * * adjustYaw: used to make an adjustment to the yaw of the bone
  45467. * * adjustPitch: used to make an adjustment to the pitch of the bone
  45468. * * adjustRoll: used to make an adjustment to the roll of the bone
  45469. **/
  45470. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  45471. maxYaw?: number;
  45472. minYaw?: number;
  45473. maxPitch?: number;
  45474. minPitch?: number;
  45475. slerpAmount?: number;
  45476. upAxis?: Vector3;
  45477. upAxisSpace?: Space;
  45478. yawAxis?: Vector3;
  45479. pitchAxis?: Vector3;
  45480. adjustYaw?: number;
  45481. adjustPitch?: number;
  45482. adjustRoll?: number;
  45483. });
  45484. /**
  45485. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  45486. */
  45487. update(): void;
  45488. private _getAngleDiff;
  45489. private _getAngleBetween;
  45490. private _isAngleBetween;
  45491. }
  45492. }
  45493. declare module "babylonjs/Bones/index" {
  45494. export * from "babylonjs/Bones/bone";
  45495. export * from "babylonjs/Bones/boneIKController";
  45496. export * from "babylonjs/Bones/boneLookController";
  45497. export * from "babylonjs/Bones/skeleton";
  45498. }
  45499. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  45500. import { Nullable } from "babylonjs/types";
  45501. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45502. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45503. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45504. /**
  45505. * Manage the gamepad inputs to control an arc rotate camera.
  45506. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45507. */
  45508. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  45509. /**
  45510. * Defines the camera the input is attached to.
  45511. */
  45512. camera: ArcRotateCamera;
  45513. /**
  45514. * Defines the gamepad the input is gathering event from.
  45515. */
  45516. gamepad: Nullable<Gamepad>;
  45517. /**
  45518. * Defines the gamepad rotation sensiblity.
  45519. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45520. */
  45521. gamepadRotationSensibility: number;
  45522. /**
  45523. * Defines the gamepad move sensiblity.
  45524. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45525. */
  45526. gamepadMoveSensibility: number;
  45527. private _yAxisScale;
  45528. /**
  45529. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45530. */
  45531. get invertYAxis(): boolean;
  45532. set invertYAxis(value: boolean);
  45533. private _onGamepadConnectedObserver;
  45534. private _onGamepadDisconnectedObserver;
  45535. /**
  45536. * Attach the input controls to a specific dom element to get the input from.
  45537. * @param element Defines the element the controls should be listened from
  45538. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45539. */
  45540. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45541. /**
  45542. * Detach the current controls from the specified dom element.
  45543. * @param element Defines the element to stop listening the inputs from
  45544. */
  45545. detachControl(element: Nullable<HTMLElement>): void;
  45546. /**
  45547. * Update the current camera state depending on the inputs that have been used this frame.
  45548. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45549. */
  45550. checkInputs(): void;
  45551. /**
  45552. * Gets the class name of the current intput.
  45553. * @returns the class name
  45554. */
  45555. getClassName(): string;
  45556. /**
  45557. * Get the friendly name associated with the input class.
  45558. * @returns the input friendly name
  45559. */
  45560. getSimpleName(): string;
  45561. }
  45562. }
  45563. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  45564. import { Nullable } from "babylonjs/types";
  45565. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45566. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45567. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  45568. interface ArcRotateCameraInputsManager {
  45569. /**
  45570. * Add orientation input support to the input manager.
  45571. * @returns the current input manager
  45572. */
  45573. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  45574. }
  45575. }
  45576. /**
  45577. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  45578. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45579. */
  45580. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  45581. /**
  45582. * Defines the camera the input is attached to.
  45583. */
  45584. camera: ArcRotateCamera;
  45585. /**
  45586. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  45587. */
  45588. alphaCorrection: number;
  45589. /**
  45590. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  45591. */
  45592. gammaCorrection: number;
  45593. private _alpha;
  45594. private _gamma;
  45595. private _dirty;
  45596. private _deviceOrientationHandler;
  45597. /**
  45598. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  45599. */
  45600. constructor();
  45601. /**
  45602. * Attach the input controls to a specific dom element to get the input from.
  45603. * @param element Defines the element the controls should be listened from
  45604. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45605. */
  45606. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45607. /** @hidden */
  45608. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  45609. /**
  45610. * Update the current camera state depending on the inputs that have been used this frame.
  45611. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45612. */
  45613. checkInputs(): void;
  45614. /**
  45615. * Detach the current controls from the specified dom element.
  45616. * @param element Defines the element to stop listening the inputs from
  45617. */
  45618. detachControl(element: Nullable<HTMLElement>): void;
  45619. /**
  45620. * Gets the class name of the current intput.
  45621. * @returns the class name
  45622. */
  45623. getClassName(): string;
  45624. /**
  45625. * Get the friendly name associated with the input class.
  45626. * @returns the input friendly name
  45627. */
  45628. getSimpleName(): string;
  45629. }
  45630. }
  45631. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  45632. import { Nullable } from "babylonjs/types";
  45633. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45634. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45635. /**
  45636. * Listen to mouse events to control the camera.
  45637. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45638. */
  45639. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  45640. /**
  45641. * Defines the camera the input is attached to.
  45642. */
  45643. camera: FlyCamera;
  45644. /**
  45645. * Defines if touch is enabled. (Default is true.)
  45646. */
  45647. touchEnabled: boolean;
  45648. /**
  45649. * Defines the buttons associated with the input to handle camera rotation.
  45650. */
  45651. buttons: number[];
  45652. /**
  45653. * Assign buttons for Yaw control.
  45654. */
  45655. buttonsYaw: number[];
  45656. /**
  45657. * Assign buttons for Pitch control.
  45658. */
  45659. buttonsPitch: number[];
  45660. /**
  45661. * Assign buttons for Roll control.
  45662. */
  45663. buttonsRoll: number[];
  45664. /**
  45665. * Detect if any button is being pressed while mouse is moved.
  45666. * -1 = Mouse locked.
  45667. * 0 = Left button.
  45668. * 1 = Middle Button.
  45669. * 2 = Right Button.
  45670. */
  45671. activeButton: number;
  45672. /**
  45673. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  45674. * Higher values reduce its sensitivity.
  45675. */
  45676. angularSensibility: number;
  45677. private _mousemoveCallback;
  45678. private _observer;
  45679. private _rollObserver;
  45680. private previousPosition;
  45681. private noPreventDefault;
  45682. private element;
  45683. /**
  45684. * Listen to mouse events to control the camera.
  45685. * @param touchEnabled Define if touch is enabled. (Default is true.)
  45686. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45687. */
  45688. constructor(touchEnabled?: boolean);
  45689. /**
  45690. * Attach the mouse control to the HTML DOM element.
  45691. * @param element Defines the element that listens to the input events.
  45692. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  45693. */
  45694. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45695. /**
  45696. * Detach the current controls from the specified dom element.
  45697. * @param element Defines the element to stop listening the inputs from
  45698. */
  45699. detachControl(element: Nullable<HTMLElement>): void;
  45700. /**
  45701. * Gets the class name of the current input.
  45702. * @returns the class name.
  45703. */
  45704. getClassName(): string;
  45705. /**
  45706. * Get the friendly name associated with the input class.
  45707. * @returns the input's friendly name.
  45708. */
  45709. getSimpleName(): string;
  45710. private _pointerInput;
  45711. private _onMouseMove;
  45712. /**
  45713. * Rotate camera by mouse offset.
  45714. */
  45715. private rotateCamera;
  45716. }
  45717. }
  45718. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  45719. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45720. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45721. /**
  45722. * Default Inputs manager for the FlyCamera.
  45723. * It groups all the default supported inputs for ease of use.
  45724. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45725. */
  45726. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  45727. /**
  45728. * Instantiates a new FlyCameraInputsManager.
  45729. * @param camera Defines the camera the inputs belong to.
  45730. */
  45731. constructor(camera: FlyCamera);
  45732. /**
  45733. * Add keyboard input support to the input manager.
  45734. * @returns the new FlyCameraKeyboardMoveInput().
  45735. */
  45736. addKeyboard(): FlyCameraInputsManager;
  45737. /**
  45738. * Add mouse input support to the input manager.
  45739. * @param touchEnabled Enable touch screen support.
  45740. * @returns the new FlyCameraMouseInput().
  45741. */
  45742. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  45743. }
  45744. }
  45745. declare module "babylonjs/Cameras/flyCamera" {
  45746. import { Scene } from "babylonjs/scene";
  45747. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  45748. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45749. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45750. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  45751. /**
  45752. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45753. * such as in a 3D Space Shooter or a Flight Simulator.
  45754. */
  45755. export class FlyCamera extends TargetCamera {
  45756. /**
  45757. * Define the collision ellipsoid of the camera.
  45758. * This is helpful for simulating a camera body, like a player's body.
  45759. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  45760. */
  45761. ellipsoid: Vector3;
  45762. /**
  45763. * Define an offset for the position of the ellipsoid around the camera.
  45764. * This can be helpful if the camera is attached away from the player's body center,
  45765. * such as at its head.
  45766. */
  45767. ellipsoidOffset: Vector3;
  45768. /**
  45769. * Enable or disable collisions of the camera with the rest of the scene objects.
  45770. */
  45771. checkCollisions: boolean;
  45772. /**
  45773. * Enable or disable gravity on the camera.
  45774. */
  45775. applyGravity: boolean;
  45776. /**
  45777. * Define the current direction the camera is moving to.
  45778. */
  45779. cameraDirection: Vector3;
  45780. /**
  45781. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  45782. * This overrides and empties cameraRotation.
  45783. */
  45784. rotationQuaternion: Quaternion;
  45785. /**
  45786. * Track Roll to maintain the wanted Rolling when looking around.
  45787. */
  45788. _trackRoll: number;
  45789. /**
  45790. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  45791. */
  45792. rollCorrect: number;
  45793. /**
  45794. * Mimic a banked turn, Rolling the camera when Yawing.
  45795. * It's recommended to use rollCorrect = 10 for faster banking correction.
  45796. */
  45797. bankedTurn: boolean;
  45798. /**
  45799. * Limit in radians for how much Roll banking will add. (Default: 90°)
  45800. */
  45801. bankedTurnLimit: number;
  45802. /**
  45803. * Value of 0 disables the banked Roll.
  45804. * Value of 1 is equal to the Yaw angle in radians.
  45805. */
  45806. bankedTurnMultiplier: number;
  45807. /**
  45808. * The inputs manager loads all the input sources, such as keyboard and mouse.
  45809. */
  45810. inputs: FlyCameraInputsManager;
  45811. /**
  45812. * Gets the input sensibility for mouse input.
  45813. * Higher values reduce sensitivity.
  45814. */
  45815. get angularSensibility(): number;
  45816. /**
  45817. * Sets the input sensibility for a mouse input.
  45818. * Higher values reduce sensitivity.
  45819. */
  45820. set angularSensibility(value: number);
  45821. /**
  45822. * Get the keys for camera movement forward.
  45823. */
  45824. get keysForward(): number[];
  45825. /**
  45826. * Set the keys for camera movement forward.
  45827. */
  45828. set keysForward(value: number[]);
  45829. /**
  45830. * Get the keys for camera movement backward.
  45831. */
  45832. get keysBackward(): number[];
  45833. set keysBackward(value: number[]);
  45834. /**
  45835. * Get the keys for camera movement up.
  45836. */
  45837. get keysUp(): number[];
  45838. /**
  45839. * Set the keys for camera movement up.
  45840. */
  45841. set keysUp(value: number[]);
  45842. /**
  45843. * Get the keys for camera movement down.
  45844. */
  45845. get keysDown(): number[];
  45846. /**
  45847. * Set the keys for camera movement down.
  45848. */
  45849. set keysDown(value: number[]);
  45850. /**
  45851. * Get the keys for camera movement left.
  45852. */
  45853. get keysLeft(): number[];
  45854. /**
  45855. * Set the keys for camera movement left.
  45856. */
  45857. set keysLeft(value: number[]);
  45858. /**
  45859. * Set the keys for camera movement right.
  45860. */
  45861. get keysRight(): number[];
  45862. /**
  45863. * Set the keys for camera movement right.
  45864. */
  45865. set keysRight(value: number[]);
  45866. /**
  45867. * Event raised when the camera collides with a mesh in the scene.
  45868. */
  45869. onCollide: (collidedMesh: AbstractMesh) => void;
  45870. private _collider;
  45871. private _needMoveForGravity;
  45872. private _oldPosition;
  45873. private _diffPosition;
  45874. private _newPosition;
  45875. /** @hidden */
  45876. _localDirection: Vector3;
  45877. /** @hidden */
  45878. _transformedDirection: Vector3;
  45879. /**
  45880. * Instantiates a FlyCamera.
  45881. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45882. * such as in a 3D Space Shooter or a Flight Simulator.
  45883. * @param name Define the name of the camera in the scene.
  45884. * @param position Define the starting position of the camera in the scene.
  45885. * @param scene Define the scene the camera belongs to.
  45886. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  45887. */
  45888. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  45889. /**
  45890. * Attach a control to the HTML DOM element.
  45891. * @param element Defines the element that listens to the input events.
  45892. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  45893. */
  45894. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45895. /**
  45896. * Detach a control from the HTML DOM element.
  45897. * The camera will stop reacting to that input.
  45898. * @param element Defines the element that listens to the input events.
  45899. */
  45900. detachControl(element: HTMLElement): void;
  45901. private _collisionMask;
  45902. /**
  45903. * Get the mask that the camera ignores in collision events.
  45904. */
  45905. get collisionMask(): number;
  45906. /**
  45907. * Set the mask that the camera ignores in collision events.
  45908. */
  45909. set collisionMask(mask: number);
  45910. /** @hidden */
  45911. _collideWithWorld(displacement: Vector3): void;
  45912. /** @hidden */
  45913. private _onCollisionPositionChange;
  45914. /** @hidden */
  45915. _checkInputs(): void;
  45916. /** @hidden */
  45917. _decideIfNeedsToMove(): boolean;
  45918. /** @hidden */
  45919. _updatePosition(): void;
  45920. /**
  45921. * Restore the Roll to its target value at the rate specified.
  45922. * @param rate - Higher means slower restoring.
  45923. * @hidden
  45924. */
  45925. restoreRoll(rate: number): void;
  45926. /**
  45927. * Destroy the camera and release the current resources held by it.
  45928. */
  45929. dispose(): void;
  45930. /**
  45931. * Get the current object class name.
  45932. * @returns the class name.
  45933. */
  45934. getClassName(): string;
  45935. }
  45936. }
  45937. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  45938. import { Nullable } from "babylonjs/types";
  45939. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45940. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45941. /**
  45942. * Listen to keyboard events to control the camera.
  45943. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45944. */
  45945. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  45946. /**
  45947. * Defines the camera the input is attached to.
  45948. */
  45949. camera: FlyCamera;
  45950. /**
  45951. * The list of keyboard keys used to control the forward move of the camera.
  45952. */
  45953. keysForward: number[];
  45954. /**
  45955. * The list of keyboard keys used to control the backward move of the camera.
  45956. */
  45957. keysBackward: number[];
  45958. /**
  45959. * The list of keyboard keys used to control the forward move of the camera.
  45960. */
  45961. keysUp: number[];
  45962. /**
  45963. * The list of keyboard keys used to control the backward move of the camera.
  45964. */
  45965. keysDown: number[];
  45966. /**
  45967. * The list of keyboard keys used to control the right strafe move of the camera.
  45968. */
  45969. keysRight: number[];
  45970. /**
  45971. * The list of keyboard keys used to control the left strafe move of the camera.
  45972. */
  45973. keysLeft: number[];
  45974. private _keys;
  45975. private _onCanvasBlurObserver;
  45976. private _onKeyboardObserver;
  45977. private _engine;
  45978. private _scene;
  45979. /**
  45980. * Attach the input controls to a specific dom element to get the input from.
  45981. * @param element Defines the element the controls should be listened from
  45982. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45983. */
  45984. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45985. /**
  45986. * Detach the current controls from the specified dom element.
  45987. * @param element Defines the element to stop listening the inputs from
  45988. */
  45989. detachControl(element: Nullable<HTMLElement>): void;
  45990. /**
  45991. * Gets the class name of the current intput.
  45992. * @returns the class name
  45993. */
  45994. getClassName(): string;
  45995. /** @hidden */
  45996. _onLostFocus(e: FocusEvent): void;
  45997. /**
  45998. * Get the friendly name associated with the input class.
  45999. * @returns the input friendly name
  46000. */
  46001. getSimpleName(): string;
  46002. /**
  46003. * Update the current camera state depending on the inputs that have been used this frame.
  46004. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46005. */
  46006. checkInputs(): void;
  46007. }
  46008. }
  46009. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  46010. import { Nullable } from "babylonjs/types";
  46011. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46012. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46013. /**
  46014. * Manage the mouse wheel inputs to control a follow camera.
  46015. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46016. */
  46017. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  46018. /**
  46019. * Defines the camera the input is attached to.
  46020. */
  46021. camera: FollowCamera;
  46022. /**
  46023. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  46024. */
  46025. axisControlRadius: boolean;
  46026. /**
  46027. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  46028. */
  46029. axisControlHeight: boolean;
  46030. /**
  46031. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  46032. */
  46033. axisControlRotation: boolean;
  46034. /**
  46035. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  46036. * relation to mouseWheel events.
  46037. */
  46038. wheelPrecision: number;
  46039. /**
  46040. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46041. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46042. */
  46043. wheelDeltaPercentage: number;
  46044. private _wheel;
  46045. private _observer;
  46046. /**
  46047. * Attach the input controls to a specific dom element to get the input from.
  46048. * @param element Defines the element the controls should be listened from
  46049. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46050. */
  46051. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46052. /**
  46053. * Detach the current controls from the specified dom element.
  46054. * @param element Defines the element to stop listening the inputs from
  46055. */
  46056. detachControl(element: Nullable<HTMLElement>): void;
  46057. /**
  46058. * Gets the class name of the current intput.
  46059. * @returns the class name
  46060. */
  46061. getClassName(): string;
  46062. /**
  46063. * Get the friendly name associated with the input class.
  46064. * @returns the input friendly name
  46065. */
  46066. getSimpleName(): string;
  46067. }
  46068. }
  46069. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  46070. import { Nullable } from "babylonjs/types";
  46071. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46072. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  46073. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  46074. /**
  46075. * Manage the pointers inputs to control an follow camera.
  46076. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46077. */
  46078. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  46079. /**
  46080. * Defines the camera the input is attached to.
  46081. */
  46082. camera: FollowCamera;
  46083. /**
  46084. * Gets the class name of the current input.
  46085. * @returns the class name
  46086. */
  46087. getClassName(): string;
  46088. /**
  46089. * Defines the pointer angular sensibility along the X axis or how fast is
  46090. * the camera rotating.
  46091. * A negative number will reverse the axis direction.
  46092. */
  46093. angularSensibilityX: number;
  46094. /**
  46095. * Defines the pointer angular sensibility along the Y axis or how fast is
  46096. * the camera rotating.
  46097. * A negative number will reverse the axis direction.
  46098. */
  46099. angularSensibilityY: number;
  46100. /**
  46101. * Defines the pointer pinch precision or how fast is the camera zooming.
  46102. * A negative number will reverse the axis direction.
  46103. */
  46104. pinchPrecision: number;
  46105. /**
  46106. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46107. * from 0.
  46108. * It defines the percentage of current camera.radius to use as delta when
  46109. * pinch zoom is used.
  46110. */
  46111. pinchDeltaPercentage: number;
  46112. /**
  46113. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  46114. */
  46115. axisXControlRadius: boolean;
  46116. /**
  46117. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  46118. */
  46119. axisXControlHeight: boolean;
  46120. /**
  46121. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  46122. */
  46123. axisXControlRotation: boolean;
  46124. /**
  46125. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  46126. */
  46127. axisYControlRadius: boolean;
  46128. /**
  46129. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  46130. */
  46131. axisYControlHeight: boolean;
  46132. /**
  46133. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  46134. */
  46135. axisYControlRotation: boolean;
  46136. /**
  46137. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  46138. */
  46139. axisPinchControlRadius: boolean;
  46140. /**
  46141. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  46142. */
  46143. axisPinchControlHeight: boolean;
  46144. /**
  46145. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  46146. */
  46147. axisPinchControlRotation: boolean;
  46148. /**
  46149. * Log error messages if basic misconfiguration has occurred.
  46150. */
  46151. warningEnable: boolean;
  46152. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46153. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46154. private _warningCounter;
  46155. private _warning;
  46156. }
  46157. }
  46158. declare module "babylonjs/Cameras/followCameraInputsManager" {
  46159. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  46160. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46161. /**
  46162. * Default Inputs manager for the FollowCamera.
  46163. * It groups all the default supported inputs for ease of use.
  46164. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46165. */
  46166. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  46167. /**
  46168. * Instantiates a new FollowCameraInputsManager.
  46169. * @param camera Defines the camera the inputs belong to
  46170. */
  46171. constructor(camera: FollowCamera);
  46172. /**
  46173. * Add keyboard input support to the input manager.
  46174. * @returns the current input manager
  46175. */
  46176. addKeyboard(): FollowCameraInputsManager;
  46177. /**
  46178. * Add mouse wheel input support to the input manager.
  46179. * @returns the current input manager
  46180. */
  46181. addMouseWheel(): FollowCameraInputsManager;
  46182. /**
  46183. * Add pointers input support to the input manager.
  46184. * @returns the current input manager
  46185. */
  46186. addPointers(): FollowCameraInputsManager;
  46187. /**
  46188. * Add orientation input support to the input manager.
  46189. * @returns the current input manager
  46190. */
  46191. addVRDeviceOrientation(): FollowCameraInputsManager;
  46192. }
  46193. }
  46194. declare module "babylonjs/Cameras/followCamera" {
  46195. import { Nullable } from "babylonjs/types";
  46196. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  46197. import { Scene } from "babylonjs/scene";
  46198. import { Vector3 } from "babylonjs/Maths/math.vector";
  46199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46200. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  46201. /**
  46202. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  46203. * an arc rotate version arcFollowCamera are available.
  46204. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46205. */
  46206. export class FollowCamera extends TargetCamera {
  46207. /**
  46208. * Distance the follow camera should follow an object at
  46209. */
  46210. radius: number;
  46211. /**
  46212. * Minimum allowed distance of the camera to the axis of rotation
  46213. * (The camera can not get closer).
  46214. * This can help limiting how the Camera is able to move in the scene.
  46215. */
  46216. lowerRadiusLimit: Nullable<number>;
  46217. /**
  46218. * Maximum allowed distance of the camera to the axis of rotation
  46219. * (The camera can not get further).
  46220. * This can help limiting how the Camera is able to move in the scene.
  46221. */
  46222. upperRadiusLimit: Nullable<number>;
  46223. /**
  46224. * Define a rotation offset between the camera and the object it follows
  46225. */
  46226. rotationOffset: number;
  46227. /**
  46228. * Minimum allowed angle to camera position relative to target object.
  46229. * This can help limiting how the Camera is able to move in the scene.
  46230. */
  46231. lowerRotationOffsetLimit: Nullable<number>;
  46232. /**
  46233. * Maximum allowed angle to camera position relative to target object.
  46234. * This can help limiting how the Camera is able to move in the scene.
  46235. */
  46236. upperRotationOffsetLimit: Nullable<number>;
  46237. /**
  46238. * Define a height offset between the camera and the object it follows.
  46239. * It can help following an object from the top (like a car chaing a plane)
  46240. */
  46241. heightOffset: number;
  46242. /**
  46243. * Minimum allowed height of camera position relative to target object.
  46244. * This can help limiting how the Camera is able to move in the scene.
  46245. */
  46246. lowerHeightOffsetLimit: Nullable<number>;
  46247. /**
  46248. * Maximum allowed height of camera position relative to target object.
  46249. * This can help limiting how the Camera is able to move in the scene.
  46250. */
  46251. upperHeightOffsetLimit: Nullable<number>;
  46252. /**
  46253. * Define how fast the camera can accelerate to follow it s target.
  46254. */
  46255. cameraAcceleration: number;
  46256. /**
  46257. * Define the speed limit of the camera following an object.
  46258. */
  46259. maxCameraSpeed: number;
  46260. /**
  46261. * Define the target of the camera.
  46262. */
  46263. lockedTarget: Nullable<AbstractMesh>;
  46264. /**
  46265. * Defines the input associated with the camera.
  46266. */
  46267. inputs: FollowCameraInputsManager;
  46268. /**
  46269. * Instantiates the follow camera.
  46270. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46271. * @param name Define the name of the camera in the scene
  46272. * @param position Define the position of the camera
  46273. * @param scene Define the scene the camera belong to
  46274. * @param lockedTarget Define the target of the camera
  46275. */
  46276. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  46277. private _follow;
  46278. /**
  46279. * Attached controls to the current camera.
  46280. * @param element Defines the element the controls should be listened from
  46281. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46282. */
  46283. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46284. /**
  46285. * Detach the current controls from the camera.
  46286. * The camera will stop reacting to inputs.
  46287. * @param element Defines the element to stop listening the inputs from
  46288. */
  46289. detachControl(element: HTMLElement): void;
  46290. /** @hidden */
  46291. _checkInputs(): void;
  46292. private _checkLimits;
  46293. /**
  46294. * Gets the camera class name.
  46295. * @returns the class name
  46296. */
  46297. getClassName(): string;
  46298. }
  46299. /**
  46300. * Arc Rotate version of the follow camera.
  46301. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  46302. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46303. */
  46304. export class ArcFollowCamera extends TargetCamera {
  46305. /** The longitudinal angle of the camera */
  46306. alpha: number;
  46307. /** The latitudinal angle of the camera */
  46308. beta: number;
  46309. /** The radius of the camera from its target */
  46310. radius: number;
  46311. private _cartesianCoordinates;
  46312. /** Define the camera target (the mesh it should follow) */
  46313. private _meshTarget;
  46314. /**
  46315. * Instantiates a new ArcFollowCamera
  46316. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46317. * @param name Define the name of the camera
  46318. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  46319. * @param beta Define the rotation angle of the camera around the elevation axis
  46320. * @param radius Define the radius of the camera from its target point
  46321. * @param target Define the target of the camera
  46322. * @param scene Define the scene the camera belongs to
  46323. */
  46324. constructor(name: string,
  46325. /** The longitudinal angle of the camera */
  46326. alpha: number,
  46327. /** The latitudinal angle of the camera */
  46328. beta: number,
  46329. /** The radius of the camera from its target */
  46330. radius: number,
  46331. /** Define the camera target (the mesh it should follow) */
  46332. target: Nullable<AbstractMesh>, scene: Scene);
  46333. private _follow;
  46334. /** @hidden */
  46335. _checkInputs(): void;
  46336. /**
  46337. * Returns the class name of the object.
  46338. * It is mostly used internally for serialization purposes.
  46339. */
  46340. getClassName(): string;
  46341. }
  46342. }
  46343. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  46344. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46345. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46346. import { Nullable } from "babylonjs/types";
  46347. /**
  46348. * Manage the keyboard inputs to control the movement of a follow camera.
  46349. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46350. */
  46351. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  46352. /**
  46353. * Defines the camera the input is attached to.
  46354. */
  46355. camera: FollowCamera;
  46356. /**
  46357. * Defines the list of key codes associated with the up action (increase heightOffset)
  46358. */
  46359. keysHeightOffsetIncr: number[];
  46360. /**
  46361. * Defines the list of key codes associated with the down action (decrease heightOffset)
  46362. */
  46363. keysHeightOffsetDecr: number[];
  46364. /**
  46365. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  46366. */
  46367. keysHeightOffsetModifierAlt: boolean;
  46368. /**
  46369. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  46370. */
  46371. keysHeightOffsetModifierCtrl: boolean;
  46372. /**
  46373. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  46374. */
  46375. keysHeightOffsetModifierShift: boolean;
  46376. /**
  46377. * Defines the list of key codes associated with the left action (increase rotationOffset)
  46378. */
  46379. keysRotationOffsetIncr: number[];
  46380. /**
  46381. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  46382. */
  46383. keysRotationOffsetDecr: number[];
  46384. /**
  46385. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  46386. */
  46387. keysRotationOffsetModifierAlt: boolean;
  46388. /**
  46389. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  46390. */
  46391. keysRotationOffsetModifierCtrl: boolean;
  46392. /**
  46393. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  46394. */
  46395. keysRotationOffsetModifierShift: boolean;
  46396. /**
  46397. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  46398. */
  46399. keysRadiusIncr: number[];
  46400. /**
  46401. * Defines the list of key codes associated with the zoom-out action (increase radius)
  46402. */
  46403. keysRadiusDecr: number[];
  46404. /**
  46405. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  46406. */
  46407. keysRadiusModifierAlt: boolean;
  46408. /**
  46409. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  46410. */
  46411. keysRadiusModifierCtrl: boolean;
  46412. /**
  46413. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  46414. */
  46415. keysRadiusModifierShift: boolean;
  46416. /**
  46417. * Defines the rate of change of heightOffset.
  46418. */
  46419. heightSensibility: number;
  46420. /**
  46421. * Defines the rate of change of rotationOffset.
  46422. */
  46423. rotationSensibility: number;
  46424. /**
  46425. * Defines the rate of change of radius.
  46426. */
  46427. radiusSensibility: number;
  46428. private _keys;
  46429. private _ctrlPressed;
  46430. private _altPressed;
  46431. private _shiftPressed;
  46432. private _onCanvasBlurObserver;
  46433. private _onKeyboardObserver;
  46434. private _engine;
  46435. private _scene;
  46436. /**
  46437. * Attach the input controls to a specific dom element to get the input from.
  46438. * @param element Defines the element the controls should be listened from
  46439. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46440. */
  46441. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46442. /**
  46443. * Detach the current controls from the specified dom element.
  46444. * @param element Defines the element to stop listening the inputs from
  46445. */
  46446. detachControl(element: Nullable<HTMLElement>): void;
  46447. /**
  46448. * Update the current camera state depending on the inputs that have been used this frame.
  46449. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46450. */
  46451. checkInputs(): void;
  46452. /**
  46453. * Gets the class name of the current input.
  46454. * @returns the class name
  46455. */
  46456. getClassName(): string;
  46457. /**
  46458. * Get the friendly name associated with the input class.
  46459. * @returns the input friendly name
  46460. */
  46461. getSimpleName(): string;
  46462. /**
  46463. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46464. * allow modification of the heightOffset value.
  46465. */
  46466. private _modifierHeightOffset;
  46467. /**
  46468. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46469. * allow modification of the rotationOffset value.
  46470. */
  46471. private _modifierRotationOffset;
  46472. /**
  46473. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46474. * allow modification of the radius value.
  46475. */
  46476. private _modifierRadius;
  46477. }
  46478. }
  46479. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  46480. import { Nullable } from "babylonjs/types";
  46481. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46482. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46483. import { Observable } from "babylonjs/Misc/observable";
  46484. module "babylonjs/Cameras/freeCameraInputsManager" {
  46485. interface FreeCameraInputsManager {
  46486. /**
  46487. * @hidden
  46488. */
  46489. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  46490. /**
  46491. * Add orientation input support to the input manager.
  46492. * @returns the current input manager
  46493. */
  46494. addDeviceOrientation(): FreeCameraInputsManager;
  46495. }
  46496. }
  46497. /**
  46498. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  46499. * Screen rotation is taken into account.
  46500. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46501. */
  46502. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  46503. private _camera;
  46504. private _screenOrientationAngle;
  46505. private _constantTranform;
  46506. private _screenQuaternion;
  46507. private _alpha;
  46508. private _beta;
  46509. private _gamma;
  46510. /**
  46511. * Can be used to detect if a device orientation sensor is available on a device
  46512. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  46513. * @returns a promise that will resolve on orientation change
  46514. */
  46515. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  46516. /**
  46517. * @hidden
  46518. */
  46519. _onDeviceOrientationChangedObservable: Observable<void>;
  46520. /**
  46521. * Instantiates a new input
  46522. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46523. */
  46524. constructor();
  46525. /**
  46526. * Define the camera controlled by the input.
  46527. */
  46528. get camera(): FreeCamera;
  46529. set camera(camera: FreeCamera);
  46530. /**
  46531. * Attach the input controls to a specific dom element to get the input from.
  46532. * @param element Defines the element the controls should be listened from
  46533. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46534. */
  46535. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46536. private _orientationChanged;
  46537. private _deviceOrientation;
  46538. /**
  46539. * Detach the current controls from the specified dom element.
  46540. * @param element Defines the element to stop listening the inputs from
  46541. */
  46542. detachControl(element: Nullable<HTMLElement>): void;
  46543. /**
  46544. * Update the current camera state depending on the inputs that have been used this frame.
  46545. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46546. */
  46547. checkInputs(): void;
  46548. /**
  46549. * Gets the class name of the current intput.
  46550. * @returns the class name
  46551. */
  46552. getClassName(): string;
  46553. /**
  46554. * Get the friendly name associated with the input class.
  46555. * @returns the input friendly name
  46556. */
  46557. getSimpleName(): string;
  46558. }
  46559. }
  46560. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  46561. import { Nullable } from "babylonjs/types";
  46562. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46563. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46564. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46565. /**
  46566. * Manage the gamepad inputs to control a free camera.
  46567. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46568. */
  46569. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  46570. /**
  46571. * Define the camera the input is attached to.
  46572. */
  46573. camera: FreeCamera;
  46574. /**
  46575. * Define the Gamepad controlling the input
  46576. */
  46577. gamepad: Nullable<Gamepad>;
  46578. /**
  46579. * Defines the gamepad rotation sensiblity.
  46580. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46581. */
  46582. gamepadAngularSensibility: number;
  46583. /**
  46584. * Defines the gamepad move sensiblity.
  46585. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46586. */
  46587. gamepadMoveSensibility: number;
  46588. private _yAxisScale;
  46589. /**
  46590. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  46591. */
  46592. get invertYAxis(): boolean;
  46593. set invertYAxis(value: boolean);
  46594. private _onGamepadConnectedObserver;
  46595. private _onGamepadDisconnectedObserver;
  46596. private _cameraTransform;
  46597. private _deltaTransform;
  46598. private _vector3;
  46599. private _vector2;
  46600. /**
  46601. * Attach the input controls to a specific dom element to get the input from.
  46602. * @param element Defines the element the controls should be listened from
  46603. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46604. */
  46605. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46606. /**
  46607. * Detach the current controls from the specified dom element.
  46608. * @param element Defines the element to stop listening the inputs from
  46609. */
  46610. detachControl(element: Nullable<HTMLElement>): void;
  46611. /**
  46612. * Update the current camera state depending on the inputs that have been used this frame.
  46613. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46614. */
  46615. checkInputs(): void;
  46616. /**
  46617. * Gets the class name of the current intput.
  46618. * @returns the class name
  46619. */
  46620. getClassName(): string;
  46621. /**
  46622. * Get the friendly name associated with the input class.
  46623. * @returns the input friendly name
  46624. */
  46625. getSimpleName(): string;
  46626. }
  46627. }
  46628. declare module "babylonjs/Misc/virtualJoystick" {
  46629. import { Nullable } from "babylonjs/types";
  46630. import { Vector3 } from "babylonjs/Maths/math.vector";
  46631. /**
  46632. * Defines the potential axis of a Joystick
  46633. */
  46634. export enum JoystickAxis {
  46635. /** X axis */
  46636. X = 0,
  46637. /** Y axis */
  46638. Y = 1,
  46639. /** Z axis */
  46640. Z = 2
  46641. }
  46642. /**
  46643. * Represents the different customization options available
  46644. * for VirtualJoystick
  46645. */
  46646. interface VirtualJoystickCustomizations {
  46647. /**
  46648. * Size of the joystick's puck
  46649. */
  46650. puckSize: number;
  46651. /**
  46652. * Size of the joystick's container
  46653. */
  46654. containerSize: number;
  46655. /**
  46656. * Color of the joystick && puck
  46657. */
  46658. color: string;
  46659. /**
  46660. * Image URL for the joystick's puck
  46661. */
  46662. puckImage?: string;
  46663. /**
  46664. * Image URL for the joystick's container
  46665. */
  46666. containerImage?: string;
  46667. /**
  46668. * Defines the unmoving position of the joystick container
  46669. */
  46670. position?: {
  46671. x: number;
  46672. y: number;
  46673. };
  46674. /**
  46675. * Defines whether or not the joystick container is always visible
  46676. */
  46677. alwaysVisible: boolean;
  46678. /**
  46679. * Defines whether or not to limit the movement of the puck to the joystick's container
  46680. */
  46681. limitToContainer: boolean;
  46682. }
  46683. /**
  46684. * Class used to define virtual joystick (used in touch mode)
  46685. */
  46686. export class VirtualJoystick {
  46687. /**
  46688. * Gets or sets a boolean indicating that left and right values must be inverted
  46689. */
  46690. reverseLeftRight: boolean;
  46691. /**
  46692. * Gets or sets a boolean indicating that up and down values must be inverted
  46693. */
  46694. reverseUpDown: boolean;
  46695. /**
  46696. * Gets the offset value for the position (ie. the change of the position value)
  46697. */
  46698. deltaPosition: Vector3;
  46699. /**
  46700. * Gets a boolean indicating if the virtual joystick was pressed
  46701. */
  46702. pressed: boolean;
  46703. /**
  46704. * Canvas the virtual joystick will render onto, default z-index of this is 5
  46705. */
  46706. static Canvas: Nullable<HTMLCanvasElement>;
  46707. /**
  46708. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  46709. */
  46710. limitToContainer: boolean;
  46711. private static _globalJoystickIndex;
  46712. private static _alwaysVisibleSticks;
  46713. private static vjCanvasContext;
  46714. private static vjCanvasWidth;
  46715. private static vjCanvasHeight;
  46716. private static halfWidth;
  46717. private static _GetDefaultOptions;
  46718. private _action;
  46719. private _axisTargetedByLeftAndRight;
  46720. private _axisTargetedByUpAndDown;
  46721. private _joystickSensibility;
  46722. private _inversedSensibility;
  46723. private _joystickPointerID;
  46724. private _joystickColor;
  46725. private _joystickPointerPos;
  46726. private _joystickPreviousPointerPos;
  46727. private _joystickPointerStartPos;
  46728. private _deltaJoystickVector;
  46729. private _leftJoystick;
  46730. private _touches;
  46731. private _joystickPosition;
  46732. private _alwaysVisible;
  46733. private _puckImage;
  46734. private _containerImage;
  46735. private _joystickPuckSize;
  46736. private _joystickContainerSize;
  46737. private _clearPuckSize;
  46738. private _clearContainerSize;
  46739. private _clearPuckSizeOffset;
  46740. private _clearContainerSizeOffset;
  46741. private _onPointerDownHandlerRef;
  46742. private _onPointerMoveHandlerRef;
  46743. private _onPointerUpHandlerRef;
  46744. private _onResize;
  46745. /**
  46746. * Creates a new virtual joystick
  46747. * @param leftJoystick defines that the joystick is for left hand (false by default)
  46748. * @param customizations Defines the options we want to customize the VirtualJoystick
  46749. */
  46750. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  46751. /**
  46752. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  46753. * @param newJoystickSensibility defines the new sensibility
  46754. */
  46755. setJoystickSensibility(newJoystickSensibility: number): void;
  46756. private _onPointerDown;
  46757. private _onPointerMove;
  46758. private _onPointerUp;
  46759. /**
  46760. * Change the color of the virtual joystick
  46761. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  46762. */
  46763. setJoystickColor(newColor: string): void;
  46764. /**
  46765. * Size of the joystick's container
  46766. */
  46767. set containerSize(newSize: number);
  46768. get containerSize(): number;
  46769. /**
  46770. * Size of the joystick's puck
  46771. */
  46772. set puckSize(newSize: number);
  46773. get puckSize(): number;
  46774. /**
  46775. * Clears the set position of the joystick
  46776. */
  46777. clearPosition(): void;
  46778. /**
  46779. * Defines whether or not the joystick container is always visible
  46780. */
  46781. set alwaysVisible(value: boolean);
  46782. get alwaysVisible(): boolean;
  46783. /**
  46784. * Sets the constant position of the Joystick container
  46785. * @param x X axis coordinate
  46786. * @param y Y axis coordinate
  46787. */
  46788. setPosition(x: number, y: number): void;
  46789. /**
  46790. * Defines a callback to call when the joystick is touched
  46791. * @param action defines the callback
  46792. */
  46793. setActionOnTouch(action: () => any): void;
  46794. /**
  46795. * Defines which axis you'd like to control for left & right
  46796. * @param axis defines the axis to use
  46797. */
  46798. setAxisForLeftRight(axis: JoystickAxis): void;
  46799. /**
  46800. * Defines which axis you'd like to control for up & down
  46801. * @param axis defines the axis to use
  46802. */
  46803. setAxisForUpDown(axis: JoystickAxis): void;
  46804. /**
  46805. * Clears the canvas from the previous puck / container draw
  46806. */
  46807. private _clearPreviousDraw;
  46808. /**
  46809. * Loads `urlPath` to be used for the container's image
  46810. * @param urlPath defines the urlPath of an image to use
  46811. */
  46812. setContainerImage(urlPath: string): void;
  46813. /**
  46814. * Loads `urlPath` to be used for the puck's image
  46815. * @param urlPath defines the urlPath of an image to use
  46816. */
  46817. setPuckImage(urlPath: string): void;
  46818. /**
  46819. * Draws the Virtual Joystick's container
  46820. */
  46821. private _drawContainer;
  46822. /**
  46823. * Draws the Virtual Joystick's puck
  46824. */
  46825. private _drawPuck;
  46826. private _drawVirtualJoystick;
  46827. /**
  46828. * Release internal HTML canvas
  46829. */
  46830. releaseCanvas(): void;
  46831. }
  46832. }
  46833. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  46834. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  46835. import { Nullable } from "babylonjs/types";
  46836. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46837. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46838. module "babylonjs/Cameras/freeCameraInputsManager" {
  46839. interface FreeCameraInputsManager {
  46840. /**
  46841. * Add virtual joystick input support to the input manager.
  46842. * @returns the current input manager
  46843. */
  46844. addVirtualJoystick(): FreeCameraInputsManager;
  46845. }
  46846. }
  46847. /**
  46848. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  46849. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46850. */
  46851. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  46852. /**
  46853. * Defines the camera the input is attached to.
  46854. */
  46855. camera: FreeCamera;
  46856. private _leftjoystick;
  46857. private _rightjoystick;
  46858. /**
  46859. * Gets the left stick of the virtual joystick.
  46860. * @returns The virtual Joystick
  46861. */
  46862. getLeftJoystick(): VirtualJoystick;
  46863. /**
  46864. * Gets the right stick of the virtual joystick.
  46865. * @returns The virtual Joystick
  46866. */
  46867. getRightJoystick(): VirtualJoystick;
  46868. /**
  46869. * Update the current camera state depending on the inputs that have been used this frame.
  46870. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46871. */
  46872. checkInputs(): void;
  46873. /**
  46874. * Attach the input controls to a specific dom element to get the input from.
  46875. * @param element Defines the element the controls should be listened from
  46876. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46877. */
  46878. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46879. /**
  46880. * Detach the current controls from the specified dom element.
  46881. * @param element Defines the element to stop listening the inputs from
  46882. */
  46883. detachControl(element: Nullable<HTMLElement>): void;
  46884. /**
  46885. * Gets the class name of the current intput.
  46886. * @returns the class name
  46887. */
  46888. getClassName(): string;
  46889. /**
  46890. * Get the friendly name associated with the input class.
  46891. * @returns the input friendly name
  46892. */
  46893. getSimpleName(): string;
  46894. }
  46895. }
  46896. declare module "babylonjs/Cameras/Inputs/index" {
  46897. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  46898. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  46899. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  46900. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  46901. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  46902. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  46903. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  46904. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  46905. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  46906. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  46907. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  46908. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  46909. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  46910. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  46911. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  46912. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  46913. }
  46914. declare module "babylonjs/Cameras/touchCamera" {
  46915. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46916. import { Scene } from "babylonjs/scene";
  46917. import { Vector3 } from "babylonjs/Maths/math.vector";
  46918. /**
  46919. * This represents a FPS type of camera controlled by touch.
  46920. * This is like a universal camera minus the Gamepad controls.
  46921. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46922. */
  46923. export class TouchCamera extends FreeCamera {
  46924. /**
  46925. * Defines the touch sensibility for rotation.
  46926. * The higher the faster.
  46927. */
  46928. get touchAngularSensibility(): number;
  46929. set touchAngularSensibility(value: number);
  46930. /**
  46931. * Defines the touch sensibility for move.
  46932. * The higher the faster.
  46933. */
  46934. get touchMoveSensibility(): number;
  46935. set touchMoveSensibility(value: number);
  46936. /**
  46937. * Instantiates a new touch camera.
  46938. * This represents a FPS type of camera controlled by touch.
  46939. * This is like a universal camera minus the Gamepad controls.
  46940. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46941. * @param name Define the name of the camera in the scene
  46942. * @param position Define the start position of the camera in the scene
  46943. * @param scene Define the scene the camera belongs to
  46944. */
  46945. constructor(name: string, position: Vector3, scene: Scene);
  46946. /**
  46947. * Gets the current object class name.
  46948. * @return the class name
  46949. */
  46950. getClassName(): string;
  46951. /** @hidden */
  46952. _setupInputs(): void;
  46953. }
  46954. }
  46955. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  46956. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46957. import { Scene } from "babylonjs/scene";
  46958. import { Vector3 } from "babylonjs/Maths/math.vector";
  46959. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  46960. import { Axis } from "babylonjs/Maths/math.axis";
  46961. /**
  46962. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  46963. * being tilted forward or back and left or right.
  46964. */
  46965. export class DeviceOrientationCamera extends FreeCamera {
  46966. private _initialQuaternion;
  46967. private _quaternionCache;
  46968. private _tmpDragQuaternion;
  46969. private _disablePointerInputWhenUsingDeviceOrientation;
  46970. /**
  46971. * Creates a new device orientation camera
  46972. * @param name The name of the camera
  46973. * @param position The start position camera
  46974. * @param scene The scene the camera belongs to
  46975. */
  46976. constructor(name: string, position: Vector3, scene: Scene);
  46977. /**
  46978. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  46979. */
  46980. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  46981. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  46982. private _dragFactor;
  46983. /**
  46984. * Enabled turning on the y axis when the orientation sensor is active
  46985. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  46986. */
  46987. enableHorizontalDragging(dragFactor?: number): void;
  46988. /**
  46989. * Gets the current instance class name ("DeviceOrientationCamera").
  46990. * This helps avoiding instanceof at run time.
  46991. * @returns the class name
  46992. */
  46993. getClassName(): string;
  46994. /**
  46995. * @hidden
  46996. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  46997. */
  46998. _checkInputs(): void;
  46999. /**
  47000. * Reset the camera to its default orientation on the specified axis only.
  47001. * @param axis The axis to reset
  47002. */
  47003. resetToCurrentRotation(axis?: Axis): void;
  47004. }
  47005. }
  47006. declare module "babylonjs/Gamepads/xboxGamepad" {
  47007. import { Observable } from "babylonjs/Misc/observable";
  47008. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47009. /**
  47010. * Defines supported buttons for XBox360 compatible gamepads
  47011. */
  47012. export enum Xbox360Button {
  47013. /** A */
  47014. A = 0,
  47015. /** B */
  47016. B = 1,
  47017. /** X */
  47018. X = 2,
  47019. /** Y */
  47020. Y = 3,
  47021. /** Left button */
  47022. LB = 4,
  47023. /** Right button */
  47024. RB = 5,
  47025. /** Back */
  47026. Back = 8,
  47027. /** Start */
  47028. Start = 9,
  47029. /** Left stick */
  47030. LeftStick = 10,
  47031. /** Right stick */
  47032. RightStick = 11
  47033. }
  47034. /** Defines values for XBox360 DPad */
  47035. export enum Xbox360Dpad {
  47036. /** Up */
  47037. Up = 12,
  47038. /** Down */
  47039. Down = 13,
  47040. /** Left */
  47041. Left = 14,
  47042. /** Right */
  47043. Right = 15
  47044. }
  47045. /**
  47046. * Defines a XBox360 gamepad
  47047. */
  47048. export class Xbox360Pad extends Gamepad {
  47049. private _leftTrigger;
  47050. private _rightTrigger;
  47051. private _onlefttriggerchanged;
  47052. private _onrighttriggerchanged;
  47053. private _onbuttondown;
  47054. private _onbuttonup;
  47055. private _ondpaddown;
  47056. private _ondpadup;
  47057. /** Observable raised when a button is pressed */
  47058. onButtonDownObservable: Observable<Xbox360Button>;
  47059. /** Observable raised when a button is released */
  47060. onButtonUpObservable: Observable<Xbox360Button>;
  47061. /** Observable raised when a pad is pressed */
  47062. onPadDownObservable: Observable<Xbox360Dpad>;
  47063. /** Observable raised when a pad is released */
  47064. onPadUpObservable: Observable<Xbox360Dpad>;
  47065. private _buttonA;
  47066. private _buttonB;
  47067. private _buttonX;
  47068. private _buttonY;
  47069. private _buttonBack;
  47070. private _buttonStart;
  47071. private _buttonLB;
  47072. private _buttonRB;
  47073. private _buttonLeftStick;
  47074. private _buttonRightStick;
  47075. private _dPadUp;
  47076. private _dPadDown;
  47077. private _dPadLeft;
  47078. private _dPadRight;
  47079. private _isXboxOnePad;
  47080. /**
  47081. * Creates a new XBox360 gamepad object
  47082. * @param id defines the id of this gamepad
  47083. * @param index defines its index
  47084. * @param gamepad defines the internal HTML gamepad object
  47085. * @param xboxOne defines if it is a XBox One gamepad
  47086. */
  47087. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  47088. /**
  47089. * Defines the callback to call when left trigger is pressed
  47090. * @param callback defines the callback to use
  47091. */
  47092. onlefttriggerchanged(callback: (value: number) => void): void;
  47093. /**
  47094. * Defines the callback to call when right trigger is pressed
  47095. * @param callback defines the callback to use
  47096. */
  47097. onrighttriggerchanged(callback: (value: number) => void): void;
  47098. /**
  47099. * Gets the left trigger value
  47100. */
  47101. get leftTrigger(): number;
  47102. /**
  47103. * Sets the left trigger value
  47104. */
  47105. set leftTrigger(newValue: number);
  47106. /**
  47107. * Gets the right trigger value
  47108. */
  47109. get rightTrigger(): number;
  47110. /**
  47111. * Sets the right trigger value
  47112. */
  47113. set rightTrigger(newValue: number);
  47114. /**
  47115. * Defines the callback to call when a button is pressed
  47116. * @param callback defines the callback to use
  47117. */
  47118. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  47119. /**
  47120. * Defines the callback to call when a button is released
  47121. * @param callback defines the callback to use
  47122. */
  47123. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  47124. /**
  47125. * Defines the callback to call when a pad is pressed
  47126. * @param callback defines the callback to use
  47127. */
  47128. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  47129. /**
  47130. * Defines the callback to call when a pad is released
  47131. * @param callback defines the callback to use
  47132. */
  47133. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  47134. private _setButtonValue;
  47135. private _setDPadValue;
  47136. /**
  47137. * Gets the value of the `A` button
  47138. */
  47139. get buttonA(): number;
  47140. /**
  47141. * Sets the value of the `A` button
  47142. */
  47143. set buttonA(value: number);
  47144. /**
  47145. * Gets the value of the `B` button
  47146. */
  47147. get buttonB(): number;
  47148. /**
  47149. * Sets the value of the `B` button
  47150. */
  47151. set buttonB(value: number);
  47152. /**
  47153. * Gets the value of the `X` button
  47154. */
  47155. get buttonX(): number;
  47156. /**
  47157. * Sets the value of the `X` button
  47158. */
  47159. set buttonX(value: number);
  47160. /**
  47161. * Gets the value of the `Y` button
  47162. */
  47163. get buttonY(): number;
  47164. /**
  47165. * Sets the value of the `Y` button
  47166. */
  47167. set buttonY(value: number);
  47168. /**
  47169. * Gets the value of the `Start` button
  47170. */
  47171. get buttonStart(): number;
  47172. /**
  47173. * Sets the value of the `Start` button
  47174. */
  47175. set buttonStart(value: number);
  47176. /**
  47177. * Gets the value of the `Back` button
  47178. */
  47179. get buttonBack(): number;
  47180. /**
  47181. * Sets the value of the `Back` button
  47182. */
  47183. set buttonBack(value: number);
  47184. /**
  47185. * Gets the value of the `Left` button
  47186. */
  47187. get buttonLB(): number;
  47188. /**
  47189. * Sets the value of the `Left` button
  47190. */
  47191. set buttonLB(value: number);
  47192. /**
  47193. * Gets the value of the `Right` button
  47194. */
  47195. get buttonRB(): number;
  47196. /**
  47197. * Sets the value of the `Right` button
  47198. */
  47199. set buttonRB(value: number);
  47200. /**
  47201. * Gets the value of the Left joystick
  47202. */
  47203. get buttonLeftStick(): number;
  47204. /**
  47205. * Sets the value of the Left joystick
  47206. */
  47207. set buttonLeftStick(value: number);
  47208. /**
  47209. * Gets the value of the Right joystick
  47210. */
  47211. get buttonRightStick(): number;
  47212. /**
  47213. * Sets the value of the Right joystick
  47214. */
  47215. set buttonRightStick(value: number);
  47216. /**
  47217. * Gets the value of D-pad up
  47218. */
  47219. get dPadUp(): number;
  47220. /**
  47221. * Sets the value of D-pad up
  47222. */
  47223. set dPadUp(value: number);
  47224. /**
  47225. * Gets the value of D-pad down
  47226. */
  47227. get dPadDown(): number;
  47228. /**
  47229. * Sets the value of D-pad down
  47230. */
  47231. set dPadDown(value: number);
  47232. /**
  47233. * Gets the value of D-pad left
  47234. */
  47235. get dPadLeft(): number;
  47236. /**
  47237. * Sets the value of D-pad left
  47238. */
  47239. set dPadLeft(value: number);
  47240. /**
  47241. * Gets the value of D-pad right
  47242. */
  47243. get dPadRight(): number;
  47244. /**
  47245. * Sets the value of D-pad right
  47246. */
  47247. set dPadRight(value: number);
  47248. /**
  47249. * Force the gamepad to synchronize with device values
  47250. */
  47251. update(): void;
  47252. /**
  47253. * Disposes the gamepad
  47254. */
  47255. dispose(): void;
  47256. }
  47257. }
  47258. declare module "babylonjs/Gamepads/dualShockGamepad" {
  47259. import { Observable } from "babylonjs/Misc/observable";
  47260. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47261. /**
  47262. * Defines supported buttons for DualShock compatible gamepads
  47263. */
  47264. export enum DualShockButton {
  47265. /** Cross */
  47266. Cross = 0,
  47267. /** Circle */
  47268. Circle = 1,
  47269. /** Square */
  47270. Square = 2,
  47271. /** Triangle */
  47272. Triangle = 3,
  47273. /** L1 */
  47274. L1 = 4,
  47275. /** R1 */
  47276. R1 = 5,
  47277. /** Share */
  47278. Share = 8,
  47279. /** Options */
  47280. Options = 9,
  47281. /** Left stick */
  47282. LeftStick = 10,
  47283. /** Right stick */
  47284. RightStick = 11
  47285. }
  47286. /** Defines values for DualShock DPad */
  47287. export enum DualShockDpad {
  47288. /** Up */
  47289. Up = 12,
  47290. /** Down */
  47291. Down = 13,
  47292. /** Left */
  47293. Left = 14,
  47294. /** Right */
  47295. Right = 15
  47296. }
  47297. /**
  47298. * Defines a DualShock gamepad
  47299. */
  47300. export class DualShockPad extends Gamepad {
  47301. private _leftTrigger;
  47302. private _rightTrigger;
  47303. private _onlefttriggerchanged;
  47304. private _onrighttriggerchanged;
  47305. private _onbuttondown;
  47306. private _onbuttonup;
  47307. private _ondpaddown;
  47308. private _ondpadup;
  47309. /** Observable raised when a button is pressed */
  47310. onButtonDownObservable: Observable<DualShockButton>;
  47311. /** Observable raised when a button is released */
  47312. onButtonUpObservable: Observable<DualShockButton>;
  47313. /** Observable raised when a pad is pressed */
  47314. onPadDownObservable: Observable<DualShockDpad>;
  47315. /** Observable raised when a pad is released */
  47316. onPadUpObservable: Observable<DualShockDpad>;
  47317. private _buttonCross;
  47318. private _buttonCircle;
  47319. private _buttonSquare;
  47320. private _buttonTriangle;
  47321. private _buttonShare;
  47322. private _buttonOptions;
  47323. private _buttonL1;
  47324. private _buttonR1;
  47325. private _buttonLeftStick;
  47326. private _buttonRightStick;
  47327. private _dPadUp;
  47328. private _dPadDown;
  47329. private _dPadLeft;
  47330. private _dPadRight;
  47331. /**
  47332. * Creates a new DualShock gamepad object
  47333. * @param id defines the id of this gamepad
  47334. * @param index defines its index
  47335. * @param gamepad defines the internal HTML gamepad object
  47336. */
  47337. constructor(id: string, index: number, gamepad: any);
  47338. /**
  47339. * Defines the callback to call when left trigger is pressed
  47340. * @param callback defines the callback to use
  47341. */
  47342. onlefttriggerchanged(callback: (value: number) => void): void;
  47343. /**
  47344. * Defines the callback to call when right trigger is pressed
  47345. * @param callback defines the callback to use
  47346. */
  47347. onrighttriggerchanged(callback: (value: number) => void): void;
  47348. /**
  47349. * Gets the left trigger value
  47350. */
  47351. get leftTrigger(): number;
  47352. /**
  47353. * Sets the left trigger value
  47354. */
  47355. set leftTrigger(newValue: number);
  47356. /**
  47357. * Gets the right trigger value
  47358. */
  47359. get rightTrigger(): number;
  47360. /**
  47361. * Sets the right trigger value
  47362. */
  47363. set rightTrigger(newValue: number);
  47364. /**
  47365. * Defines the callback to call when a button is pressed
  47366. * @param callback defines the callback to use
  47367. */
  47368. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  47369. /**
  47370. * Defines the callback to call when a button is released
  47371. * @param callback defines the callback to use
  47372. */
  47373. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  47374. /**
  47375. * Defines the callback to call when a pad is pressed
  47376. * @param callback defines the callback to use
  47377. */
  47378. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  47379. /**
  47380. * Defines the callback to call when a pad is released
  47381. * @param callback defines the callback to use
  47382. */
  47383. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  47384. private _setButtonValue;
  47385. private _setDPadValue;
  47386. /**
  47387. * Gets the value of the `Cross` button
  47388. */
  47389. get buttonCross(): number;
  47390. /**
  47391. * Sets the value of the `Cross` button
  47392. */
  47393. set buttonCross(value: number);
  47394. /**
  47395. * Gets the value of the `Circle` button
  47396. */
  47397. get buttonCircle(): number;
  47398. /**
  47399. * Sets the value of the `Circle` button
  47400. */
  47401. set buttonCircle(value: number);
  47402. /**
  47403. * Gets the value of the `Square` button
  47404. */
  47405. get buttonSquare(): number;
  47406. /**
  47407. * Sets the value of the `Square` button
  47408. */
  47409. set buttonSquare(value: number);
  47410. /**
  47411. * Gets the value of the `Triangle` button
  47412. */
  47413. get buttonTriangle(): number;
  47414. /**
  47415. * Sets the value of the `Triangle` button
  47416. */
  47417. set buttonTriangle(value: number);
  47418. /**
  47419. * Gets the value of the `Options` button
  47420. */
  47421. get buttonOptions(): number;
  47422. /**
  47423. * Sets the value of the `Options` button
  47424. */
  47425. set buttonOptions(value: number);
  47426. /**
  47427. * Gets the value of the `Share` button
  47428. */
  47429. get buttonShare(): number;
  47430. /**
  47431. * Sets the value of the `Share` button
  47432. */
  47433. set buttonShare(value: number);
  47434. /**
  47435. * Gets the value of the `L1` button
  47436. */
  47437. get buttonL1(): number;
  47438. /**
  47439. * Sets the value of the `L1` button
  47440. */
  47441. set buttonL1(value: number);
  47442. /**
  47443. * Gets the value of the `R1` button
  47444. */
  47445. get buttonR1(): number;
  47446. /**
  47447. * Sets the value of the `R1` button
  47448. */
  47449. set buttonR1(value: number);
  47450. /**
  47451. * Gets the value of the Left joystick
  47452. */
  47453. get buttonLeftStick(): number;
  47454. /**
  47455. * Sets the value of the Left joystick
  47456. */
  47457. set buttonLeftStick(value: number);
  47458. /**
  47459. * Gets the value of the Right joystick
  47460. */
  47461. get buttonRightStick(): number;
  47462. /**
  47463. * Sets the value of the Right joystick
  47464. */
  47465. set buttonRightStick(value: number);
  47466. /**
  47467. * Gets the value of D-pad up
  47468. */
  47469. get dPadUp(): number;
  47470. /**
  47471. * Sets the value of D-pad up
  47472. */
  47473. set dPadUp(value: number);
  47474. /**
  47475. * Gets the value of D-pad down
  47476. */
  47477. get dPadDown(): number;
  47478. /**
  47479. * Sets the value of D-pad down
  47480. */
  47481. set dPadDown(value: number);
  47482. /**
  47483. * Gets the value of D-pad left
  47484. */
  47485. get dPadLeft(): number;
  47486. /**
  47487. * Sets the value of D-pad left
  47488. */
  47489. set dPadLeft(value: number);
  47490. /**
  47491. * Gets the value of D-pad right
  47492. */
  47493. get dPadRight(): number;
  47494. /**
  47495. * Sets the value of D-pad right
  47496. */
  47497. set dPadRight(value: number);
  47498. /**
  47499. * Force the gamepad to synchronize with device values
  47500. */
  47501. update(): void;
  47502. /**
  47503. * Disposes the gamepad
  47504. */
  47505. dispose(): void;
  47506. }
  47507. }
  47508. declare module "babylonjs/Gamepads/gamepadManager" {
  47509. import { Observable } from "babylonjs/Misc/observable";
  47510. import { Nullable } from "babylonjs/types";
  47511. import { Scene } from "babylonjs/scene";
  47512. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47513. /**
  47514. * Manager for handling gamepads
  47515. */
  47516. export class GamepadManager {
  47517. private _scene?;
  47518. private _babylonGamepads;
  47519. private _oneGamepadConnected;
  47520. /** @hidden */
  47521. _isMonitoring: boolean;
  47522. private _gamepadEventSupported;
  47523. private _gamepadSupport?;
  47524. /**
  47525. * observable to be triggered when the gamepad controller has been connected
  47526. */
  47527. onGamepadConnectedObservable: Observable<Gamepad>;
  47528. /**
  47529. * observable to be triggered when the gamepad controller has been disconnected
  47530. */
  47531. onGamepadDisconnectedObservable: Observable<Gamepad>;
  47532. private _onGamepadConnectedEvent;
  47533. private _onGamepadDisconnectedEvent;
  47534. /**
  47535. * Initializes the gamepad manager
  47536. * @param _scene BabylonJS scene
  47537. */
  47538. constructor(_scene?: Scene | undefined);
  47539. /**
  47540. * The gamepads in the game pad manager
  47541. */
  47542. get gamepads(): Gamepad[];
  47543. /**
  47544. * Get the gamepad controllers based on type
  47545. * @param type The type of gamepad controller
  47546. * @returns Nullable gamepad
  47547. */
  47548. getGamepadByType(type?: number): Nullable<Gamepad>;
  47549. /**
  47550. * Disposes the gamepad manager
  47551. */
  47552. dispose(): void;
  47553. private _addNewGamepad;
  47554. private _startMonitoringGamepads;
  47555. private _stopMonitoringGamepads;
  47556. /** @hidden */
  47557. _checkGamepadsStatus(): void;
  47558. private _updateGamepadObjects;
  47559. }
  47560. }
  47561. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  47562. import { Nullable } from "babylonjs/types";
  47563. import { Scene } from "babylonjs/scene";
  47564. import { ISceneComponent } from "babylonjs/sceneComponent";
  47565. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  47566. module "babylonjs/scene" {
  47567. interface Scene {
  47568. /** @hidden */
  47569. _gamepadManager: Nullable<GamepadManager>;
  47570. /**
  47571. * Gets the gamepad manager associated with the scene
  47572. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  47573. */
  47574. gamepadManager: GamepadManager;
  47575. }
  47576. }
  47577. module "babylonjs/Cameras/freeCameraInputsManager" {
  47578. /**
  47579. * Interface representing a free camera inputs manager
  47580. */
  47581. interface FreeCameraInputsManager {
  47582. /**
  47583. * Adds gamepad input support to the FreeCameraInputsManager.
  47584. * @returns the FreeCameraInputsManager
  47585. */
  47586. addGamepad(): FreeCameraInputsManager;
  47587. }
  47588. }
  47589. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47590. /**
  47591. * Interface representing an arc rotate camera inputs manager
  47592. */
  47593. interface ArcRotateCameraInputsManager {
  47594. /**
  47595. * Adds gamepad input support to the ArcRotateCamera InputManager.
  47596. * @returns the camera inputs manager
  47597. */
  47598. addGamepad(): ArcRotateCameraInputsManager;
  47599. }
  47600. }
  47601. /**
  47602. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  47603. */
  47604. export class GamepadSystemSceneComponent implements ISceneComponent {
  47605. /**
  47606. * The component name helpfull to identify the component in the list of scene components.
  47607. */
  47608. readonly name: string;
  47609. /**
  47610. * The scene the component belongs to.
  47611. */
  47612. scene: Scene;
  47613. /**
  47614. * Creates a new instance of the component for the given scene
  47615. * @param scene Defines the scene to register the component in
  47616. */
  47617. constructor(scene: Scene);
  47618. /**
  47619. * Registers the component in a given scene
  47620. */
  47621. register(): void;
  47622. /**
  47623. * Rebuilds the elements related to this component in case of
  47624. * context lost for instance.
  47625. */
  47626. rebuild(): void;
  47627. /**
  47628. * Disposes the component and the associated ressources
  47629. */
  47630. dispose(): void;
  47631. private _beforeCameraUpdate;
  47632. }
  47633. }
  47634. declare module "babylonjs/Cameras/universalCamera" {
  47635. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  47636. import { Scene } from "babylonjs/scene";
  47637. import { Vector3 } from "babylonjs/Maths/math.vector";
  47638. import "babylonjs/Gamepads/gamepadSceneComponent";
  47639. /**
  47640. * 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,
  47641. * which still works and will still be found in many Playgrounds.
  47642. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47643. */
  47644. export class UniversalCamera extends TouchCamera {
  47645. /**
  47646. * Defines the gamepad rotation sensiblity.
  47647. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47648. */
  47649. get gamepadAngularSensibility(): number;
  47650. set gamepadAngularSensibility(value: number);
  47651. /**
  47652. * Defines the gamepad move sensiblity.
  47653. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47654. */
  47655. get gamepadMoveSensibility(): number;
  47656. set gamepadMoveSensibility(value: number);
  47657. /**
  47658. * 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,
  47659. * which still works and will still be found in many Playgrounds.
  47660. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47661. * @param name Define the name of the camera in the scene
  47662. * @param position Define the start position of the camera in the scene
  47663. * @param scene Define the scene the camera belongs to
  47664. */
  47665. constructor(name: string, position: Vector3, scene: Scene);
  47666. /**
  47667. * Gets the current object class name.
  47668. * @return the class name
  47669. */
  47670. getClassName(): string;
  47671. }
  47672. }
  47673. declare module "babylonjs/Cameras/gamepadCamera" {
  47674. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47675. import { Scene } from "babylonjs/scene";
  47676. import { Vector3 } from "babylonjs/Maths/math.vector";
  47677. /**
  47678. * This represents a FPS type of camera. This is only here for back compat purpose.
  47679. * Please use the UniversalCamera instead as both are identical.
  47680. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47681. */
  47682. export class GamepadCamera extends UniversalCamera {
  47683. /**
  47684. * Instantiates a new Gamepad Camera
  47685. * This represents a FPS type of camera. This is only here for back compat purpose.
  47686. * Please use the UniversalCamera instead as both are identical.
  47687. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47688. * @param name Define the name of the camera in the scene
  47689. * @param position Define the start position of the camera in the scene
  47690. * @param scene Define the scene the camera belongs to
  47691. */
  47692. constructor(name: string, position: Vector3, scene: Scene);
  47693. /**
  47694. * Gets the current object class name.
  47695. * @return the class name
  47696. */
  47697. getClassName(): string;
  47698. }
  47699. }
  47700. declare module "babylonjs/Shaders/pass.fragment" {
  47701. /** @hidden */
  47702. export var passPixelShader: {
  47703. name: string;
  47704. shader: string;
  47705. };
  47706. }
  47707. declare module "babylonjs/Shaders/passCube.fragment" {
  47708. /** @hidden */
  47709. export var passCubePixelShader: {
  47710. name: string;
  47711. shader: string;
  47712. };
  47713. }
  47714. declare module "babylonjs/PostProcesses/passPostProcess" {
  47715. import { Nullable } from "babylonjs/types";
  47716. import { Camera } from "babylonjs/Cameras/camera";
  47717. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47718. import { Engine } from "babylonjs/Engines/engine";
  47719. import "babylonjs/Shaders/pass.fragment";
  47720. import "babylonjs/Shaders/passCube.fragment";
  47721. import { Scene } from "babylonjs/scene";
  47722. /**
  47723. * PassPostProcess which produces an output the same as it's input
  47724. */
  47725. export class PassPostProcess extends PostProcess {
  47726. /**
  47727. * Gets a string identifying the name of the class
  47728. * @returns "PassPostProcess" string
  47729. */
  47730. getClassName(): string;
  47731. /**
  47732. * Creates the PassPostProcess
  47733. * @param name The name of the effect.
  47734. * @param options The required width/height ratio to downsize to before computing the render pass.
  47735. * @param camera The camera to apply the render pass to.
  47736. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47737. * @param engine The engine which the post process will be applied. (default: current engine)
  47738. * @param reusable If the post process can be reused on the same frame. (default: false)
  47739. * @param textureType The type of texture to be used when performing the post processing.
  47740. * @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)
  47741. */
  47742. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47743. /** @hidden */
  47744. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  47745. }
  47746. /**
  47747. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  47748. */
  47749. export class PassCubePostProcess extends PostProcess {
  47750. private _face;
  47751. /**
  47752. * Gets or sets the cube face to display.
  47753. * * 0 is +X
  47754. * * 1 is -X
  47755. * * 2 is +Y
  47756. * * 3 is -Y
  47757. * * 4 is +Z
  47758. * * 5 is -Z
  47759. */
  47760. get face(): number;
  47761. set face(value: number);
  47762. /**
  47763. * Gets a string identifying the name of the class
  47764. * @returns "PassCubePostProcess" string
  47765. */
  47766. getClassName(): string;
  47767. /**
  47768. * Creates the PassCubePostProcess
  47769. * @param name The name of the effect.
  47770. * @param options The required width/height ratio to downsize to before computing the render pass.
  47771. * @param camera The camera to apply the render pass to.
  47772. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47773. * @param engine The engine which the post process will be applied. (default: current engine)
  47774. * @param reusable If the post process can be reused on the same frame. (default: false)
  47775. * @param textureType The type of texture to be used when performing the post processing.
  47776. * @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)
  47777. */
  47778. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47779. /** @hidden */
  47780. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  47781. }
  47782. }
  47783. declare module "babylonjs/Shaders/anaglyph.fragment" {
  47784. /** @hidden */
  47785. export var anaglyphPixelShader: {
  47786. name: string;
  47787. shader: string;
  47788. };
  47789. }
  47790. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  47791. import { Engine } from "babylonjs/Engines/engine";
  47792. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47793. import { Camera } from "babylonjs/Cameras/camera";
  47794. import "babylonjs/Shaders/anaglyph.fragment";
  47795. /**
  47796. * Postprocess used to generate anaglyphic rendering
  47797. */
  47798. export class AnaglyphPostProcess extends PostProcess {
  47799. private _passedProcess;
  47800. /**
  47801. * Gets a string identifying the name of the class
  47802. * @returns "AnaglyphPostProcess" string
  47803. */
  47804. getClassName(): string;
  47805. /**
  47806. * Creates a new AnaglyphPostProcess
  47807. * @param name defines postprocess name
  47808. * @param options defines creation options or target ratio scale
  47809. * @param rigCameras defines cameras using this postprocess
  47810. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  47811. * @param engine defines hosting engine
  47812. * @param reusable defines if the postprocess will be reused multiple times per frame
  47813. */
  47814. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  47815. }
  47816. }
  47817. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  47818. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  47819. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47820. import { Scene } from "babylonjs/scene";
  47821. import { Vector3 } from "babylonjs/Maths/math.vector";
  47822. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47823. /**
  47824. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  47825. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47826. */
  47827. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  47828. /**
  47829. * Creates a new AnaglyphArcRotateCamera
  47830. * @param name defines camera name
  47831. * @param alpha defines alpha angle (in radians)
  47832. * @param beta defines beta angle (in radians)
  47833. * @param radius defines radius
  47834. * @param target defines camera target
  47835. * @param interaxialDistance defines distance between each color axis
  47836. * @param scene defines the hosting scene
  47837. */
  47838. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  47839. /**
  47840. * Gets camera class name
  47841. * @returns AnaglyphArcRotateCamera
  47842. */
  47843. getClassName(): string;
  47844. }
  47845. }
  47846. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  47847. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47848. import { Scene } from "babylonjs/scene";
  47849. import { Vector3 } from "babylonjs/Maths/math.vector";
  47850. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47851. /**
  47852. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  47853. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47854. */
  47855. export class AnaglyphFreeCamera extends FreeCamera {
  47856. /**
  47857. * Creates a new AnaglyphFreeCamera
  47858. * @param name defines camera name
  47859. * @param position defines initial position
  47860. * @param interaxialDistance defines distance between each color axis
  47861. * @param scene defines the hosting scene
  47862. */
  47863. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47864. /**
  47865. * Gets camera class name
  47866. * @returns AnaglyphFreeCamera
  47867. */
  47868. getClassName(): string;
  47869. }
  47870. }
  47871. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  47872. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47873. import { Scene } from "babylonjs/scene";
  47874. import { Vector3 } from "babylonjs/Maths/math.vector";
  47875. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47876. /**
  47877. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  47878. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47879. */
  47880. export class AnaglyphGamepadCamera extends GamepadCamera {
  47881. /**
  47882. * Creates a new AnaglyphGamepadCamera
  47883. * @param name defines camera name
  47884. * @param position defines initial position
  47885. * @param interaxialDistance defines distance between each color axis
  47886. * @param scene defines the hosting scene
  47887. */
  47888. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47889. /**
  47890. * Gets camera class name
  47891. * @returns AnaglyphGamepadCamera
  47892. */
  47893. getClassName(): string;
  47894. }
  47895. }
  47896. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  47897. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47898. import { Scene } from "babylonjs/scene";
  47899. import { Vector3 } from "babylonjs/Maths/math.vector";
  47900. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47901. /**
  47902. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  47903. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47904. */
  47905. export class AnaglyphUniversalCamera extends UniversalCamera {
  47906. /**
  47907. * Creates a new AnaglyphUniversalCamera
  47908. * @param name defines camera name
  47909. * @param position defines initial position
  47910. * @param interaxialDistance defines distance between each color axis
  47911. * @param scene defines the hosting scene
  47912. */
  47913. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47914. /**
  47915. * Gets camera class name
  47916. * @returns AnaglyphUniversalCamera
  47917. */
  47918. getClassName(): string;
  47919. }
  47920. }
  47921. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  47922. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  47923. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47924. import { Scene } from "babylonjs/scene";
  47925. import { Vector3 } from "babylonjs/Maths/math.vector";
  47926. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47927. /**
  47928. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  47929. * @see https://doc.babylonjs.com/features/cameras
  47930. */
  47931. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  47932. /**
  47933. * Creates a new StereoscopicArcRotateCamera
  47934. * @param name defines camera name
  47935. * @param alpha defines alpha angle (in radians)
  47936. * @param beta defines beta angle (in radians)
  47937. * @param radius defines radius
  47938. * @param target defines camera target
  47939. * @param interaxialDistance defines distance between each color axis
  47940. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47941. * @param scene defines the hosting scene
  47942. */
  47943. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47944. /**
  47945. * Gets camera class name
  47946. * @returns StereoscopicArcRotateCamera
  47947. */
  47948. getClassName(): string;
  47949. }
  47950. }
  47951. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  47952. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47953. import { Scene } from "babylonjs/scene";
  47954. import { Vector3 } from "babylonjs/Maths/math.vector";
  47955. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47956. /**
  47957. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  47958. * @see https://doc.babylonjs.com/features/cameras
  47959. */
  47960. export class StereoscopicFreeCamera extends FreeCamera {
  47961. /**
  47962. * Creates a new StereoscopicFreeCamera
  47963. * @param name defines camera name
  47964. * @param position defines initial position
  47965. * @param interaxialDistance defines distance between each color axis
  47966. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47967. * @param scene defines the hosting scene
  47968. */
  47969. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47970. /**
  47971. * Gets camera class name
  47972. * @returns StereoscopicFreeCamera
  47973. */
  47974. getClassName(): string;
  47975. }
  47976. }
  47977. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  47978. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47979. import { Scene } from "babylonjs/scene";
  47980. import { Vector3 } from "babylonjs/Maths/math.vector";
  47981. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47982. /**
  47983. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  47984. * @see https://doc.babylonjs.com/features/cameras
  47985. */
  47986. export class StereoscopicGamepadCamera extends GamepadCamera {
  47987. /**
  47988. * Creates a new StereoscopicGamepadCamera
  47989. * @param name defines camera name
  47990. * @param position defines initial position
  47991. * @param interaxialDistance defines distance between each color axis
  47992. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47993. * @param scene defines the hosting scene
  47994. */
  47995. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47996. /**
  47997. * Gets camera class name
  47998. * @returns StereoscopicGamepadCamera
  47999. */
  48000. getClassName(): string;
  48001. }
  48002. }
  48003. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  48004. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  48005. import { Scene } from "babylonjs/scene";
  48006. import { Vector3 } from "babylonjs/Maths/math.vector";
  48007. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48008. /**
  48009. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  48010. * @see https://doc.babylonjs.com/features/cameras
  48011. */
  48012. export class StereoscopicUniversalCamera extends UniversalCamera {
  48013. /**
  48014. * Creates a new StereoscopicUniversalCamera
  48015. * @param name defines camera name
  48016. * @param position defines initial position
  48017. * @param interaxialDistance defines distance between each color axis
  48018. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48019. * @param scene defines the hosting scene
  48020. */
  48021. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48022. /**
  48023. * Gets camera class name
  48024. * @returns StereoscopicUniversalCamera
  48025. */
  48026. getClassName(): string;
  48027. }
  48028. }
  48029. declare module "babylonjs/Cameras/Stereoscopic/index" {
  48030. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  48031. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  48032. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  48033. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  48034. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  48035. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  48036. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  48037. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  48038. }
  48039. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  48040. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48041. import { Scene } from "babylonjs/scene";
  48042. import { Vector3 } from "babylonjs/Maths/math.vector";
  48043. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  48044. /**
  48045. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  48046. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48047. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48048. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48049. */
  48050. export class VirtualJoysticksCamera extends FreeCamera {
  48051. /**
  48052. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  48053. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48054. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48055. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48056. * @param name Define the name of the camera in the scene
  48057. * @param position Define the start position of the camera in the scene
  48058. * @param scene Define the scene the camera belongs to
  48059. */
  48060. constructor(name: string, position: Vector3, scene: Scene);
  48061. /**
  48062. * Gets the current object class name.
  48063. * @return the class name
  48064. */
  48065. getClassName(): string;
  48066. }
  48067. }
  48068. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  48069. import { Matrix } from "babylonjs/Maths/math.vector";
  48070. /**
  48071. * This represents all the required metrics to create a VR camera.
  48072. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  48073. */
  48074. export class VRCameraMetrics {
  48075. /**
  48076. * Define the horizontal resolution off the screen.
  48077. */
  48078. hResolution: number;
  48079. /**
  48080. * Define the vertical resolution off the screen.
  48081. */
  48082. vResolution: number;
  48083. /**
  48084. * Define the horizontal screen size.
  48085. */
  48086. hScreenSize: number;
  48087. /**
  48088. * Define the vertical screen size.
  48089. */
  48090. vScreenSize: number;
  48091. /**
  48092. * Define the vertical screen center position.
  48093. */
  48094. vScreenCenter: number;
  48095. /**
  48096. * Define the distance of the eyes to the screen.
  48097. */
  48098. eyeToScreenDistance: number;
  48099. /**
  48100. * Define the distance between both lenses
  48101. */
  48102. lensSeparationDistance: number;
  48103. /**
  48104. * Define the distance between both viewer's eyes.
  48105. */
  48106. interpupillaryDistance: number;
  48107. /**
  48108. * Define the distortion factor of the VR postprocess.
  48109. * Please, touch with care.
  48110. */
  48111. distortionK: number[];
  48112. /**
  48113. * Define the chromatic aberration correction factors for the VR post process.
  48114. */
  48115. chromaAbCorrection: number[];
  48116. /**
  48117. * Define the scale factor of the post process.
  48118. * The smaller the better but the slower.
  48119. */
  48120. postProcessScaleFactor: number;
  48121. /**
  48122. * Define an offset for the lens center.
  48123. */
  48124. lensCenterOffset: number;
  48125. /**
  48126. * Define if the current vr camera should compensate the distortion of the lense or not.
  48127. */
  48128. compensateDistortion: boolean;
  48129. /**
  48130. * Defines if multiview should be enabled when rendering (Default: false)
  48131. */
  48132. multiviewEnabled: boolean;
  48133. /**
  48134. * Gets the rendering aspect ratio based on the provided resolutions.
  48135. */
  48136. get aspectRatio(): number;
  48137. /**
  48138. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  48139. */
  48140. get aspectRatioFov(): number;
  48141. /**
  48142. * @hidden
  48143. */
  48144. get leftHMatrix(): Matrix;
  48145. /**
  48146. * @hidden
  48147. */
  48148. get rightHMatrix(): Matrix;
  48149. /**
  48150. * @hidden
  48151. */
  48152. get leftPreViewMatrix(): Matrix;
  48153. /**
  48154. * @hidden
  48155. */
  48156. get rightPreViewMatrix(): Matrix;
  48157. /**
  48158. * Get the default VRMetrics based on the most generic setup.
  48159. * @returns the default vr metrics
  48160. */
  48161. static GetDefault(): VRCameraMetrics;
  48162. }
  48163. }
  48164. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  48165. /** @hidden */
  48166. export var vrDistortionCorrectionPixelShader: {
  48167. name: string;
  48168. shader: string;
  48169. };
  48170. }
  48171. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  48172. import { Camera } from "babylonjs/Cameras/camera";
  48173. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48174. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48175. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  48176. /**
  48177. * VRDistortionCorrectionPostProcess used for mobile VR
  48178. */
  48179. export class VRDistortionCorrectionPostProcess extends PostProcess {
  48180. private _isRightEye;
  48181. private _distortionFactors;
  48182. private _postProcessScaleFactor;
  48183. private _lensCenterOffset;
  48184. private _scaleIn;
  48185. private _scaleFactor;
  48186. private _lensCenter;
  48187. /**
  48188. * Gets a string identifying the name of the class
  48189. * @returns "VRDistortionCorrectionPostProcess" string
  48190. */
  48191. getClassName(): string;
  48192. /**
  48193. * Initializes the VRDistortionCorrectionPostProcess
  48194. * @param name The name of the effect.
  48195. * @param camera The camera to apply the render pass to.
  48196. * @param isRightEye If this is for the right eye distortion
  48197. * @param vrMetrics All the required metrics for the VR camera
  48198. */
  48199. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  48200. }
  48201. }
  48202. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  48203. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  48204. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48205. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48206. import { Scene } from "babylonjs/scene";
  48207. import { Vector3 } from "babylonjs/Maths/math.vector";
  48208. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  48209. import "babylonjs/Cameras/RigModes/vrRigMode";
  48210. /**
  48211. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  48212. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48213. */
  48214. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  48215. /**
  48216. * Creates a new VRDeviceOrientationArcRotateCamera
  48217. * @param name defines camera name
  48218. * @param alpha defines the camera rotation along the logitudinal axis
  48219. * @param beta defines the camera rotation along the latitudinal axis
  48220. * @param radius defines the camera distance from its target
  48221. * @param target defines the camera target
  48222. * @param scene defines the scene the camera belongs to
  48223. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48224. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48225. */
  48226. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48227. /**
  48228. * Gets camera class name
  48229. * @returns VRDeviceOrientationArcRotateCamera
  48230. */
  48231. getClassName(): string;
  48232. }
  48233. }
  48234. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  48235. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  48236. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48237. import { Scene } from "babylonjs/scene";
  48238. import { Vector3 } from "babylonjs/Maths/math.vector";
  48239. import "babylonjs/Cameras/RigModes/vrRigMode";
  48240. /**
  48241. * Camera used to simulate VR rendering (based on FreeCamera)
  48242. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48243. */
  48244. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  48245. /**
  48246. * Creates a new VRDeviceOrientationFreeCamera
  48247. * @param name defines camera name
  48248. * @param position defines the start position of the camera
  48249. * @param scene defines the scene the camera belongs to
  48250. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48251. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48252. */
  48253. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48254. /**
  48255. * Gets camera class name
  48256. * @returns VRDeviceOrientationFreeCamera
  48257. */
  48258. getClassName(): string;
  48259. }
  48260. }
  48261. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  48262. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  48263. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48264. import { Scene } from "babylonjs/scene";
  48265. import { Vector3 } from "babylonjs/Maths/math.vector";
  48266. import "babylonjs/Gamepads/gamepadSceneComponent";
  48267. /**
  48268. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  48269. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48270. */
  48271. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  48272. /**
  48273. * Creates a new VRDeviceOrientationGamepadCamera
  48274. * @param name defines camera name
  48275. * @param position defines the start position of the camera
  48276. * @param scene defines the scene the camera belongs to
  48277. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48278. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48279. */
  48280. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48281. /**
  48282. * Gets camera class name
  48283. * @returns VRDeviceOrientationGamepadCamera
  48284. */
  48285. getClassName(): string;
  48286. }
  48287. }
  48288. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  48289. import { Scene } from "babylonjs/scene";
  48290. import { Texture } from "babylonjs/Materials/Textures/texture";
  48291. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48292. /**
  48293. * A class extending Texture allowing drawing on a texture
  48294. * @see https://doc.babylonjs.com/how_to/dynamictexture
  48295. */
  48296. export class DynamicTexture extends Texture {
  48297. private _generateMipMaps;
  48298. private _canvas;
  48299. private _context;
  48300. /**
  48301. * Creates a DynamicTexture
  48302. * @param name defines the name of the texture
  48303. * @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
  48304. * @param scene defines the scene where you want the texture
  48305. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  48306. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  48307. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  48308. */
  48309. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  48310. /**
  48311. * Get the current class name of the texture useful for serialization or dynamic coding.
  48312. * @returns "DynamicTexture"
  48313. */
  48314. getClassName(): string;
  48315. /**
  48316. * Gets the current state of canRescale
  48317. */
  48318. get canRescale(): boolean;
  48319. private _recreate;
  48320. /**
  48321. * Scales the texture
  48322. * @param ratio the scale factor to apply to both width and height
  48323. */
  48324. scale(ratio: number): void;
  48325. /**
  48326. * Resizes the texture
  48327. * @param width the new width
  48328. * @param height the new height
  48329. */
  48330. scaleTo(width: number, height: number): void;
  48331. /**
  48332. * Gets the context of the canvas used by the texture
  48333. * @returns the canvas context of the dynamic texture
  48334. */
  48335. getContext(): CanvasRenderingContext2D;
  48336. /**
  48337. * Clears the texture
  48338. */
  48339. clear(): void;
  48340. /**
  48341. * Updates the texture
  48342. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48343. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  48344. */
  48345. update(invertY?: boolean, premulAlpha?: boolean): void;
  48346. /**
  48347. * Draws text onto the texture
  48348. * @param text defines the text to be drawn
  48349. * @param x defines the placement of the text from the left
  48350. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  48351. * @param font defines the font to be used with font-style, font-size, font-name
  48352. * @param color defines the color used for the text
  48353. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  48354. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48355. * @param update defines whether texture is immediately update (default is true)
  48356. */
  48357. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  48358. /**
  48359. * Clones the texture
  48360. * @returns the clone of the texture.
  48361. */
  48362. clone(): DynamicTexture;
  48363. /**
  48364. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  48365. * @returns a serialized dynamic texture object
  48366. */
  48367. serialize(): any;
  48368. private _IsCanvasElement;
  48369. /** @hidden */
  48370. _rebuild(): void;
  48371. }
  48372. }
  48373. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  48374. import { Scene } from "babylonjs/scene";
  48375. import { Color3 } from "babylonjs/Maths/math.color";
  48376. import { Mesh } from "babylonjs/Meshes/mesh";
  48377. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  48378. import { Nullable } from "babylonjs/types";
  48379. /**
  48380. * Class containing static functions to help procedurally build meshes
  48381. */
  48382. export class GroundBuilder {
  48383. /**
  48384. * Creates a ground mesh
  48385. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  48386. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  48387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48388. * @param name defines the name of the mesh
  48389. * @param options defines the options used to create the mesh
  48390. * @param scene defines the hosting scene
  48391. * @returns the ground mesh
  48392. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  48393. */
  48394. static CreateGround(name: string, options: {
  48395. width?: number;
  48396. height?: number;
  48397. subdivisions?: number;
  48398. subdivisionsX?: number;
  48399. subdivisionsY?: number;
  48400. updatable?: boolean;
  48401. }, scene: any): Mesh;
  48402. /**
  48403. * Creates a tiled ground mesh
  48404. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  48405. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  48406. * * 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
  48407. * * 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
  48408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48409. * @param name defines the name of the mesh
  48410. * @param options defines the options used to create the mesh
  48411. * @param scene defines the hosting scene
  48412. * @returns the tiled ground mesh
  48413. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  48414. */
  48415. static CreateTiledGround(name: string, options: {
  48416. xmin: number;
  48417. zmin: number;
  48418. xmax: number;
  48419. zmax: number;
  48420. subdivisions?: {
  48421. w: number;
  48422. h: number;
  48423. };
  48424. precision?: {
  48425. w: number;
  48426. h: number;
  48427. };
  48428. updatable?: boolean;
  48429. }, scene?: Nullable<Scene>): Mesh;
  48430. /**
  48431. * Creates a ground mesh from a height map
  48432. * * The parameter `url` sets the URL of the height map image resource.
  48433. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  48434. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  48435. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  48436. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  48437. * * 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.
  48438. * * 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).
  48439. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  48440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48441. * @param name defines the name of the mesh
  48442. * @param url defines the url to the height map
  48443. * @param options defines the options used to create the mesh
  48444. * @param scene defines the hosting scene
  48445. * @returns the ground mesh
  48446. * @see https://doc.babylonjs.com/babylon101/height_map
  48447. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  48448. */
  48449. static CreateGroundFromHeightMap(name: string, url: string, options: {
  48450. width?: number;
  48451. height?: number;
  48452. subdivisions?: number;
  48453. minHeight?: number;
  48454. maxHeight?: number;
  48455. colorFilter?: Color3;
  48456. alphaFilter?: number;
  48457. updatable?: boolean;
  48458. onReady?: (mesh: GroundMesh) => void;
  48459. }, scene?: Nullable<Scene>): GroundMesh;
  48460. }
  48461. }
  48462. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  48463. import { Vector4 } from "babylonjs/Maths/math.vector";
  48464. import { Mesh } from "babylonjs/Meshes/mesh";
  48465. /**
  48466. * Class containing static functions to help procedurally build meshes
  48467. */
  48468. export class TorusBuilder {
  48469. /**
  48470. * Creates a torus mesh
  48471. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  48472. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  48473. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  48474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48475. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48477. * @param name defines the name of the mesh
  48478. * @param options defines the options used to create the mesh
  48479. * @param scene defines the hosting scene
  48480. * @returns the torus mesh
  48481. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  48482. */
  48483. static CreateTorus(name: string, options: {
  48484. diameter?: number;
  48485. thickness?: number;
  48486. tessellation?: number;
  48487. updatable?: boolean;
  48488. sideOrientation?: number;
  48489. frontUVs?: Vector4;
  48490. backUVs?: Vector4;
  48491. }, scene: any): Mesh;
  48492. }
  48493. }
  48494. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  48495. import { Vector4 } from "babylonjs/Maths/math.vector";
  48496. import { Color4 } from "babylonjs/Maths/math.color";
  48497. import { Mesh } from "babylonjs/Meshes/mesh";
  48498. /**
  48499. * Class containing static functions to help procedurally build meshes
  48500. */
  48501. export class CylinderBuilder {
  48502. /**
  48503. * Creates a cylinder or a cone mesh
  48504. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  48505. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  48506. * * 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.
  48507. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  48508. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  48509. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  48510. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  48511. * * 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).
  48512. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  48513. * * 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).
  48514. * * 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
  48515. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  48516. * * 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
  48517. * * 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.
  48518. * * If `enclose` is false, a ring surface is one element.
  48519. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  48520. * * 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
  48521. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48522. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48524. * @param name defines the name of the mesh
  48525. * @param options defines the options used to create the mesh
  48526. * @param scene defines the hosting scene
  48527. * @returns the cylinder mesh
  48528. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  48529. */
  48530. static CreateCylinder(name: string, options: {
  48531. height?: number;
  48532. diameterTop?: number;
  48533. diameterBottom?: number;
  48534. diameter?: number;
  48535. tessellation?: number;
  48536. subdivisions?: number;
  48537. arc?: number;
  48538. faceColors?: Color4[];
  48539. faceUV?: Vector4[];
  48540. updatable?: boolean;
  48541. hasRings?: boolean;
  48542. enclose?: boolean;
  48543. cap?: number;
  48544. sideOrientation?: number;
  48545. frontUVs?: Vector4;
  48546. backUVs?: Vector4;
  48547. }, scene: any): Mesh;
  48548. }
  48549. }
  48550. declare module "babylonjs/XR/webXRTypes" {
  48551. import { Nullable } from "babylonjs/types";
  48552. import { IDisposable } from "babylonjs/scene";
  48553. /**
  48554. * States of the webXR experience
  48555. */
  48556. export enum WebXRState {
  48557. /**
  48558. * Transitioning to being in XR mode
  48559. */
  48560. ENTERING_XR = 0,
  48561. /**
  48562. * Transitioning to non XR mode
  48563. */
  48564. EXITING_XR = 1,
  48565. /**
  48566. * In XR mode and presenting
  48567. */
  48568. IN_XR = 2,
  48569. /**
  48570. * Not entered XR mode
  48571. */
  48572. NOT_IN_XR = 3
  48573. }
  48574. /**
  48575. * Abstraction of the XR render target
  48576. */
  48577. export interface WebXRRenderTarget extends IDisposable {
  48578. /**
  48579. * xrpresent context of the canvas which can be used to display/mirror xr content
  48580. */
  48581. canvasContext: WebGLRenderingContext;
  48582. /**
  48583. * xr layer for the canvas
  48584. */
  48585. xrLayer: Nullable<XRWebGLLayer>;
  48586. /**
  48587. * Initializes the xr layer for the session
  48588. * @param xrSession xr session
  48589. * @returns a promise that will resolve once the XR Layer has been created
  48590. */
  48591. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48592. }
  48593. }
  48594. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  48595. import { Nullable } from "babylonjs/types";
  48596. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  48597. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48598. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48599. import { Observable } from "babylonjs/Misc/observable";
  48600. /**
  48601. * COnfiguration object for WebXR output canvas
  48602. */
  48603. export class WebXRManagedOutputCanvasOptions {
  48604. /**
  48605. * An optional canvas in case you wish to create it yourself and provide it here.
  48606. * If not provided, a new canvas will be created
  48607. */
  48608. canvasElement?: HTMLCanvasElement;
  48609. /**
  48610. * Options for this XR Layer output
  48611. */
  48612. canvasOptions?: XRWebGLLayerOptions;
  48613. /**
  48614. * CSS styling for a newly created canvas (if not provided)
  48615. */
  48616. newCanvasCssStyle?: string;
  48617. /**
  48618. * Get the default values of the configuration object
  48619. * @param engine defines the engine to use (can be null)
  48620. * @returns default values of this configuration object
  48621. */
  48622. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  48623. }
  48624. /**
  48625. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  48626. */
  48627. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  48628. private _options;
  48629. private _canvas;
  48630. private _engine;
  48631. private _originalCanvasSize;
  48632. /**
  48633. * Rendering context of the canvas which can be used to display/mirror xr content
  48634. */
  48635. canvasContext: WebGLRenderingContext;
  48636. /**
  48637. * xr layer for the canvas
  48638. */
  48639. xrLayer: Nullable<XRWebGLLayer>;
  48640. /**
  48641. * Obseervers registered here will be triggered when the xr layer was initialized
  48642. */
  48643. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  48644. /**
  48645. * Initializes the canvas to be added/removed upon entering/exiting xr
  48646. * @param _xrSessionManager The XR Session manager
  48647. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  48648. */
  48649. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  48650. /**
  48651. * Disposes of the object
  48652. */
  48653. dispose(): void;
  48654. /**
  48655. * Initializes the xr layer for the session
  48656. * @param xrSession xr session
  48657. * @returns a promise that will resolve once the XR Layer has been created
  48658. */
  48659. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48660. private _addCanvas;
  48661. private _removeCanvas;
  48662. private _setCanvasSize;
  48663. private _setManagedOutputCanvas;
  48664. }
  48665. }
  48666. declare module "babylonjs/XR/webXRSessionManager" {
  48667. import { Observable } from "babylonjs/Misc/observable";
  48668. import { Nullable } from "babylonjs/types";
  48669. import { IDisposable, Scene } from "babylonjs/scene";
  48670. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48671. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48672. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  48673. /**
  48674. * Manages an XRSession to work with Babylon's engine
  48675. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  48676. */
  48677. export class WebXRSessionManager implements IDisposable {
  48678. /** The scene which the session should be created for */
  48679. scene: Scene;
  48680. private _referenceSpace;
  48681. private _rttProvider;
  48682. private _sessionEnded;
  48683. private _xrNavigator;
  48684. private baseLayer;
  48685. /**
  48686. * The base reference space from which the session started. good if you want to reset your
  48687. * reference space
  48688. */
  48689. baseReferenceSpace: XRReferenceSpace;
  48690. /**
  48691. * Current XR frame
  48692. */
  48693. currentFrame: Nullable<XRFrame>;
  48694. /** WebXR timestamp updated every frame */
  48695. currentTimestamp: number;
  48696. /**
  48697. * Used just in case of a failure to initialize an immersive session.
  48698. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  48699. */
  48700. defaultHeightCompensation: number;
  48701. /**
  48702. * Fires every time a new xrFrame arrives which can be used to update the camera
  48703. */
  48704. onXRFrameObservable: Observable<XRFrame>;
  48705. /**
  48706. * Fires when the reference space changed
  48707. */
  48708. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  48709. /**
  48710. * Fires when the xr session is ended either by the device or manually done
  48711. */
  48712. onXRSessionEnded: Observable<any>;
  48713. /**
  48714. * Fires when the xr session is ended either by the device or manually done
  48715. */
  48716. onXRSessionInit: Observable<XRSession>;
  48717. /**
  48718. * Underlying xr session
  48719. */
  48720. session: XRSession;
  48721. /**
  48722. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  48723. * or get the offset the player is currently at.
  48724. */
  48725. viewerReferenceSpace: XRReferenceSpace;
  48726. /**
  48727. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  48728. * @param scene The scene which the session should be created for
  48729. */
  48730. constructor(
  48731. /** The scene which the session should be created for */
  48732. scene: Scene);
  48733. /**
  48734. * The current reference space used in this session. This reference space can constantly change!
  48735. * It is mainly used to offset the camera's position.
  48736. */
  48737. get referenceSpace(): XRReferenceSpace;
  48738. /**
  48739. * Set a new reference space and triggers the observable
  48740. */
  48741. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  48742. /**
  48743. * Disposes of the session manager
  48744. */
  48745. dispose(): void;
  48746. /**
  48747. * Stops the xrSession and restores the render loop
  48748. * @returns Promise which resolves after it exits XR
  48749. */
  48750. exitXRAsync(): Promise<void>;
  48751. /**
  48752. * Gets the correct render target texture to be rendered this frame for this eye
  48753. * @param eye the eye for which to get the render target
  48754. * @returns the render target for the specified eye
  48755. */
  48756. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  48757. /**
  48758. * Creates a WebXRRenderTarget object for the XR session
  48759. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  48760. * @param options optional options to provide when creating a new render target
  48761. * @returns a WebXR render target to which the session can render
  48762. */
  48763. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  48764. /**
  48765. * Initializes the manager
  48766. * After initialization enterXR can be called to start an XR session
  48767. * @returns Promise which resolves after it is initialized
  48768. */
  48769. initializeAsync(): Promise<void>;
  48770. /**
  48771. * Initializes an xr session
  48772. * @param xrSessionMode mode to initialize
  48773. * @param xrSessionInit defines optional and required values to pass to the session builder
  48774. * @returns a promise which will resolve once the session has been initialized
  48775. */
  48776. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  48777. /**
  48778. * Checks if a session would be supported for the creation options specified
  48779. * @param sessionMode session mode to check if supported eg. immersive-vr
  48780. * @returns A Promise that resolves to true if supported and false if not
  48781. */
  48782. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48783. /**
  48784. * Resets the reference space to the one started the session
  48785. */
  48786. resetReferenceSpace(): void;
  48787. /**
  48788. * Starts rendering to the xr layer
  48789. */
  48790. runXRRenderLoop(): void;
  48791. /**
  48792. * Sets the reference space on the xr session
  48793. * @param referenceSpaceType space to set
  48794. * @returns a promise that will resolve once the reference space has been set
  48795. */
  48796. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  48797. /**
  48798. * Updates the render state of the session
  48799. * @param state state to set
  48800. * @returns a promise that resolves once the render state has been updated
  48801. */
  48802. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  48803. /**
  48804. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  48805. * @param sessionMode defines the session to test
  48806. * @returns a promise with boolean as final value
  48807. */
  48808. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48809. private _createRenderTargetTexture;
  48810. }
  48811. }
  48812. declare module "babylonjs/XR/webXRCamera" {
  48813. import { Vector3 } from "babylonjs/Maths/math.vector";
  48814. import { Scene } from "babylonjs/scene";
  48815. import { Camera } from "babylonjs/Cameras/camera";
  48816. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48817. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48818. import { Observable } from "babylonjs/Misc/observable";
  48819. /**
  48820. * WebXR Camera which holds the views for the xrSession
  48821. * @see https://doc.babylonjs.com/how_to/webxr_camera
  48822. */
  48823. export class WebXRCamera extends FreeCamera {
  48824. private _xrSessionManager;
  48825. private _firstFrame;
  48826. private _referenceQuaternion;
  48827. private _referencedPosition;
  48828. private _xrInvPositionCache;
  48829. private _xrInvQuaternionCache;
  48830. /**
  48831. * Observable raised before camera teleportation
  48832. */
  48833. onBeforeCameraTeleport: Observable<Vector3>;
  48834. /**
  48835. * Observable raised after camera teleportation
  48836. */
  48837. onAfterCameraTeleport: Observable<Vector3>;
  48838. /**
  48839. * Should position compensation execute on first frame.
  48840. * This is used when copying the position from a native (non XR) camera
  48841. */
  48842. compensateOnFirstFrame: boolean;
  48843. /**
  48844. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  48845. * @param name the name of the camera
  48846. * @param scene the scene to add the camera to
  48847. * @param _xrSessionManager a constructed xr session manager
  48848. */
  48849. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  48850. /**
  48851. * Return the user's height, unrelated to the current ground.
  48852. * This will be the y position of this camera, when ground level is 0.
  48853. */
  48854. get realWorldHeight(): number;
  48855. /** @hidden */
  48856. _updateForDualEyeDebugging(): void;
  48857. /**
  48858. * Sets this camera's transformation based on a non-vr camera
  48859. * @param otherCamera the non-vr camera to copy the transformation from
  48860. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  48861. */
  48862. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  48863. /**
  48864. * Gets the current instance class name ("WebXRCamera").
  48865. * @returns the class name
  48866. */
  48867. getClassName(): string;
  48868. private _rotate180;
  48869. private _updateFromXRSession;
  48870. private _updateNumberOfRigCameras;
  48871. private _updateReferenceSpace;
  48872. private _updateReferenceSpaceOffset;
  48873. }
  48874. }
  48875. declare module "babylonjs/XR/webXRFeaturesManager" {
  48876. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48877. import { IDisposable } from "babylonjs/scene";
  48878. /**
  48879. * Defining the interface required for a (webxr) feature
  48880. */
  48881. export interface IWebXRFeature extends IDisposable {
  48882. /**
  48883. * Is this feature attached
  48884. */
  48885. attached: boolean;
  48886. /**
  48887. * Should auto-attach be disabled?
  48888. */
  48889. disableAutoAttach: boolean;
  48890. /**
  48891. * Attach the feature to the session
  48892. * Will usually be called by the features manager
  48893. *
  48894. * @param force should attachment be forced (even when already attached)
  48895. * @returns true if successful.
  48896. */
  48897. attach(force?: boolean): boolean;
  48898. /**
  48899. * Detach the feature from the session
  48900. * Will usually be called by the features manager
  48901. *
  48902. * @returns true if successful.
  48903. */
  48904. detach(): boolean;
  48905. /**
  48906. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48907. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48908. *
  48909. * @returns whether or not the feature is compatible in this environment
  48910. */
  48911. isCompatible(): boolean;
  48912. /**
  48913. * Was this feature disposed;
  48914. */
  48915. isDisposed: boolean;
  48916. /**
  48917. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  48918. */
  48919. xrNativeFeatureName?: string;
  48920. /**
  48921. * A list of (Babylon WebXR) features this feature depends on
  48922. */
  48923. dependsOn?: string[];
  48924. }
  48925. /**
  48926. * A list of the currently available features without referencing them
  48927. */
  48928. export class WebXRFeatureName {
  48929. /**
  48930. * The name of the anchor system feature
  48931. */
  48932. static readonly ANCHOR_SYSTEM: string;
  48933. /**
  48934. * The name of the background remover feature
  48935. */
  48936. static readonly BACKGROUND_REMOVER: string;
  48937. /**
  48938. * The name of the hit test feature
  48939. */
  48940. static readonly HIT_TEST: string;
  48941. /**
  48942. * physics impostors for xr controllers feature
  48943. */
  48944. static readonly PHYSICS_CONTROLLERS: string;
  48945. /**
  48946. * The name of the plane detection feature
  48947. */
  48948. static readonly PLANE_DETECTION: string;
  48949. /**
  48950. * The name of the pointer selection feature
  48951. */
  48952. static readonly POINTER_SELECTION: string;
  48953. /**
  48954. * The name of the teleportation feature
  48955. */
  48956. static readonly TELEPORTATION: string;
  48957. /**
  48958. * The name of the feature points feature.
  48959. */
  48960. static readonly FEATURE_POINTS: string;
  48961. /**
  48962. * The name of the hand tracking feature.
  48963. */
  48964. static readonly HAND_TRACKING: string;
  48965. }
  48966. /**
  48967. * Defining the constructor of a feature. Used to register the modules.
  48968. */
  48969. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  48970. /**
  48971. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  48972. * It is mainly used in AR sessions.
  48973. *
  48974. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  48975. */
  48976. export class WebXRFeaturesManager implements IDisposable {
  48977. private _xrSessionManager;
  48978. private static readonly _AvailableFeatures;
  48979. private _features;
  48980. /**
  48981. * constructs a new features manages.
  48982. *
  48983. * @param _xrSessionManager an instance of WebXRSessionManager
  48984. */
  48985. constructor(_xrSessionManager: WebXRSessionManager);
  48986. /**
  48987. * Used to register a module. After calling this function a developer can use this feature in the scene.
  48988. * Mainly used internally.
  48989. *
  48990. * @param featureName the name of the feature to register
  48991. * @param constructorFunction the function used to construct the module
  48992. * @param version the (babylon) version of the module
  48993. * @param stable is that a stable version of this module
  48994. */
  48995. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  48996. /**
  48997. * Returns a constructor of a specific feature.
  48998. *
  48999. * @param featureName the name of the feature to construct
  49000. * @param version the version of the feature to load
  49001. * @param xrSessionManager the xrSessionManager. Used to construct the module
  49002. * @param options optional options provided to the module.
  49003. * @returns a function that, when called, will return a new instance of this feature
  49004. */
  49005. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  49006. /**
  49007. * Can be used to return the list of features currently registered
  49008. *
  49009. * @returns an Array of available features
  49010. */
  49011. static GetAvailableFeatures(): string[];
  49012. /**
  49013. * Gets the versions available for a specific feature
  49014. * @param featureName the name of the feature
  49015. * @returns an array with the available versions
  49016. */
  49017. static GetAvailableVersions(featureName: string): string[];
  49018. /**
  49019. * Return the latest unstable version of this feature
  49020. * @param featureName the name of the feature to search
  49021. * @returns the version number. if not found will return -1
  49022. */
  49023. static GetLatestVersionOfFeature(featureName: string): number;
  49024. /**
  49025. * Return the latest stable version of this feature
  49026. * @param featureName the name of the feature to search
  49027. * @returns the version number. if not found will return -1
  49028. */
  49029. static GetStableVersionOfFeature(featureName: string): number;
  49030. /**
  49031. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  49032. * Can be used during a session to start a feature
  49033. * @param featureName the name of feature to attach
  49034. */
  49035. attachFeature(featureName: string): void;
  49036. /**
  49037. * Can be used inside a session or when the session ends to detach a specific feature
  49038. * @param featureName the name of the feature to detach
  49039. */
  49040. detachFeature(featureName: string): void;
  49041. /**
  49042. * Used to disable an already-enabled feature
  49043. * The feature will be disposed and will be recreated once enabled.
  49044. * @param featureName the feature to disable
  49045. * @returns true if disable was successful
  49046. */
  49047. disableFeature(featureName: string | {
  49048. Name: string;
  49049. }): boolean;
  49050. /**
  49051. * dispose this features manager
  49052. */
  49053. dispose(): void;
  49054. /**
  49055. * 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.
  49056. * 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.
  49057. *
  49058. * @param featureName the name of the feature to load or the class of the feature
  49059. * @param version optional version to load. if not provided the latest version will be enabled
  49060. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  49061. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  49062. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  49063. * @returns a new constructed feature or throws an error if feature not found.
  49064. */
  49065. enableFeature(featureName: string | {
  49066. Name: string;
  49067. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  49068. /**
  49069. * get the implementation of an enabled feature.
  49070. * @param featureName the name of the feature to load
  49071. * @returns the feature class, if found
  49072. */
  49073. getEnabledFeature(featureName: string): IWebXRFeature;
  49074. /**
  49075. * Get the list of enabled features
  49076. * @returns an array of enabled features
  49077. */
  49078. getEnabledFeatures(): string[];
  49079. /**
  49080. * This function will exten the session creation configuration object with enabled features.
  49081. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  49082. * according to the defined "required" variable, provided during enableFeature call
  49083. * @param xrSessionInit the xr Session init object to extend
  49084. *
  49085. * @returns an extended XRSessionInit object
  49086. */
  49087. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  49088. }
  49089. }
  49090. declare module "babylonjs/XR/webXRExperienceHelper" {
  49091. import { Observable } from "babylonjs/Misc/observable";
  49092. import { IDisposable, Scene } from "babylonjs/scene";
  49093. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49094. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49095. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49096. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  49097. /**
  49098. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  49099. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  49100. */
  49101. export class WebXRExperienceHelper implements IDisposable {
  49102. private scene;
  49103. private _nonVRCamera;
  49104. private _originalSceneAutoClear;
  49105. private _supported;
  49106. /**
  49107. * Camera used to render xr content
  49108. */
  49109. camera: WebXRCamera;
  49110. /** A features manager for this xr session */
  49111. featuresManager: WebXRFeaturesManager;
  49112. /**
  49113. * Observers registered here will be triggered after the camera's initial transformation is set
  49114. * This can be used to set a different ground level or an extra rotation.
  49115. *
  49116. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  49117. * to the position set after this observable is done executing.
  49118. */
  49119. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  49120. /**
  49121. * Fires when the state of the experience helper has changed
  49122. */
  49123. onStateChangedObservable: Observable<WebXRState>;
  49124. /** Session manager used to keep track of xr session */
  49125. sessionManager: WebXRSessionManager;
  49126. /**
  49127. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  49128. */
  49129. state: WebXRState;
  49130. /**
  49131. * Creates a WebXRExperienceHelper
  49132. * @param scene The scene the helper should be created in
  49133. */
  49134. private constructor();
  49135. /**
  49136. * Creates the experience helper
  49137. * @param scene the scene to attach the experience helper to
  49138. * @returns a promise for the experience helper
  49139. */
  49140. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  49141. /**
  49142. * Disposes of the experience helper
  49143. */
  49144. dispose(): void;
  49145. /**
  49146. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  49147. * @param sessionMode options for the XR session
  49148. * @param referenceSpaceType frame of reference of the XR session
  49149. * @param renderTarget the output canvas that will be used to enter XR mode
  49150. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  49151. * @returns promise that resolves after xr mode has entered
  49152. */
  49153. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  49154. /**
  49155. * Exits XR mode and returns the scene to its original state
  49156. * @returns promise that resolves after xr mode has exited
  49157. */
  49158. exitXRAsync(): Promise<void>;
  49159. private _nonXRToXRCamera;
  49160. private _setState;
  49161. }
  49162. }
  49163. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  49164. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49165. import { Observable } from "babylonjs/Misc/observable";
  49166. import { IDisposable } from "babylonjs/scene";
  49167. /**
  49168. * X-Y values for axes in WebXR
  49169. */
  49170. export interface IWebXRMotionControllerAxesValue {
  49171. /**
  49172. * The value of the x axis
  49173. */
  49174. x: number;
  49175. /**
  49176. * The value of the y-axis
  49177. */
  49178. y: number;
  49179. }
  49180. /**
  49181. * changed / previous values for the values of this component
  49182. */
  49183. export interface IWebXRMotionControllerComponentChangesValues<T> {
  49184. /**
  49185. * current (this frame) value
  49186. */
  49187. current: T;
  49188. /**
  49189. * previous (last change) value
  49190. */
  49191. previous: T;
  49192. }
  49193. /**
  49194. * Represents changes in the component between current frame and last values recorded
  49195. */
  49196. export interface IWebXRMotionControllerComponentChanges {
  49197. /**
  49198. * will be populated with previous and current values if axes changed
  49199. */
  49200. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  49201. /**
  49202. * will be populated with previous and current values if pressed changed
  49203. */
  49204. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49205. /**
  49206. * will be populated with previous and current values if touched changed
  49207. */
  49208. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49209. /**
  49210. * will be populated with previous and current values if value changed
  49211. */
  49212. value?: IWebXRMotionControllerComponentChangesValues<number>;
  49213. }
  49214. /**
  49215. * This class represents a single component (for example button or thumbstick) of a motion controller
  49216. */
  49217. export class WebXRControllerComponent implements IDisposable {
  49218. /**
  49219. * the id of this component
  49220. */
  49221. id: string;
  49222. /**
  49223. * the type of the component
  49224. */
  49225. type: MotionControllerComponentType;
  49226. private _buttonIndex;
  49227. private _axesIndices;
  49228. private _axes;
  49229. private _changes;
  49230. private _currentValue;
  49231. private _hasChanges;
  49232. private _pressed;
  49233. private _touched;
  49234. /**
  49235. * button component type
  49236. */
  49237. static BUTTON_TYPE: MotionControllerComponentType;
  49238. /**
  49239. * squeeze component type
  49240. */
  49241. static SQUEEZE_TYPE: MotionControllerComponentType;
  49242. /**
  49243. * Thumbstick component type
  49244. */
  49245. static THUMBSTICK_TYPE: MotionControllerComponentType;
  49246. /**
  49247. * Touchpad component type
  49248. */
  49249. static TOUCHPAD_TYPE: MotionControllerComponentType;
  49250. /**
  49251. * trigger component type
  49252. */
  49253. static TRIGGER_TYPE: MotionControllerComponentType;
  49254. /**
  49255. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  49256. * the axes data changes
  49257. */
  49258. onAxisValueChangedObservable: Observable<{
  49259. x: number;
  49260. y: number;
  49261. }>;
  49262. /**
  49263. * Observers registered here will be triggered when the state of a button changes
  49264. * State change is either pressed / touched / value
  49265. */
  49266. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  49267. /**
  49268. * Creates a new component for a motion controller.
  49269. * It is created by the motion controller itself
  49270. *
  49271. * @param id the id of this component
  49272. * @param type the type of the component
  49273. * @param _buttonIndex index in the buttons array of the gamepad
  49274. * @param _axesIndices indices of the values in the axes array of the gamepad
  49275. */
  49276. constructor(
  49277. /**
  49278. * the id of this component
  49279. */
  49280. id: string,
  49281. /**
  49282. * the type of the component
  49283. */
  49284. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  49285. /**
  49286. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  49287. */
  49288. get axes(): IWebXRMotionControllerAxesValue;
  49289. /**
  49290. * Get the changes. Elements will be populated only if they changed with their previous and current value
  49291. */
  49292. get changes(): IWebXRMotionControllerComponentChanges;
  49293. /**
  49294. * Return whether or not the component changed the last frame
  49295. */
  49296. get hasChanges(): boolean;
  49297. /**
  49298. * is the button currently pressed
  49299. */
  49300. get pressed(): boolean;
  49301. /**
  49302. * is the button currently touched
  49303. */
  49304. get touched(): boolean;
  49305. /**
  49306. * Get the current value of this component
  49307. */
  49308. get value(): number;
  49309. /**
  49310. * Dispose this component
  49311. */
  49312. dispose(): void;
  49313. /**
  49314. * Are there axes correlating to this component
  49315. * @return true is axes data is available
  49316. */
  49317. isAxes(): boolean;
  49318. /**
  49319. * Is this component a button (hence - pressable)
  49320. * @returns true if can be pressed
  49321. */
  49322. isButton(): boolean;
  49323. /**
  49324. * update this component using the gamepad object it is in. Called on every frame
  49325. * @param nativeController the native gamepad controller object
  49326. */
  49327. update(nativeController: IMinimalMotionControllerObject): void;
  49328. }
  49329. }
  49330. declare module "babylonjs/Loading/sceneLoader" {
  49331. import { Observable } from "babylonjs/Misc/observable";
  49332. import { Nullable } from "babylonjs/types";
  49333. import { Scene } from "babylonjs/scene";
  49334. import { Engine } from "babylonjs/Engines/engine";
  49335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49336. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49337. import { AssetContainer } from "babylonjs/assetContainer";
  49338. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49339. import { Skeleton } from "babylonjs/Bones/skeleton";
  49340. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  49341. import { WebRequest } from "babylonjs/Misc/webRequest";
  49342. /**
  49343. * Interface used to represent data loading progression
  49344. */
  49345. export interface ISceneLoaderProgressEvent {
  49346. /**
  49347. * Defines if data length to load can be evaluated
  49348. */
  49349. readonly lengthComputable: boolean;
  49350. /**
  49351. * Defines the loaded data length
  49352. */
  49353. readonly loaded: number;
  49354. /**
  49355. * Defines the data length to load
  49356. */
  49357. readonly total: number;
  49358. }
  49359. /**
  49360. * Interface used by SceneLoader plugins to define supported file extensions
  49361. */
  49362. export interface ISceneLoaderPluginExtensions {
  49363. /**
  49364. * Defines the list of supported extensions
  49365. */
  49366. [extension: string]: {
  49367. isBinary: boolean;
  49368. };
  49369. }
  49370. /**
  49371. * Interface used by SceneLoader plugin factory
  49372. */
  49373. export interface ISceneLoaderPluginFactory {
  49374. /**
  49375. * Defines the name of the factory
  49376. */
  49377. name: string;
  49378. /**
  49379. * Function called to create a new plugin
  49380. * @return the new plugin
  49381. */
  49382. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  49383. /**
  49384. * The callback that returns true if the data can be directly loaded.
  49385. * @param data string containing the file data
  49386. * @returns if the data can be loaded directly
  49387. */
  49388. canDirectLoad?(data: string): boolean;
  49389. }
  49390. /**
  49391. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  49392. */
  49393. export interface ISceneLoaderPluginBase {
  49394. /**
  49395. * The friendly name of this plugin.
  49396. */
  49397. name: string;
  49398. /**
  49399. * The file extensions supported by this plugin.
  49400. */
  49401. extensions: string | ISceneLoaderPluginExtensions;
  49402. /**
  49403. * The callback called when loading from a url.
  49404. * @param scene scene loading this url
  49405. * @param url url to load
  49406. * @param onSuccess callback called when the file successfully loads
  49407. * @param onProgress callback called while file is loading (if the server supports this mode)
  49408. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  49409. * @param onError callback called when the file fails to load
  49410. * @returns a file request object
  49411. */
  49412. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49413. /**
  49414. * The callback called when loading from a file object.
  49415. * @param scene scene loading this file
  49416. * @param file defines the file to load
  49417. * @param onSuccess defines the callback to call when data is loaded
  49418. * @param onProgress defines the callback to call during loading process
  49419. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  49420. * @param onError defines the callback to call when an error occurs
  49421. * @returns a file request object
  49422. */
  49423. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49424. /**
  49425. * The callback that returns true if the data can be directly loaded.
  49426. * @param data string containing the file data
  49427. * @returns if the data can be loaded directly
  49428. */
  49429. canDirectLoad?(data: string): boolean;
  49430. /**
  49431. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  49432. * @param scene scene loading this data
  49433. * @param data string containing the data
  49434. * @returns data to pass to the plugin
  49435. */
  49436. directLoad?(scene: Scene, data: string): any;
  49437. /**
  49438. * The callback that allows custom handling of the root url based on the response url.
  49439. * @param rootUrl the original root url
  49440. * @param responseURL the response url if available
  49441. * @returns the new root url
  49442. */
  49443. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  49444. }
  49445. /**
  49446. * Interface used to define a SceneLoader plugin
  49447. */
  49448. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  49449. /**
  49450. * Import meshes into a scene.
  49451. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49452. * @param scene The scene to import into
  49453. * @param data The data to import
  49454. * @param rootUrl The root url for scene and resources
  49455. * @param meshes The meshes array to import into
  49456. * @param particleSystems The particle systems array to import into
  49457. * @param skeletons The skeletons array to import into
  49458. * @param onError The callback when import fails
  49459. * @returns True if successful or false otherwise
  49460. */
  49461. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  49462. /**
  49463. * Load into a scene.
  49464. * @param scene The scene to load into
  49465. * @param data The data to import
  49466. * @param rootUrl The root url for scene and resources
  49467. * @param onError The callback when import fails
  49468. * @returns True if successful or false otherwise
  49469. */
  49470. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  49471. /**
  49472. * Load into an asset container.
  49473. * @param scene The scene to load into
  49474. * @param data The data to import
  49475. * @param rootUrl The root url for scene and resources
  49476. * @param onError The callback when import fails
  49477. * @returns The loaded asset container
  49478. */
  49479. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  49480. }
  49481. /**
  49482. * Interface used to define an async SceneLoader plugin
  49483. */
  49484. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  49485. /**
  49486. * Import meshes into a scene.
  49487. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49488. * @param scene The scene to import into
  49489. * @param data The data to import
  49490. * @param rootUrl The root url for scene and resources
  49491. * @param onProgress The callback when the load progresses
  49492. * @param fileName Defines the name of the file to load
  49493. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  49494. */
  49495. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  49496. meshes: AbstractMesh[];
  49497. particleSystems: IParticleSystem[];
  49498. skeletons: Skeleton[];
  49499. animationGroups: AnimationGroup[];
  49500. }>;
  49501. /**
  49502. * Load into a scene.
  49503. * @param scene The scene to load into
  49504. * @param data The data to import
  49505. * @param rootUrl The root url for scene and resources
  49506. * @param onProgress The callback when the load progresses
  49507. * @param fileName Defines the name of the file to load
  49508. * @returns Nothing
  49509. */
  49510. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  49511. /**
  49512. * Load into an asset container.
  49513. * @param scene The scene to load into
  49514. * @param data The data to import
  49515. * @param rootUrl The root url for scene and resources
  49516. * @param onProgress The callback when the load progresses
  49517. * @param fileName Defines the name of the file to load
  49518. * @returns The loaded asset container
  49519. */
  49520. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  49521. }
  49522. /**
  49523. * Mode that determines how to handle old animation groups before loading new ones.
  49524. */
  49525. export enum SceneLoaderAnimationGroupLoadingMode {
  49526. /**
  49527. * Reset all old animations to initial state then dispose them.
  49528. */
  49529. Clean = 0,
  49530. /**
  49531. * Stop all old animations.
  49532. */
  49533. Stop = 1,
  49534. /**
  49535. * Restart old animations from first frame.
  49536. */
  49537. Sync = 2,
  49538. /**
  49539. * Old animations remains untouched.
  49540. */
  49541. NoSync = 3
  49542. }
  49543. /**
  49544. * Defines a plugin registered by the SceneLoader
  49545. */
  49546. interface IRegisteredPlugin {
  49547. /**
  49548. * Defines the plugin to use
  49549. */
  49550. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49551. /**
  49552. * Defines if the plugin supports binary data
  49553. */
  49554. isBinary: boolean;
  49555. }
  49556. /**
  49557. * Class used to load scene from various file formats using registered plugins
  49558. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  49559. */
  49560. export class SceneLoader {
  49561. /**
  49562. * No logging while loading
  49563. */
  49564. static readonly NO_LOGGING: number;
  49565. /**
  49566. * Minimal logging while loading
  49567. */
  49568. static readonly MINIMAL_LOGGING: number;
  49569. /**
  49570. * Summary logging while loading
  49571. */
  49572. static readonly SUMMARY_LOGGING: number;
  49573. /**
  49574. * Detailled logging while loading
  49575. */
  49576. static readonly DETAILED_LOGGING: number;
  49577. /**
  49578. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49579. */
  49580. static get ForceFullSceneLoadingForIncremental(): boolean;
  49581. static set ForceFullSceneLoadingForIncremental(value: boolean);
  49582. /**
  49583. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49584. */
  49585. static get ShowLoadingScreen(): boolean;
  49586. static set ShowLoadingScreen(value: boolean);
  49587. /**
  49588. * Defines the current logging level (while loading the scene)
  49589. * @ignorenaming
  49590. */
  49591. static get loggingLevel(): number;
  49592. static set loggingLevel(value: number);
  49593. /**
  49594. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49595. */
  49596. static get CleanBoneMatrixWeights(): boolean;
  49597. static set CleanBoneMatrixWeights(value: boolean);
  49598. /**
  49599. * Event raised when a plugin is used to load a scene
  49600. */
  49601. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  49602. private static _registeredPlugins;
  49603. private static _showingLoadingScreen;
  49604. /**
  49605. * Gets the default plugin (used to load Babylon files)
  49606. * @returns the .babylon plugin
  49607. */
  49608. static GetDefaultPlugin(): IRegisteredPlugin;
  49609. private static _GetPluginForExtension;
  49610. private static _GetPluginForDirectLoad;
  49611. private static _GetPluginForFilename;
  49612. private static _GetDirectLoad;
  49613. private static _LoadData;
  49614. private static _GetFileInfo;
  49615. /**
  49616. * Gets a plugin that can load the given extension
  49617. * @param extension defines the extension to load
  49618. * @returns a plugin or null if none works
  49619. */
  49620. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49621. /**
  49622. * Gets a boolean indicating that the given extension can be loaded
  49623. * @param extension defines the extension to load
  49624. * @returns true if the extension is supported
  49625. */
  49626. static IsPluginForExtensionAvailable(extension: string): boolean;
  49627. /**
  49628. * Adds a new plugin to the list of registered plugins
  49629. * @param plugin defines the plugin to add
  49630. */
  49631. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  49632. /**
  49633. * Import meshes into a scene
  49634. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49635. * @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)
  49636. * @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)
  49637. * @param scene the instance of BABYLON.Scene to append to
  49638. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  49639. * @param onProgress a callback with a progress event for each file being loaded
  49640. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49641. * @param pluginExtension the extension used to determine the plugin
  49642. * @returns The loaded plugin
  49643. */
  49644. 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>;
  49645. /**
  49646. * Import meshes into a scene
  49647. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49648. * @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)
  49649. * @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)
  49650. * @param scene the instance of BABYLON.Scene to append to
  49651. * @param onProgress a callback with a progress event for each file being loaded
  49652. * @param pluginExtension the extension used to determine the plugin
  49653. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  49654. */
  49655. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  49656. meshes: AbstractMesh[];
  49657. particleSystems: IParticleSystem[];
  49658. skeletons: Skeleton[];
  49659. animationGroups: AnimationGroup[];
  49660. }>;
  49661. /**
  49662. * Load a scene
  49663. * @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)
  49664. * @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)
  49665. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49666. * @param onSuccess a callback with the scene when import succeeds
  49667. * @param onProgress a callback with a progress event for each file being loaded
  49668. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49669. * @param pluginExtension the extension used to determine the plugin
  49670. * @returns The loaded plugin
  49671. */
  49672. 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>;
  49673. /**
  49674. * Load a scene
  49675. * @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)
  49676. * @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)
  49677. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49678. * @param onProgress a callback with a progress event for each file being loaded
  49679. * @param pluginExtension the extension used to determine the plugin
  49680. * @returns The loaded scene
  49681. */
  49682. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49683. /**
  49684. * Append a scene
  49685. * @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)
  49686. * @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)
  49687. * @param scene is the instance of BABYLON.Scene to append to
  49688. * @param onSuccess a callback with the scene when import succeeds
  49689. * @param onProgress a callback with a progress event for each file being loaded
  49690. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49691. * @param pluginExtension the extension used to determine the plugin
  49692. * @returns The loaded plugin
  49693. */
  49694. 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>;
  49695. /**
  49696. * Append a scene
  49697. * @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)
  49698. * @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)
  49699. * @param scene is the instance of BABYLON.Scene to append to
  49700. * @param onProgress a callback with a progress event for each file being loaded
  49701. * @param pluginExtension the extension used to determine the plugin
  49702. * @returns The given scene
  49703. */
  49704. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49705. /**
  49706. * Load a scene into an asset container
  49707. * @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)
  49708. * @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)
  49709. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49710. * @param onSuccess a callback with the scene when import succeeds
  49711. * @param onProgress a callback with a progress event for each file being loaded
  49712. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49713. * @param pluginExtension the extension used to determine the plugin
  49714. * @returns The loaded plugin
  49715. */
  49716. 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>;
  49717. /**
  49718. * Load a scene into an asset container
  49719. * @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)
  49720. * @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)
  49721. * @param scene is the instance of Scene to append to
  49722. * @param onProgress a callback with a progress event for each file being loaded
  49723. * @param pluginExtension the extension used to determine the plugin
  49724. * @returns The loaded asset container
  49725. */
  49726. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  49727. /**
  49728. * Import animations from a file into a scene
  49729. * @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)
  49730. * @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)
  49731. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49732. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49733. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49734. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49735. * @param onSuccess a callback with the scene when import succeeds
  49736. * @param onProgress a callback with a progress event for each file being loaded
  49737. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49738. * @param pluginExtension the extension used to determine the plugin
  49739. */
  49740. 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;
  49741. /**
  49742. * Import animations from a file into a scene
  49743. * @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)
  49744. * @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)
  49745. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49746. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49747. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49748. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49749. * @param onSuccess a callback with the scene when import succeeds
  49750. * @param onProgress a callback with a progress event for each file being loaded
  49751. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49752. * @param pluginExtension the extension used to determine the plugin
  49753. * @returns the updated scene with imported animations
  49754. */
  49755. 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>;
  49756. }
  49757. }
  49758. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  49759. import { IDisposable, Scene } from "babylonjs/scene";
  49760. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  49761. import { Observable } from "babylonjs/Misc/observable";
  49762. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49763. import { Nullable } from "babylonjs/types";
  49764. /**
  49765. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  49766. */
  49767. export type MotionControllerHandedness = "none" | "left" | "right";
  49768. /**
  49769. * The type of components available in motion controllers.
  49770. * This is not the name of the component.
  49771. */
  49772. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  49773. /**
  49774. * The state of a controller component
  49775. */
  49776. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  49777. /**
  49778. * The schema of motion controller layout.
  49779. * No object will be initialized using this interface
  49780. * This is used just to define the profile.
  49781. */
  49782. export interface IMotionControllerLayout {
  49783. /**
  49784. * Path to load the assets. Usually relative to the base path
  49785. */
  49786. assetPath: string;
  49787. /**
  49788. * Available components (unsorted)
  49789. */
  49790. components: {
  49791. /**
  49792. * A map of component Ids
  49793. */
  49794. [componentId: string]: {
  49795. /**
  49796. * The type of input the component outputs
  49797. */
  49798. type: MotionControllerComponentType;
  49799. /**
  49800. * The indices of this component in the gamepad object
  49801. */
  49802. gamepadIndices: {
  49803. /**
  49804. * Index of button
  49805. */
  49806. button?: number;
  49807. /**
  49808. * If available, index of x-axis
  49809. */
  49810. xAxis?: number;
  49811. /**
  49812. * If available, index of y-axis
  49813. */
  49814. yAxis?: number;
  49815. };
  49816. /**
  49817. * The mesh's root node name
  49818. */
  49819. rootNodeName: string;
  49820. /**
  49821. * Animation definitions for this model
  49822. */
  49823. visualResponses: {
  49824. [stateKey: string]: {
  49825. /**
  49826. * What property will be animated
  49827. */
  49828. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  49829. /**
  49830. * What states influence this visual response
  49831. */
  49832. states: MotionControllerComponentStateType[];
  49833. /**
  49834. * Type of animation - movement or visibility
  49835. */
  49836. valueNodeProperty: "transform" | "visibility";
  49837. /**
  49838. * Base node name to move. Its position will be calculated according to the min and max nodes
  49839. */
  49840. valueNodeName?: string;
  49841. /**
  49842. * Minimum movement node
  49843. */
  49844. minNodeName?: string;
  49845. /**
  49846. * Max movement node
  49847. */
  49848. maxNodeName?: string;
  49849. };
  49850. };
  49851. /**
  49852. * If touch enabled, what is the name of node to display user feedback
  49853. */
  49854. touchPointNodeName?: string;
  49855. };
  49856. };
  49857. /**
  49858. * Is it xr standard mapping or not
  49859. */
  49860. gamepadMapping: "" | "xr-standard";
  49861. /**
  49862. * Base root node of this entire model
  49863. */
  49864. rootNodeName: string;
  49865. /**
  49866. * Defines the main button component id
  49867. */
  49868. selectComponentId: string;
  49869. }
  49870. /**
  49871. * A definition for the layout map in the input profile
  49872. */
  49873. export interface IMotionControllerLayoutMap {
  49874. /**
  49875. * Layouts with handedness type as a key
  49876. */
  49877. [handedness: string]: IMotionControllerLayout;
  49878. }
  49879. /**
  49880. * The XR Input profile schema
  49881. * Profiles can be found here:
  49882. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  49883. */
  49884. export interface IMotionControllerProfile {
  49885. /**
  49886. * fallback profiles for this profileId
  49887. */
  49888. fallbackProfileIds: string[];
  49889. /**
  49890. * The layout map, with handedness as key
  49891. */
  49892. layouts: IMotionControllerLayoutMap;
  49893. /**
  49894. * The id of this profile
  49895. * correlates to the profile(s) in the xrInput.profiles array
  49896. */
  49897. profileId: string;
  49898. }
  49899. /**
  49900. * A helper-interface for the 3 meshes needed for controller button animation
  49901. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  49902. */
  49903. export interface IMotionControllerButtonMeshMap {
  49904. /**
  49905. * the mesh that defines the pressed value mesh position.
  49906. * This is used to find the max-position of this button
  49907. */
  49908. pressedMesh: AbstractMesh;
  49909. /**
  49910. * the mesh that defines the unpressed value mesh position.
  49911. * This is used to find the min (or initial) position of this button
  49912. */
  49913. unpressedMesh: AbstractMesh;
  49914. /**
  49915. * The mesh that will be changed when value changes
  49916. */
  49917. valueMesh: AbstractMesh;
  49918. }
  49919. /**
  49920. * A helper-interface for the 3 meshes needed for controller axis animation.
  49921. * This will be expanded when touchpad animations are fully supported
  49922. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  49923. */
  49924. export interface IMotionControllerMeshMap {
  49925. /**
  49926. * the mesh that defines the maximum value mesh position.
  49927. */
  49928. maxMesh?: AbstractMesh;
  49929. /**
  49930. * the mesh that defines the minimum value mesh position.
  49931. */
  49932. minMesh?: AbstractMesh;
  49933. /**
  49934. * The mesh that will be changed when axis value changes
  49935. */
  49936. valueMesh?: AbstractMesh;
  49937. }
  49938. /**
  49939. * The elements needed for change-detection of the gamepad objects in motion controllers
  49940. */
  49941. export interface IMinimalMotionControllerObject {
  49942. /**
  49943. * Available axes of this controller
  49944. */
  49945. axes: number[];
  49946. /**
  49947. * An array of available buttons
  49948. */
  49949. buttons: Array<{
  49950. /**
  49951. * Value of the button/trigger
  49952. */
  49953. value: number;
  49954. /**
  49955. * If the button/trigger is currently touched
  49956. */
  49957. touched: boolean;
  49958. /**
  49959. * If the button/trigger is currently pressed
  49960. */
  49961. pressed: boolean;
  49962. }>;
  49963. /**
  49964. * EXPERIMENTAL haptic support.
  49965. */
  49966. hapticActuators?: Array<{
  49967. pulse: (value: number, duration: number) => Promise<boolean>;
  49968. }>;
  49969. }
  49970. /**
  49971. * An Abstract Motion controller
  49972. * This class receives an xrInput and a profile layout and uses those to initialize the components
  49973. * Each component has an observable to check for changes in value and state
  49974. */
  49975. export abstract class WebXRAbstractMotionController implements IDisposable {
  49976. protected scene: Scene;
  49977. protected layout: IMotionControllerLayout;
  49978. /**
  49979. * The gamepad object correlating to this controller
  49980. */
  49981. gamepadObject: IMinimalMotionControllerObject;
  49982. /**
  49983. * handedness (left/right/none) of this controller
  49984. */
  49985. handedness: MotionControllerHandedness;
  49986. private _initComponent;
  49987. private _modelReady;
  49988. /**
  49989. * A map of components (WebXRControllerComponent) in this motion controller
  49990. * Components have a ComponentType and can also have both button and axis definitions
  49991. */
  49992. readonly components: {
  49993. [id: string]: WebXRControllerComponent;
  49994. };
  49995. /**
  49996. * Disable the model's animation. Can be set at any time.
  49997. */
  49998. disableAnimation: boolean;
  49999. /**
  50000. * Observers registered here will be triggered when the model of this controller is done loading
  50001. */
  50002. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  50003. /**
  50004. * The profile id of this motion controller
  50005. */
  50006. abstract profileId: string;
  50007. /**
  50008. * The root mesh of the model. It is null if the model was not yet initialized
  50009. */
  50010. rootMesh: Nullable<AbstractMesh>;
  50011. /**
  50012. * constructs a new abstract motion controller
  50013. * @param scene the scene to which the model of the controller will be added
  50014. * @param layout The profile layout to load
  50015. * @param gamepadObject The gamepad object correlating to this controller
  50016. * @param handedness handedness (left/right/none) of this controller
  50017. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  50018. */
  50019. constructor(scene: Scene, layout: IMotionControllerLayout,
  50020. /**
  50021. * The gamepad object correlating to this controller
  50022. */
  50023. gamepadObject: IMinimalMotionControllerObject,
  50024. /**
  50025. * handedness (left/right/none) of this controller
  50026. */
  50027. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  50028. /**
  50029. * Dispose this controller, the model mesh and all its components
  50030. */
  50031. dispose(): void;
  50032. /**
  50033. * Returns all components of specific type
  50034. * @param type the type to search for
  50035. * @return an array of components with this type
  50036. */
  50037. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  50038. /**
  50039. * get a component based an its component id as defined in layout.components
  50040. * @param id the id of the component
  50041. * @returns the component correlates to the id or undefined if not found
  50042. */
  50043. getComponent(id: string): WebXRControllerComponent;
  50044. /**
  50045. * Get the list of components available in this motion controller
  50046. * @returns an array of strings correlating to available components
  50047. */
  50048. getComponentIds(): string[];
  50049. /**
  50050. * Get the first component of specific type
  50051. * @param type type of component to find
  50052. * @return a controller component or null if not found
  50053. */
  50054. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  50055. /**
  50056. * Get the main (Select) component of this controller as defined in the layout
  50057. * @returns the main component of this controller
  50058. */
  50059. getMainComponent(): WebXRControllerComponent;
  50060. /**
  50061. * Loads the model correlating to this controller
  50062. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  50063. * @returns A promise fulfilled with the result of the model loading
  50064. */
  50065. loadModel(): Promise<boolean>;
  50066. /**
  50067. * Update this model using the current XRFrame
  50068. * @param xrFrame the current xr frame to use and update the model
  50069. */
  50070. updateFromXRFrame(xrFrame: XRFrame): void;
  50071. /**
  50072. * Backwards compatibility due to a deeply-integrated typo
  50073. */
  50074. get handness(): XREye;
  50075. /**
  50076. * Pulse (vibrate) this controller
  50077. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  50078. * Consecutive calls to this function will cancel the last pulse call
  50079. *
  50080. * @param value the strength of the pulse in 0.0...1.0 range
  50081. * @param duration Duration of the pulse in milliseconds
  50082. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  50083. * @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
  50084. */
  50085. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  50086. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50087. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50088. /**
  50089. * Moves the axis on the controller mesh based on its current state
  50090. * @param axis the index of the axis
  50091. * @param axisValue the value of the axis which determines the meshes new position
  50092. * @hidden
  50093. */
  50094. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  50095. /**
  50096. * Update the model itself with the current frame data
  50097. * @param xrFrame the frame to use for updating the model mesh
  50098. */
  50099. protected updateModel(xrFrame: XRFrame): void;
  50100. /**
  50101. * Get the filename and path for this controller's model
  50102. * @returns a map of filename and path
  50103. */
  50104. protected abstract _getFilenameAndPath(): {
  50105. filename: string;
  50106. path: string;
  50107. };
  50108. /**
  50109. * This function is called before the mesh is loaded. It checks for loading constraints.
  50110. * For example, this function can check if the GLB loader is available
  50111. * If this function returns false, the generic controller will be loaded instead
  50112. * @returns Is the client ready to load the mesh
  50113. */
  50114. protected abstract _getModelLoadingConstraints(): boolean;
  50115. /**
  50116. * This function will be called after the model was successfully loaded and can be used
  50117. * for mesh transformations before it is available for the user
  50118. * @param meshes the loaded meshes
  50119. */
  50120. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  50121. /**
  50122. * Set the root mesh for this controller. Important for the WebXR controller class
  50123. * @param meshes the loaded meshes
  50124. */
  50125. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  50126. /**
  50127. * A function executed each frame that updates the mesh (if needed)
  50128. * @param xrFrame the current xrFrame
  50129. */
  50130. protected abstract _updateModel(xrFrame: XRFrame): void;
  50131. private _getGenericFilenameAndPath;
  50132. private _getGenericParentMesh;
  50133. }
  50134. }
  50135. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  50136. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50137. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50138. import { Scene } from "babylonjs/scene";
  50139. /**
  50140. * A generic trigger-only motion controller for WebXR
  50141. */
  50142. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  50143. /**
  50144. * Static version of the profile id of this controller
  50145. */
  50146. static ProfileId: string;
  50147. profileId: string;
  50148. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  50149. protected _getFilenameAndPath(): {
  50150. filename: string;
  50151. path: string;
  50152. };
  50153. protected _getModelLoadingConstraints(): boolean;
  50154. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  50155. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50156. protected _updateModel(): void;
  50157. }
  50158. }
  50159. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  50160. import { Vector4 } from "babylonjs/Maths/math.vector";
  50161. import { Mesh } from "babylonjs/Meshes/mesh";
  50162. import { Scene } from "babylonjs/scene";
  50163. import { Nullable } from "babylonjs/types";
  50164. /**
  50165. * Class containing static functions to help procedurally build meshes
  50166. */
  50167. export class SphereBuilder {
  50168. /**
  50169. * Creates a sphere mesh
  50170. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50171. * * 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`)
  50172. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50173. * * 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
  50174. * * 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)
  50175. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50176. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50178. * @param name defines the name of the mesh
  50179. * @param options defines the options used to create the mesh
  50180. * @param scene defines the hosting scene
  50181. * @returns the sphere mesh
  50182. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50183. */
  50184. static CreateSphere(name: string, options: {
  50185. segments?: number;
  50186. diameter?: number;
  50187. diameterX?: number;
  50188. diameterY?: number;
  50189. diameterZ?: number;
  50190. arc?: number;
  50191. slice?: number;
  50192. sideOrientation?: number;
  50193. frontUVs?: Vector4;
  50194. backUVs?: Vector4;
  50195. updatable?: boolean;
  50196. }, scene?: Nullable<Scene>): Mesh;
  50197. }
  50198. }
  50199. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  50200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50201. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50202. import { Scene } from "babylonjs/scene";
  50203. /**
  50204. * A profiled motion controller has its profile loaded from an online repository.
  50205. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  50206. */
  50207. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  50208. private _repositoryUrl;
  50209. private _buttonMeshMapping;
  50210. private _touchDots;
  50211. /**
  50212. * The profile ID of this controller. Will be populated when the controller initializes.
  50213. */
  50214. profileId: string;
  50215. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  50216. dispose(): void;
  50217. protected _getFilenameAndPath(): {
  50218. filename: string;
  50219. path: string;
  50220. };
  50221. protected _getModelLoadingConstraints(): boolean;
  50222. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  50223. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50224. protected _updateModel(_xrFrame: XRFrame): void;
  50225. }
  50226. }
  50227. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  50228. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50229. import { Scene } from "babylonjs/scene";
  50230. /**
  50231. * A construction function type to create a new controller based on an xrInput object
  50232. */
  50233. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  50234. /**
  50235. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  50236. *
  50237. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  50238. * it should be replaced with auto-loaded controllers.
  50239. *
  50240. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  50241. */
  50242. export class WebXRMotionControllerManager {
  50243. private static _AvailableControllers;
  50244. private static _Fallbacks;
  50245. private static _ProfileLoadingPromises;
  50246. private static _ProfilesList;
  50247. /**
  50248. * The base URL of the online controller repository. Can be changed at any time.
  50249. */
  50250. static BaseRepositoryUrl: string;
  50251. /**
  50252. * Which repository gets priority - local or online
  50253. */
  50254. static PrioritizeOnlineRepository: boolean;
  50255. /**
  50256. * Use the online repository, or use only locally-defined controllers
  50257. */
  50258. static UseOnlineRepository: boolean;
  50259. /**
  50260. * Clear the cache used for profile loading and reload when requested again
  50261. */
  50262. static ClearProfilesCache(): void;
  50263. /**
  50264. * Register the default fallbacks.
  50265. * This function is called automatically when this file is imported.
  50266. */
  50267. static DefaultFallbacks(): void;
  50268. /**
  50269. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  50270. * @param profileId the profile to which a fallback needs to be found
  50271. * @return an array with corresponding fallback profiles
  50272. */
  50273. static FindFallbackWithProfileId(profileId: string): string[];
  50274. /**
  50275. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  50276. * The order of search:
  50277. *
  50278. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  50279. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  50280. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  50281. * 4) return the generic trigger controller if none were found
  50282. *
  50283. * @param xrInput the xrInput to which a new controller is initialized
  50284. * @param scene the scene to which the model will be added
  50285. * @param forceProfile force a certain profile for this controller
  50286. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  50287. */
  50288. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  50289. /**
  50290. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  50291. *
  50292. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  50293. *
  50294. * @param type the profile type to register
  50295. * @param constructFunction the function to be called when loading this profile
  50296. */
  50297. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  50298. /**
  50299. * Register a fallback to a specific profile.
  50300. * @param profileId the profileId that will receive the fallbacks
  50301. * @param fallbacks A list of fallback profiles
  50302. */
  50303. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  50304. /**
  50305. * Will update the list of profiles available in the repository
  50306. * @return a promise that resolves to a map of profiles available online
  50307. */
  50308. static UpdateProfilesList(): Promise<{
  50309. [profile: string]: string;
  50310. }>;
  50311. private static _LoadProfileFromRepository;
  50312. private static _LoadProfilesFromAvailableControllers;
  50313. }
  50314. }
  50315. declare module "babylonjs/XR/webXRInputSource" {
  50316. import { Observable } from "babylonjs/Misc/observable";
  50317. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50318. import { Ray } from "babylonjs/Culling/ray";
  50319. import { Scene } from "babylonjs/scene";
  50320. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50321. /**
  50322. * Configuration options for the WebXR controller creation
  50323. */
  50324. export interface IWebXRControllerOptions {
  50325. /**
  50326. * Should the controller mesh be animated when a user interacts with it
  50327. * The pressed buttons / thumbstick and touchpad animations will be disabled
  50328. */
  50329. disableMotionControllerAnimation?: boolean;
  50330. /**
  50331. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  50332. */
  50333. doNotLoadControllerMesh?: boolean;
  50334. /**
  50335. * Force a specific controller type for this controller.
  50336. * This can be used when creating your own profile or when testing different controllers
  50337. */
  50338. forceControllerProfile?: string;
  50339. /**
  50340. * Defines a rendering group ID for meshes that will be loaded.
  50341. * This is for the default controllers only.
  50342. */
  50343. renderingGroupId?: number;
  50344. }
  50345. /**
  50346. * Represents an XR controller
  50347. */
  50348. export class WebXRInputSource {
  50349. private _scene;
  50350. /** The underlying input source for the controller */
  50351. inputSource: XRInputSource;
  50352. private _options;
  50353. private _tmpVector;
  50354. private _uniqueId;
  50355. private _disposed;
  50356. /**
  50357. * 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
  50358. */
  50359. grip?: AbstractMesh;
  50360. /**
  50361. * If available, this is the gamepad object related to this controller.
  50362. * Using this object it is possible to get click events and trackpad changes of the
  50363. * webxr controller that is currently being used.
  50364. */
  50365. motionController?: WebXRAbstractMotionController;
  50366. /**
  50367. * Event that fires when the controller is removed/disposed.
  50368. * The object provided as event data is this controller, after associated assets were disposed.
  50369. * uniqueId is still available.
  50370. */
  50371. onDisposeObservable: Observable<WebXRInputSource>;
  50372. /**
  50373. * Will be triggered when the mesh associated with the motion controller is done loading.
  50374. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  50375. * A shortened version of controller -> motion controller -> on mesh loaded.
  50376. */
  50377. onMeshLoadedObservable: Observable<AbstractMesh>;
  50378. /**
  50379. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  50380. */
  50381. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  50382. /**
  50383. * Pointer which can be used to select objects or attach a visible laser to
  50384. */
  50385. pointer: AbstractMesh;
  50386. /**
  50387. * Creates the input source object
  50388. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  50389. * @param _scene the scene which the controller should be associated to
  50390. * @param inputSource the underlying input source for the controller
  50391. * @param _options options for this controller creation
  50392. */
  50393. constructor(_scene: Scene,
  50394. /** The underlying input source for the controller */
  50395. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  50396. /**
  50397. * Get this controllers unique id
  50398. */
  50399. get uniqueId(): string;
  50400. /**
  50401. * Disposes of the object
  50402. */
  50403. dispose(): void;
  50404. /**
  50405. * Gets a world space ray coming from the pointer or grip
  50406. * @param result the resulting ray
  50407. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  50408. */
  50409. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  50410. /**
  50411. * Updates the controller pose based on the given XRFrame
  50412. * @param xrFrame xr frame to update the pose with
  50413. * @param referenceSpace reference space to use
  50414. */
  50415. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  50416. }
  50417. }
  50418. declare module "babylonjs/XR/webXRInput" {
  50419. import { Observable } from "babylonjs/Misc/observable";
  50420. import { IDisposable } from "babylonjs/scene";
  50421. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  50422. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50423. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50424. /**
  50425. * The schema for initialization options of the XR Input class
  50426. */
  50427. export interface IWebXRInputOptions {
  50428. /**
  50429. * If set to true no model will be automatically loaded
  50430. */
  50431. doNotLoadControllerMeshes?: boolean;
  50432. /**
  50433. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  50434. * If not found, the xr input profile data will be used.
  50435. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  50436. */
  50437. forceInputProfile?: string;
  50438. /**
  50439. * Do not send a request to the controller repository to load the profile.
  50440. *
  50441. * Instead, use the controllers available in babylon itself.
  50442. */
  50443. disableOnlineControllerRepository?: boolean;
  50444. /**
  50445. * A custom URL for the controllers repository
  50446. */
  50447. customControllersRepositoryURL?: string;
  50448. /**
  50449. * Should the controller model's components not move according to the user input
  50450. */
  50451. disableControllerAnimation?: boolean;
  50452. /**
  50453. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  50454. */
  50455. controllerOptions?: IWebXRControllerOptions;
  50456. }
  50457. /**
  50458. * XR input used to track XR inputs such as controllers/rays
  50459. */
  50460. export class WebXRInput implements IDisposable {
  50461. /**
  50462. * the xr session manager for this session
  50463. */
  50464. xrSessionManager: WebXRSessionManager;
  50465. /**
  50466. * the WebXR camera for this session. Mainly used for teleportation
  50467. */
  50468. xrCamera: WebXRCamera;
  50469. private readonly options;
  50470. /**
  50471. * XR controllers being tracked
  50472. */
  50473. controllers: Array<WebXRInputSource>;
  50474. private _frameObserver;
  50475. private _sessionEndedObserver;
  50476. private _sessionInitObserver;
  50477. /**
  50478. * Event when a controller has been connected/added
  50479. */
  50480. onControllerAddedObservable: Observable<WebXRInputSource>;
  50481. /**
  50482. * Event when a controller has been removed/disconnected
  50483. */
  50484. onControllerRemovedObservable: Observable<WebXRInputSource>;
  50485. /**
  50486. * Initializes the WebXRInput
  50487. * @param xrSessionManager the xr session manager for this session
  50488. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  50489. * @param options = initialization options for this xr input
  50490. */
  50491. constructor(
  50492. /**
  50493. * the xr session manager for this session
  50494. */
  50495. xrSessionManager: WebXRSessionManager,
  50496. /**
  50497. * the WebXR camera for this session. Mainly used for teleportation
  50498. */
  50499. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  50500. private _onInputSourcesChange;
  50501. private _addAndRemoveControllers;
  50502. /**
  50503. * Disposes of the object
  50504. */
  50505. dispose(): void;
  50506. }
  50507. }
  50508. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  50509. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50510. import { Observable, EventState } from "babylonjs/Misc/observable";
  50511. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50512. /**
  50513. * This is the base class for all WebXR features.
  50514. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  50515. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  50516. */
  50517. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  50518. protected _xrSessionManager: WebXRSessionManager;
  50519. private _attached;
  50520. private _removeOnDetach;
  50521. /**
  50522. * Is this feature disposed?
  50523. */
  50524. isDisposed: boolean;
  50525. /**
  50526. * Should auto-attach be disabled?
  50527. */
  50528. disableAutoAttach: boolean;
  50529. /**
  50530. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  50531. */
  50532. xrNativeFeatureName: string;
  50533. /**
  50534. * Construct a new (abstract) WebXR feature
  50535. * @param _xrSessionManager the xr session manager for this feature
  50536. */
  50537. constructor(_xrSessionManager: WebXRSessionManager);
  50538. /**
  50539. * Is this feature attached
  50540. */
  50541. get attached(): boolean;
  50542. /**
  50543. * attach this feature
  50544. *
  50545. * @param force should attachment be forced (even when already attached)
  50546. * @returns true if successful, false is failed or already attached
  50547. */
  50548. attach(force?: boolean): boolean;
  50549. /**
  50550. * detach this feature.
  50551. *
  50552. * @returns true if successful, false if failed or already detached
  50553. */
  50554. detach(): boolean;
  50555. /**
  50556. * Dispose this feature and all of the resources attached
  50557. */
  50558. dispose(): void;
  50559. /**
  50560. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50561. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50562. *
  50563. * @returns whether or not the feature is compatible in this environment
  50564. */
  50565. isCompatible(): boolean;
  50566. /**
  50567. * This is used to register callbacks that will automatically be removed when detach is called.
  50568. * @param observable the observable to which the observer will be attached
  50569. * @param callback the callback to register
  50570. */
  50571. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  50572. /**
  50573. * Code in this function will be executed on each xrFrame received from the browser.
  50574. * This function will not execute after the feature is detached.
  50575. * @param _xrFrame the current frame
  50576. */
  50577. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  50578. }
  50579. }
  50580. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  50581. import { IDisposable, Scene } from "babylonjs/scene";
  50582. import { Nullable } from "babylonjs/types";
  50583. import { Observable } from "babylonjs/Misc/observable";
  50584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50585. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  50586. import { Camera } from "babylonjs/Cameras/camera";
  50587. /**
  50588. * Renders a layer on top of an existing scene
  50589. */
  50590. export class UtilityLayerRenderer implements IDisposable {
  50591. /** the original scene that will be rendered on top of */
  50592. originalScene: Scene;
  50593. private _pointerCaptures;
  50594. private _lastPointerEvents;
  50595. private static _DefaultUtilityLayer;
  50596. private static _DefaultKeepDepthUtilityLayer;
  50597. private _sharedGizmoLight;
  50598. private _renderCamera;
  50599. /**
  50600. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  50601. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  50602. * @returns the camera that is used when rendering the utility layer
  50603. */
  50604. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  50605. /**
  50606. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  50607. * @param cam the camera that should be used when rendering the utility layer
  50608. */
  50609. setRenderCamera(cam: Nullable<Camera>): void;
  50610. /**
  50611. * @hidden
  50612. * Light which used by gizmos to get light shading
  50613. */
  50614. _getSharedGizmoLight(): HemisphericLight;
  50615. /**
  50616. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  50617. */
  50618. pickUtilitySceneFirst: boolean;
  50619. /**
  50620. * 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)
  50621. */
  50622. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  50623. /**
  50624. * 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)
  50625. */
  50626. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  50627. /**
  50628. * The scene that is rendered on top of the original scene
  50629. */
  50630. utilityLayerScene: Scene;
  50631. /**
  50632. * If the utility layer should automatically be rendered on top of existing scene
  50633. */
  50634. shouldRender: boolean;
  50635. /**
  50636. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  50637. */
  50638. onlyCheckPointerDownEvents: boolean;
  50639. /**
  50640. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  50641. */
  50642. processAllEvents: boolean;
  50643. /**
  50644. * Observable raised when the pointer move from the utility layer scene to the main scene
  50645. */
  50646. onPointerOutObservable: Observable<number>;
  50647. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  50648. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  50649. private _afterRenderObserver;
  50650. private _sceneDisposeObserver;
  50651. private _originalPointerObserver;
  50652. /**
  50653. * Instantiates a UtilityLayerRenderer
  50654. * @param originalScene the original scene that will be rendered on top of
  50655. * @param handleEvents boolean indicating if the utility layer should handle events
  50656. */
  50657. constructor(
  50658. /** the original scene that will be rendered on top of */
  50659. originalScene: Scene, handleEvents?: boolean);
  50660. private _notifyObservers;
  50661. /**
  50662. * Renders the utility layers scene on top of the original scene
  50663. */
  50664. render(): void;
  50665. /**
  50666. * Disposes of the renderer
  50667. */
  50668. dispose(): void;
  50669. private _updateCamera;
  50670. }
  50671. }
  50672. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  50673. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50675. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50676. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  50677. import { Scene } from "babylonjs/scene";
  50678. import { Nullable } from "babylonjs/types";
  50679. import { Color3 } from "babylonjs/Maths/math.color";
  50680. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50681. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50682. /**
  50683. * Options interface for the pointer selection module
  50684. */
  50685. export interface IWebXRControllerPointerSelectionOptions {
  50686. /**
  50687. * if provided, this scene will be used to render meshes.
  50688. */
  50689. customUtilityLayerScene?: Scene;
  50690. /**
  50691. * 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)
  50692. * If not disabled, the last picked point will be used to execute a pointer up event
  50693. * If disabled, pointer up event will be triggered right after the pointer down event.
  50694. * Used in screen and gaze target ray mode only
  50695. */
  50696. disablePointerUpOnTouchOut: boolean;
  50697. /**
  50698. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  50699. */
  50700. forceGazeMode: boolean;
  50701. /**
  50702. * 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
  50703. * to start a new countdown to the pointer down event.
  50704. * Defaults to 1.
  50705. */
  50706. gazeModePointerMovedFactor?: number;
  50707. /**
  50708. * Different button type to use instead of the main component
  50709. */
  50710. overrideButtonId?: string;
  50711. /**
  50712. * use this rendering group id for the meshes (optional)
  50713. */
  50714. renderingGroupId?: number;
  50715. /**
  50716. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  50717. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  50718. * 3000 means 3 seconds between pointing at something and selecting it
  50719. */
  50720. timeToSelect?: number;
  50721. /**
  50722. * Should meshes created here be added to a utility layer or the main scene
  50723. */
  50724. useUtilityLayer?: boolean;
  50725. /**
  50726. * Optional WebXR camera to be used for gaze selection
  50727. */
  50728. gazeCamera?: WebXRCamera;
  50729. /**
  50730. * the xr input to use with this pointer selection
  50731. */
  50732. xrInput: WebXRInput;
  50733. }
  50734. /**
  50735. * A module that will enable pointer selection for motion controllers of XR Input Sources
  50736. */
  50737. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  50738. private readonly _options;
  50739. private static _idCounter;
  50740. private _attachController;
  50741. private _controllers;
  50742. private _scene;
  50743. private _tmpVectorForPickCompare;
  50744. /**
  50745. * The module's name
  50746. */
  50747. static readonly Name: string;
  50748. /**
  50749. * The (Babylon) version of this module.
  50750. * This is an integer representing the implementation version.
  50751. * This number does not correspond to the WebXR specs version
  50752. */
  50753. static readonly Version: number;
  50754. /**
  50755. * Disable lighting on the laser pointer (so it will always be visible)
  50756. */
  50757. disablePointerLighting: boolean;
  50758. /**
  50759. * Disable lighting on the selection mesh (so it will always be visible)
  50760. */
  50761. disableSelectionMeshLighting: boolean;
  50762. /**
  50763. * Should the laser pointer be displayed
  50764. */
  50765. displayLaserPointer: boolean;
  50766. /**
  50767. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  50768. */
  50769. displaySelectionMesh: boolean;
  50770. /**
  50771. * This color will be set to the laser pointer when selection is triggered
  50772. */
  50773. laserPointerPickedColor: Color3;
  50774. /**
  50775. * Default color of the laser pointer
  50776. */
  50777. laserPointerDefaultColor: Color3;
  50778. /**
  50779. * default color of the selection ring
  50780. */
  50781. selectionMeshDefaultColor: Color3;
  50782. /**
  50783. * This color will be applied to the selection ring when selection is triggered
  50784. */
  50785. selectionMeshPickedColor: Color3;
  50786. /**
  50787. * Optional filter to be used for ray selection. This predicate shares behavior with
  50788. * scene.pointerMovePredicate which takes priority if it is also assigned.
  50789. */
  50790. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50791. /**
  50792. * constructs a new background remover module
  50793. * @param _xrSessionManager the session manager for this module
  50794. * @param _options read-only options to be used in this module
  50795. */
  50796. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  50797. /**
  50798. * attach this feature
  50799. * Will usually be called by the features manager
  50800. *
  50801. * @returns true if successful.
  50802. */
  50803. attach(): boolean;
  50804. /**
  50805. * detach this feature.
  50806. * Will usually be called by the features manager
  50807. *
  50808. * @returns true if successful.
  50809. */
  50810. detach(): boolean;
  50811. /**
  50812. * Will get the mesh under a specific pointer.
  50813. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  50814. * @param controllerId the controllerId to check
  50815. * @returns The mesh under pointer or null if no mesh is under the pointer
  50816. */
  50817. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  50818. /**
  50819. * Get the xr controller that correlates to the pointer id in the pointer event
  50820. *
  50821. * @param id the pointer id to search for
  50822. * @returns the controller that correlates to this id or null if not found
  50823. */
  50824. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  50825. protected _onXRFrame(_xrFrame: XRFrame): void;
  50826. private _attachGazeMode;
  50827. private _attachScreenRayMode;
  50828. private _attachTrackedPointerRayMode;
  50829. private _convertNormalToDirectionOfRay;
  50830. private _detachController;
  50831. private _generateNewMeshPair;
  50832. private _pickingMoved;
  50833. private _updatePointerDistance;
  50834. /** @hidden */
  50835. get lasterPointerDefaultColor(): Color3;
  50836. }
  50837. }
  50838. declare module "babylonjs/XR/webXREnterExitUI" {
  50839. import { Nullable } from "babylonjs/types";
  50840. import { Observable } from "babylonjs/Misc/observable";
  50841. import { IDisposable, Scene } from "babylonjs/scene";
  50842. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50843. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50844. /**
  50845. * Button which can be used to enter a different mode of XR
  50846. */
  50847. export class WebXREnterExitUIButton {
  50848. /** button element */
  50849. element: HTMLElement;
  50850. /** XR initialization options for the button */
  50851. sessionMode: XRSessionMode;
  50852. /** Reference space type */
  50853. referenceSpaceType: XRReferenceSpaceType;
  50854. /**
  50855. * Creates a WebXREnterExitUIButton
  50856. * @param element button element
  50857. * @param sessionMode XR initialization session mode
  50858. * @param referenceSpaceType the type of reference space to be used
  50859. */
  50860. constructor(
  50861. /** button element */
  50862. element: HTMLElement,
  50863. /** XR initialization options for the button */
  50864. sessionMode: XRSessionMode,
  50865. /** Reference space type */
  50866. referenceSpaceType: XRReferenceSpaceType);
  50867. /**
  50868. * Extendable function which can be used to update the button's visuals when the state changes
  50869. * @param activeButton the current active button in the UI
  50870. */
  50871. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  50872. }
  50873. /**
  50874. * Options to create the webXR UI
  50875. */
  50876. export class WebXREnterExitUIOptions {
  50877. /**
  50878. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  50879. */
  50880. customButtons?: Array<WebXREnterExitUIButton>;
  50881. /**
  50882. * A reference space type to use when creating the default button.
  50883. * Default is local-floor
  50884. */
  50885. referenceSpaceType?: XRReferenceSpaceType;
  50886. /**
  50887. * Context to enter xr with
  50888. */
  50889. renderTarget?: Nullable<WebXRRenderTarget>;
  50890. /**
  50891. * A session mode to use when creating the default button.
  50892. * Default is immersive-vr
  50893. */
  50894. sessionMode?: XRSessionMode;
  50895. /**
  50896. * A list of optional features to init the session with
  50897. */
  50898. optionalFeatures?: string[];
  50899. /**
  50900. * A list of optional features to init the session with
  50901. */
  50902. requiredFeatures?: string[];
  50903. }
  50904. /**
  50905. * UI to allow the user to enter/exit XR mode
  50906. */
  50907. export class WebXREnterExitUI implements IDisposable {
  50908. private scene;
  50909. /** version of the options passed to this UI */
  50910. options: WebXREnterExitUIOptions;
  50911. private _activeButton;
  50912. private _buttons;
  50913. /**
  50914. * The HTML Div Element to which buttons are added.
  50915. */
  50916. readonly overlay: HTMLDivElement;
  50917. /**
  50918. * Fired every time the active button is changed.
  50919. *
  50920. * When xr is entered via a button that launches xr that button will be the callback parameter
  50921. *
  50922. * When exiting xr the callback parameter will be null)
  50923. */
  50924. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  50925. /**
  50926. *
  50927. * @param scene babylon scene object to use
  50928. * @param options (read-only) version of the options passed to this UI
  50929. */
  50930. private constructor();
  50931. /**
  50932. * Creates UI to allow the user to enter/exit XR mode
  50933. * @param scene the scene to add the ui to
  50934. * @param helper the xr experience helper to enter/exit xr with
  50935. * @param options options to configure the UI
  50936. * @returns the created ui
  50937. */
  50938. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  50939. /**
  50940. * Disposes of the XR UI component
  50941. */
  50942. dispose(): void;
  50943. private _updateButtons;
  50944. }
  50945. }
  50946. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  50947. import { Vector3 } from "babylonjs/Maths/math.vector";
  50948. import { Color4 } from "babylonjs/Maths/math.color";
  50949. import { Nullable } from "babylonjs/types";
  50950. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50951. import { Scene } from "babylonjs/scene";
  50952. /**
  50953. * Class containing static functions to help procedurally build meshes
  50954. */
  50955. export class LinesBuilder {
  50956. /**
  50957. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50958. * * 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
  50959. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50960. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50961. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50962. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50963. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50964. * * 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
  50965. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50967. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50968. * @param name defines the name of the new line system
  50969. * @param options defines the options used to create the line system
  50970. * @param scene defines the hosting scene
  50971. * @returns a new line system mesh
  50972. */
  50973. static CreateLineSystem(name: string, options: {
  50974. lines: Vector3[][];
  50975. updatable?: boolean;
  50976. instance?: Nullable<LinesMesh>;
  50977. colors?: Nullable<Color4[][]>;
  50978. useVertexAlpha?: boolean;
  50979. }, scene: Nullable<Scene>): LinesMesh;
  50980. /**
  50981. * Creates a line mesh
  50982. * 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
  50983. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50984. * * The parameter `points` is an array successive Vector3
  50985. * * 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
  50986. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50987. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50988. * * When updating an instance, remember that only point positions can change, not the number of points
  50989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50990. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50991. * @param name defines the name of the new line system
  50992. * @param options defines the options used to create the line system
  50993. * @param scene defines the hosting scene
  50994. * @returns a new line mesh
  50995. */
  50996. static CreateLines(name: string, options: {
  50997. points: Vector3[];
  50998. updatable?: boolean;
  50999. instance?: Nullable<LinesMesh>;
  51000. colors?: Color4[];
  51001. useVertexAlpha?: boolean;
  51002. }, scene?: Nullable<Scene>): LinesMesh;
  51003. /**
  51004. * Creates a dashed line mesh
  51005. * * 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
  51006. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51007. * * The parameter `points` is an array successive Vector3
  51008. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  51009. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  51010. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  51011. * * 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
  51012. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51013. * * When updating an instance, remember that only point positions can change, not the number of points
  51014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51015. * @param name defines the name of the mesh
  51016. * @param options defines the options used to create the mesh
  51017. * @param scene defines the hosting scene
  51018. * @returns the dashed line mesh
  51019. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  51020. */
  51021. static CreateDashedLines(name: string, options: {
  51022. points: Vector3[];
  51023. dashSize?: number;
  51024. gapSize?: number;
  51025. dashNb?: number;
  51026. updatable?: boolean;
  51027. instance?: LinesMesh;
  51028. useVertexAlpha?: boolean;
  51029. }, scene?: Nullable<Scene>): LinesMesh;
  51030. }
  51031. }
  51032. declare module "babylonjs/Misc/timer" {
  51033. import { Observable, Observer } from "babylonjs/Misc/observable";
  51034. import { Nullable } from "babylonjs/types";
  51035. import { IDisposable } from "babylonjs/scene";
  51036. /**
  51037. * Construction options for a timer
  51038. */
  51039. export interface ITimerOptions<T> {
  51040. /**
  51041. * Time-to-end
  51042. */
  51043. timeout: number;
  51044. /**
  51045. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  51046. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  51047. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  51048. */
  51049. contextObservable: Observable<T>;
  51050. /**
  51051. * Optional parameters when adding an observer to the observable
  51052. */
  51053. observableParameters?: {
  51054. mask?: number;
  51055. insertFirst?: boolean;
  51056. scope?: any;
  51057. };
  51058. /**
  51059. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  51060. */
  51061. breakCondition?: (data?: ITimerData<T>) => boolean;
  51062. /**
  51063. * Will be triggered when the time condition has met
  51064. */
  51065. onEnded?: (data: ITimerData<any>) => void;
  51066. /**
  51067. * Will be triggered when the break condition has met (prematurely ended)
  51068. */
  51069. onAborted?: (data: ITimerData<any>) => void;
  51070. /**
  51071. * Optional function to execute on each tick (or count)
  51072. */
  51073. onTick?: (data: ITimerData<any>) => void;
  51074. }
  51075. /**
  51076. * An interface defining the data sent by the timer
  51077. */
  51078. export interface ITimerData<T> {
  51079. /**
  51080. * When did it start
  51081. */
  51082. startTime: number;
  51083. /**
  51084. * Time now
  51085. */
  51086. currentTime: number;
  51087. /**
  51088. * Time passed since started
  51089. */
  51090. deltaTime: number;
  51091. /**
  51092. * How much is completed, in [0.0...1.0].
  51093. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  51094. */
  51095. completeRate: number;
  51096. /**
  51097. * What the registered observable sent in the last count
  51098. */
  51099. payload: T;
  51100. }
  51101. /**
  51102. * The current state of the timer
  51103. */
  51104. export enum TimerState {
  51105. /**
  51106. * Timer initialized, not yet started
  51107. */
  51108. INIT = 0,
  51109. /**
  51110. * Timer started and counting
  51111. */
  51112. STARTED = 1,
  51113. /**
  51114. * Timer ended (whether aborted or time reached)
  51115. */
  51116. ENDED = 2
  51117. }
  51118. /**
  51119. * A simple version of the timer. Will take options and start the timer immediately after calling it
  51120. *
  51121. * @param options options with which to initialize this timer
  51122. */
  51123. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  51124. /**
  51125. * An advanced implementation of a timer class
  51126. */
  51127. export class AdvancedTimer<T = any> implements IDisposable {
  51128. /**
  51129. * Will notify each time the timer calculates the remaining time
  51130. */
  51131. onEachCountObservable: Observable<ITimerData<T>>;
  51132. /**
  51133. * Will trigger when the timer was aborted due to the break condition
  51134. */
  51135. onTimerAbortedObservable: Observable<ITimerData<T>>;
  51136. /**
  51137. * Will trigger when the timer ended successfully
  51138. */
  51139. onTimerEndedObservable: Observable<ITimerData<T>>;
  51140. /**
  51141. * Will trigger when the timer state has changed
  51142. */
  51143. onStateChangedObservable: Observable<TimerState>;
  51144. private _observer;
  51145. private _contextObservable;
  51146. private _observableParameters;
  51147. private _startTime;
  51148. private _timer;
  51149. private _state;
  51150. private _breakCondition;
  51151. private _timeToEnd;
  51152. private _breakOnNextTick;
  51153. /**
  51154. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  51155. * @param options construction options for this advanced timer
  51156. */
  51157. constructor(options: ITimerOptions<T>);
  51158. /**
  51159. * set a breaking condition for this timer. Default is to never break during count
  51160. * @param predicate the new break condition. Returns true to break, false otherwise
  51161. */
  51162. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  51163. /**
  51164. * Reset ALL associated observables in this advanced timer
  51165. */
  51166. clearObservables(): void;
  51167. /**
  51168. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  51169. *
  51170. * @param timeToEnd how much time to measure until timer ended
  51171. */
  51172. start(timeToEnd?: number): void;
  51173. /**
  51174. * Will force a stop on the next tick.
  51175. */
  51176. stop(): void;
  51177. /**
  51178. * Dispose this timer, clearing all resources
  51179. */
  51180. dispose(): void;
  51181. private _setState;
  51182. private _tick;
  51183. private _stop;
  51184. }
  51185. }
  51186. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  51187. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  51188. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51189. import { Nullable } from "babylonjs/types";
  51190. import { WebXRInput } from "babylonjs/XR/webXRInput";
  51191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51192. import { Vector3 } from "babylonjs/Maths/math.vector";
  51193. import { Material } from "babylonjs/Materials/material";
  51194. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  51195. import { Scene } from "babylonjs/scene";
  51196. /**
  51197. * The options container for the teleportation module
  51198. */
  51199. export interface IWebXRTeleportationOptions {
  51200. /**
  51201. * if provided, this scene will be used to render meshes.
  51202. */
  51203. customUtilityLayerScene?: Scene;
  51204. /**
  51205. * Values to configure the default target mesh
  51206. */
  51207. defaultTargetMeshOptions?: {
  51208. /**
  51209. * Fill color of the teleportation area
  51210. */
  51211. teleportationFillColor?: string;
  51212. /**
  51213. * Border color for the teleportation area
  51214. */
  51215. teleportationBorderColor?: string;
  51216. /**
  51217. * Disable the mesh's animation sequence
  51218. */
  51219. disableAnimation?: boolean;
  51220. /**
  51221. * Disable lighting on the material or the ring and arrow
  51222. */
  51223. disableLighting?: boolean;
  51224. /**
  51225. * Override the default material of the torus and arrow
  51226. */
  51227. torusArrowMaterial?: Material;
  51228. };
  51229. /**
  51230. * A list of meshes to use as floor meshes.
  51231. * Meshes can be added and removed after initializing the feature using the
  51232. * addFloorMesh and removeFloorMesh functions
  51233. * If empty, rotation will still work
  51234. */
  51235. floorMeshes?: AbstractMesh[];
  51236. /**
  51237. * use this rendering group id for the meshes (optional)
  51238. */
  51239. renderingGroupId?: number;
  51240. /**
  51241. * Should teleportation move only to snap points
  51242. */
  51243. snapPointsOnly?: boolean;
  51244. /**
  51245. * An array of points to which the teleportation will snap to.
  51246. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  51247. */
  51248. snapPositions?: Vector3[];
  51249. /**
  51250. * How close should the teleportation ray be in order to snap to position.
  51251. * Default to 0.8 units (meters)
  51252. */
  51253. snapToPositionRadius?: number;
  51254. /**
  51255. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  51256. * If you want to support rotation, make sure your mesh has a direction indicator.
  51257. *
  51258. * When left untouched, the default mesh will be initialized.
  51259. */
  51260. teleportationTargetMesh?: AbstractMesh;
  51261. /**
  51262. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  51263. */
  51264. timeToTeleport?: number;
  51265. /**
  51266. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  51267. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  51268. */
  51269. useMainComponentOnly?: boolean;
  51270. /**
  51271. * Should meshes created here be added to a utility layer or the main scene
  51272. */
  51273. useUtilityLayer?: boolean;
  51274. /**
  51275. * Babylon XR Input class for controller
  51276. */
  51277. xrInput: WebXRInput;
  51278. /**
  51279. * Meshes that the teleportation ray cannot go through
  51280. */
  51281. pickBlockerMeshes?: AbstractMesh[];
  51282. }
  51283. /**
  51284. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  51285. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  51286. * the input of the attached controllers.
  51287. */
  51288. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  51289. private _options;
  51290. private _controllers;
  51291. private _currentTeleportationControllerId;
  51292. private _floorMeshes;
  51293. private _quadraticBezierCurve;
  51294. private _selectionFeature;
  51295. private _snapToPositions;
  51296. private _snappedToPoint;
  51297. private _teleportationRingMaterial?;
  51298. private _tmpRay;
  51299. private _tmpVector;
  51300. private _tmpQuaternion;
  51301. /**
  51302. * The module's name
  51303. */
  51304. static readonly Name: string;
  51305. /**
  51306. * The (Babylon) version of this module.
  51307. * This is an integer representing the implementation version.
  51308. * This number does not correspond to the webxr specs version
  51309. */
  51310. static readonly Version: number;
  51311. /**
  51312. * Is movement backwards enabled
  51313. */
  51314. backwardsMovementEnabled: boolean;
  51315. /**
  51316. * Distance to travel when moving backwards
  51317. */
  51318. backwardsTeleportationDistance: number;
  51319. /**
  51320. * The distance from the user to the inspection point in the direction of the controller
  51321. * A higher number will allow the user to move further
  51322. * defaults to 5 (meters, in xr units)
  51323. */
  51324. parabolicCheckRadius: number;
  51325. /**
  51326. * Should the module support parabolic ray on top of direct ray
  51327. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  51328. * Very helpful when moving between floors / different heights
  51329. */
  51330. parabolicRayEnabled: boolean;
  51331. /**
  51332. * How much rotation should be applied when rotating right and left
  51333. */
  51334. rotationAngle: number;
  51335. /**
  51336. * Is rotation enabled when moving forward?
  51337. * Disabling this feature will prevent the user from deciding the direction when teleporting
  51338. */
  51339. rotationEnabled: boolean;
  51340. /**
  51341. * constructs a new anchor system
  51342. * @param _xrSessionManager an instance of WebXRSessionManager
  51343. * @param _options configuration object for this feature
  51344. */
  51345. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  51346. /**
  51347. * Get the snapPointsOnly flag
  51348. */
  51349. get snapPointsOnly(): boolean;
  51350. /**
  51351. * Sets the snapPointsOnly flag
  51352. * @param snapToPoints should teleportation be exclusively to snap points
  51353. */
  51354. set snapPointsOnly(snapToPoints: boolean);
  51355. /**
  51356. * Add a new mesh to the floor meshes array
  51357. * @param mesh the mesh to use as floor mesh
  51358. */
  51359. addFloorMesh(mesh: AbstractMesh): void;
  51360. /**
  51361. * Add a new snap-to point to fix teleportation to this position
  51362. * @param newSnapPoint The new Snap-To point
  51363. */
  51364. addSnapPoint(newSnapPoint: Vector3): void;
  51365. attach(): boolean;
  51366. detach(): boolean;
  51367. dispose(): void;
  51368. /**
  51369. * Remove a mesh from the floor meshes array
  51370. * @param mesh the mesh to remove
  51371. */
  51372. removeFloorMesh(mesh: AbstractMesh): void;
  51373. /**
  51374. * Remove a mesh from the floor meshes array using its name
  51375. * @param name the mesh name to remove
  51376. */
  51377. removeFloorMeshByName(name: string): void;
  51378. /**
  51379. * 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
  51380. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  51381. * @returns was the point found and removed or not
  51382. */
  51383. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  51384. /**
  51385. * This function sets a selection feature that will be disabled when
  51386. * the forward ray is shown and will be reattached when hidden.
  51387. * This is used to remove the selection rays when moving.
  51388. * @param selectionFeature the feature to disable when forward movement is enabled
  51389. */
  51390. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  51391. protected _onXRFrame(_xrFrame: XRFrame): void;
  51392. private _attachController;
  51393. private _createDefaultTargetMesh;
  51394. private _detachController;
  51395. private _findClosestSnapPointWithRadius;
  51396. private _setTargetMeshPosition;
  51397. private _setTargetMeshVisibility;
  51398. private _showParabolicPath;
  51399. private _teleportForward;
  51400. }
  51401. }
  51402. declare module "babylonjs/XR/webXRDefaultExperience" {
  51403. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51404. import { Scene } from "babylonjs/scene";
  51405. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  51406. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  51407. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51408. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  51409. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51410. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51411. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  51412. /**
  51413. * Options for the default xr helper
  51414. */
  51415. export class WebXRDefaultExperienceOptions {
  51416. /**
  51417. * Enable or disable default UI to enter XR
  51418. */
  51419. disableDefaultUI?: boolean;
  51420. /**
  51421. * Should teleportation not initialize. defaults to false.
  51422. */
  51423. disableTeleportation?: boolean;
  51424. /**
  51425. * Floor meshes that will be used for teleport
  51426. */
  51427. floorMeshes?: Array<AbstractMesh>;
  51428. /**
  51429. * If set to true, the first frame will not be used to reset position
  51430. * The first frame is mainly used when copying transformation from the old camera
  51431. * Mainly used in AR
  51432. */
  51433. ignoreNativeCameraTransformation?: boolean;
  51434. /**
  51435. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  51436. */
  51437. inputOptions?: IWebXRInputOptions;
  51438. /**
  51439. * optional configuration for the output canvas
  51440. */
  51441. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  51442. /**
  51443. * optional UI options. This can be used among other to change session mode and reference space type
  51444. */
  51445. uiOptions?: WebXREnterExitUIOptions;
  51446. /**
  51447. * When loading teleportation and pointer select, use stable versions instead of latest.
  51448. */
  51449. useStablePlugins?: boolean;
  51450. /**
  51451. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  51452. */
  51453. renderingGroupId?: number;
  51454. /**
  51455. * A list of optional features to init the session with
  51456. * If set to true, all features we support will be added
  51457. */
  51458. optionalFeatures?: boolean | string[];
  51459. }
  51460. /**
  51461. * Default experience which provides a similar setup to the previous webVRExperience
  51462. */
  51463. export class WebXRDefaultExperience {
  51464. /**
  51465. * Base experience
  51466. */
  51467. baseExperience: WebXRExperienceHelper;
  51468. /**
  51469. * Enables ui for entering/exiting xr
  51470. */
  51471. enterExitUI: WebXREnterExitUI;
  51472. /**
  51473. * Input experience extension
  51474. */
  51475. input: WebXRInput;
  51476. /**
  51477. * Enables laser pointer and selection
  51478. */
  51479. pointerSelection: WebXRControllerPointerSelection;
  51480. /**
  51481. * Default target xr should render to
  51482. */
  51483. renderTarget: WebXRRenderTarget;
  51484. /**
  51485. * Enables teleportation
  51486. */
  51487. teleportation: WebXRMotionControllerTeleportation;
  51488. private constructor();
  51489. /**
  51490. * Creates the default xr experience
  51491. * @param scene scene
  51492. * @param options options for basic configuration
  51493. * @returns resulting WebXRDefaultExperience
  51494. */
  51495. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51496. /**
  51497. * DIsposes of the experience helper
  51498. */
  51499. dispose(): void;
  51500. }
  51501. }
  51502. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  51503. import { Observable } from "babylonjs/Misc/observable";
  51504. import { Nullable } from "babylonjs/types";
  51505. import { Camera } from "babylonjs/Cameras/camera";
  51506. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51507. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51508. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  51509. import { Scene } from "babylonjs/scene";
  51510. import { Vector3 } from "babylonjs/Maths/math.vector";
  51511. import { Color3 } from "babylonjs/Maths/math.color";
  51512. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  51513. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51514. import { Mesh } from "babylonjs/Meshes/mesh";
  51515. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  51516. import { EasingFunction } from "babylonjs/Animations/easing";
  51517. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51518. import "babylonjs/Meshes/Builders/groundBuilder";
  51519. import "babylonjs/Meshes/Builders/torusBuilder";
  51520. import "babylonjs/Meshes/Builders/cylinderBuilder";
  51521. import "babylonjs/Gamepads/gamepadSceneComponent";
  51522. import "babylonjs/Animations/animatable";
  51523. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  51524. /**
  51525. * Options to modify the vr teleportation behavior.
  51526. */
  51527. export interface VRTeleportationOptions {
  51528. /**
  51529. * The name of the mesh which should be used as the teleportation floor. (default: null)
  51530. */
  51531. floorMeshName?: string;
  51532. /**
  51533. * A list of meshes to be used as the teleportation floor. (default: empty)
  51534. */
  51535. floorMeshes?: Mesh[];
  51536. /**
  51537. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  51538. */
  51539. teleportationMode?: number;
  51540. /**
  51541. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  51542. */
  51543. teleportationTime?: number;
  51544. /**
  51545. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  51546. */
  51547. teleportationSpeed?: number;
  51548. /**
  51549. * The easing function used in the animation or null for Linear. (default CircleEase)
  51550. */
  51551. easingFunction?: EasingFunction;
  51552. }
  51553. /**
  51554. * Options to modify the vr experience helper's behavior.
  51555. */
  51556. export interface VRExperienceHelperOptions extends WebVROptions {
  51557. /**
  51558. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  51559. */
  51560. createDeviceOrientationCamera?: boolean;
  51561. /**
  51562. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  51563. */
  51564. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  51565. /**
  51566. * Uses the main button on the controller to toggle the laser casted. (default: true)
  51567. */
  51568. laserToggle?: boolean;
  51569. /**
  51570. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  51571. */
  51572. floorMeshes?: Mesh[];
  51573. /**
  51574. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  51575. */
  51576. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  51577. /**
  51578. * Defines if WebXR should be used instead of WebVR (if available)
  51579. */
  51580. useXR?: boolean;
  51581. }
  51582. /**
  51583. * Event containing information after VR has been entered
  51584. */
  51585. export class OnAfterEnteringVRObservableEvent {
  51586. /**
  51587. * If entering vr was successful
  51588. */
  51589. success: boolean;
  51590. }
  51591. /**
  51592. * Helps to quickly add VR support to an existing scene.
  51593. * See https://doc.babylonjs.com/how_to/webvr_helper
  51594. */
  51595. export class VRExperienceHelper {
  51596. /** Options to modify the vr experience helper's behavior. */
  51597. webVROptions: VRExperienceHelperOptions;
  51598. private _scene;
  51599. private _position;
  51600. private _btnVR;
  51601. private _btnVRDisplayed;
  51602. private _webVRsupported;
  51603. private _webVRready;
  51604. private _webVRrequesting;
  51605. private _webVRpresenting;
  51606. private _hasEnteredVR;
  51607. private _fullscreenVRpresenting;
  51608. private _inputElement;
  51609. private _webVRCamera;
  51610. private _vrDeviceOrientationCamera;
  51611. private _deviceOrientationCamera;
  51612. private _existingCamera;
  51613. private _onKeyDown;
  51614. private _onVrDisplayPresentChange;
  51615. private _onVRDisplayChanged;
  51616. private _onVRRequestPresentStart;
  51617. private _onVRRequestPresentComplete;
  51618. /**
  51619. * 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)
  51620. */
  51621. enableGazeEvenWhenNoPointerLock: boolean;
  51622. /**
  51623. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  51624. */
  51625. exitVROnDoubleTap: boolean;
  51626. /**
  51627. * Observable raised right before entering VR.
  51628. */
  51629. onEnteringVRObservable: Observable<VRExperienceHelper>;
  51630. /**
  51631. * Observable raised when entering VR has completed.
  51632. */
  51633. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  51634. /**
  51635. * Observable raised when exiting VR.
  51636. */
  51637. onExitingVRObservable: Observable<VRExperienceHelper>;
  51638. /**
  51639. * Observable raised when controller mesh is loaded.
  51640. */
  51641. onControllerMeshLoadedObservable: Observable<WebVRController>;
  51642. /** Return this.onEnteringVRObservable
  51643. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  51644. */
  51645. get onEnteringVR(): Observable<VRExperienceHelper>;
  51646. /** Return this.onExitingVRObservable
  51647. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  51648. */
  51649. get onExitingVR(): Observable<VRExperienceHelper>;
  51650. /** Return this.onControllerMeshLoadedObservable
  51651. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  51652. */
  51653. get onControllerMeshLoaded(): Observable<WebVRController>;
  51654. private _rayLength;
  51655. private _useCustomVRButton;
  51656. private _teleportationRequested;
  51657. private _teleportActive;
  51658. private _floorMeshName;
  51659. private _floorMeshesCollection;
  51660. private _teleportationMode;
  51661. private _teleportationTime;
  51662. private _teleportationSpeed;
  51663. private _teleportationEasing;
  51664. private _rotationAllowed;
  51665. private _teleportBackwardsVector;
  51666. private _teleportationTarget;
  51667. private _isDefaultTeleportationTarget;
  51668. private _postProcessMove;
  51669. private _teleportationFillColor;
  51670. private _teleportationBorderColor;
  51671. private _rotationAngle;
  51672. private _haloCenter;
  51673. private _cameraGazer;
  51674. private _padSensibilityUp;
  51675. private _padSensibilityDown;
  51676. private _leftController;
  51677. private _rightController;
  51678. private _gazeColor;
  51679. private _laserColor;
  51680. private _pickedLaserColor;
  51681. private _pickedGazeColor;
  51682. /**
  51683. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  51684. */
  51685. onNewMeshSelected: Observable<AbstractMesh>;
  51686. /**
  51687. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  51688. * This observable will provide the mesh and the controller used to select the mesh
  51689. */
  51690. onMeshSelectedWithController: Observable<{
  51691. mesh: AbstractMesh;
  51692. controller: WebVRController;
  51693. }>;
  51694. /**
  51695. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  51696. */
  51697. onNewMeshPicked: Observable<PickingInfo>;
  51698. private _circleEase;
  51699. /**
  51700. * Observable raised before camera teleportation
  51701. */
  51702. onBeforeCameraTeleport: Observable<Vector3>;
  51703. /**
  51704. * Observable raised after camera teleportation
  51705. */
  51706. onAfterCameraTeleport: Observable<Vector3>;
  51707. /**
  51708. * Observable raised when current selected mesh gets unselected
  51709. */
  51710. onSelectedMeshUnselected: Observable<AbstractMesh>;
  51711. private _raySelectionPredicate;
  51712. /**
  51713. * To be optionaly changed by user to define custom ray selection
  51714. */
  51715. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51716. /**
  51717. * To be optionaly changed by user to define custom selection logic (after ray selection)
  51718. */
  51719. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51720. /**
  51721. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  51722. */
  51723. teleportationEnabled: boolean;
  51724. private _defaultHeight;
  51725. private _teleportationInitialized;
  51726. private _interactionsEnabled;
  51727. private _interactionsRequested;
  51728. private _displayGaze;
  51729. private _displayLaserPointer;
  51730. /**
  51731. * The mesh used to display where the user is going to teleport.
  51732. */
  51733. get teleportationTarget(): Mesh;
  51734. /**
  51735. * Sets the mesh to be used to display where the user is going to teleport.
  51736. */
  51737. set teleportationTarget(value: Mesh);
  51738. /**
  51739. * 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
  51740. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  51741. * See https://doc.babylonjs.com/resources/baking_transformations
  51742. */
  51743. get gazeTrackerMesh(): Mesh;
  51744. set gazeTrackerMesh(value: Mesh);
  51745. /**
  51746. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  51747. */
  51748. updateGazeTrackerScale: boolean;
  51749. /**
  51750. * If the gaze trackers color should be updated when selecting meshes
  51751. */
  51752. updateGazeTrackerColor: boolean;
  51753. /**
  51754. * If the controller laser color should be updated when selecting meshes
  51755. */
  51756. updateControllerLaserColor: boolean;
  51757. /**
  51758. * The gaze tracking mesh corresponding to the left controller
  51759. */
  51760. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  51761. /**
  51762. * The gaze tracking mesh corresponding to the right controller
  51763. */
  51764. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  51765. /**
  51766. * If the ray of the gaze should be displayed.
  51767. */
  51768. get displayGaze(): boolean;
  51769. /**
  51770. * Sets if the ray of the gaze should be displayed.
  51771. */
  51772. set displayGaze(value: boolean);
  51773. /**
  51774. * If the ray of the LaserPointer should be displayed.
  51775. */
  51776. get displayLaserPointer(): boolean;
  51777. /**
  51778. * Sets if the ray of the LaserPointer should be displayed.
  51779. */
  51780. set displayLaserPointer(value: boolean);
  51781. /**
  51782. * The deviceOrientationCamera used as the camera when not in VR.
  51783. */
  51784. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  51785. /**
  51786. * Based on the current WebVR support, returns the current VR camera used.
  51787. */
  51788. get currentVRCamera(): Nullable<Camera>;
  51789. /**
  51790. * The webVRCamera which is used when in VR.
  51791. */
  51792. get webVRCamera(): WebVRFreeCamera;
  51793. /**
  51794. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  51795. */
  51796. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  51797. /**
  51798. * The html button that is used to trigger entering into VR.
  51799. */
  51800. get vrButton(): Nullable<HTMLButtonElement>;
  51801. private get _teleportationRequestInitiated();
  51802. /**
  51803. * Defines whether or not Pointer lock should be requested when switching to
  51804. * full screen.
  51805. */
  51806. requestPointerLockOnFullScreen: boolean;
  51807. /**
  51808. * If asking to force XR, this will be populated with the default xr experience
  51809. */
  51810. xr: WebXRDefaultExperience;
  51811. /**
  51812. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  51813. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  51814. */
  51815. xrTestDone: boolean;
  51816. /**
  51817. * Instantiates a VRExperienceHelper.
  51818. * Helps to quickly add VR support to an existing scene.
  51819. * @param scene The scene the VRExperienceHelper belongs to.
  51820. * @param webVROptions Options to modify the vr experience helper's behavior.
  51821. */
  51822. constructor(scene: Scene,
  51823. /** Options to modify the vr experience helper's behavior. */
  51824. webVROptions?: VRExperienceHelperOptions);
  51825. private completeVRInit;
  51826. private _onDefaultMeshLoaded;
  51827. private _onResize;
  51828. private _onFullscreenChange;
  51829. /**
  51830. * Gets a value indicating if we are currently in VR mode.
  51831. */
  51832. get isInVRMode(): boolean;
  51833. private onVrDisplayPresentChange;
  51834. private onVRDisplayChanged;
  51835. private moveButtonToBottomRight;
  51836. private displayVRButton;
  51837. private updateButtonVisibility;
  51838. private _cachedAngularSensibility;
  51839. /**
  51840. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  51841. * Otherwise, will use the fullscreen API.
  51842. */
  51843. enterVR(): void;
  51844. /**
  51845. * Attempt to exit VR, or fullscreen.
  51846. */
  51847. exitVR(): void;
  51848. /**
  51849. * The position of the vr experience helper.
  51850. */
  51851. get position(): Vector3;
  51852. /**
  51853. * Sets the position of the vr experience helper.
  51854. */
  51855. set position(value: Vector3);
  51856. /**
  51857. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  51858. */
  51859. enableInteractions(): void;
  51860. private get _noControllerIsActive();
  51861. private beforeRender;
  51862. private _isTeleportationFloor;
  51863. /**
  51864. * Adds a floor mesh to be used for teleportation.
  51865. * @param floorMesh the mesh to be used for teleportation.
  51866. */
  51867. addFloorMesh(floorMesh: Mesh): void;
  51868. /**
  51869. * Removes a floor mesh from being used for teleportation.
  51870. * @param floorMesh the mesh to be removed.
  51871. */
  51872. removeFloorMesh(floorMesh: Mesh): void;
  51873. /**
  51874. * Enables interactions and teleportation using the VR controllers and gaze.
  51875. * @param vrTeleportationOptions options to modify teleportation behavior.
  51876. */
  51877. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  51878. private _onNewGamepadConnected;
  51879. private _tryEnableInteractionOnController;
  51880. private _onNewGamepadDisconnected;
  51881. private _enableInteractionOnController;
  51882. private _checkTeleportWithRay;
  51883. private _checkRotate;
  51884. private _checkTeleportBackwards;
  51885. private _enableTeleportationOnController;
  51886. private _createTeleportationCircles;
  51887. private _displayTeleportationTarget;
  51888. private _hideTeleportationTarget;
  51889. private _rotateCamera;
  51890. private _moveTeleportationSelectorTo;
  51891. private _workingVector;
  51892. private _workingQuaternion;
  51893. private _workingMatrix;
  51894. /**
  51895. * Time Constant Teleportation Mode
  51896. */
  51897. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  51898. /**
  51899. * Speed Constant Teleportation Mode
  51900. */
  51901. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  51902. /**
  51903. * Teleports the users feet to the desired location
  51904. * @param location The location where the user's feet should be placed
  51905. */
  51906. teleportCamera(location: Vector3): void;
  51907. private _convertNormalToDirectionOfRay;
  51908. private _castRayAndSelectObject;
  51909. private _notifySelectedMeshUnselected;
  51910. /**
  51911. * Permanently set new colors for the laser pointer
  51912. * @param color the new laser color
  51913. * @param pickedColor the new laser color when picked mesh detected
  51914. */
  51915. setLaserColor(color: Color3, pickedColor?: Color3): void;
  51916. /**
  51917. * Set lighting enabled / disabled on the laser pointer of both controllers
  51918. * @param enabled should the lighting be enabled on the laser pointer
  51919. */
  51920. setLaserLightingState(enabled?: boolean): void;
  51921. /**
  51922. * Permanently set new colors for the gaze pointer
  51923. * @param color the new gaze color
  51924. * @param pickedColor the new gaze color when picked mesh detected
  51925. */
  51926. setGazeColor(color: Color3, pickedColor?: Color3): void;
  51927. /**
  51928. * Sets the color of the laser ray from the vr controllers.
  51929. * @param color new color for the ray.
  51930. */
  51931. changeLaserColor(color: Color3): void;
  51932. /**
  51933. * Sets the color of the ray from the vr headsets gaze.
  51934. * @param color new color for the ray.
  51935. */
  51936. changeGazeColor(color: Color3): void;
  51937. /**
  51938. * Exits VR and disposes of the vr experience helper
  51939. */
  51940. dispose(): void;
  51941. /**
  51942. * Gets the name of the VRExperienceHelper class
  51943. * @returns "VRExperienceHelper"
  51944. */
  51945. getClassName(): string;
  51946. }
  51947. }
  51948. declare module "babylonjs/Cameras/VR/index" {
  51949. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  51950. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  51951. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51952. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  51953. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  51954. export * from "babylonjs/Cameras/VR/webVRCamera";
  51955. }
  51956. declare module "babylonjs/Cameras/RigModes/index" {
  51957. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51958. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51959. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  51960. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  51961. }
  51962. declare module "babylonjs/Cameras/index" {
  51963. export * from "babylonjs/Cameras/Inputs/index";
  51964. export * from "babylonjs/Cameras/cameraInputsManager";
  51965. export * from "babylonjs/Cameras/camera";
  51966. export * from "babylonjs/Cameras/targetCamera";
  51967. export * from "babylonjs/Cameras/freeCamera";
  51968. export * from "babylonjs/Cameras/freeCameraInputsManager";
  51969. export * from "babylonjs/Cameras/touchCamera";
  51970. export * from "babylonjs/Cameras/arcRotateCamera";
  51971. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  51972. export * from "babylonjs/Cameras/deviceOrientationCamera";
  51973. export * from "babylonjs/Cameras/flyCamera";
  51974. export * from "babylonjs/Cameras/flyCameraInputsManager";
  51975. export * from "babylonjs/Cameras/followCamera";
  51976. export * from "babylonjs/Cameras/followCameraInputsManager";
  51977. export * from "babylonjs/Cameras/gamepadCamera";
  51978. export * from "babylonjs/Cameras/Stereoscopic/index";
  51979. export * from "babylonjs/Cameras/universalCamera";
  51980. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  51981. export * from "babylonjs/Cameras/VR/index";
  51982. export * from "babylonjs/Cameras/RigModes/index";
  51983. }
  51984. declare module "babylonjs/Collisions/index" {
  51985. export * from "babylonjs/Collisions/collider";
  51986. export * from "babylonjs/Collisions/collisionCoordinator";
  51987. export * from "babylonjs/Collisions/pickingInfo";
  51988. export * from "babylonjs/Collisions/intersectionInfo";
  51989. export * from "babylonjs/Collisions/meshCollisionData";
  51990. }
  51991. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  51992. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  51993. import { Vector3 } from "babylonjs/Maths/math.vector";
  51994. import { Ray } from "babylonjs/Culling/ray";
  51995. import { Plane } from "babylonjs/Maths/math.plane";
  51996. /**
  51997. * Contains an array of blocks representing the octree
  51998. */
  51999. export interface IOctreeContainer<T> {
  52000. /**
  52001. * Blocks within the octree
  52002. */
  52003. blocks: Array<OctreeBlock<T>>;
  52004. }
  52005. /**
  52006. * Class used to store a cell in an octree
  52007. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52008. */
  52009. export class OctreeBlock<T> {
  52010. /**
  52011. * Gets the content of the current block
  52012. */
  52013. entries: T[];
  52014. /**
  52015. * Gets the list of block children
  52016. */
  52017. blocks: Array<OctreeBlock<T>>;
  52018. private _depth;
  52019. private _maxDepth;
  52020. private _capacity;
  52021. private _minPoint;
  52022. private _maxPoint;
  52023. private _boundingVectors;
  52024. private _creationFunc;
  52025. /**
  52026. * Creates a new block
  52027. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  52028. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  52029. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52030. * @param depth defines the current depth of this block in the octree
  52031. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  52032. * @param creationFunc defines a callback to call when an element is added to the block
  52033. */
  52034. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  52035. /**
  52036. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52037. */
  52038. get capacity(): number;
  52039. /**
  52040. * Gets the minimum vector (in world space) of the block's bounding box
  52041. */
  52042. get minPoint(): Vector3;
  52043. /**
  52044. * Gets the maximum vector (in world space) of the block's bounding box
  52045. */
  52046. get maxPoint(): Vector3;
  52047. /**
  52048. * Add a new element to this block
  52049. * @param entry defines the element to add
  52050. */
  52051. addEntry(entry: T): void;
  52052. /**
  52053. * Remove an element from this block
  52054. * @param entry defines the element to remove
  52055. */
  52056. removeEntry(entry: T): void;
  52057. /**
  52058. * Add an array of elements to this block
  52059. * @param entries defines the array of elements to add
  52060. */
  52061. addEntries(entries: T[]): void;
  52062. /**
  52063. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  52064. * @param frustumPlanes defines the frustum planes to test
  52065. * @param selection defines the array to store current content if selection is positive
  52066. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52067. */
  52068. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52069. /**
  52070. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  52071. * @param sphereCenter defines the bounding sphere center
  52072. * @param sphereRadius defines the bounding sphere radius
  52073. * @param selection defines the array to store current content if selection is positive
  52074. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52075. */
  52076. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52077. /**
  52078. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  52079. * @param ray defines the ray to test with
  52080. * @param selection defines the array to store current content if selection is positive
  52081. */
  52082. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  52083. /**
  52084. * Subdivide the content into child blocks (this block will then be empty)
  52085. */
  52086. createInnerBlocks(): void;
  52087. /**
  52088. * @hidden
  52089. */
  52090. 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;
  52091. }
  52092. }
  52093. declare module "babylonjs/Culling/Octrees/octree" {
  52094. import { SmartArray } from "babylonjs/Misc/smartArray";
  52095. import { Vector3 } from "babylonjs/Maths/math.vector";
  52096. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52098. import { Ray } from "babylonjs/Culling/ray";
  52099. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  52100. import { Plane } from "babylonjs/Maths/math.plane";
  52101. /**
  52102. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  52103. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52104. */
  52105. export class Octree<T> {
  52106. /** 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.) */
  52107. maxDepth: number;
  52108. /**
  52109. * Blocks within the octree containing objects
  52110. */
  52111. blocks: Array<OctreeBlock<T>>;
  52112. /**
  52113. * Content stored in the octree
  52114. */
  52115. dynamicContent: T[];
  52116. private _maxBlockCapacity;
  52117. private _selectionContent;
  52118. private _creationFunc;
  52119. /**
  52120. * Creates a octree
  52121. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52122. * @param creationFunc function to be used to instatiate the octree
  52123. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  52124. * @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.)
  52125. */
  52126. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  52127. /** 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.) */
  52128. maxDepth?: number);
  52129. /**
  52130. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  52131. * @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);
  52132. * @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);
  52133. * @param entries meshes to be added to the octree blocks
  52134. */
  52135. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  52136. /**
  52137. * Adds a mesh to the octree
  52138. * @param entry Mesh to add to the octree
  52139. */
  52140. addMesh(entry: T): void;
  52141. /**
  52142. * Remove an element from the octree
  52143. * @param entry defines the element to remove
  52144. */
  52145. removeMesh(entry: T): void;
  52146. /**
  52147. * Selects an array of meshes within the frustum
  52148. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  52149. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  52150. * @returns array of meshes within the frustum
  52151. */
  52152. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  52153. /**
  52154. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  52155. * @param sphereCenter defines the bounding sphere center
  52156. * @param sphereRadius defines the bounding sphere radius
  52157. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52158. * @returns an array of objects that intersect the sphere
  52159. */
  52160. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  52161. /**
  52162. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  52163. * @param ray defines the ray to test with
  52164. * @returns array of intersected objects
  52165. */
  52166. intersectsRay(ray: Ray): SmartArray<T>;
  52167. /**
  52168. * Adds a mesh into the octree block if it intersects the block
  52169. */
  52170. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  52171. /**
  52172. * Adds a submesh into the octree block if it intersects the block
  52173. */
  52174. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  52175. }
  52176. }
  52177. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  52178. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  52179. import { Scene } from "babylonjs/scene";
  52180. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52182. import { Ray } from "babylonjs/Culling/ray";
  52183. import { Octree } from "babylonjs/Culling/Octrees/octree";
  52184. import { Collider } from "babylonjs/Collisions/collider";
  52185. module "babylonjs/scene" {
  52186. interface Scene {
  52187. /**
  52188. * @hidden
  52189. * Backing Filed
  52190. */
  52191. _selectionOctree: Octree<AbstractMesh>;
  52192. /**
  52193. * Gets the octree used to boost mesh selection (picking)
  52194. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52195. */
  52196. selectionOctree: Octree<AbstractMesh>;
  52197. /**
  52198. * Creates or updates the octree used to boost selection (picking)
  52199. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52200. * @param maxCapacity defines the maximum capacity per leaf
  52201. * @param maxDepth defines the maximum depth of the octree
  52202. * @returns an octree of AbstractMesh
  52203. */
  52204. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  52205. }
  52206. }
  52207. module "babylonjs/Meshes/abstractMesh" {
  52208. interface AbstractMesh {
  52209. /**
  52210. * @hidden
  52211. * Backing Field
  52212. */
  52213. _submeshesOctree: Octree<SubMesh>;
  52214. /**
  52215. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  52216. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  52217. * @param maxCapacity defines the maximum size of each block (64 by default)
  52218. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  52219. * @returns the new octree
  52220. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  52221. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52222. */
  52223. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  52224. }
  52225. }
  52226. /**
  52227. * Defines the octree scene component responsible to manage any octrees
  52228. * in a given scene.
  52229. */
  52230. export class OctreeSceneComponent {
  52231. /**
  52232. * The component name help to identify the component in the list of scene components.
  52233. */
  52234. readonly name: string;
  52235. /**
  52236. * The scene the component belongs to.
  52237. */
  52238. scene: Scene;
  52239. /**
  52240. * Indicates if the meshes have been checked to make sure they are isEnabled()
  52241. */
  52242. readonly checksIsEnabled: boolean;
  52243. /**
  52244. * Creates a new instance of the component for the given scene
  52245. * @param scene Defines the scene to register the component in
  52246. */
  52247. constructor(scene: Scene);
  52248. /**
  52249. * Registers the component in a given scene
  52250. */
  52251. register(): void;
  52252. /**
  52253. * Return the list of active meshes
  52254. * @returns the list of active meshes
  52255. */
  52256. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  52257. /**
  52258. * Return the list of active sub meshes
  52259. * @param mesh The mesh to get the candidates sub meshes from
  52260. * @returns the list of active sub meshes
  52261. */
  52262. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  52263. private _tempRay;
  52264. /**
  52265. * Return the list of sub meshes intersecting with a given local ray
  52266. * @param mesh defines the mesh to find the submesh for
  52267. * @param localRay defines the ray in local space
  52268. * @returns the list of intersecting sub meshes
  52269. */
  52270. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  52271. /**
  52272. * Return the list of sub meshes colliding with a collider
  52273. * @param mesh defines the mesh to find the submesh for
  52274. * @param collider defines the collider to evaluate the collision against
  52275. * @returns the list of colliding sub meshes
  52276. */
  52277. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  52278. /**
  52279. * Rebuilds the elements related to this component in case of
  52280. * context lost for instance.
  52281. */
  52282. rebuild(): void;
  52283. /**
  52284. * Disposes the component and the associated ressources.
  52285. */
  52286. dispose(): void;
  52287. }
  52288. }
  52289. declare module "babylonjs/Culling/Octrees/index" {
  52290. export * from "babylonjs/Culling/Octrees/octree";
  52291. export * from "babylonjs/Culling/Octrees/octreeBlock";
  52292. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  52293. }
  52294. declare module "babylonjs/Culling/index" {
  52295. export * from "babylonjs/Culling/boundingBox";
  52296. export * from "babylonjs/Culling/boundingInfo";
  52297. export * from "babylonjs/Culling/boundingSphere";
  52298. export * from "babylonjs/Culling/Octrees/index";
  52299. export * from "babylonjs/Culling/ray";
  52300. }
  52301. declare module "babylonjs/Gizmos/gizmo" {
  52302. import { Nullable } from "babylonjs/types";
  52303. import { IDisposable } from "babylonjs/scene";
  52304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52305. import { Mesh } from "babylonjs/Meshes/mesh";
  52306. import { Node } from "babylonjs/node";
  52307. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52308. /**
  52309. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  52310. */
  52311. export class Gizmo implements IDisposable {
  52312. /** The utility layer the gizmo will be added to */
  52313. gizmoLayer: UtilityLayerRenderer;
  52314. /**
  52315. * The root mesh of the gizmo
  52316. */
  52317. _rootMesh: Mesh;
  52318. private _attachedMesh;
  52319. private _attachedNode;
  52320. /**
  52321. * Ratio for the scale of the gizmo (Default: 1)
  52322. */
  52323. protected _scaleRatio: number;
  52324. /**
  52325. * Ratio for the scale of the gizmo (Default: 1)
  52326. */
  52327. set scaleRatio(value: number);
  52328. get scaleRatio(): number;
  52329. /**
  52330. * If a custom mesh has been set (Default: false)
  52331. */
  52332. protected _customMeshSet: boolean;
  52333. /**
  52334. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  52335. * * When set, interactions will be enabled
  52336. */
  52337. get attachedMesh(): Nullable<AbstractMesh>;
  52338. set attachedMesh(value: Nullable<AbstractMesh>);
  52339. /**
  52340. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  52341. * * When set, interactions will be enabled
  52342. */
  52343. get attachedNode(): Nullable<Node>;
  52344. set attachedNode(value: Nullable<Node>);
  52345. /**
  52346. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52347. * @param mesh The mesh to replace the default mesh of the gizmo
  52348. */
  52349. setCustomMesh(mesh: Mesh): void;
  52350. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  52351. /**
  52352. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  52353. */
  52354. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52355. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52356. /**
  52357. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  52358. */
  52359. updateGizmoPositionToMatchAttachedMesh: boolean;
  52360. /**
  52361. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  52362. */
  52363. updateScale: boolean;
  52364. protected _interactionsEnabled: boolean;
  52365. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52366. private _beforeRenderObserver;
  52367. private _tempQuaternion;
  52368. private _tempVector;
  52369. private _tempVector2;
  52370. private _tempMatrix1;
  52371. private _tempMatrix2;
  52372. private _rightHandtoLeftHandMatrix;
  52373. /**
  52374. * Creates a gizmo
  52375. * @param gizmoLayer The utility layer the gizmo will be added to
  52376. */
  52377. constructor(
  52378. /** The utility layer the gizmo will be added to */
  52379. gizmoLayer?: UtilityLayerRenderer);
  52380. /**
  52381. * Updates the gizmo to match the attached mesh's position/rotation
  52382. */
  52383. protected _update(): void;
  52384. /**
  52385. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  52386. * @param value Node, TransformNode or mesh
  52387. */
  52388. protected _matrixChanged(): void;
  52389. /**
  52390. * Disposes of the gizmo
  52391. */
  52392. dispose(): void;
  52393. }
  52394. }
  52395. declare module "babylonjs/Gizmos/planeDragGizmo" {
  52396. import { Observable } from "babylonjs/Misc/observable";
  52397. import { Nullable } from "babylonjs/types";
  52398. import { Vector3 } from "babylonjs/Maths/math.vector";
  52399. import { Color3 } from "babylonjs/Maths/math.color";
  52400. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52401. import { Node } from "babylonjs/node";
  52402. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52403. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52404. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52405. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52406. import { Scene } from "babylonjs/scene";
  52407. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52408. /**
  52409. * Single plane drag gizmo
  52410. */
  52411. export class PlaneDragGizmo extends Gizmo {
  52412. /**
  52413. * Drag behavior responsible for the gizmos dragging interactions
  52414. */
  52415. dragBehavior: PointerDragBehavior;
  52416. private _pointerObserver;
  52417. /**
  52418. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52419. */
  52420. snapDistance: number;
  52421. /**
  52422. * Event that fires each time the gizmo snaps to a new location.
  52423. * * snapDistance is the the change in distance
  52424. */
  52425. onSnapObservable: Observable<{
  52426. snapDistance: number;
  52427. }>;
  52428. private _plane;
  52429. private _coloredMaterial;
  52430. private _hoverMaterial;
  52431. private _isEnabled;
  52432. private _parent;
  52433. /** @hidden */
  52434. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  52435. /** @hidden */
  52436. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52437. /**
  52438. * Creates a PlaneDragGizmo
  52439. * @param gizmoLayer The utility layer the gizmo will be added to
  52440. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  52441. * @param color The color of the gizmo
  52442. */
  52443. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  52444. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52445. /**
  52446. * If the gizmo is enabled
  52447. */
  52448. set isEnabled(value: boolean);
  52449. get isEnabled(): boolean;
  52450. /**
  52451. * Disposes of the gizmo
  52452. */
  52453. dispose(): void;
  52454. }
  52455. }
  52456. declare module "babylonjs/Gizmos/positionGizmo" {
  52457. import { Observable } from "babylonjs/Misc/observable";
  52458. import { Nullable } from "babylonjs/types";
  52459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52460. import { Node } from "babylonjs/node";
  52461. import { Mesh } from "babylonjs/Meshes/mesh";
  52462. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52463. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  52464. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  52465. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52466. /**
  52467. * Gizmo that enables dragging a mesh along 3 axis
  52468. */
  52469. export class PositionGizmo extends Gizmo {
  52470. /**
  52471. * Internal gizmo used for interactions on the x axis
  52472. */
  52473. xGizmo: AxisDragGizmo;
  52474. /**
  52475. * Internal gizmo used for interactions on the y axis
  52476. */
  52477. yGizmo: AxisDragGizmo;
  52478. /**
  52479. * Internal gizmo used for interactions on the z axis
  52480. */
  52481. zGizmo: AxisDragGizmo;
  52482. /**
  52483. * Internal gizmo used for interactions on the yz plane
  52484. */
  52485. xPlaneGizmo: PlaneDragGizmo;
  52486. /**
  52487. * Internal gizmo used for interactions on the xz plane
  52488. */
  52489. yPlaneGizmo: PlaneDragGizmo;
  52490. /**
  52491. * Internal gizmo used for interactions on the xy plane
  52492. */
  52493. zPlaneGizmo: PlaneDragGizmo;
  52494. /**
  52495. * private variables
  52496. */
  52497. private _meshAttached;
  52498. private _nodeAttached;
  52499. private _snapDistance;
  52500. /** Fires an event when any of it's sub gizmos are dragged */
  52501. onDragStartObservable: Observable<unknown>;
  52502. /** Fires an event when any of it's sub gizmos are released from dragging */
  52503. onDragEndObservable: Observable<unknown>;
  52504. /**
  52505. * If set to true, planar drag is enabled
  52506. */
  52507. private _planarGizmoEnabled;
  52508. get attachedMesh(): Nullable<AbstractMesh>;
  52509. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52510. get attachedNode(): Nullable<Node>;
  52511. set attachedNode(node: Nullable<Node>);
  52512. /**
  52513. * Creates a PositionGizmo
  52514. * @param gizmoLayer The utility layer the gizmo will be added to
  52515. @param thickness display gizmo axis thickness
  52516. */
  52517. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52518. /**
  52519. * If the planar drag gizmo is enabled
  52520. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  52521. */
  52522. set planarGizmoEnabled(value: boolean);
  52523. get planarGizmoEnabled(): boolean;
  52524. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52525. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52526. /**
  52527. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52528. */
  52529. set snapDistance(value: number);
  52530. get snapDistance(): number;
  52531. /**
  52532. * Ratio for the scale of the gizmo (Default: 1)
  52533. */
  52534. set scaleRatio(value: number);
  52535. get scaleRatio(): number;
  52536. /**
  52537. * Disposes of the gizmo
  52538. */
  52539. dispose(): void;
  52540. /**
  52541. * CustomMeshes are not supported by this gizmo
  52542. * @param mesh The mesh to replace the default mesh of the gizmo
  52543. */
  52544. setCustomMesh(mesh: Mesh): void;
  52545. }
  52546. }
  52547. declare module "babylonjs/Gizmos/axisDragGizmo" {
  52548. import { Observable } from "babylonjs/Misc/observable";
  52549. import { Nullable } from "babylonjs/types";
  52550. import { Vector3 } from "babylonjs/Maths/math.vector";
  52551. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52552. import { Node } from "babylonjs/node";
  52553. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52554. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52555. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52556. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52557. import { Scene } from "babylonjs/scene";
  52558. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52559. import { Color3 } from "babylonjs/Maths/math.color";
  52560. /**
  52561. * Single axis drag gizmo
  52562. */
  52563. export class AxisDragGizmo extends Gizmo {
  52564. /**
  52565. * Drag behavior responsible for the gizmos dragging interactions
  52566. */
  52567. dragBehavior: PointerDragBehavior;
  52568. private _pointerObserver;
  52569. /**
  52570. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52571. */
  52572. snapDistance: number;
  52573. /**
  52574. * Event that fires each time the gizmo snaps to a new location.
  52575. * * snapDistance is the the change in distance
  52576. */
  52577. onSnapObservable: Observable<{
  52578. snapDistance: number;
  52579. }>;
  52580. private _isEnabled;
  52581. private _parent;
  52582. private _arrow;
  52583. private _coloredMaterial;
  52584. private _hoverMaterial;
  52585. /** @hidden */
  52586. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  52587. /** @hidden */
  52588. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52589. /**
  52590. * Creates an AxisDragGizmo
  52591. * @param gizmoLayer The utility layer the gizmo will be added to
  52592. * @param dragAxis The axis which the gizmo will be able to drag on
  52593. * @param color The color of the gizmo
  52594. * @param thickness display gizmo axis thickness
  52595. */
  52596. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  52597. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52598. /**
  52599. * If the gizmo is enabled
  52600. */
  52601. set isEnabled(value: boolean);
  52602. get isEnabled(): boolean;
  52603. /**
  52604. * Disposes of the gizmo
  52605. */
  52606. dispose(): void;
  52607. }
  52608. }
  52609. declare module "babylonjs/Debug/axesViewer" {
  52610. import { Vector3 } from "babylonjs/Maths/math.vector";
  52611. import { Nullable } from "babylonjs/types";
  52612. import { Scene } from "babylonjs/scene";
  52613. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52614. /**
  52615. * The Axes viewer will show 3 axes in a specific point in space
  52616. */
  52617. export class AxesViewer {
  52618. private _xAxis;
  52619. private _yAxis;
  52620. private _zAxis;
  52621. private _scaleLinesFactor;
  52622. private _instanced;
  52623. /**
  52624. * Gets the hosting scene
  52625. */
  52626. scene: Nullable<Scene>;
  52627. /**
  52628. * Gets or sets a number used to scale line length
  52629. */
  52630. scaleLines: number;
  52631. /** Gets the node hierarchy used to render x-axis */
  52632. get xAxis(): TransformNode;
  52633. /** Gets the node hierarchy used to render y-axis */
  52634. get yAxis(): TransformNode;
  52635. /** Gets the node hierarchy used to render z-axis */
  52636. get zAxis(): TransformNode;
  52637. /**
  52638. * Creates a new AxesViewer
  52639. * @param scene defines the hosting scene
  52640. * @param scaleLines defines a number used to scale line length (1 by default)
  52641. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  52642. * @param xAxis defines the node hierarchy used to render the x-axis
  52643. * @param yAxis defines the node hierarchy used to render the y-axis
  52644. * @param zAxis defines the node hierarchy used to render the z-axis
  52645. */
  52646. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  52647. /**
  52648. * Force the viewer to update
  52649. * @param position defines the position of the viewer
  52650. * @param xaxis defines the x axis of the viewer
  52651. * @param yaxis defines the y axis of the viewer
  52652. * @param zaxis defines the z axis of the viewer
  52653. */
  52654. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  52655. /**
  52656. * Creates an instance of this axes viewer.
  52657. * @returns a new axes viewer with instanced meshes
  52658. */
  52659. createInstance(): AxesViewer;
  52660. /** Releases resources */
  52661. dispose(): void;
  52662. private static _SetRenderingGroupId;
  52663. }
  52664. }
  52665. declare module "babylonjs/Debug/boneAxesViewer" {
  52666. import { Nullable } from "babylonjs/types";
  52667. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  52668. import { Vector3 } from "babylonjs/Maths/math.vector";
  52669. import { Mesh } from "babylonjs/Meshes/mesh";
  52670. import { Bone } from "babylonjs/Bones/bone";
  52671. import { Scene } from "babylonjs/scene";
  52672. /**
  52673. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  52674. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  52675. */
  52676. export class BoneAxesViewer extends AxesViewer {
  52677. /**
  52678. * Gets or sets the target mesh where to display the axes viewer
  52679. */
  52680. mesh: Nullable<Mesh>;
  52681. /**
  52682. * Gets or sets the target bone where to display the axes viewer
  52683. */
  52684. bone: Nullable<Bone>;
  52685. /** Gets current position */
  52686. pos: Vector3;
  52687. /** Gets direction of X axis */
  52688. xaxis: Vector3;
  52689. /** Gets direction of Y axis */
  52690. yaxis: Vector3;
  52691. /** Gets direction of Z axis */
  52692. zaxis: Vector3;
  52693. /**
  52694. * Creates a new BoneAxesViewer
  52695. * @param scene defines the hosting scene
  52696. * @param bone defines the target bone
  52697. * @param mesh defines the target mesh
  52698. * @param scaleLines defines a scaling factor for line length (1 by default)
  52699. */
  52700. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  52701. /**
  52702. * Force the viewer to update
  52703. */
  52704. update(): void;
  52705. /** Releases resources */
  52706. dispose(): void;
  52707. }
  52708. }
  52709. declare module "babylonjs/Debug/debugLayer" {
  52710. import { Scene } from "babylonjs/scene";
  52711. /**
  52712. * Interface used to define scene explorer extensibility option
  52713. */
  52714. export interface IExplorerExtensibilityOption {
  52715. /**
  52716. * Define the option label
  52717. */
  52718. label: string;
  52719. /**
  52720. * Defines the action to execute on click
  52721. */
  52722. action: (entity: any) => void;
  52723. }
  52724. /**
  52725. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  52726. */
  52727. export interface IExplorerExtensibilityGroup {
  52728. /**
  52729. * Defines a predicate to test if a given type mut be extended
  52730. */
  52731. predicate: (entity: any) => boolean;
  52732. /**
  52733. * Gets the list of options added to a type
  52734. */
  52735. entries: IExplorerExtensibilityOption[];
  52736. }
  52737. /**
  52738. * Interface used to define the options to use to create the Inspector
  52739. */
  52740. export interface IInspectorOptions {
  52741. /**
  52742. * Display in overlay mode (default: false)
  52743. */
  52744. overlay?: boolean;
  52745. /**
  52746. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  52747. */
  52748. globalRoot?: HTMLElement;
  52749. /**
  52750. * Display the Scene explorer
  52751. */
  52752. showExplorer?: boolean;
  52753. /**
  52754. * Display the property inspector
  52755. */
  52756. showInspector?: boolean;
  52757. /**
  52758. * Display in embed mode (both panes on the right)
  52759. */
  52760. embedMode?: boolean;
  52761. /**
  52762. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  52763. */
  52764. handleResize?: boolean;
  52765. /**
  52766. * Allow the panes to popup (default: true)
  52767. */
  52768. enablePopup?: boolean;
  52769. /**
  52770. * Allow the panes to be closed by users (default: true)
  52771. */
  52772. enableClose?: boolean;
  52773. /**
  52774. * Optional list of extensibility entries
  52775. */
  52776. explorerExtensibility?: IExplorerExtensibilityGroup[];
  52777. /**
  52778. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  52779. */
  52780. inspectorURL?: string;
  52781. /**
  52782. * Optional initial tab (default to DebugLayerTab.Properties)
  52783. */
  52784. initialTab?: DebugLayerTab;
  52785. }
  52786. module "babylonjs/scene" {
  52787. interface Scene {
  52788. /**
  52789. * @hidden
  52790. * Backing field
  52791. */
  52792. _debugLayer: DebugLayer;
  52793. /**
  52794. * Gets the debug layer (aka Inspector) associated with the scene
  52795. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52796. */
  52797. debugLayer: DebugLayer;
  52798. }
  52799. }
  52800. /**
  52801. * Enum of inspector action tab
  52802. */
  52803. export enum DebugLayerTab {
  52804. /**
  52805. * Properties tag (default)
  52806. */
  52807. Properties = 0,
  52808. /**
  52809. * Debug tab
  52810. */
  52811. Debug = 1,
  52812. /**
  52813. * Statistics tab
  52814. */
  52815. Statistics = 2,
  52816. /**
  52817. * Tools tab
  52818. */
  52819. Tools = 3,
  52820. /**
  52821. * Settings tab
  52822. */
  52823. Settings = 4
  52824. }
  52825. /**
  52826. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52827. * what is happening in your scene
  52828. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52829. */
  52830. export class DebugLayer {
  52831. /**
  52832. * Define the url to get the inspector script from.
  52833. * By default it uses the babylonjs CDN.
  52834. * @ignoreNaming
  52835. */
  52836. static InspectorURL: string;
  52837. private _scene;
  52838. private BJSINSPECTOR;
  52839. private _onPropertyChangedObservable?;
  52840. /**
  52841. * Observable triggered when a property is changed through the inspector.
  52842. */
  52843. get onPropertyChangedObservable(): any;
  52844. /**
  52845. * Instantiates a new debug layer.
  52846. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52847. * what is happening in your scene
  52848. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52849. * @param scene Defines the scene to inspect
  52850. */
  52851. constructor(scene: Scene);
  52852. /** Creates the inspector window. */
  52853. private _createInspector;
  52854. /**
  52855. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  52856. * @param entity defines the entity to select
  52857. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  52858. */
  52859. select(entity: any, lineContainerTitles?: string | string[]): void;
  52860. /** Get the inspector from bundle or global */
  52861. private _getGlobalInspector;
  52862. /**
  52863. * Get if the inspector is visible or not.
  52864. * @returns true if visible otherwise, false
  52865. */
  52866. isVisible(): boolean;
  52867. /**
  52868. * Hide the inspector and close its window.
  52869. */
  52870. hide(): void;
  52871. /**
  52872. * Update the scene in the inspector
  52873. */
  52874. setAsActiveScene(): void;
  52875. /**
  52876. * Launch the debugLayer.
  52877. * @param config Define the configuration of the inspector
  52878. * @return a promise fulfilled when the debug layer is visible
  52879. */
  52880. show(config?: IInspectorOptions): Promise<DebugLayer>;
  52881. }
  52882. }
  52883. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  52884. import { Nullable } from "babylonjs/types";
  52885. import { Scene } from "babylonjs/scene";
  52886. import { Vector4 } from "babylonjs/Maths/math.vector";
  52887. import { Color4 } from "babylonjs/Maths/math.color";
  52888. import { Mesh } from "babylonjs/Meshes/mesh";
  52889. /**
  52890. * Class containing static functions to help procedurally build meshes
  52891. */
  52892. export class BoxBuilder {
  52893. /**
  52894. * Creates a box mesh
  52895. * * The parameter `size` sets the size (float) of each box side (default 1)
  52896. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52897. * * 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)
  52898. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52899. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52900. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52902. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52903. * @param name defines the name of the mesh
  52904. * @param options defines the options used to create the mesh
  52905. * @param scene defines the hosting scene
  52906. * @returns the box mesh
  52907. */
  52908. static CreateBox(name: string, options: {
  52909. size?: number;
  52910. width?: number;
  52911. height?: number;
  52912. depth?: number;
  52913. faceUV?: Vector4[];
  52914. faceColors?: Color4[];
  52915. sideOrientation?: number;
  52916. frontUVs?: Vector4;
  52917. backUVs?: Vector4;
  52918. wrap?: boolean;
  52919. topBaseAt?: number;
  52920. bottomBaseAt?: number;
  52921. updatable?: boolean;
  52922. }, scene?: Nullable<Scene>): Mesh;
  52923. }
  52924. }
  52925. declare module "babylonjs/Debug/physicsViewer" {
  52926. import { Nullable } from "babylonjs/types";
  52927. import { Scene } from "babylonjs/scene";
  52928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52929. import { Mesh } from "babylonjs/Meshes/mesh";
  52930. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52931. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52932. /**
  52933. * Used to show the physics impostor around the specific mesh
  52934. */
  52935. export class PhysicsViewer {
  52936. /** @hidden */
  52937. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  52938. /** @hidden */
  52939. protected _meshes: Array<Nullable<AbstractMesh>>;
  52940. /** @hidden */
  52941. protected _scene: Nullable<Scene>;
  52942. /** @hidden */
  52943. protected _numMeshes: number;
  52944. /** @hidden */
  52945. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  52946. private _renderFunction;
  52947. private _utilityLayer;
  52948. private _debugBoxMesh;
  52949. private _debugSphereMesh;
  52950. private _debugCylinderMesh;
  52951. private _debugMaterial;
  52952. private _debugMeshMeshes;
  52953. /**
  52954. * Creates a new PhysicsViewer
  52955. * @param scene defines the hosting scene
  52956. */
  52957. constructor(scene: Scene);
  52958. /** @hidden */
  52959. protected _updateDebugMeshes(): void;
  52960. /**
  52961. * Renders a specified physic impostor
  52962. * @param impostor defines the impostor to render
  52963. * @param targetMesh defines the mesh represented by the impostor
  52964. * @returns the new debug mesh used to render the impostor
  52965. */
  52966. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  52967. /**
  52968. * Hides a specified physic impostor
  52969. * @param impostor defines the impostor to hide
  52970. */
  52971. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  52972. private _getDebugMaterial;
  52973. private _getDebugBoxMesh;
  52974. private _getDebugSphereMesh;
  52975. private _getDebugCylinderMesh;
  52976. private _getDebugMeshMesh;
  52977. private _getDebugMesh;
  52978. /** Releases all resources */
  52979. dispose(): void;
  52980. }
  52981. }
  52982. declare module "babylonjs/Debug/rayHelper" {
  52983. import { Nullable } from "babylonjs/types";
  52984. import { Ray } from "babylonjs/Culling/ray";
  52985. import { Vector3 } from "babylonjs/Maths/math.vector";
  52986. import { Color3 } from "babylonjs/Maths/math.color";
  52987. import { Scene } from "babylonjs/scene";
  52988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52989. import "babylonjs/Meshes/Builders/linesBuilder";
  52990. /**
  52991. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52992. * in order to better appreciate the issue one might have.
  52993. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52994. */
  52995. export class RayHelper {
  52996. /**
  52997. * Defines the ray we are currently tryin to visualize.
  52998. */
  52999. ray: Nullable<Ray>;
  53000. private _renderPoints;
  53001. private _renderLine;
  53002. private _renderFunction;
  53003. private _scene;
  53004. private _onAfterRenderObserver;
  53005. private _onAfterStepObserver;
  53006. private _attachedToMesh;
  53007. private _meshSpaceDirection;
  53008. private _meshSpaceOrigin;
  53009. /**
  53010. * Helper function to create a colored helper in a scene in one line.
  53011. * @param ray Defines the ray we are currently tryin to visualize
  53012. * @param scene Defines the scene the ray is used in
  53013. * @param color Defines the color we want to see the ray in
  53014. * @returns The newly created ray helper.
  53015. */
  53016. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  53017. /**
  53018. * Instantiate a new ray helper.
  53019. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53020. * in order to better appreciate the issue one might have.
  53021. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53022. * @param ray Defines the ray we are currently tryin to visualize
  53023. */
  53024. constructor(ray: Ray);
  53025. /**
  53026. * Shows the ray we are willing to debug.
  53027. * @param scene Defines the scene the ray needs to be rendered in
  53028. * @param color Defines the color the ray needs to be rendered in
  53029. */
  53030. show(scene: Scene, color?: Color3): void;
  53031. /**
  53032. * Hides the ray we are debugging.
  53033. */
  53034. hide(): void;
  53035. private _render;
  53036. /**
  53037. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  53038. * @param mesh Defines the mesh we want the helper attached to
  53039. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  53040. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  53041. * @param length Defines the length of the ray
  53042. */
  53043. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  53044. /**
  53045. * Detach the ray helper from the mesh it has previously been attached to.
  53046. */
  53047. detachFromMesh(): void;
  53048. private _updateToMesh;
  53049. /**
  53050. * Dispose the helper and release its associated resources.
  53051. */
  53052. dispose(): void;
  53053. }
  53054. }
  53055. declare module "babylonjs/Debug/ISkeletonViewer" {
  53056. import { Skeleton } from "babylonjs/Bones/skeleton";
  53057. import { Color3 } from "babylonjs/Maths/math.color";
  53058. /**
  53059. * Defines the options associated with the creation of a SkeletonViewer.
  53060. */
  53061. export interface ISkeletonViewerOptions {
  53062. /** Should the system pause animations before building the Viewer? */
  53063. pauseAnimations: boolean;
  53064. /** Should the system return the skeleton to rest before building? */
  53065. returnToRest: boolean;
  53066. /** public Display Mode of the Viewer */
  53067. displayMode: number;
  53068. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53069. displayOptions: ISkeletonViewerDisplayOptions;
  53070. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53071. computeBonesUsingShaders: boolean;
  53072. /** Flag ignore non weighted bones */
  53073. useAllBones: boolean;
  53074. }
  53075. /**
  53076. * Defines how to display the various bone meshes for the viewer.
  53077. */
  53078. export interface ISkeletonViewerDisplayOptions {
  53079. /** How far down to start tapering the bone spurs */
  53080. midStep?: number;
  53081. /** How big is the midStep? */
  53082. midStepFactor?: number;
  53083. /** Base for the Sphere Size */
  53084. sphereBaseSize?: number;
  53085. /** The ratio of the sphere to the longest bone in units */
  53086. sphereScaleUnit?: number;
  53087. /** Ratio for the Sphere Size */
  53088. sphereFactor?: number;
  53089. }
  53090. /**
  53091. * Defines the constructor options for the BoneWeight Shader.
  53092. */
  53093. export interface IBoneWeightShaderOptions {
  53094. /** Skeleton to Map */
  53095. skeleton: Skeleton;
  53096. /** Colors for Uninfluenced bones */
  53097. colorBase?: Color3;
  53098. /** Colors for 0.0-0.25 Weight bones */
  53099. colorZero?: Color3;
  53100. /** Color for 0.25-0.5 Weight Influence */
  53101. colorQuarter?: Color3;
  53102. /** Color for 0.5-0.75 Weight Influence */
  53103. colorHalf?: Color3;
  53104. /** Color for 0.75-1 Weight Influence */
  53105. colorFull?: Color3;
  53106. /** Color for Zero Weight Influence */
  53107. targetBoneIndex?: number;
  53108. }
  53109. /**
  53110. * Simple structure of the gradient steps for the Color Map.
  53111. */
  53112. export interface ISkeletonMapShaderColorMapKnot {
  53113. /** Color of the Knot */
  53114. color: Color3;
  53115. /** Location of the Knot */
  53116. location: number;
  53117. }
  53118. /**
  53119. * Defines the constructor options for the SkeletonMap Shader.
  53120. */
  53121. export interface ISkeletonMapShaderOptions {
  53122. /** Skeleton to Map */
  53123. skeleton: Skeleton;
  53124. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  53125. colorMap?: ISkeletonMapShaderColorMapKnot[];
  53126. }
  53127. }
  53128. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53129. import { Nullable } from "babylonjs/types";
  53130. import { Scene } from "babylonjs/scene";
  53131. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53132. import { Color4 } from "babylonjs/Maths/math.color";
  53133. import { Mesh } from "babylonjs/Meshes/mesh";
  53134. /**
  53135. * Class containing static functions to help procedurally build meshes
  53136. */
  53137. export class RibbonBuilder {
  53138. /**
  53139. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53140. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53141. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53142. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53143. * * 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
  53144. * * 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
  53145. * * 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
  53146. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53147. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53148. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53149. * * 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
  53150. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53151. * * 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
  53152. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53154. * @param name defines the name of the mesh
  53155. * @param options defines the options used to create the mesh
  53156. * @param scene defines the hosting scene
  53157. * @returns the ribbon mesh
  53158. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53159. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53160. */
  53161. static CreateRibbon(name: string, options: {
  53162. pathArray: Vector3[][];
  53163. closeArray?: boolean;
  53164. closePath?: boolean;
  53165. offset?: number;
  53166. updatable?: boolean;
  53167. sideOrientation?: number;
  53168. frontUVs?: Vector4;
  53169. backUVs?: Vector4;
  53170. instance?: Mesh;
  53171. invertUV?: boolean;
  53172. uvs?: Vector2[];
  53173. colors?: Color4[];
  53174. }, scene?: Nullable<Scene>): Mesh;
  53175. }
  53176. }
  53177. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53178. import { Nullable } from "babylonjs/types";
  53179. import { Scene } from "babylonjs/scene";
  53180. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53181. import { Mesh } from "babylonjs/Meshes/mesh";
  53182. /**
  53183. * Class containing static functions to help procedurally build meshes
  53184. */
  53185. export class ShapeBuilder {
  53186. /**
  53187. * 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.
  53188. * * 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.
  53189. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53190. * * 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.
  53191. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53192. * * 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
  53193. * * 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
  53194. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53195. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53196. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53197. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53199. * @param name defines the name of the mesh
  53200. * @param options defines the options used to create the mesh
  53201. * @param scene defines the hosting scene
  53202. * @returns the extruded shape mesh
  53203. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53204. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53205. */
  53206. static ExtrudeShape(name: string, options: {
  53207. shape: Vector3[];
  53208. path: Vector3[];
  53209. scale?: number;
  53210. rotation?: number;
  53211. cap?: number;
  53212. updatable?: boolean;
  53213. sideOrientation?: number;
  53214. frontUVs?: Vector4;
  53215. backUVs?: Vector4;
  53216. instance?: Mesh;
  53217. invertUV?: boolean;
  53218. }, scene?: Nullable<Scene>): Mesh;
  53219. /**
  53220. * Creates an custom extruded shape mesh.
  53221. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53222. * * 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.
  53223. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53224. * * 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
  53225. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53226. * * 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
  53227. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53228. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53229. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53230. * * 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
  53231. * * 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
  53232. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53233. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53234. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53235. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53237. * @param name defines the name of the mesh
  53238. * @param options defines the options used to create the mesh
  53239. * @param scene defines the hosting scene
  53240. * @returns the custom extruded shape mesh
  53241. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53242. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53243. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53244. */
  53245. static ExtrudeShapeCustom(name: string, options: {
  53246. shape: Vector3[];
  53247. path: Vector3[];
  53248. scaleFunction?: any;
  53249. rotationFunction?: any;
  53250. ribbonCloseArray?: boolean;
  53251. ribbonClosePath?: boolean;
  53252. cap?: number;
  53253. updatable?: boolean;
  53254. sideOrientation?: number;
  53255. frontUVs?: Vector4;
  53256. backUVs?: Vector4;
  53257. instance?: Mesh;
  53258. invertUV?: boolean;
  53259. }, scene?: Nullable<Scene>): Mesh;
  53260. private static _ExtrudeShapeGeneric;
  53261. }
  53262. }
  53263. declare module "babylonjs/Debug/skeletonViewer" {
  53264. import { Color3 } from "babylonjs/Maths/math.color";
  53265. import { Scene } from "babylonjs/scene";
  53266. import { Nullable } from "babylonjs/types";
  53267. import { Skeleton } from "babylonjs/Bones/skeleton";
  53268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53269. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  53270. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  53271. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  53272. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  53273. /**
  53274. * Class used to render a debug view of a given skeleton
  53275. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  53276. */
  53277. export class SkeletonViewer {
  53278. /** defines the skeleton to render */
  53279. skeleton: Skeleton;
  53280. /** defines the mesh attached to the skeleton */
  53281. mesh: AbstractMesh;
  53282. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53283. autoUpdateBonesMatrices: boolean;
  53284. /** defines the rendering group id to use with the viewer */
  53285. renderingGroupId: number;
  53286. /** is the options for the viewer */
  53287. options: Partial<ISkeletonViewerOptions>;
  53288. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  53289. static readonly DISPLAY_LINES: number;
  53290. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  53291. static readonly DISPLAY_SPHERES: number;
  53292. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  53293. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  53294. /** public static method to create a BoneWeight Shader
  53295. * @param options The constructor options
  53296. * @param scene The scene that the shader is scoped to
  53297. * @returns The created ShaderMaterial
  53298. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  53299. */
  53300. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  53301. /** public static method to create a BoneWeight Shader
  53302. * @param options The constructor options
  53303. * @param scene The scene that the shader is scoped to
  53304. * @returns The created ShaderMaterial
  53305. */
  53306. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  53307. /** private static method to create a BoneWeight Shader
  53308. * @param size The size of the buffer to create (usually the bone count)
  53309. * @param colorMap The gradient data to generate
  53310. * @param scene The scene that the shader is scoped to
  53311. * @returns an Array of floats from the color gradient values
  53312. */
  53313. private static _CreateBoneMapColorBuffer;
  53314. /** If SkeletonViewer scene scope. */
  53315. private _scene;
  53316. /** Gets or sets the color used to render the skeleton */
  53317. color: Color3;
  53318. /** Array of the points of the skeleton fo the line view. */
  53319. private _debugLines;
  53320. /** The SkeletonViewers Mesh. */
  53321. private _debugMesh;
  53322. /** If SkeletonViewer is enabled. */
  53323. private _isEnabled;
  53324. /** If SkeletonViewer is ready. */
  53325. private _ready;
  53326. /** SkeletonViewer render observable. */
  53327. private _obs;
  53328. /** The Utility Layer to render the gizmos in. */
  53329. private _utilityLayer;
  53330. private _boneIndices;
  53331. /** Gets the Scene. */
  53332. get scene(): Scene;
  53333. /** Gets the utilityLayer. */
  53334. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  53335. /** Checks Ready Status. */
  53336. get isReady(): Boolean;
  53337. /** Sets Ready Status. */
  53338. set ready(value: boolean);
  53339. /** Gets the debugMesh */
  53340. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  53341. /** Sets the debugMesh */
  53342. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  53343. /** Gets the displayMode */
  53344. get displayMode(): number;
  53345. /** Sets the displayMode */
  53346. set displayMode(value: number);
  53347. /**
  53348. * Creates a new SkeletonViewer
  53349. * @param skeleton defines the skeleton to render
  53350. * @param mesh defines the mesh attached to the skeleton
  53351. * @param scene defines the hosting scene
  53352. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  53353. * @param renderingGroupId defines the rendering group id to use with the viewer
  53354. * @param options All of the extra constructor options for the SkeletonViewer
  53355. */
  53356. constructor(
  53357. /** defines the skeleton to render */
  53358. skeleton: Skeleton,
  53359. /** defines the mesh attached to the skeleton */
  53360. mesh: AbstractMesh,
  53361. /** The Scene scope*/
  53362. scene: Scene,
  53363. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53364. autoUpdateBonesMatrices?: boolean,
  53365. /** defines the rendering group id to use with the viewer */
  53366. renderingGroupId?: number,
  53367. /** is the options for the viewer */
  53368. options?: Partial<ISkeletonViewerOptions>);
  53369. /** The Dynamic bindings for the update functions */
  53370. private _bindObs;
  53371. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  53372. update(): void;
  53373. /** Gets or sets a boolean indicating if the viewer is enabled */
  53374. set isEnabled(value: boolean);
  53375. get isEnabled(): boolean;
  53376. private _getBonePosition;
  53377. private _getLinesForBonesWithLength;
  53378. private _getLinesForBonesNoLength;
  53379. /** function to revert the mesh and scene back to the initial state. */
  53380. private _revert;
  53381. /** function to build and bind sphere joint points and spur bone representations. */
  53382. private _buildSpheresAndSpurs;
  53383. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  53384. private _displayLinesUpdate;
  53385. /** Changes the displayMode of the skeleton viewer
  53386. * @param mode The displayMode numerical value
  53387. */
  53388. changeDisplayMode(mode: number): void;
  53389. /** Changes the displayMode of the skeleton viewer
  53390. * @param option String of the option name
  53391. * @param value The numerical option value
  53392. */
  53393. changeDisplayOptions(option: string, value: number): void;
  53394. /** Release associated resources */
  53395. dispose(): void;
  53396. }
  53397. }
  53398. declare module "babylonjs/Debug/index" {
  53399. export * from "babylonjs/Debug/axesViewer";
  53400. export * from "babylonjs/Debug/boneAxesViewer";
  53401. export * from "babylonjs/Debug/debugLayer";
  53402. export * from "babylonjs/Debug/physicsViewer";
  53403. export * from "babylonjs/Debug/rayHelper";
  53404. export * from "babylonjs/Debug/skeletonViewer";
  53405. export * from "babylonjs/Debug/ISkeletonViewer";
  53406. }
  53407. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  53408. /**
  53409. * Enum for Device Types
  53410. */
  53411. export enum DeviceType {
  53412. /** Generic */
  53413. Generic = 0,
  53414. /** Keyboard */
  53415. Keyboard = 1,
  53416. /** Mouse */
  53417. Mouse = 2,
  53418. /** Touch Pointers */
  53419. Touch = 3,
  53420. /** PS4 Dual Shock */
  53421. DualShock = 4,
  53422. /** Xbox */
  53423. Xbox = 5,
  53424. /** Switch Controller */
  53425. Switch = 6
  53426. }
  53427. /**
  53428. * Enum for All Pointers (Touch/Mouse)
  53429. */
  53430. export enum PointerInput {
  53431. /** Horizontal Axis */
  53432. Horizontal = 0,
  53433. /** Vertical Axis */
  53434. Vertical = 1,
  53435. /** Left Click or Touch */
  53436. LeftClick = 2,
  53437. /** Middle Click */
  53438. MiddleClick = 3,
  53439. /** Right Click */
  53440. RightClick = 4,
  53441. /** Browser Back */
  53442. BrowserBack = 5,
  53443. /** Browser Forward */
  53444. BrowserForward = 6
  53445. }
  53446. /**
  53447. * Enum for Dual Shock Gamepad
  53448. */
  53449. export enum DualShockInput {
  53450. /** Cross */
  53451. Cross = 0,
  53452. /** Circle */
  53453. Circle = 1,
  53454. /** Square */
  53455. Square = 2,
  53456. /** Triangle */
  53457. Triangle = 3,
  53458. /** L1 */
  53459. L1 = 4,
  53460. /** R1 */
  53461. R1 = 5,
  53462. /** L2 */
  53463. L2 = 6,
  53464. /** R2 */
  53465. R2 = 7,
  53466. /** Share */
  53467. Share = 8,
  53468. /** Options */
  53469. Options = 9,
  53470. /** L3 */
  53471. L3 = 10,
  53472. /** R3 */
  53473. R3 = 11,
  53474. /** DPadUp */
  53475. DPadUp = 12,
  53476. /** DPadDown */
  53477. DPadDown = 13,
  53478. /** DPadLeft */
  53479. DPadLeft = 14,
  53480. /** DRight */
  53481. DPadRight = 15,
  53482. /** Home */
  53483. Home = 16,
  53484. /** TouchPad */
  53485. TouchPad = 17,
  53486. /** LStickXAxis */
  53487. LStickXAxis = 18,
  53488. /** LStickYAxis */
  53489. LStickYAxis = 19,
  53490. /** RStickXAxis */
  53491. RStickXAxis = 20,
  53492. /** RStickYAxis */
  53493. RStickYAxis = 21
  53494. }
  53495. /**
  53496. * Enum for Xbox Gamepad
  53497. */
  53498. export enum XboxInput {
  53499. /** A */
  53500. A = 0,
  53501. /** B */
  53502. B = 1,
  53503. /** X */
  53504. X = 2,
  53505. /** Y */
  53506. Y = 3,
  53507. /** LB */
  53508. LB = 4,
  53509. /** RB */
  53510. RB = 5,
  53511. /** LT */
  53512. LT = 6,
  53513. /** RT */
  53514. RT = 7,
  53515. /** Back */
  53516. Back = 8,
  53517. /** Start */
  53518. Start = 9,
  53519. /** LS */
  53520. LS = 10,
  53521. /** RS */
  53522. RS = 11,
  53523. /** DPadUp */
  53524. DPadUp = 12,
  53525. /** DPadDown */
  53526. DPadDown = 13,
  53527. /** DPadLeft */
  53528. DPadLeft = 14,
  53529. /** DRight */
  53530. DPadRight = 15,
  53531. /** Home */
  53532. Home = 16,
  53533. /** LStickXAxis */
  53534. LStickXAxis = 17,
  53535. /** LStickYAxis */
  53536. LStickYAxis = 18,
  53537. /** RStickXAxis */
  53538. RStickXAxis = 19,
  53539. /** RStickYAxis */
  53540. RStickYAxis = 20
  53541. }
  53542. /**
  53543. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  53544. */
  53545. export enum SwitchInput {
  53546. /** B */
  53547. B = 0,
  53548. /** A */
  53549. A = 1,
  53550. /** Y */
  53551. Y = 2,
  53552. /** X */
  53553. X = 3,
  53554. /** L */
  53555. L = 4,
  53556. /** R */
  53557. R = 5,
  53558. /** ZL */
  53559. ZL = 6,
  53560. /** ZR */
  53561. ZR = 7,
  53562. /** Minus */
  53563. Minus = 8,
  53564. /** Plus */
  53565. Plus = 9,
  53566. /** LS */
  53567. LS = 10,
  53568. /** RS */
  53569. RS = 11,
  53570. /** DPadUp */
  53571. DPadUp = 12,
  53572. /** DPadDown */
  53573. DPadDown = 13,
  53574. /** DPadLeft */
  53575. DPadLeft = 14,
  53576. /** DRight */
  53577. DPadRight = 15,
  53578. /** Home */
  53579. Home = 16,
  53580. /** Capture */
  53581. Capture = 17,
  53582. /** LStickXAxis */
  53583. LStickXAxis = 18,
  53584. /** LStickYAxis */
  53585. LStickYAxis = 19,
  53586. /** RStickXAxis */
  53587. RStickXAxis = 20,
  53588. /** RStickYAxis */
  53589. RStickYAxis = 21
  53590. }
  53591. }
  53592. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  53593. import { Engine } from "babylonjs/Engines/engine";
  53594. import { IDisposable } from "babylonjs/scene";
  53595. import { Nullable } from "babylonjs/types";
  53596. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53597. /**
  53598. * This class will take all inputs from Keyboard, Pointer, and
  53599. * any Gamepads and provide a polling system that all devices
  53600. * will use. This class assumes that there will only be one
  53601. * pointer device and one keyboard.
  53602. */
  53603. export class DeviceInputSystem implements IDisposable {
  53604. /**
  53605. * Callback to be triggered when a device is connected
  53606. */
  53607. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53608. /**
  53609. * Callback to be triggered when a device is disconnected
  53610. */
  53611. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53612. /**
  53613. * Callback to be triggered when event driven input is updated
  53614. */
  53615. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  53616. private _inputs;
  53617. private _gamepads;
  53618. private _keyboardActive;
  53619. private _pointerActive;
  53620. private _elementToAttachTo;
  53621. private _keyboardDownEvent;
  53622. private _keyboardUpEvent;
  53623. private _pointerMoveEvent;
  53624. private _pointerDownEvent;
  53625. private _pointerUpEvent;
  53626. private _gamepadConnectedEvent;
  53627. private _gamepadDisconnectedEvent;
  53628. private static _MAX_KEYCODES;
  53629. private static _MAX_POINTER_INPUTS;
  53630. private constructor();
  53631. /**
  53632. * Creates a new DeviceInputSystem instance
  53633. * @param engine Engine to pull input element from
  53634. * @returns The new instance
  53635. */
  53636. static Create(engine: Engine): DeviceInputSystem;
  53637. /**
  53638. * Checks for current device input value, given an id and input index
  53639. * @param deviceName Id of connected device
  53640. * @param inputIndex Index of device input
  53641. * @returns Current value of input
  53642. */
  53643. /**
  53644. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  53645. * @param deviceType Enum specifiying device type
  53646. * @param deviceSlot "Slot" or index that device is referenced in
  53647. * @param inputIndex Id of input to be checked
  53648. * @returns Current value of input
  53649. */
  53650. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  53651. /**
  53652. * Dispose of all the eventlisteners
  53653. */
  53654. dispose(): void;
  53655. /**
  53656. * Add device and inputs to device array
  53657. * @param deviceType Enum specifiying device type
  53658. * @param deviceSlot "Slot" or index that device is referenced in
  53659. * @param numberOfInputs Number of input entries to create for given device
  53660. */
  53661. private _registerDevice;
  53662. /**
  53663. * Given a specific device name, remove that device from the device map
  53664. * @param deviceType Enum specifiying device type
  53665. * @param deviceSlot "Slot" or index that device is referenced in
  53666. */
  53667. private _unregisterDevice;
  53668. /**
  53669. * Handle all actions that come from keyboard interaction
  53670. */
  53671. private _handleKeyActions;
  53672. /**
  53673. * Handle all actions that come from pointer interaction
  53674. */
  53675. private _handlePointerActions;
  53676. /**
  53677. * Handle all actions that come from gamepad interaction
  53678. */
  53679. private _handleGamepadActions;
  53680. /**
  53681. * Update all non-event based devices with each frame
  53682. * @param deviceType Enum specifiying device type
  53683. * @param deviceSlot "Slot" or index that device is referenced in
  53684. * @param inputIndex Id of input to be checked
  53685. */
  53686. private _updateDevice;
  53687. /**
  53688. * Gets DeviceType from the device name
  53689. * @param deviceName Name of Device from DeviceInputSystem
  53690. * @returns DeviceType enum value
  53691. */
  53692. private _getGamepadDeviceType;
  53693. }
  53694. }
  53695. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  53696. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53697. /**
  53698. * Type to handle enforcement of inputs
  53699. */
  53700. 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;
  53701. }
  53702. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  53703. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  53704. import { Engine } from "babylonjs/Engines/engine";
  53705. import { IDisposable } from "babylonjs/scene";
  53706. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53707. import { Nullable } from "babylonjs/types";
  53708. import { Observable } from "babylonjs/Misc/observable";
  53709. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53710. /**
  53711. * Class that handles all input for a specific device
  53712. */
  53713. export class DeviceSource<T extends DeviceType> {
  53714. /** Type of device */
  53715. readonly deviceType: DeviceType;
  53716. /** "Slot" or index that device is referenced in */
  53717. readonly deviceSlot: number;
  53718. /**
  53719. * Observable to handle device input changes per device
  53720. */
  53721. readonly onInputChangedObservable: Observable<{
  53722. inputIndex: DeviceInput<T>;
  53723. previousState: Nullable<number>;
  53724. currentState: Nullable<number>;
  53725. }>;
  53726. private readonly _deviceInputSystem;
  53727. /**
  53728. * Default Constructor
  53729. * @param deviceInputSystem Reference to DeviceInputSystem
  53730. * @param deviceType Type of device
  53731. * @param deviceSlot "Slot" or index that device is referenced in
  53732. */
  53733. constructor(deviceInputSystem: DeviceInputSystem,
  53734. /** Type of device */
  53735. deviceType: DeviceType,
  53736. /** "Slot" or index that device is referenced in */
  53737. deviceSlot?: number);
  53738. /**
  53739. * Get input for specific input
  53740. * @param inputIndex index of specific input on device
  53741. * @returns Input value from DeviceInputSystem
  53742. */
  53743. getInput(inputIndex: DeviceInput<T>): number;
  53744. }
  53745. /**
  53746. * Class to keep track of devices
  53747. */
  53748. export class DeviceSourceManager implements IDisposable {
  53749. /**
  53750. * Observable to be triggered when before a device is connected
  53751. */
  53752. readonly onBeforeDeviceConnectedObservable: Observable<{
  53753. deviceType: DeviceType;
  53754. deviceSlot: number;
  53755. }>;
  53756. /**
  53757. * Observable to be triggered when before a device is disconnected
  53758. */
  53759. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  53760. deviceType: DeviceType;
  53761. deviceSlot: number;
  53762. }>;
  53763. /**
  53764. * Observable to be triggered when after a device is connected
  53765. */
  53766. readonly onAfterDeviceConnectedObservable: Observable<{
  53767. deviceType: DeviceType;
  53768. deviceSlot: number;
  53769. }>;
  53770. /**
  53771. * Observable to be triggered when after a device is disconnected
  53772. */
  53773. readonly onAfterDeviceDisconnectedObservable: Observable<{
  53774. deviceType: DeviceType;
  53775. deviceSlot: number;
  53776. }>;
  53777. private readonly _devices;
  53778. private readonly _firstDevice;
  53779. private readonly _deviceInputSystem;
  53780. /**
  53781. * Default Constructor
  53782. * @param engine engine to pull input element from
  53783. */
  53784. constructor(engine: Engine);
  53785. /**
  53786. * Gets a DeviceSource, given a type and slot
  53787. * @param deviceType Enum specifying device type
  53788. * @param deviceSlot "Slot" or index that device is referenced in
  53789. * @returns DeviceSource object
  53790. */
  53791. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  53792. /**
  53793. * Gets an array of DeviceSource objects for a given device type
  53794. * @param deviceType Enum specifying device type
  53795. * @returns Array of DeviceSource objects
  53796. */
  53797. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  53798. /**
  53799. * Dispose of DeviceInputSystem and other parts
  53800. */
  53801. dispose(): void;
  53802. /**
  53803. * Function to add device name to device list
  53804. * @param deviceType Enum specifying device type
  53805. * @param deviceSlot "Slot" or index that device is referenced in
  53806. */
  53807. private _addDevice;
  53808. /**
  53809. * Function to remove device name to device list
  53810. * @param deviceType Enum specifying device type
  53811. * @param deviceSlot "Slot" or index that device is referenced in
  53812. */
  53813. private _removeDevice;
  53814. /**
  53815. * Updates array storing first connected device of each type
  53816. * @param type Type of Device
  53817. */
  53818. private _updateFirstDevices;
  53819. }
  53820. }
  53821. declare module "babylonjs/DeviceInput/index" {
  53822. export * from "babylonjs/DeviceInput/deviceInputSystem";
  53823. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53824. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53825. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53826. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53827. }
  53828. declare module "babylonjs/Engines/nullEngine" {
  53829. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  53830. import { Engine } from "babylonjs/Engines/engine";
  53831. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53832. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53833. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53834. import { Effect } from "babylonjs/Materials/effect";
  53835. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53836. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53837. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  53838. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53839. /**
  53840. * Options to create the null engine
  53841. */
  53842. export class NullEngineOptions {
  53843. /**
  53844. * Render width (Default: 512)
  53845. */
  53846. renderWidth: number;
  53847. /**
  53848. * Render height (Default: 256)
  53849. */
  53850. renderHeight: number;
  53851. /**
  53852. * Texture size (Default: 512)
  53853. */
  53854. textureSize: number;
  53855. /**
  53856. * If delta time between frames should be constant
  53857. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53858. */
  53859. deterministicLockstep: boolean;
  53860. /**
  53861. * Maximum about of steps between frames (Default: 4)
  53862. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53863. */
  53864. lockstepMaxSteps: number;
  53865. /**
  53866. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  53867. */
  53868. useHighPrecisionMatrix?: boolean;
  53869. }
  53870. /**
  53871. * The null engine class provides support for headless version of babylon.js.
  53872. * This can be used in server side scenario or for testing purposes
  53873. */
  53874. export class NullEngine extends Engine {
  53875. private _options;
  53876. /**
  53877. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  53878. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53879. * @returns true if engine is in deterministic lock step mode
  53880. */
  53881. isDeterministicLockStep(): boolean;
  53882. /**
  53883. * Gets the max steps when engine is running in deterministic lock step
  53884. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53885. * @returns the max steps
  53886. */
  53887. getLockstepMaxSteps(): number;
  53888. /**
  53889. * Gets the current hardware scaling level.
  53890. * By default the hardware scaling level is computed from the window device ratio.
  53891. * 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.
  53892. * @returns a number indicating the current hardware scaling level
  53893. */
  53894. getHardwareScalingLevel(): number;
  53895. constructor(options?: NullEngineOptions);
  53896. /**
  53897. * Creates a vertex buffer
  53898. * @param vertices the data for the vertex buffer
  53899. * @returns the new WebGL static buffer
  53900. */
  53901. createVertexBuffer(vertices: FloatArray): DataBuffer;
  53902. /**
  53903. * Creates a new index buffer
  53904. * @param indices defines the content of the index buffer
  53905. * @param updatable defines if the index buffer must be updatable
  53906. * @returns a new webGL buffer
  53907. */
  53908. createIndexBuffer(indices: IndicesArray): DataBuffer;
  53909. /**
  53910. * Clear the current render buffer or the current render target (if any is set up)
  53911. * @param color defines the color to use
  53912. * @param backBuffer defines if the back buffer must be cleared
  53913. * @param depth defines if the depth buffer must be cleared
  53914. * @param stencil defines if the stencil buffer must be cleared
  53915. */
  53916. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53917. /**
  53918. * Gets the current render width
  53919. * @param useScreen defines if screen size must be used (or the current render target if any)
  53920. * @returns a number defining the current render width
  53921. */
  53922. getRenderWidth(useScreen?: boolean): number;
  53923. /**
  53924. * Gets the current render height
  53925. * @param useScreen defines if screen size must be used (or the current render target if any)
  53926. * @returns a number defining the current render height
  53927. */
  53928. getRenderHeight(useScreen?: boolean): number;
  53929. /**
  53930. * Set the WebGL's viewport
  53931. * @param viewport defines the viewport element to be used
  53932. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  53933. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  53934. */
  53935. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  53936. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  53937. /**
  53938. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  53939. * @param pipelineContext defines the pipeline context to use
  53940. * @param uniformsNames defines the list of uniform names
  53941. * @returns an array of webGL uniform locations
  53942. */
  53943. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  53944. /**
  53945. * Gets the lsit of active attributes for a given webGL program
  53946. * @param pipelineContext defines the pipeline context to use
  53947. * @param attributesNames defines the list of attribute names to get
  53948. * @returns an array of indices indicating the offset of each attribute
  53949. */
  53950. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53951. /**
  53952. * Binds an effect to the webGL context
  53953. * @param effect defines the effect to bind
  53954. */
  53955. bindSamplers(effect: Effect): void;
  53956. /**
  53957. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  53958. * @param effect defines the effect to activate
  53959. */
  53960. enableEffect(effect: Effect): void;
  53961. /**
  53962. * Set various states to the webGL context
  53963. * @param culling defines backface culling state
  53964. * @param zOffset defines the value to apply to zOffset (0 by default)
  53965. * @param force defines if states must be applied even if cache is up to date
  53966. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  53967. */
  53968. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53969. /**
  53970. * Set the value of an uniform to an array of int32
  53971. * @param uniform defines the webGL uniform location where to store the value
  53972. * @param array defines the array of int32 to store
  53973. */
  53974. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53975. /**
  53976. * Set the value of an uniform to an array of int32 (stored as vec2)
  53977. * @param uniform defines the webGL uniform location where to store the value
  53978. * @param array defines the array of int32 to store
  53979. */
  53980. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53981. /**
  53982. * Set the value of an uniform to an array of int32 (stored as vec3)
  53983. * @param uniform defines the webGL uniform location where to store the value
  53984. * @param array defines the array of int32 to store
  53985. */
  53986. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53987. /**
  53988. * Set the value of an uniform to an array of int32 (stored as vec4)
  53989. * @param uniform defines the webGL uniform location where to store the value
  53990. * @param array defines the array of int32 to store
  53991. */
  53992. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53993. /**
  53994. * Set the value of an uniform to an array of float32
  53995. * @param uniform defines the webGL uniform location where to store the value
  53996. * @param array defines the array of float32 to store
  53997. */
  53998. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53999. /**
  54000. * Set the value of an uniform to an array of float32 (stored as vec2)
  54001. * @param uniform defines the webGL uniform location where to store the value
  54002. * @param array defines the array of float32 to store
  54003. */
  54004. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  54005. /**
  54006. * Set the value of an uniform to an array of float32 (stored as vec3)
  54007. * @param uniform defines the webGL uniform location where to store the value
  54008. * @param array defines the array of float32 to store
  54009. */
  54010. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  54011. /**
  54012. * Set the value of an uniform to an array of float32 (stored as vec4)
  54013. * @param uniform defines the webGL uniform location where to store the value
  54014. * @param array defines the array of float32 to store
  54015. */
  54016. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  54017. /**
  54018. * Set the value of an uniform to an array of number
  54019. * @param uniform defines the webGL uniform location where to store the value
  54020. * @param array defines the array of number to store
  54021. */
  54022. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  54023. /**
  54024. * Set the value of an uniform to an array of number (stored as vec2)
  54025. * @param uniform defines the webGL uniform location where to store the value
  54026. * @param array defines the array of number to store
  54027. */
  54028. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  54029. /**
  54030. * Set the value of an uniform to an array of number (stored as vec3)
  54031. * @param uniform defines the webGL uniform location where to store the value
  54032. * @param array defines the array of number to store
  54033. */
  54034. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  54035. /**
  54036. * Set the value of an uniform to an array of number (stored as vec4)
  54037. * @param uniform defines the webGL uniform location where to store the value
  54038. * @param array defines the array of number to store
  54039. */
  54040. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  54041. /**
  54042. * Set the value of an uniform to an array of float32 (stored as matrices)
  54043. * @param uniform defines the webGL uniform location where to store the value
  54044. * @param matrices defines the array of float32 to store
  54045. */
  54046. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  54047. /**
  54048. * Set the value of an uniform to a matrix (3x3)
  54049. * @param uniform defines the webGL uniform location where to store the value
  54050. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  54051. */
  54052. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54053. /**
  54054. * Set the value of an uniform to a matrix (2x2)
  54055. * @param uniform defines the webGL uniform location where to store the value
  54056. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  54057. */
  54058. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  54059. /**
  54060. * Set the value of an uniform to a number (float)
  54061. * @param uniform defines the webGL uniform location where to store the value
  54062. * @param value defines the float number to store
  54063. */
  54064. setFloat(uniform: WebGLUniformLocation, value: number): void;
  54065. /**
  54066. * Set the value of an uniform to a vec2
  54067. * @param uniform defines the webGL uniform location where to store the value
  54068. * @param x defines the 1st component of the value
  54069. * @param y defines the 2nd component of the value
  54070. */
  54071. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  54072. /**
  54073. * Set the value of an uniform to a vec3
  54074. * @param uniform defines the webGL uniform location where to store the value
  54075. * @param x defines the 1st component of the value
  54076. * @param y defines the 2nd component of the value
  54077. * @param z defines the 3rd component of the value
  54078. */
  54079. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  54080. /**
  54081. * Set the value of an uniform to a boolean
  54082. * @param uniform defines the webGL uniform location where to store the value
  54083. * @param bool defines the boolean to store
  54084. */
  54085. setBool(uniform: WebGLUniformLocation, bool: number): void;
  54086. /**
  54087. * Set the value of an uniform to a vec4
  54088. * @param uniform defines the webGL uniform location where to store the value
  54089. * @param x defines the 1st component of the value
  54090. * @param y defines the 2nd component of the value
  54091. * @param z defines the 3rd component of the value
  54092. * @param w defines the 4th component of the value
  54093. */
  54094. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  54095. /**
  54096. * Sets the current alpha mode
  54097. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  54098. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  54099. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54100. */
  54101. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  54102. /**
  54103. * Bind webGl buffers directly to the webGL context
  54104. * @param vertexBuffers defines the vertex buffer to bind
  54105. * @param indexBuffer defines the index buffer to bind
  54106. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  54107. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  54108. * @param effect defines the effect associated with the vertex buffer
  54109. */
  54110. bindBuffers(vertexBuffers: {
  54111. [key: string]: VertexBuffer;
  54112. }, indexBuffer: DataBuffer, effect: Effect): void;
  54113. /**
  54114. * Force the entire cache to be cleared
  54115. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  54116. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  54117. */
  54118. wipeCaches(bruteForce?: boolean): void;
  54119. /**
  54120. * Send a draw order
  54121. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  54122. * @param indexStart defines the starting index
  54123. * @param indexCount defines the number of index to draw
  54124. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54125. */
  54126. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  54127. /**
  54128. * Draw a list of indexed primitives
  54129. * @param fillMode defines the primitive to use
  54130. * @param indexStart defines the starting index
  54131. * @param indexCount defines the number of index to draw
  54132. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54133. */
  54134. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54135. /**
  54136. * Draw a list of unindexed primitives
  54137. * @param fillMode defines the primitive to use
  54138. * @param verticesStart defines the index of first vertex to draw
  54139. * @param verticesCount defines the count of vertices to draw
  54140. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54141. */
  54142. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54143. /** @hidden */
  54144. _createTexture(): WebGLTexture;
  54145. /** @hidden */
  54146. _releaseTexture(texture: InternalTexture): void;
  54147. /**
  54148. * Usually called from Texture.ts.
  54149. * Passed information to create a WebGLTexture
  54150. * @param urlArg defines a value which contains one of the following:
  54151. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54152. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54153. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54154. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54155. * @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)
  54156. * @param scene needed for loading to the correct scene
  54157. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54158. * @param onLoad optional callback to be called upon successful completion
  54159. * @param onError optional callback to be called upon failure
  54160. * @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
  54161. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54162. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54163. * @param forcedExtension defines the extension to use to pick the right loader
  54164. * @param mimeType defines an optional mime type
  54165. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54166. */
  54167. 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;
  54168. /**
  54169. * Creates a new render target texture
  54170. * @param size defines the size of the texture
  54171. * @param options defines the options used to create the texture
  54172. * @returns a new render target texture stored in an InternalTexture
  54173. */
  54174. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  54175. /**
  54176. * Update the sampling mode of a given texture
  54177. * @param samplingMode defines the required sampling mode
  54178. * @param texture defines the texture to update
  54179. */
  54180. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54181. /**
  54182. * Binds the frame buffer to the specified texture.
  54183. * @param texture The texture to render to or null for the default canvas
  54184. * @param faceIndex The face of the texture to render to in case of cube texture
  54185. * @param requiredWidth The width of the target to render to
  54186. * @param requiredHeight The height of the target to render to
  54187. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  54188. * @param lodLevel defines le lod level to bind to the frame buffer
  54189. */
  54190. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54191. /**
  54192. * Unbind the current render target texture from the webGL context
  54193. * @param texture defines the render target texture to unbind
  54194. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  54195. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  54196. */
  54197. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54198. /**
  54199. * Creates a dynamic vertex buffer
  54200. * @param vertices the data for the dynamic vertex buffer
  54201. * @returns the new WebGL dynamic buffer
  54202. */
  54203. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  54204. /**
  54205. * Update the content of a dynamic texture
  54206. * @param texture defines the texture to update
  54207. * @param canvas defines the canvas containing the source
  54208. * @param invertY defines if data must be stored with Y axis inverted
  54209. * @param premulAlpha defines if alpha is stored as premultiplied
  54210. * @param format defines the format of the data
  54211. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  54212. */
  54213. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  54214. /**
  54215. * Gets a boolean indicating if all created effects are ready
  54216. * @returns true if all effects are ready
  54217. */
  54218. areAllEffectsReady(): boolean;
  54219. /**
  54220. * @hidden
  54221. * Get the current error code of the webGL context
  54222. * @returns the error code
  54223. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  54224. */
  54225. getError(): number;
  54226. /** @hidden */
  54227. _getUnpackAlignement(): number;
  54228. /** @hidden */
  54229. _unpackFlipY(value: boolean): void;
  54230. /**
  54231. * Update a dynamic index buffer
  54232. * @param indexBuffer defines the target index buffer
  54233. * @param indices defines the data to update
  54234. * @param offset defines the offset in the target index buffer where update should start
  54235. */
  54236. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  54237. /**
  54238. * Updates a dynamic vertex buffer.
  54239. * @param vertexBuffer the vertex buffer to update
  54240. * @param vertices the data used to update the vertex buffer
  54241. * @param byteOffset the byte offset of the data (optional)
  54242. * @param byteLength the byte length of the data (optional)
  54243. */
  54244. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  54245. /** @hidden */
  54246. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  54247. /** @hidden */
  54248. _bindTexture(channel: number, texture: InternalTexture): void;
  54249. protected _deleteBuffer(buffer: WebGLBuffer): void;
  54250. /**
  54251. * 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
  54252. */
  54253. releaseEffects(): void;
  54254. displayLoadingUI(): void;
  54255. hideLoadingUI(): void;
  54256. /** @hidden */
  54257. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54258. /** @hidden */
  54259. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54260. /** @hidden */
  54261. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54262. /** @hidden */
  54263. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54264. }
  54265. }
  54266. declare module "babylonjs/Instrumentation/timeToken" {
  54267. import { Nullable } from "babylonjs/types";
  54268. /**
  54269. * @hidden
  54270. **/
  54271. export class _TimeToken {
  54272. _startTimeQuery: Nullable<WebGLQuery>;
  54273. _endTimeQuery: Nullable<WebGLQuery>;
  54274. _timeElapsedQuery: Nullable<WebGLQuery>;
  54275. _timeElapsedQueryEnded: boolean;
  54276. }
  54277. }
  54278. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  54279. import { Nullable, int } from "babylonjs/types";
  54280. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  54281. /** @hidden */
  54282. export class _OcclusionDataStorage {
  54283. /** @hidden */
  54284. occlusionInternalRetryCounter: number;
  54285. /** @hidden */
  54286. isOcclusionQueryInProgress: boolean;
  54287. /** @hidden */
  54288. isOccluded: boolean;
  54289. /** @hidden */
  54290. occlusionRetryCount: number;
  54291. /** @hidden */
  54292. occlusionType: number;
  54293. /** @hidden */
  54294. occlusionQueryAlgorithmType: number;
  54295. }
  54296. module "babylonjs/Engines/engine" {
  54297. interface Engine {
  54298. /**
  54299. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  54300. * @return the new query
  54301. */
  54302. createQuery(): WebGLQuery;
  54303. /**
  54304. * Delete and release a webGL query
  54305. * @param query defines the query to delete
  54306. * @return the current engine
  54307. */
  54308. deleteQuery(query: WebGLQuery): Engine;
  54309. /**
  54310. * Check if a given query has resolved and got its value
  54311. * @param query defines the query to check
  54312. * @returns true if the query got its value
  54313. */
  54314. isQueryResultAvailable(query: WebGLQuery): boolean;
  54315. /**
  54316. * Gets the value of a given query
  54317. * @param query defines the query to check
  54318. * @returns the value of the query
  54319. */
  54320. getQueryResult(query: WebGLQuery): number;
  54321. /**
  54322. * Initiates an occlusion query
  54323. * @param algorithmType defines the algorithm to use
  54324. * @param query defines the query to use
  54325. * @returns the current engine
  54326. * @see https://doc.babylonjs.com/features/occlusionquery
  54327. */
  54328. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  54329. /**
  54330. * Ends an occlusion query
  54331. * @see https://doc.babylonjs.com/features/occlusionquery
  54332. * @param algorithmType defines the algorithm to use
  54333. * @returns the current engine
  54334. */
  54335. endOcclusionQuery(algorithmType: number): Engine;
  54336. /**
  54337. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  54338. * Please note that only one query can be issued at a time
  54339. * @returns a time token used to track the time span
  54340. */
  54341. startTimeQuery(): Nullable<_TimeToken>;
  54342. /**
  54343. * Ends a time query
  54344. * @param token defines the token used to measure the time span
  54345. * @returns the time spent (in ns)
  54346. */
  54347. endTimeQuery(token: _TimeToken): int;
  54348. /** @hidden */
  54349. _currentNonTimestampToken: Nullable<_TimeToken>;
  54350. /** @hidden */
  54351. _createTimeQuery(): WebGLQuery;
  54352. /** @hidden */
  54353. _deleteTimeQuery(query: WebGLQuery): void;
  54354. /** @hidden */
  54355. _getGlAlgorithmType(algorithmType: number): number;
  54356. /** @hidden */
  54357. _getTimeQueryResult(query: WebGLQuery): any;
  54358. /** @hidden */
  54359. _getTimeQueryAvailability(query: WebGLQuery): any;
  54360. }
  54361. }
  54362. module "babylonjs/Meshes/abstractMesh" {
  54363. interface AbstractMesh {
  54364. /**
  54365. * Backing filed
  54366. * @hidden
  54367. */
  54368. __occlusionDataStorage: _OcclusionDataStorage;
  54369. /**
  54370. * Access property
  54371. * @hidden
  54372. */
  54373. _occlusionDataStorage: _OcclusionDataStorage;
  54374. /**
  54375. * 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.
  54376. * The default value is -1 which means don't break the query and wait till the result
  54377. * @see https://doc.babylonjs.com/features/occlusionquery
  54378. */
  54379. occlusionRetryCount: number;
  54380. /**
  54381. * 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:
  54382. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  54383. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  54384. * * 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.
  54385. * @see https://doc.babylonjs.com/features/occlusionquery
  54386. */
  54387. occlusionType: number;
  54388. /**
  54389. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  54390. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  54391. * * 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.
  54392. * @see https://doc.babylonjs.com/features/occlusionquery
  54393. */
  54394. occlusionQueryAlgorithmType: number;
  54395. /**
  54396. * 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
  54397. * @see https://doc.babylonjs.com/features/occlusionquery
  54398. */
  54399. isOccluded: boolean;
  54400. /**
  54401. * Flag to check the progress status of the query
  54402. * @see https://doc.babylonjs.com/features/occlusionquery
  54403. */
  54404. isOcclusionQueryInProgress: boolean;
  54405. }
  54406. }
  54407. }
  54408. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  54409. import { Nullable } from "babylonjs/types";
  54410. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54411. /** @hidden */
  54412. export var _forceTransformFeedbackToBundle: boolean;
  54413. module "babylonjs/Engines/engine" {
  54414. interface Engine {
  54415. /**
  54416. * Creates a webGL transform feedback object
  54417. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  54418. * @returns the webGL transform feedback object
  54419. */
  54420. createTransformFeedback(): WebGLTransformFeedback;
  54421. /**
  54422. * Delete a webGL transform feedback object
  54423. * @param value defines the webGL transform feedback object to delete
  54424. */
  54425. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  54426. /**
  54427. * Bind a webGL transform feedback object to the webgl context
  54428. * @param value defines the webGL transform feedback object to bind
  54429. */
  54430. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  54431. /**
  54432. * Begins a transform feedback operation
  54433. * @param usePoints defines if points or triangles must be used
  54434. */
  54435. beginTransformFeedback(usePoints: boolean): void;
  54436. /**
  54437. * Ends a transform feedback operation
  54438. */
  54439. endTransformFeedback(): void;
  54440. /**
  54441. * Specify the varyings to use with transform feedback
  54442. * @param program defines the associated webGL program
  54443. * @param value defines the list of strings representing the varying names
  54444. */
  54445. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  54446. /**
  54447. * Bind a webGL buffer for a transform feedback operation
  54448. * @param value defines the webGL buffer to bind
  54449. */
  54450. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  54451. }
  54452. }
  54453. }
  54454. declare module "babylonjs/Engines/Extensions/engine.views" {
  54455. import { Camera } from "babylonjs/Cameras/camera";
  54456. import { Nullable } from "babylonjs/types";
  54457. /**
  54458. * Class used to define an additional view for the engine
  54459. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54460. */
  54461. export class EngineView {
  54462. /** Defines the canvas where to render the view */
  54463. target: HTMLCanvasElement;
  54464. /** Defines an optional camera used to render the view (will use active camera else) */
  54465. camera?: Camera;
  54466. }
  54467. module "babylonjs/Engines/engine" {
  54468. interface Engine {
  54469. /**
  54470. * Gets or sets the HTML element to use for attaching events
  54471. */
  54472. inputElement: Nullable<HTMLElement>;
  54473. /**
  54474. * Gets the current engine view
  54475. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54476. */
  54477. activeView: Nullable<EngineView>;
  54478. /** Gets or sets the list of views */
  54479. views: EngineView[];
  54480. /**
  54481. * Register a new child canvas
  54482. * @param canvas defines the canvas to register
  54483. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  54484. * @returns the associated view
  54485. */
  54486. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  54487. /**
  54488. * Remove a registered child canvas
  54489. * @param canvas defines the canvas to remove
  54490. * @returns the current engine
  54491. */
  54492. unRegisterView(canvas: HTMLCanvasElement): Engine;
  54493. }
  54494. }
  54495. }
  54496. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  54497. import { Nullable } from "babylonjs/types";
  54498. module "babylonjs/Engines/engine" {
  54499. interface Engine {
  54500. /** @hidden */
  54501. _excludedCompressedTextures: string[];
  54502. /** @hidden */
  54503. _textureFormatInUse: string;
  54504. /**
  54505. * Gets the list of texture formats supported
  54506. */
  54507. readonly texturesSupported: Array<string>;
  54508. /**
  54509. * Gets the texture format in use
  54510. */
  54511. readonly textureFormatInUse: Nullable<string>;
  54512. /**
  54513. * Set the compressed texture extensions or file names to skip.
  54514. *
  54515. * @param skippedFiles defines the list of those texture files you want to skip
  54516. * Example: [".dds", ".env", "myfile.png"]
  54517. */
  54518. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  54519. /**
  54520. * Set the compressed texture format to use, based on the formats you have, and the formats
  54521. * supported by the hardware / browser.
  54522. *
  54523. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  54524. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  54525. * to API arguments needed to compressed textures. This puts the burden on the container
  54526. * generator to house the arcane code for determining these for current & future formats.
  54527. *
  54528. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54529. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54530. *
  54531. * Note: The result of this call is not taken into account when a texture is base64.
  54532. *
  54533. * @param formatsAvailable defines the list of those format families you have created
  54534. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  54535. *
  54536. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  54537. * @returns The extension selected.
  54538. */
  54539. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  54540. }
  54541. }
  54542. }
  54543. declare module "babylonjs/Engines/Extensions/index" {
  54544. export * from "babylonjs/Engines/Extensions/engine.alpha";
  54545. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  54546. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  54547. export * from "babylonjs/Engines/Extensions/engine.multiview";
  54548. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  54549. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54550. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  54551. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  54552. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  54553. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  54554. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54555. export * from "babylonjs/Engines/Extensions/engine.webVR";
  54556. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  54557. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  54558. export * from "babylonjs/Engines/Extensions/engine.views";
  54559. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  54560. import "babylonjs/Engines/Extensions/engine.textureSelector";
  54561. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  54562. }
  54563. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  54564. import { Nullable } from "babylonjs/types";
  54565. /**
  54566. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  54567. */
  54568. export interface CubeMapInfo {
  54569. /**
  54570. * The pixel array for the front face.
  54571. * This is stored in format, left to right, up to down format.
  54572. */
  54573. front: Nullable<ArrayBufferView>;
  54574. /**
  54575. * The pixel array for the back face.
  54576. * This is stored in format, left to right, up to down format.
  54577. */
  54578. back: Nullable<ArrayBufferView>;
  54579. /**
  54580. * The pixel array for the left face.
  54581. * This is stored in format, left to right, up to down format.
  54582. */
  54583. left: Nullable<ArrayBufferView>;
  54584. /**
  54585. * The pixel array for the right face.
  54586. * This is stored in format, left to right, up to down format.
  54587. */
  54588. right: Nullable<ArrayBufferView>;
  54589. /**
  54590. * The pixel array for the up face.
  54591. * This is stored in format, left to right, up to down format.
  54592. */
  54593. up: Nullable<ArrayBufferView>;
  54594. /**
  54595. * The pixel array for the down face.
  54596. * This is stored in format, left to right, up to down format.
  54597. */
  54598. down: Nullable<ArrayBufferView>;
  54599. /**
  54600. * The size of the cubemap stored.
  54601. *
  54602. * Each faces will be size * size pixels.
  54603. */
  54604. size: number;
  54605. /**
  54606. * The format of the texture.
  54607. *
  54608. * RGBA, RGB.
  54609. */
  54610. format: number;
  54611. /**
  54612. * The type of the texture data.
  54613. *
  54614. * UNSIGNED_INT, FLOAT.
  54615. */
  54616. type: number;
  54617. /**
  54618. * Specifies whether the texture is in gamma space.
  54619. */
  54620. gammaSpace: boolean;
  54621. }
  54622. /**
  54623. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  54624. */
  54625. export class PanoramaToCubeMapTools {
  54626. private static FACE_LEFT;
  54627. private static FACE_RIGHT;
  54628. private static FACE_FRONT;
  54629. private static FACE_BACK;
  54630. private static FACE_DOWN;
  54631. private static FACE_UP;
  54632. /**
  54633. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  54634. *
  54635. * @param float32Array The source data.
  54636. * @param inputWidth The width of the input panorama.
  54637. * @param inputHeight The height of the input panorama.
  54638. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  54639. * @return The cubemap data
  54640. */
  54641. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  54642. private static CreateCubemapTexture;
  54643. private static CalcProjectionSpherical;
  54644. }
  54645. }
  54646. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  54647. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54648. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54649. import { Nullable } from "babylonjs/types";
  54650. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54651. /**
  54652. * Helper class dealing with the extraction of spherical polynomial dataArray
  54653. * from a cube map.
  54654. */
  54655. export class CubeMapToSphericalPolynomialTools {
  54656. private static FileFaces;
  54657. /**
  54658. * Converts a texture to the according Spherical Polynomial data.
  54659. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54660. *
  54661. * @param texture The texture to extract the information from.
  54662. * @return The Spherical Polynomial data.
  54663. */
  54664. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  54665. /**
  54666. * Converts a cubemap to the according Spherical Polynomial data.
  54667. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54668. *
  54669. * @param cubeInfo The Cube map to extract the information from.
  54670. * @return The Spherical Polynomial data.
  54671. */
  54672. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  54673. }
  54674. }
  54675. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  54676. import { Nullable } from "babylonjs/types";
  54677. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54678. module "babylonjs/Materials/Textures/baseTexture" {
  54679. interface BaseTexture {
  54680. /**
  54681. * Get the polynomial representation of the texture data.
  54682. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54683. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54684. */
  54685. sphericalPolynomial: Nullable<SphericalPolynomial>;
  54686. }
  54687. }
  54688. }
  54689. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  54690. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54691. /** @hidden */
  54692. export var rgbdEncodePixelShader: {
  54693. name: string;
  54694. shader: string;
  54695. };
  54696. }
  54697. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  54698. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54699. /** @hidden */
  54700. export var rgbdDecodePixelShader: {
  54701. name: string;
  54702. shader: string;
  54703. };
  54704. }
  54705. declare module "babylonjs/Misc/environmentTextureTools" {
  54706. import { Nullable } from "babylonjs/types";
  54707. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54708. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54709. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54710. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54711. import "babylonjs/Engines/Extensions/engine.readTexture";
  54712. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54713. import "babylonjs/Shaders/rgbdEncode.fragment";
  54714. import "babylonjs/Shaders/rgbdDecode.fragment";
  54715. /**
  54716. * Raw texture data and descriptor sufficient for WebGL texture upload
  54717. */
  54718. export interface EnvironmentTextureInfo {
  54719. /**
  54720. * Version of the environment map
  54721. */
  54722. version: number;
  54723. /**
  54724. * Width of image
  54725. */
  54726. width: number;
  54727. /**
  54728. * Irradiance information stored in the file.
  54729. */
  54730. irradiance: any;
  54731. /**
  54732. * Specular information stored in the file.
  54733. */
  54734. specular: any;
  54735. }
  54736. /**
  54737. * Defines One Image in the file. It requires only the position in the file
  54738. * as well as the length.
  54739. */
  54740. interface BufferImageData {
  54741. /**
  54742. * Length of the image data.
  54743. */
  54744. length: number;
  54745. /**
  54746. * Position of the data from the null terminator delimiting the end of the JSON.
  54747. */
  54748. position: number;
  54749. }
  54750. /**
  54751. * Defines the specular data enclosed in the file.
  54752. * This corresponds to the version 1 of the data.
  54753. */
  54754. export interface EnvironmentTextureSpecularInfoV1 {
  54755. /**
  54756. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  54757. */
  54758. specularDataPosition?: number;
  54759. /**
  54760. * This contains all the images data needed to reconstruct the cubemap.
  54761. */
  54762. mipmaps: Array<BufferImageData>;
  54763. /**
  54764. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  54765. */
  54766. lodGenerationScale: number;
  54767. }
  54768. /**
  54769. * Sets of helpers addressing the serialization and deserialization of environment texture
  54770. * stored in a BabylonJS env file.
  54771. * Those files are usually stored as .env files.
  54772. */
  54773. export class EnvironmentTextureTools {
  54774. /**
  54775. * Magic number identifying the env file.
  54776. */
  54777. private static _MagicBytes;
  54778. /**
  54779. * Gets the environment info from an env file.
  54780. * @param data The array buffer containing the .env bytes.
  54781. * @returns the environment file info (the json header) if successfully parsed.
  54782. */
  54783. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  54784. /**
  54785. * Creates an environment texture from a loaded cube texture.
  54786. * @param texture defines the cube texture to convert in env file
  54787. * @return a promise containing the environment data if succesfull.
  54788. */
  54789. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  54790. /**
  54791. * Creates a JSON representation of the spherical data.
  54792. * @param texture defines the texture containing the polynomials
  54793. * @return the JSON representation of the spherical info
  54794. */
  54795. private static _CreateEnvTextureIrradiance;
  54796. /**
  54797. * Creates the ArrayBufferViews used for initializing environment texture image data.
  54798. * @param data the image data
  54799. * @param info parameters that determine what views will be created for accessing the underlying buffer
  54800. * @return the views described by info providing access to the underlying buffer
  54801. */
  54802. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  54803. /**
  54804. * Uploads the texture info contained in the env file to the GPU.
  54805. * @param texture defines the internal texture to upload to
  54806. * @param data defines the data to load
  54807. * @param info defines the texture info retrieved through the GetEnvInfo method
  54808. * @returns a promise
  54809. */
  54810. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  54811. private static _OnImageReadyAsync;
  54812. /**
  54813. * Uploads the levels of image data to the GPU.
  54814. * @param texture defines the internal texture to upload to
  54815. * @param imageData defines the array buffer views of image data [mipmap][face]
  54816. * @returns a promise
  54817. */
  54818. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  54819. /**
  54820. * Uploads spherical polynomials information to the texture.
  54821. * @param texture defines the texture we are trying to upload the information to
  54822. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  54823. */
  54824. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  54825. /** @hidden */
  54826. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54827. }
  54828. }
  54829. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  54830. /**
  54831. * Class used to inline functions in shader code
  54832. */
  54833. export class ShaderCodeInliner {
  54834. private static readonly _RegexpFindFunctionNameAndType;
  54835. private _sourceCode;
  54836. private _functionDescr;
  54837. private _numMaxIterations;
  54838. /** Gets or sets the token used to mark the functions to inline */
  54839. inlineToken: string;
  54840. /** Gets or sets the debug mode */
  54841. debug: boolean;
  54842. /** Gets the code after the inlining process */
  54843. get code(): string;
  54844. /**
  54845. * Initializes the inliner
  54846. * @param sourceCode shader code source to inline
  54847. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  54848. */
  54849. constructor(sourceCode: string, numMaxIterations?: number);
  54850. /**
  54851. * Start the processing of the shader code
  54852. */
  54853. processCode(): void;
  54854. private _collectFunctions;
  54855. private _processInlining;
  54856. private _extractBetweenMarkers;
  54857. private _skipWhitespaces;
  54858. private _removeComments;
  54859. private _replaceFunctionCallsByCode;
  54860. private _findBackward;
  54861. private _escapeRegExp;
  54862. private _replaceNames;
  54863. }
  54864. }
  54865. declare module "babylonjs/Engines/nativeEngine" {
  54866. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  54867. import { Engine } from "babylonjs/Engines/engine";
  54868. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  54869. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54870. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54871. import { Effect } from "babylonjs/Materials/effect";
  54872. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54873. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  54874. import { IColor4Like } from "babylonjs/Maths/math.like";
  54875. import { Scene } from "babylonjs/scene";
  54876. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  54877. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  54878. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  54879. /**
  54880. * Container for accessors for natively-stored mesh data buffers.
  54881. */
  54882. class NativeDataBuffer extends DataBuffer {
  54883. /**
  54884. * Accessor value used to identify/retrieve a natively-stored index buffer.
  54885. */
  54886. nativeIndexBuffer?: any;
  54887. /**
  54888. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  54889. */
  54890. nativeVertexBuffer?: any;
  54891. }
  54892. /** @hidden */
  54893. class NativeTexture extends InternalTexture {
  54894. getInternalTexture(): InternalTexture;
  54895. getViewCount(): number;
  54896. }
  54897. /** @hidden */
  54898. export class NativeEngine extends Engine {
  54899. private readonly _native;
  54900. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  54901. private readonly INVALID_HANDLE;
  54902. private _boundBuffersVertexArray;
  54903. getHardwareScalingLevel(): number;
  54904. constructor();
  54905. dispose(): void;
  54906. /**
  54907. * Can be used to override the current requestAnimationFrame requester.
  54908. * @hidden
  54909. */
  54910. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  54911. /**
  54912. * Override default engine behavior.
  54913. * @param color
  54914. * @param backBuffer
  54915. * @param depth
  54916. * @param stencil
  54917. */
  54918. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  54919. /**
  54920. * Gets host document
  54921. * @returns the host document object
  54922. */
  54923. getHostDocument(): Nullable<Document>;
  54924. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54925. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  54926. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  54927. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  54928. [key: string]: VertexBuffer;
  54929. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  54930. bindBuffers(vertexBuffers: {
  54931. [key: string]: VertexBuffer;
  54932. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  54933. recordVertexArrayObject(vertexBuffers: {
  54934. [key: string]: VertexBuffer;
  54935. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  54936. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  54937. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  54938. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54939. /**
  54940. * Draw a list of indexed primitives
  54941. * @param fillMode defines the primitive to use
  54942. * @param indexStart defines the starting index
  54943. * @param indexCount defines the number of index to draw
  54944. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54945. */
  54946. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54947. /**
  54948. * Draw a list of unindexed primitives
  54949. * @param fillMode defines the primitive to use
  54950. * @param verticesStart defines the index of first vertex to draw
  54951. * @param verticesCount defines the count of vertices to draw
  54952. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54953. */
  54954. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54955. createPipelineContext(): IPipelineContext;
  54956. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  54957. /** @hidden */
  54958. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  54959. /** @hidden */
  54960. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  54961. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  54962. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  54963. protected _setProgram(program: WebGLProgram): void;
  54964. _releaseEffect(effect: Effect): void;
  54965. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  54966. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  54967. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  54968. bindSamplers(effect: Effect): void;
  54969. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  54970. getRenderWidth(useScreen?: boolean): number;
  54971. getRenderHeight(useScreen?: boolean): number;
  54972. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  54973. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54974. /**
  54975. * Set the z offset to apply to current rendering
  54976. * @param value defines the offset to apply
  54977. */
  54978. setZOffset(value: number): void;
  54979. /**
  54980. * Gets the current value of the zOffset
  54981. * @returns the current zOffset state
  54982. */
  54983. getZOffset(): number;
  54984. /**
  54985. * Enable or disable depth buffering
  54986. * @param enable defines the state to set
  54987. */
  54988. setDepthBuffer(enable: boolean): void;
  54989. /**
  54990. * Gets a boolean indicating if depth writing is enabled
  54991. * @returns the current depth writing state
  54992. */
  54993. getDepthWrite(): boolean;
  54994. /**
  54995. * Enable or disable depth writing
  54996. * @param enable defines the state to set
  54997. */
  54998. setDepthWrite(enable: boolean): void;
  54999. /**
  55000. * Enable or disable color writing
  55001. * @param enable defines the state to set
  55002. */
  55003. setColorWrite(enable: boolean): void;
  55004. /**
  55005. * Gets a boolean indicating if color writing is enabled
  55006. * @returns the current color writing state
  55007. */
  55008. getColorWrite(): boolean;
  55009. /**
  55010. * Sets alpha constants used by some alpha blending modes
  55011. * @param r defines the red component
  55012. * @param g defines the green component
  55013. * @param b defines the blue component
  55014. * @param a defines the alpha component
  55015. */
  55016. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  55017. /**
  55018. * Sets the current alpha mode
  55019. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  55020. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55021. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55022. */
  55023. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55024. /**
  55025. * Gets the current alpha mode
  55026. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55027. * @returns the current alpha mode
  55028. */
  55029. getAlphaMode(): number;
  55030. setInt(uniform: WebGLUniformLocation, int: number): void;
  55031. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  55032. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  55033. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  55034. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  55035. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  55036. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  55037. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  55038. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  55039. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  55040. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  55041. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  55042. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  55043. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  55044. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  55045. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  55046. setFloat(uniform: WebGLUniformLocation, value: number): void;
  55047. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  55048. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  55049. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  55050. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  55051. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  55052. wipeCaches(bruteForce?: boolean): void;
  55053. _createTexture(): WebGLTexture;
  55054. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  55055. /**
  55056. * Usually called from Texture.ts.
  55057. * Passed information to create a WebGLTexture
  55058. * @param url defines a value which contains one of the following:
  55059. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55060. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55061. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55062. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55063. * @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)
  55064. * @param scene needed for loading to the correct scene
  55065. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55066. * @param onLoad optional callback to be called upon successful completion
  55067. * @param onError optional callback to be called upon failure
  55068. * @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
  55069. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55070. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55071. * @param forcedExtension defines the extension to use to pick the right loader
  55072. * @param mimeType defines an optional mime type
  55073. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55074. */
  55075. 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;
  55076. /**
  55077. * Creates a cube texture
  55078. * @param rootUrl defines the url where the files to load is located
  55079. * @param scene defines the current scene
  55080. * @param files defines the list of files to load (1 per face)
  55081. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  55082. * @param onLoad defines an optional callback raised when the texture is loaded
  55083. * @param onError defines an optional callback raised if there is an issue to load the texture
  55084. * @param format defines the format of the data
  55085. * @param forcedExtension defines the extension to use to pick the right loader
  55086. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  55087. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55088. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55089. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  55090. * @returns the cube texture as an InternalTexture
  55091. */
  55092. 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;
  55093. private _getSamplingFilter;
  55094. private static _GetNativeTextureFormat;
  55095. createRenderTargetTexture(size: number | {
  55096. width: number;
  55097. height: number;
  55098. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  55099. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55100. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55101. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55102. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  55103. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  55104. /**
  55105. * Updates a dynamic vertex buffer.
  55106. * @param vertexBuffer the vertex buffer to update
  55107. * @param data the data used to update the vertex buffer
  55108. * @param byteOffset the byte offset of the data (optional)
  55109. * @param byteLength the byte length of the data (optional)
  55110. */
  55111. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  55112. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  55113. private _updateAnisotropicLevel;
  55114. private _getAddressMode;
  55115. /** @hidden */
  55116. _bindTexture(channel: number, texture: InternalTexture): void;
  55117. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  55118. releaseEffects(): void;
  55119. /** @hidden */
  55120. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55121. /** @hidden */
  55122. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55123. /** @hidden */
  55124. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55125. /** @hidden */
  55126. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55127. }
  55128. }
  55129. declare module "babylonjs/Engines/index" {
  55130. export * from "babylonjs/Engines/constants";
  55131. export * from "babylonjs/Engines/engineCapabilities";
  55132. export * from "babylonjs/Engines/instancingAttributeInfo";
  55133. export * from "babylonjs/Engines/thinEngine";
  55134. export * from "babylonjs/Engines/engine";
  55135. export * from "babylonjs/Engines/engineStore";
  55136. export * from "babylonjs/Engines/nullEngine";
  55137. export * from "babylonjs/Engines/Extensions/index";
  55138. export * from "babylonjs/Engines/IPipelineContext";
  55139. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  55140. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  55141. export * from "babylonjs/Engines/nativeEngine";
  55142. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  55143. export * from "babylonjs/Engines/performanceConfigurator";
  55144. }
  55145. declare module "babylonjs/Events/clipboardEvents" {
  55146. /**
  55147. * Gather the list of clipboard event types as constants.
  55148. */
  55149. export class ClipboardEventTypes {
  55150. /**
  55151. * The clipboard event is fired when a copy command is active (pressed).
  55152. */
  55153. static readonly COPY: number;
  55154. /**
  55155. * The clipboard event is fired when a cut command is active (pressed).
  55156. */
  55157. static readonly CUT: number;
  55158. /**
  55159. * The clipboard event is fired when a paste command is active (pressed).
  55160. */
  55161. static readonly PASTE: number;
  55162. }
  55163. /**
  55164. * This class is used to store clipboard related info for the onClipboardObservable event.
  55165. */
  55166. export class ClipboardInfo {
  55167. /**
  55168. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55169. */
  55170. type: number;
  55171. /**
  55172. * Defines the related dom event
  55173. */
  55174. event: ClipboardEvent;
  55175. /**
  55176. *Creates an instance of ClipboardInfo.
  55177. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  55178. * @param event Defines the related dom event
  55179. */
  55180. constructor(
  55181. /**
  55182. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55183. */
  55184. type: number,
  55185. /**
  55186. * Defines the related dom event
  55187. */
  55188. event: ClipboardEvent);
  55189. /**
  55190. * Get the clipboard event's type from the keycode.
  55191. * @param keyCode Defines the keyCode for the current keyboard event.
  55192. * @return {number}
  55193. */
  55194. static GetTypeFromCharacter(keyCode: number): number;
  55195. }
  55196. }
  55197. declare module "babylonjs/Events/index" {
  55198. export * from "babylonjs/Events/keyboardEvents";
  55199. export * from "babylonjs/Events/pointerEvents";
  55200. export * from "babylonjs/Events/clipboardEvents";
  55201. }
  55202. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  55203. import { Scene } from "babylonjs/scene";
  55204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55205. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55206. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55207. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55208. /**
  55209. * Google Daydream controller
  55210. */
  55211. export class DaydreamController extends WebVRController {
  55212. /**
  55213. * Base Url for the controller model.
  55214. */
  55215. static MODEL_BASE_URL: string;
  55216. /**
  55217. * File name for the controller model.
  55218. */
  55219. static MODEL_FILENAME: string;
  55220. /**
  55221. * Gamepad Id prefix used to identify Daydream Controller.
  55222. */
  55223. static readonly GAMEPAD_ID_PREFIX: string;
  55224. /**
  55225. * Creates a new DaydreamController from a gamepad
  55226. * @param vrGamepad the gamepad that the controller should be created from
  55227. */
  55228. constructor(vrGamepad: any);
  55229. /**
  55230. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55231. * @param scene scene in which to add meshes
  55232. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55233. */
  55234. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55235. /**
  55236. * Called once for each button that changed state since the last frame
  55237. * @param buttonIdx Which button index changed
  55238. * @param state New state of the button
  55239. * @param changes Which properties on the state changed since last frame
  55240. */
  55241. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55242. }
  55243. }
  55244. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  55245. import { Scene } from "babylonjs/scene";
  55246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55247. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55248. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55249. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55250. /**
  55251. * Gear VR Controller
  55252. */
  55253. export class GearVRController extends WebVRController {
  55254. /**
  55255. * Base Url for the controller model.
  55256. */
  55257. static MODEL_BASE_URL: string;
  55258. /**
  55259. * File name for the controller model.
  55260. */
  55261. static MODEL_FILENAME: string;
  55262. /**
  55263. * Gamepad Id prefix used to identify this controller.
  55264. */
  55265. static readonly GAMEPAD_ID_PREFIX: string;
  55266. private readonly _buttonIndexToObservableNameMap;
  55267. /**
  55268. * Creates a new GearVRController from a gamepad
  55269. * @param vrGamepad the gamepad that the controller should be created from
  55270. */
  55271. constructor(vrGamepad: any);
  55272. /**
  55273. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55274. * @param scene scene in which to add meshes
  55275. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55276. */
  55277. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55278. /**
  55279. * Called once for each button that changed state since the last frame
  55280. * @param buttonIdx Which button index changed
  55281. * @param state New state of the button
  55282. * @param changes Which properties on the state changed since last frame
  55283. */
  55284. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55285. }
  55286. }
  55287. declare module "babylonjs/Gamepads/Controllers/genericController" {
  55288. import { Scene } from "babylonjs/scene";
  55289. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55290. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55291. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55292. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55293. /**
  55294. * Generic Controller
  55295. */
  55296. export class GenericController extends WebVRController {
  55297. /**
  55298. * Base Url for the controller model.
  55299. */
  55300. static readonly MODEL_BASE_URL: string;
  55301. /**
  55302. * File name for the controller model.
  55303. */
  55304. static readonly MODEL_FILENAME: string;
  55305. /**
  55306. * Creates a new GenericController from a gamepad
  55307. * @param vrGamepad the gamepad that the controller should be created from
  55308. */
  55309. constructor(vrGamepad: any);
  55310. /**
  55311. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55312. * @param scene scene in which to add meshes
  55313. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55314. */
  55315. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55316. /**
  55317. * Called once for each button that changed state since the last frame
  55318. * @param buttonIdx Which button index changed
  55319. * @param state New state of the button
  55320. * @param changes Which properties on the state changed since last frame
  55321. */
  55322. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55323. }
  55324. }
  55325. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  55326. import { Observable } from "babylonjs/Misc/observable";
  55327. import { Scene } from "babylonjs/scene";
  55328. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55329. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55330. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55331. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55332. /**
  55333. * Oculus Touch Controller
  55334. */
  55335. export class OculusTouchController extends WebVRController {
  55336. /**
  55337. * Base Url for the controller model.
  55338. */
  55339. static MODEL_BASE_URL: string;
  55340. /**
  55341. * File name for the left controller model.
  55342. */
  55343. static MODEL_LEFT_FILENAME: string;
  55344. /**
  55345. * File name for the right controller model.
  55346. */
  55347. static MODEL_RIGHT_FILENAME: string;
  55348. /**
  55349. * Base Url for the Quest controller model.
  55350. */
  55351. static QUEST_MODEL_BASE_URL: string;
  55352. /**
  55353. * @hidden
  55354. * If the controllers are running on a device that needs the updated Quest controller models
  55355. */
  55356. static _IsQuest: boolean;
  55357. /**
  55358. * Fired when the secondary trigger on this controller is modified
  55359. */
  55360. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  55361. /**
  55362. * Fired when the thumb rest on this controller is modified
  55363. */
  55364. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  55365. /**
  55366. * Creates a new OculusTouchController from a gamepad
  55367. * @param vrGamepad the gamepad that the controller should be created from
  55368. */
  55369. constructor(vrGamepad: any);
  55370. /**
  55371. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55372. * @param scene scene in which to add meshes
  55373. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55374. */
  55375. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55376. /**
  55377. * Fired when the A button on this controller is modified
  55378. */
  55379. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55380. /**
  55381. * Fired when the B button on this controller is modified
  55382. */
  55383. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55384. /**
  55385. * Fired when the X button on this controller is modified
  55386. */
  55387. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55388. /**
  55389. * Fired when the Y button on this controller is modified
  55390. */
  55391. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55392. /**
  55393. * Called once for each button that changed state since the last frame
  55394. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  55395. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  55396. * 2) secondary trigger (same)
  55397. * 3) A (right) X (left), touch, pressed = value
  55398. * 4) B / Y
  55399. * 5) thumb rest
  55400. * @param buttonIdx Which button index changed
  55401. * @param state New state of the button
  55402. * @param changes Which properties on the state changed since last frame
  55403. */
  55404. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55405. }
  55406. }
  55407. declare module "babylonjs/Gamepads/Controllers/viveController" {
  55408. import { Scene } from "babylonjs/scene";
  55409. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55410. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55411. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55412. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55413. import { Observable } from "babylonjs/Misc/observable";
  55414. /**
  55415. * Vive Controller
  55416. */
  55417. export class ViveController extends WebVRController {
  55418. /**
  55419. * Base Url for the controller model.
  55420. */
  55421. static MODEL_BASE_URL: string;
  55422. /**
  55423. * File name for the controller model.
  55424. */
  55425. static MODEL_FILENAME: string;
  55426. /**
  55427. * Creates a new ViveController from a gamepad
  55428. * @param vrGamepad the gamepad that the controller should be created from
  55429. */
  55430. constructor(vrGamepad: any);
  55431. /**
  55432. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55433. * @param scene scene in which to add meshes
  55434. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55435. */
  55436. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55437. /**
  55438. * Fired when the left button on this controller is modified
  55439. */
  55440. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55441. /**
  55442. * Fired when the right button on this controller is modified
  55443. */
  55444. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55445. /**
  55446. * Fired when the menu button on this controller is modified
  55447. */
  55448. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55449. /**
  55450. * Called once for each button that changed state since the last frame
  55451. * Vive mapping:
  55452. * 0: touchpad
  55453. * 1: trigger
  55454. * 2: left AND right buttons
  55455. * 3: menu button
  55456. * @param buttonIdx Which button index changed
  55457. * @param state New state of the button
  55458. * @param changes Which properties on the state changed since last frame
  55459. */
  55460. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55461. }
  55462. }
  55463. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  55464. import { Observable } from "babylonjs/Misc/observable";
  55465. import { Scene } from "babylonjs/scene";
  55466. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55467. import { Ray } from "babylonjs/Culling/ray";
  55468. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55469. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55470. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55471. /**
  55472. * Defines the WindowsMotionController object that the state of the windows motion controller
  55473. */
  55474. export class WindowsMotionController extends WebVRController {
  55475. /**
  55476. * The base url used to load the left and right controller models
  55477. */
  55478. static MODEL_BASE_URL: string;
  55479. /**
  55480. * The name of the left controller model file
  55481. */
  55482. static MODEL_LEFT_FILENAME: string;
  55483. /**
  55484. * The name of the right controller model file
  55485. */
  55486. static MODEL_RIGHT_FILENAME: string;
  55487. /**
  55488. * The controller name prefix for this controller type
  55489. */
  55490. static readonly GAMEPAD_ID_PREFIX: string;
  55491. /**
  55492. * The controller id pattern for this controller type
  55493. */
  55494. private static readonly GAMEPAD_ID_PATTERN;
  55495. private _loadedMeshInfo;
  55496. protected readonly _mapping: {
  55497. buttons: string[];
  55498. buttonMeshNames: {
  55499. trigger: string;
  55500. menu: string;
  55501. grip: string;
  55502. thumbstick: string;
  55503. trackpad: string;
  55504. };
  55505. buttonObservableNames: {
  55506. trigger: string;
  55507. menu: string;
  55508. grip: string;
  55509. thumbstick: string;
  55510. trackpad: string;
  55511. };
  55512. axisMeshNames: string[];
  55513. pointingPoseMeshName: string;
  55514. };
  55515. /**
  55516. * Fired when the trackpad on this controller is clicked
  55517. */
  55518. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55519. /**
  55520. * Fired when the trackpad on this controller is modified
  55521. */
  55522. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55523. /**
  55524. * The current x and y values of this controller's trackpad
  55525. */
  55526. trackpad: StickValues;
  55527. /**
  55528. * Creates a new WindowsMotionController from a gamepad
  55529. * @param vrGamepad the gamepad that the controller should be created from
  55530. */
  55531. constructor(vrGamepad: any);
  55532. /**
  55533. * Fired when the trigger on this controller is modified
  55534. */
  55535. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55536. /**
  55537. * Fired when the menu button on this controller is modified
  55538. */
  55539. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55540. /**
  55541. * Fired when the grip button on this controller is modified
  55542. */
  55543. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55544. /**
  55545. * Fired when the thumbstick button on this controller is modified
  55546. */
  55547. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55548. /**
  55549. * Fired when the touchpad button on this controller is modified
  55550. */
  55551. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55552. /**
  55553. * Fired when the touchpad values on this controller are modified
  55554. */
  55555. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  55556. protected _updateTrackpad(): void;
  55557. /**
  55558. * Called once per frame by the engine.
  55559. */
  55560. update(): void;
  55561. /**
  55562. * Called once for each button that changed state since the last frame
  55563. * @param buttonIdx Which button index changed
  55564. * @param state New state of the button
  55565. * @param changes Which properties on the state changed since last frame
  55566. */
  55567. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55568. /**
  55569. * Moves the buttons on the controller mesh based on their current state
  55570. * @param buttonName the name of the button to move
  55571. * @param buttonValue the value of the button which determines the buttons new position
  55572. */
  55573. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  55574. /**
  55575. * Moves the axis on the controller mesh based on its current state
  55576. * @param axis the index of the axis
  55577. * @param axisValue the value of the axis which determines the meshes new position
  55578. * @hidden
  55579. */
  55580. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  55581. /**
  55582. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55583. * @param scene scene in which to add meshes
  55584. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55585. */
  55586. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  55587. /**
  55588. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  55589. * can be transformed by button presses and axes values, based on this._mapping.
  55590. *
  55591. * @param scene scene in which the meshes exist
  55592. * @param meshes list of meshes that make up the controller model to process
  55593. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  55594. */
  55595. private processModel;
  55596. private createMeshInfo;
  55597. /**
  55598. * Gets the ray of the controller in the direction the controller is pointing
  55599. * @param length the length the resulting ray should be
  55600. * @returns a ray in the direction the controller is pointing
  55601. */
  55602. getForwardRay(length?: number): Ray;
  55603. /**
  55604. * Disposes of the controller
  55605. */
  55606. dispose(): void;
  55607. }
  55608. /**
  55609. * This class represents a new windows motion controller in XR.
  55610. */
  55611. export class XRWindowsMotionController extends WindowsMotionController {
  55612. /**
  55613. * Changing the original WIndowsMotionController mapping to fir the new mapping
  55614. */
  55615. protected readonly _mapping: {
  55616. buttons: string[];
  55617. buttonMeshNames: {
  55618. trigger: string;
  55619. menu: string;
  55620. grip: string;
  55621. thumbstick: string;
  55622. trackpad: string;
  55623. };
  55624. buttonObservableNames: {
  55625. trigger: string;
  55626. menu: string;
  55627. grip: string;
  55628. thumbstick: string;
  55629. trackpad: string;
  55630. };
  55631. axisMeshNames: string[];
  55632. pointingPoseMeshName: string;
  55633. };
  55634. /**
  55635. * Construct a new XR-Based windows motion controller
  55636. *
  55637. * @param gamepadInfo the gamepad object from the browser
  55638. */
  55639. constructor(gamepadInfo: any);
  55640. /**
  55641. * holds the thumbstick values (X,Y)
  55642. */
  55643. thumbstickValues: StickValues;
  55644. /**
  55645. * Fired when the thumbstick on this controller is clicked
  55646. */
  55647. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  55648. /**
  55649. * Fired when the thumbstick on this controller is modified
  55650. */
  55651. onThumbstickValuesChangedObservable: Observable<StickValues>;
  55652. /**
  55653. * Fired when the touchpad button on this controller is modified
  55654. */
  55655. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55656. /**
  55657. * Fired when the touchpad values on this controller are modified
  55658. */
  55659. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55660. /**
  55661. * Fired when the thumbstick button on this controller is modified
  55662. * here to prevent breaking changes
  55663. */
  55664. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55665. /**
  55666. * updating the thumbstick(!) and not the trackpad.
  55667. * This is named this way due to the difference between WebVR and XR and to avoid
  55668. * changing the parent class.
  55669. */
  55670. protected _updateTrackpad(): void;
  55671. /**
  55672. * Disposes the class with joy
  55673. */
  55674. dispose(): void;
  55675. }
  55676. }
  55677. declare module "babylonjs/Gamepads/Controllers/index" {
  55678. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  55679. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  55680. export * from "babylonjs/Gamepads/Controllers/genericController";
  55681. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  55682. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55683. export * from "babylonjs/Gamepads/Controllers/viveController";
  55684. export * from "babylonjs/Gamepads/Controllers/webVRController";
  55685. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  55686. }
  55687. declare module "babylonjs/Gamepads/index" {
  55688. export * from "babylonjs/Gamepads/Controllers/index";
  55689. export * from "babylonjs/Gamepads/gamepad";
  55690. export * from "babylonjs/Gamepads/gamepadManager";
  55691. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  55692. export * from "babylonjs/Gamepads/xboxGamepad";
  55693. export * from "babylonjs/Gamepads/dualShockGamepad";
  55694. }
  55695. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  55696. import { Scene } from "babylonjs/scene";
  55697. import { Vector4 } from "babylonjs/Maths/math.vector";
  55698. import { Color4 } from "babylonjs/Maths/math.color";
  55699. import { Mesh } from "babylonjs/Meshes/mesh";
  55700. import { Nullable } from "babylonjs/types";
  55701. /**
  55702. * Class containing static functions to help procedurally build meshes
  55703. */
  55704. export class PolyhedronBuilder {
  55705. /**
  55706. * Creates a polyhedron mesh
  55707. * * 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
  55708. * * The parameter `size` (positive float, default 1) sets the polygon size
  55709. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55710. * * 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`
  55711. * * 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
  55712. * * 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)`)
  55713. * * 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
  55714. * * 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
  55715. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55716. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55717. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55718. * @param name defines the name of the mesh
  55719. * @param options defines the options used to create the mesh
  55720. * @param scene defines the hosting scene
  55721. * @returns the polyhedron mesh
  55722. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55723. */
  55724. static CreatePolyhedron(name: string, options: {
  55725. type?: number;
  55726. size?: number;
  55727. sizeX?: number;
  55728. sizeY?: number;
  55729. sizeZ?: number;
  55730. custom?: any;
  55731. faceUV?: Vector4[];
  55732. faceColors?: Color4[];
  55733. flat?: boolean;
  55734. updatable?: boolean;
  55735. sideOrientation?: number;
  55736. frontUVs?: Vector4;
  55737. backUVs?: Vector4;
  55738. }, scene?: Nullable<Scene>): Mesh;
  55739. }
  55740. }
  55741. declare module "babylonjs/Gizmos/scaleGizmo" {
  55742. import { Observable } from "babylonjs/Misc/observable";
  55743. import { Nullable } from "babylonjs/types";
  55744. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55745. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55746. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  55747. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55748. import { Node } from "babylonjs/node";
  55749. /**
  55750. * Gizmo that enables scaling a mesh along 3 axis
  55751. */
  55752. export class ScaleGizmo extends Gizmo {
  55753. /**
  55754. * Internal gizmo used for interactions on the x axis
  55755. */
  55756. xGizmo: AxisScaleGizmo;
  55757. /**
  55758. * Internal gizmo used for interactions on the y axis
  55759. */
  55760. yGizmo: AxisScaleGizmo;
  55761. /**
  55762. * Internal gizmo used for interactions on the z axis
  55763. */
  55764. zGizmo: AxisScaleGizmo;
  55765. /**
  55766. * Internal gizmo used to scale all axis equally
  55767. */
  55768. uniformScaleGizmo: AxisScaleGizmo;
  55769. private _meshAttached;
  55770. private _nodeAttached;
  55771. private _snapDistance;
  55772. private _uniformScalingMesh;
  55773. private _octahedron;
  55774. private _sensitivity;
  55775. /** Fires an event when any of it's sub gizmos are dragged */
  55776. onDragStartObservable: Observable<unknown>;
  55777. /** Fires an event when any of it's sub gizmos are released from dragging */
  55778. onDragEndObservable: Observable<unknown>;
  55779. get attachedMesh(): Nullable<AbstractMesh>;
  55780. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55781. get attachedNode(): Nullable<Node>;
  55782. set attachedNode(node: Nullable<Node>);
  55783. /**
  55784. * Creates a ScaleGizmo
  55785. * @param gizmoLayer The utility layer the gizmo will be added to
  55786. * @param thickness display gizmo axis thickness
  55787. */
  55788. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55789. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55790. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55791. /**
  55792. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55793. */
  55794. set snapDistance(value: number);
  55795. get snapDistance(): number;
  55796. /**
  55797. * Ratio for the scale of the gizmo (Default: 1)
  55798. */
  55799. set scaleRatio(value: number);
  55800. get scaleRatio(): number;
  55801. /**
  55802. * Sensitivity factor for dragging (Default: 1)
  55803. */
  55804. set sensitivity(value: number);
  55805. get sensitivity(): number;
  55806. /**
  55807. * Disposes of the gizmo
  55808. */
  55809. dispose(): void;
  55810. }
  55811. }
  55812. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  55813. import { Observable } from "babylonjs/Misc/observable";
  55814. import { Nullable } from "babylonjs/types";
  55815. import { Vector3 } from "babylonjs/Maths/math.vector";
  55816. import { Node } from "babylonjs/node";
  55817. import { Mesh } from "babylonjs/Meshes/mesh";
  55818. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55819. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55820. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55821. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55822. import { Color3 } from "babylonjs/Maths/math.color";
  55823. /**
  55824. * Single axis scale gizmo
  55825. */
  55826. export class AxisScaleGizmo extends Gizmo {
  55827. /**
  55828. * Drag behavior responsible for the gizmos dragging interactions
  55829. */
  55830. dragBehavior: PointerDragBehavior;
  55831. private _pointerObserver;
  55832. /**
  55833. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55834. */
  55835. snapDistance: number;
  55836. /**
  55837. * Event that fires each time the gizmo snaps to a new location.
  55838. * * snapDistance is the the change in distance
  55839. */
  55840. onSnapObservable: Observable<{
  55841. snapDistance: number;
  55842. }>;
  55843. /**
  55844. * If the scaling operation should be done on all axis (default: false)
  55845. */
  55846. uniformScaling: boolean;
  55847. /**
  55848. * Custom sensitivity value for the drag strength
  55849. */
  55850. sensitivity: number;
  55851. private _isEnabled;
  55852. private _parent;
  55853. private _arrow;
  55854. private _coloredMaterial;
  55855. private _hoverMaterial;
  55856. /**
  55857. * Creates an AxisScaleGizmo
  55858. * @param gizmoLayer The utility layer the gizmo will be added to
  55859. * @param dragAxis The axis which the gizmo will be able to scale on
  55860. * @param color The color of the gizmo
  55861. * @param thickness display gizmo axis thickness
  55862. */
  55863. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  55864. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55865. /**
  55866. * If the gizmo is enabled
  55867. */
  55868. set isEnabled(value: boolean);
  55869. get isEnabled(): boolean;
  55870. /**
  55871. * Disposes of the gizmo
  55872. */
  55873. dispose(): void;
  55874. /**
  55875. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  55876. * @param mesh The mesh to replace the default mesh of the gizmo
  55877. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  55878. */
  55879. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  55880. }
  55881. }
  55882. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  55883. import { Observable } from "babylonjs/Misc/observable";
  55884. import { Nullable } from "babylonjs/types";
  55885. import { Vector3 } from "babylonjs/Maths/math.vector";
  55886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55887. import { Mesh } from "babylonjs/Meshes/mesh";
  55888. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55889. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55890. import { Color3 } from "babylonjs/Maths/math.color";
  55891. import "babylonjs/Meshes/Builders/boxBuilder";
  55892. /**
  55893. * Bounding box gizmo
  55894. */
  55895. export class BoundingBoxGizmo extends Gizmo {
  55896. private _lineBoundingBox;
  55897. private _rotateSpheresParent;
  55898. private _scaleBoxesParent;
  55899. private _boundingDimensions;
  55900. private _renderObserver;
  55901. private _pointerObserver;
  55902. private _scaleDragSpeed;
  55903. private _tmpQuaternion;
  55904. private _tmpVector;
  55905. private _tmpRotationMatrix;
  55906. /**
  55907. * 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)
  55908. */
  55909. ignoreChildren: boolean;
  55910. /**
  55911. * 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)
  55912. */
  55913. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  55914. /**
  55915. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  55916. */
  55917. rotationSphereSize: number;
  55918. /**
  55919. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  55920. */
  55921. scaleBoxSize: number;
  55922. /**
  55923. * 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)
  55924. */
  55925. fixedDragMeshScreenSize: boolean;
  55926. /**
  55927. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  55928. */
  55929. fixedDragMeshScreenSizeDistanceFactor: number;
  55930. /**
  55931. * Fired when a rotation sphere or scale box is dragged
  55932. */
  55933. onDragStartObservable: Observable<{}>;
  55934. /**
  55935. * Fired when a scale box is dragged
  55936. */
  55937. onScaleBoxDragObservable: Observable<{}>;
  55938. /**
  55939. * Fired when a scale box drag is ended
  55940. */
  55941. onScaleBoxDragEndObservable: Observable<{}>;
  55942. /**
  55943. * Fired when a rotation sphere is dragged
  55944. */
  55945. onRotationSphereDragObservable: Observable<{}>;
  55946. /**
  55947. * Fired when a rotation sphere drag is ended
  55948. */
  55949. onRotationSphereDragEndObservable: Observable<{}>;
  55950. /**
  55951. * 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)
  55952. */
  55953. scalePivot: Nullable<Vector3>;
  55954. /**
  55955. * Mesh used as a pivot to rotate the attached node
  55956. */
  55957. private _anchorMesh;
  55958. private _existingMeshScale;
  55959. private _dragMesh;
  55960. private pointerDragBehavior;
  55961. private coloredMaterial;
  55962. private hoverColoredMaterial;
  55963. /**
  55964. * Sets the color of the bounding box gizmo
  55965. * @param color the color to set
  55966. */
  55967. setColor(color: Color3): void;
  55968. /**
  55969. * Creates an BoundingBoxGizmo
  55970. * @param gizmoLayer The utility layer the gizmo will be added to
  55971. * @param color The color of the gizmo
  55972. */
  55973. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  55974. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  55975. private _selectNode;
  55976. /**
  55977. * Updates the bounding box information for the Gizmo
  55978. */
  55979. updateBoundingBox(): void;
  55980. private _updateRotationSpheres;
  55981. private _updateScaleBoxes;
  55982. /**
  55983. * Enables rotation on the specified axis and disables rotation on the others
  55984. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  55985. */
  55986. setEnabledRotationAxis(axis: string): void;
  55987. /**
  55988. * Enables/disables scaling
  55989. * @param enable if scaling should be enabled
  55990. * @param homogeneousScaling defines if scaling should only be homogeneous
  55991. */
  55992. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  55993. private _updateDummy;
  55994. /**
  55995. * Enables a pointer drag behavior on the bounding box of the gizmo
  55996. */
  55997. enableDragBehavior(): void;
  55998. /**
  55999. * Disposes of the gizmo
  56000. */
  56001. dispose(): void;
  56002. /**
  56003. * 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)
  56004. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  56005. * @returns the bounding box mesh with the passed in mesh as a child
  56006. */
  56007. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  56008. /**
  56009. * CustomMeshes are not supported by this gizmo
  56010. * @param mesh The mesh to replace the default mesh of the gizmo
  56011. */
  56012. setCustomMesh(mesh: Mesh): void;
  56013. }
  56014. }
  56015. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  56016. import { Observable } from "babylonjs/Misc/observable";
  56017. import { Nullable } from "babylonjs/types";
  56018. import { Vector3 } from "babylonjs/Maths/math.vector";
  56019. import { Color3 } from "babylonjs/Maths/math.color";
  56020. import { Node } from "babylonjs/node";
  56021. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56022. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56023. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56024. import "babylonjs/Meshes/Builders/linesBuilder";
  56025. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56026. /**
  56027. * Single plane rotation gizmo
  56028. */
  56029. export class PlaneRotationGizmo extends Gizmo {
  56030. /**
  56031. * Drag behavior responsible for the gizmos dragging interactions
  56032. */
  56033. dragBehavior: PointerDragBehavior;
  56034. private _pointerObserver;
  56035. /**
  56036. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56037. */
  56038. snapDistance: number;
  56039. /**
  56040. * Event that fires each time the gizmo snaps to a new location.
  56041. * * snapDistance is the the change in distance
  56042. */
  56043. onSnapObservable: Observable<{
  56044. snapDistance: number;
  56045. }>;
  56046. private _isEnabled;
  56047. private _parent;
  56048. /**
  56049. * Creates a PlaneRotationGizmo
  56050. * @param gizmoLayer The utility layer the gizmo will be added to
  56051. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  56052. * @param color The color of the gizmo
  56053. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56054. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56055. * @param thickness display gizmo axis thickness
  56056. */
  56057. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  56058. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56059. /**
  56060. * If the gizmo is enabled
  56061. */
  56062. set isEnabled(value: boolean);
  56063. get isEnabled(): boolean;
  56064. /**
  56065. * Disposes of the gizmo
  56066. */
  56067. dispose(): void;
  56068. }
  56069. }
  56070. declare module "babylonjs/Gizmos/rotationGizmo" {
  56071. import { Observable } from "babylonjs/Misc/observable";
  56072. import { Nullable } from "babylonjs/types";
  56073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56074. import { Mesh } from "babylonjs/Meshes/mesh";
  56075. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56076. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  56077. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56078. import { Node } from "babylonjs/node";
  56079. /**
  56080. * Gizmo that enables rotating a mesh along 3 axis
  56081. */
  56082. export class RotationGizmo extends Gizmo {
  56083. /**
  56084. * Internal gizmo used for interactions on the x axis
  56085. */
  56086. xGizmo: PlaneRotationGizmo;
  56087. /**
  56088. * Internal gizmo used for interactions on the y axis
  56089. */
  56090. yGizmo: PlaneRotationGizmo;
  56091. /**
  56092. * Internal gizmo used for interactions on the z axis
  56093. */
  56094. zGizmo: PlaneRotationGizmo;
  56095. /** Fires an event when any of it's sub gizmos are dragged */
  56096. onDragStartObservable: Observable<unknown>;
  56097. /** Fires an event when any of it's sub gizmos are released from dragging */
  56098. onDragEndObservable: Observable<unknown>;
  56099. private _meshAttached;
  56100. private _nodeAttached;
  56101. get attachedMesh(): Nullable<AbstractMesh>;
  56102. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56103. get attachedNode(): Nullable<Node>;
  56104. set attachedNode(node: Nullable<Node>);
  56105. /**
  56106. * Creates a RotationGizmo
  56107. * @param gizmoLayer The utility layer the gizmo will be added to
  56108. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56109. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56110. * @param thickness display gizmo axis thickness
  56111. */
  56112. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  56113. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56114. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56115. /**
  56116. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56117. */
  56118. set snapDistance(value: number);
  56119. get snapDistance(): number;
  56120. /**
  56121. * Ratio for the scale of the gizmo (Default: 1)
  56122. */
  56123. set scaleRatio(value: number);
  56124. get scaleRatio(): number;
  56125. /**
  56126. * Disposes of the gizmo
  56127. */
  56128. dispose(): void;
  56129. /**
  56130. * CustomMeshes are not supported by this gizmo
  56131. * @param mesh The mesh to replace the default mesh of the gizmo
  56132. */
  56133. setCustomMesh(mesh: Mesh): void;
  56134. }
  56135. }
  56136. declare module "babylonjs/Gizmos/gizmoManager" {
  56137. import { Observable } from "babylonjs/Misc/observable";
  56138. import { Nullable } from "babylonjs/types";
  56139. import { Scene, IDisposable } from "babylonjs/scene";
  56140. import { Node } from "babylonjs/node";
  56141. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56142. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56143. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  56144. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56145. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56146. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  56147. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  56148. /**
  56149. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  56150. */
  56151. export class GizmoManager implements IDisposable {
  56152. private scene;
  56153. /**
  56154. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  56155. */
  56156. gizmos: {
  56157. positionGizmo: Nullable<PositionGizmo>;
  56158. rotationGizmo: Nullable<RotationGizmo>;
  56159. scaleGizmo: Nullable<ScaleGizmo>;
  56160. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  56161. };
  56162. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  56163. clearGizmoOnEmptyPointerEvent: boolean;
  56164. /** Fires an event when the manager is attached to a mesh */
  56165. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  56166. /** Fires an event when the manager is attached to a node */
  56167. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  56168. private _gizmosEnabled;
  56169. private _pointerObserver;
  56170. private _attachedMesh;
  56171. private _attachedNode;
  56172. private _boundingBoxColor;
  56173. private _defaultUtilityLayer;
  56174. private _defaultKeepDepthUtilityLayer;
  56175. private _thickness;
  56176. /**
  56177. * When bounding box gizmo is enabled, this can be used to track drag/end events
  56178. */
  56179. boundingBoxDragBehavior: SixDofDragBehavior;
  56180. /**
  56181. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  56182. */
  56183. attachableMeshes: Nullable<Array<AbstractMesh>>;
  56184. /**
  56185. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  56186. */
  56187. attachableNodes: Nullable<Array<Node>>;
  56188. /**
  56189. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  56190. */
  56191. usePointerToAttachGizmos: boolean;
  56192. /**
  56193. * Utility layer that the bounding box gizmo belongs to
  56194. */
  56195. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  56196. /**
  56197. * Utility layer that all gizmos besides bounding box belong to
  56198. */
  56199. get utilityLayer(): UtilityLayerRenderer;
  56200. /**
  56201. * Instatiates a gizmo manager
  56202. * @param scene the scene to overlay the gizmos on top of
  56203. * @param thickness display gizmo axis thickness
  56204. */
  56205. constructor(scene: Scene, thickness?: number);
  56206. /**
  56207. * Attaches a set of gizmos to the specified mesh
  56208. * @param mesh The mesh the gizmo's should be attached to
  56209. */
  56210. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56211. /**
  56212. * Attaches a set of gizmos to the specified node
  56213. * @param node The node the gizmo's should be attached to
  56214. */
  56215. attachToNode(node: Nullable<Node>): void;
  56216. /**
  56217. * If the position gizmo is enabled
  56218. */
  56219. set positionGizmoEnabled(value: boolean);
  56220. get positionGizmoEnabled(): boolean;
  56221. /**
  56222. * If the rotation gizmo is enabled
  56223. */
  56224. set rotationGizmoEnabled(value: boolean);
  56225. get rotationGizmoEnabled(): boolean;
  56226. /**
  56227. * If the scale gizmo is enabled
  56228. */
  56229. set scaleGizmoEnabled(value: boolean);
  56230. get scaleGizmoEnabled(): boolean;
  56231. /**
  56232. * If the boundingBox gizmo is enabled
  56233. */
  56234. set boundingBoxGizmoEnabled(value: boolean);
  56235. get boundingBoxGizmoEnabled(): boolean;
  56236. /**
  56237. * Disposes of the gizmo manager
  56238. */
  56239. dispose(): void;
  56240. }
  56241. }
  56242. declare module "babylonjs/Lights/directionalLight" {
  56243. import { Camera } from "babylonjs/Cameras/camera";
  56244. import { Scene } from "babylonjs/scene";
  56245. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56247. import { Light } from "babylonjs/Lights/light";
  56248. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56249. import { Effect } from "babylonjs/Materials/effect";
  56250. /**
  56251. * A directional light is defined by a direction (what a surprise!).
  56252. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  56253. * 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.
  56254. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56255. */
  56256. export class DirectionalLight extends ShadowLight {
  56257. private _shadowFrustumSize;
  56258. /**
  56259. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  56260. */
  56261. get shadowFrustumSize(): number;
  56262. /**
  56263. * Specifies a fix frustum size for the shadow generation.
  56264. */
  56265. set shadowFrustumSize(value: number);
  56266. private _shadowOrthoScale;
  56267. /**
  56268. * Gets the shadow projection scale against the optimal computed one.
  56269. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56270. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56271. */
  56272. get shadowOrthoScale(): number;
  56273. /**
  56274. * Sets the shadow projection scale against the optimal computed one.
  56275. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56276. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56277. */
  56278. set shadowOrthoScale(value: number);
  56279. /**
  56280. * Automatically compute the projection matrix to best fit (including all the casters)
  56281. * on each frame.
  56282. */
  56283. autoUpdateExtends: boolean;
  56284. /**
  56285. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  56286. * on each frame. autoUpdateExtends must be set to true for this to work
  56287. */
  56288. autoCalcShadowZBounds: boolean;
  56289. private _orthoLeft;
  56290. private _orthoRight;
  56291. private _orthoTop;
  56292. private _orthoBottom;
  56293. /**
  56294. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  56295. * The directional light is emitted from everywhere in the given direction.
  56296. * It can cast shadows.
  56297. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56298. * @param name The friendly name of the light
  56299. * @param direction The direction of the light
  56300. * @param scene The scene the light belongs to
  56301. */
  56302. constructor(name: string, direction: Vector3, scene: Scene);
  56303. /**
  56304. * Returns the string "DirectionalLight".
  56305. * @return The class name
  56306. */
  56307. getClassName(): string;
  56308. /**
  56309. * Returns the integer 1.
  56310. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56311. */
  56312. getTypeID(): number;
  56313. /**
  56314. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  56315. * Returns the DirectionalLight Shadow projection matrix.
  56316. */
  56317. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56318. /**
  56319. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  56320. * Returns the DirectionalLight Shadow projection matrix.
  56321. */
  56322. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  56323. /**
  56324. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  56325. * Returns the DirectionalLight Shadow projection matrix.
  56326. */
  56327. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56328. protected _buildUniformLayout(): void;
  56329. /**
  56330. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  56331. * @param effect The effect to update
  56332. * @param lightIndex The index of the light in the effect to update
  56333. * @returns The directional light
  56334. */
  56335. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  56336. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  56337. /**
  56338. * Gets the minZ used for shadow according to both the scene and the light.
  56339. *
  56340. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56341. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56342. * @param activeCamera The camera we are returning the min for
  56343. * @returns the depth min z
  56344. */
  56345. getDepthMinZ(activeCamera: Camera): number;
  56346. /**
  56347. * Gets the maxZ used for shadow according to both the scene and the light.
  56348. *
  56349. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56350. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56351. * @param activeCamera The camera we are returning the max for
  56352. * @returns the depth max z
  56353. */
  56354. getDepthMaxZ(activeCamera: Camera): number;
  56355. /**
  56356. * Prepares the list of defines specific to the light type.
  56357. * @param defines the list of defines
  56358. * @param lightIndex defines the index of the light for the effect
  56359. */
  56360. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56361. }
  56362. }
  56363. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  56364. import { Mesh } from "babylonjs/Meshes/mesh";
  56365. /**
  56366. * Class containing static functions to help procedurally build meshes
  56367. */
  56368. export class HemisphereBuilder {
  56369. /**
  56370. * Creates a hemisphere mesh
  56371. * @param name defines the name of the mesh
  56372. * @param options defines the options used to create the mesh
  56373. * @param scene defines the hosting scene
  56374. * @returns the hemisphere mesh
  56375. */
  56376. static CreateHemisphere(name: string, options: {
  56377. segments?: number;
  56378. diameter?: number;
  56379. sideOrientation?: number;
  56380. }, scene: any): Mesh;
  56381. }
  56382. }
  56383. declare module "babylonjs/Lights/spotLight" {
  56384. import { Nullable } from "babylonjs/types";
  56385. import { Scene } from "babylonjs/scene";
  56386. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56387. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56388. import { Effect } from "babylonjs/Materials/effect";
  56389. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56390. import { Light } from "babylonjs/Lights/light";
  56391. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56392. /**
  56393. * A spot light is defined by a position, a direction, an angle, and an exponent.
  56394. * These values define a cone of light starting from the position, emitting toward the direction.
  56395. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  56396. * and the exponent defines the speed of the decay of the light with distance (reach).
  56397. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56398. */
  56399. export class SpotLight extends ShadowLight {
  56400. private _angle;
  56401. private _innerAngle;
  56402. private _cosHalfAngle;
  56403. private _lightAngleScale;
  56404. private _lightAngleOffset;
  56405. /**
  56406. * Gets the cone angle of the spot light in Radians.
  56407. */
  56408. get angle(): number;
  56409. /**
  56410. * Sets the cone angle of the spot light in Radians.
  56411. */
  56412. set angle(value: number);
  56413. /**
  56414. * Only used in gltf falloff mode, this defines the angle where
  56415. * the directional falloff will start before cutting at angle which could be seen
  56416. * as outer angle.
  56417. */
  56418. get innerAngle(): number;
  56419. /**
  56420. * Only used in gltf falloff mode, this defines the angle where
  56421. * the directional falloff will start before cutting at angle which could be seen
  56422. * as outer angle.
  56423. */
  56424. set innerAngle(value: number);
  56425. private _shadowAngleScale;
  56426. /**
  56427. * Allows scaling the angle of the light for shadow generation only.
  56428. */
  56429. get shadowAngleScale(): number;
  56430. /**
  56431. * Allows scaling the angle of the light for shadow generation only.
  56432. */
  56433. set shadowAngleScale(value: number);
  56434. /**
  56435. * The light decay speed with the distance from the emission spot.
  56436. */
  56437. exponent: number;
  56438. private _projectionTextureMatrix;
  56439. /**
  56440. * Allows reading the projecton texture
  56441. */
  56442. get projectionTextureMatrix(): Matrix;
  56443. protected _projectionTextureLightNear: number;
  56444. /**
  56445. * Gets the near clip of the Spotlight for texture projection.
  56446. */
  56447. get projectionTextureLightNear(): number;
  56448. /**
  56449. * Sets the near clip of the Spotlight for texture projection.
  56450. */
  56451. set projectionTextureLightNear(value: number);
  56452. protected _projectionTextureLightFar: number;
  56453. /**
  56454. * Gets the far clip of the Spotlight for texture projection.
  56455. */
  56456. get projectionTextureLightFar(): number;
  56457. /**
  56458. * Sets the far clip of the Spotlight for texture projection.
  56459. */
  56460. set projectionTextureLightFar(value: number);
  56461. protected _projectionTextureUpDirection: Vector3;
  56462. /**
  56463. * Gets the Up vector of the Spotlight for texture projection.
  56464. */
  56465. get projectionTextureUpDirection(): Vector3;
  56466. /**
  56467. * Sets the Up vector of the Spotlight for texture projection.
  56468. */
  56469. set projectionTextureUpDirection(value: Vector3);
  56470. private _projectionTexture;
  56471. /**
  56472. * Gets the projection texture of the light.
  56473. */
  56474. get projectionTexture(): Nullable<BaseTexture>;
  56475. /**
  56476. * Sets the projection texture of the light.
  56477. */
  56478. set projectionTexture(value: Nullable<BaseTexture>);
  56479. private _projectionTextureViewLightDirty;
  56480. private _projectionTextureProjectionLightDirty;
  56481. private _projectionTextureDirty;
  56482. private _projectionTextureViewTargetVector;
  56483. private _projectionTextureViewLightMatrix;
  56484. private _projectionTextureProjectionLightMatrix;
  56485. private _projectionTextureScalingMatrix;
  56486. /**
  56487. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  56488. * It can cast shadows.
  56489. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56490. * @param name The light friendly name
  56491. * @param position The position of the spot light in the scene
  56492. * @param direction The direction of the light in the scene
  56493. * @param angle The cone angle of the light in Radians
  56494. * @param exponent The light decay speed with the distance from the emission spot
  56495. * @param scene The scene the lights belongs to
  56496. */
  56497. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  56498. /**
  56499. * Returns the string "SpotLight".
  56500. * @returns the class name
  56501. */
  56502. getClassName(): string;
  56503. /**
  56504. * Returns the integer 2.
  56505. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56506. */
  56507. getTypeID(): number;
  56508. /**
  56509. * Overrides the direction setter to recompute the projection texture view light Matrix.
  56510. */
  56511. protected _setDirection(value: Vector3): void;
  56512. /**
  56513. * Overrides the position setter to recompute the projection texture view light Matrix.
  56514. */
  56515. protected _setPosition(value: Vector3): void;
  56516. /**
  56517. * 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.
  56518. * Returns the SpotLight.
  56519. */
  56520. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56521. protected _computeProjectionTextureViewLightMatrix(): void;
  56522. protected _computeProjectionTextureProjectionLightMatrix(): void;
  56523. /**
  56524. * Main function for light texture projection matrix computing.
  56525. */
  56526. protected _computeProjectionTextureMatrix(): void;
  56527. protected _buildUniformLayout(): void;
  56528. private _computeAngleValues;
  56529. /**
  56530. * Sets the passed Effect "effect" with the Light textures.
  56531. * @param effect The effect to update
  56532. * @param lightIndex The index of the light in the effect to update
  56533. * @returns The light
  56534. */
  56535. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  56536. /**
  56537. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  56538. * @param effect The effect to update
  56539. * @param lightIndex The index of the light in the effect to update
  56540. * @returns The spot light
  56541. */
  56542. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  56543. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56544. /**
  56545. * Disposes the light and the associated resources.
  56546. */
  56547. dispose(): void;
  56548. /**
  56549. * Prepares the list of defines specific to the light type.
  56550. * @param defines the list of defines
  56551. * @param lightIndex defines the index of the light for the effect
  56552. */
  56553. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56554. }
  56555. }
  56556. declare module "babylonjs/Gizmos/lightGizmo" {
  56557. import { Nullable } from "babylonjs/types";
  56558. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56559. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56560. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56561. import { Light } from "babylonjs/Lights/light";
  56562. import { Observable } from "babylonjs/Misc/observable";
  56563. /**
  56564. * Gizmo that enables viewing a light
  56565. */
  56566. export class LightGizmo extends Gizmo {
  56567. private _lightMesh;
  56568. private _material;
  56569. private _cachedPosition;
  56570. private _cachedForward;
  56571. private _attachedMeshParent;
  56572. private _pointerObserver;
  56573. /**
  56574. * Event that fires each time the gizmo is clicked
  56575. */
  56576. onClickedObservable: Observable<Light>;
  56577. /**
  56578. * Creates a LightGizmo
  56579. * @param gizmoLayer The utility layer the gizmo will be added to
  56580. */
  56581. constructor(gizmoLayer?: UtilityLayerRenderer);
  56582. private _light;
  56583. /**
  56584. * The light that the gizmo is attached to
  56585. */
  56586. set light(light: Nullable<Light>);
  56587. get light(): Nullable<Light>;
  56588. /**
  56589. * Gets the material used to render the light gizmo
  56590. */
  56591. get material(): StandardMaterial;
  56592. /**
  56593. * @hidden
  56594. * Updates the gizmo to match the attached mesh's position/rotation
  56595. */
  56596. protected _update(): void;
  56597. private static _Scale;
  56598. /**
  56599. * Creates the lines for a light mesh
  56600. */
  56601. private static _CreateLightLines;
  56602. /**
  56603. * Disposes of the light gizmo
  56604. */
  56605. dispose(): void;
  56606. private static _CreateHemisphericLightMesh;
  56607. private static _CreatePointLightMesh;
  56608. private static _CreateSpotLightMesh;
  56609. private static _CreateDirectionalLightMesh;
  56610. }
  56611. }
  56612. declare module "babylonjs/Gizmos/cameraGizmo" {
  56613. import { Nullable } from "babylonjs/types";
  56614. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56615. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56616. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56617. import { Camera } from "babylonjs/Cameras/camera";
  56618. import { Observable } from "babylonjs/Misc/observable";
  56619. /**
  56620. * Gizmo that enables viewing a camera
  56621. */
  56622. export class CameraGizmo extends Gizmo {
  56623. private _cameraMesh;
  56624. private _cameraLinesMesh;
  56625. private _material;
  56626. private _pointerObserver;
  56627. /**
  56628. * Event that fires each time the gizmo is clicked
  56629. */
  56630. onClickedObservable: Observable<Camera>;
  56631. /**
  56632. * Creates a CameraGizmo
  56633. * @param gizmoLayer The utility layer the gizmo will be added to
  56634. */
  56635. constructor(gizmoLayer?: UtilityLayerRenderer);
  56636. private _camera;
  56637. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  56638. get displayFrustum(): boolean;
  56639. set displayFrustum(value: boolean);
  56640. /**
  56641. * The camera that the gizmo is attached to
  56642. */
  56643. set camera(camera: Nullable<Camera>);
  56644. get camera(): Nullable<Camera>;
  56645. /**
  56646. * Gets the material used to render the camera gizmo
  56647. */
  56648. get material(): StandardMaterial;
  56649. /**
  56650. * @hidden
  56651. * Updates the gizmo to match the attached mesh's position/rotation
  56652. */
  56653. protected _update(): void;
  56654. private static _Scale;
  56655. private _invProjection;
  56656. /**
  56657. * Disposes of the camera gizmo
  56658. */
  56659. dispose(): void;
  56660. private static _CreateCameraMesh;
  56661. private static _CreateCameraFrustum;
  56662. }
  56663. }
  56664. declare module "babylonjs/Gizmos/index" {
  56665. export * from "babylonjs/Gizmos/axisDragGizmo";
  56666. export * from "babylonjs/Gizmos/axisScaleGizmo";
  56667. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  56668. export * from "babylonjs/Gizmos/gizmo";
  56669. export * from "babylonjs/Gizmos/gizmoManager";
  56670. export * from "babylonjs/Gizmos/planeRotationGizmo";
  56671. export * from "babylonjs/Gizmos/positionGizmo";
  56672. export * from "babylonjs/Gizmos/rotationGizmo";
  56673. export * from "babylonjs/Gizmos/scaleGizmo";
  56674. export * from "babylonjs/Gizmos/lightGizmo";
  56675. export * from "babylonjs/Gizmos/cameraGizmo";
  56676. export * from "babylonjs/Gizmos/planeDragGizmo";
  56677. }
  56678. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  56679. /** @hidden */
  56680. export var backgroundFragmentDeclaration: {
  56681. name: string;
  56682. shader: string;
  56683. };
  56684. }
  56685. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  56686. /** @hidden */
  56687. export var backgroundUboDeclaration: {
  56688. name: string;
  56689. shader: string;
  56690. };
  56691. }
  56692. declare module "babylonjs/Shaders/background.fragment" {
  56693. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  56694. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56695. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56696. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56697. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56698. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56699. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56700. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56701. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56702. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56703. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  56704. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56705. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56706. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56707. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  56708. /** @hidden */
  56709. export var backgroundPixelShader: {
  56710. name: string;
  56711. shader: string;
  56712. };
  56713. }
  56714. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  56715. /** @hidden */
  56716. export var backgroundVertexDeclaration: {
  56717. name: string;
  56718. shader: string;
  56719. };
  56720. }
  56721. declare module "babylonjs/Shaders/background.vertex" {
  56722. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  56723. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56724. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56725. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56726. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56727. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  56728. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  56729. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56730. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56731. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56732. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56733. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56734. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  56735. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56736. /** @hidden */
  56737. export var backgroundVertexShader: {
  56738. name: string;
  56739. shader: string;
  56740. };
  56741. }
  56742. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  56743. import { Nullable, int, float } from "babylonjs/types";
  56744. import { Scene } from "babylonjs/scene";
  56745. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56746. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56747. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56748. import { Mesh } from "babylonjs/Meshes/mesh";
  56749. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56750. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  56751. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  56752. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56753. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  56754. import { Color3 } from "babylonjs/Maths/math.color";
  56755. import "babylonjs/Shaders/background.fragment";
  56756. import "babylonjs/Shaders/background.vertex";
  56757. /**
  56758. * Background material used to create an efficient environement around your scene.
  56759. */
  56760. export class BackgroundMaterial extends PushMaterial {
  56761. /**
  56762. * Standard reflectance value at parallel view angle.
  56763. */
  56764. static StandardReflectance0: number;
  56765. /**
  56766. * Standard reflectance value at grazing angle.
  56767. */
  56768. static StandardReflectance90: number;
  56769. protected _primaryColor: Color3;
  56770. /**
  56771. * Key light Color (multiply against the environement texture)
  56772. */
  56773. primaryColor: Color3;
  56774. protected __perceptualColor: Nullable<Color3>;
  56775. /**
  56776. * Experimental Internal Use Only.
  56777. *
  56778. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  56779. * This acts as a helper to set the primary color to a more "human friendly" value.
  56780. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  56781. * output color as close as possible from the chosen value.
  56782. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  56783. * part of lighting setup.)
  56784. */
  56785. get _perceptualColor(): Nullable<Color3>;
  56786. set _perceptualColor(value: Nullable<Color3>);
  56787. protected _primaryColorShadowLevel: float;
  56788. /**
  56789. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  56790. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  56791. */
  56792. get primaryColorShadowLevel(): float;
  56793. set primaryColorShadowLevel(value: float);
  56794. protected _primaryColorHighlightLevel: float;
  56795. /**
  56796. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  56797. * The primary color is used at the level chosen to define what the white area would look.
  56798. */
  56799. get primaryColorHighlightLevel(): float;
  56800. set primaryColorHighlightLevel(value: float);
  56801. protected _reflectionTexture: Nullable<BaseTexture>;
  56802. /**
  56803. * Reflection Texture used in the material.
  56804. * Should be author in a specific way for the best result (refer to the documentation).
  56805. */
  56806. reflectionTexture: Nullable<BaseTexture>;
  56807. protected _reflectionBlur: float;
  56808. /**
  56809. * Reflection Texture level of blur.
  56810. *
  56811. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  56812. * texture twice.
  56813. */
  56814. reflectionBlur: float;
  56815. protected _diffuseTexture: Nullable<BaseTexture>;
  56816. /**
  56817. * Diffuse Texture used in the material.
  56818. * Should be author in a specific way for the best result (refer to the documentation).
  56819. */
  56820. diffuseTexture: Nullable<BaseTexture>;
  56821. protected _shadowLights: Nullable<IShadowLight[]>;
  56822. /**
  56823. * Specify the list of lights casting shadow on the material.
  56824. * All scene shadow lights will be included if null.
  56825. */
  56826. shadowLights: Nullable<IShadowLight[]>;
  56827. protected _shadowLevel: float;
  56828. /**
  56829. * Helps adjusting the shadow to a softer level if required.
  56830. * 0 means black shadows and 1 means no shadows.
  56831. */
  56832. shadowLevel: float;
  56833. protected _sceneCenter: Vector3;
  56834. /**
  56835. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  56836. * It is usually zero but might be interesting to modify according to your setup.
  56837. */
  56838. sceneCenter: Vector3;
  56839. protected _opacityFresnel: boolean;
  56840. /**
  56841. * This helps specifying that the material is falling off to the sky box at grazing angle.
  56842. * This helps ensuring a nice transition when the camera goes under the ground.
  56843. */
  56844. opacityFresnel: boolean;
  56845. protected _reflectionFresnel: boolean;
  56846. /**
  56847. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  56848. * This helps adding a mirror texture on the ground.
  56849. */
  56850. reflectionFresnel: boolean;
  56851. protected _reflectionFalloffDistance: number;
  56852. /**
  56853. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  56854. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  56855. */
  56856. reflectionFalloffDistance: number;
  56857. protected _reflectionAmount: number;
  56858. /**
  56859. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  56860. */
  56861. reflectionAmount: number;
  56862. protected _reflectionReflectance0: number;
  56863. /**
  56864. * This specifies the weight of the reflection at grazing angle.
  56865. */
  56866. reflectionReflectance0: number;
  56867. protected _reflectionReflectance90: number;
  56868. /**
  56869. * This specifies the weight of the reflection at a perpendicular point of view.
  56870. */
  56871. reflectionReflectance90: number;
  56872. /**
  56873. * Sets the reflection reflectance fresnel values according to the default standard
  56874. * empirically know to work well :-)
  56875. */
  56876. set reflectionStandardFresnelWeight(value: number);
  56877. protected _useRGBColor: boolean;
  56878. /**
  56879. * Helps to directly use the maps channels instead of their level.
  56880. */
  56881. useRGBColor: boolean;
  56882. protected _enableNoise: boolean;
  56883. /**
  56884. * This helps reducing the banding effect that could occur on the background.
  56885. */
  56886. enableNoise: boolean;
  56887. /**
  56888. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56889. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  56890. * Recommended to be keep at 1.0 except for special cases.
  56891. */
  56892. get fovMultiplier(): number;
  56893. set fovMultiplier(value: number);
  56894. private _fovMultiplier;
  56895. /**
  56896. * Enable the FOV adjustment feature controlled by fovMultiplier.
  56897. */
  56898. useEquirectangularFOV: boolean;
  56899. private _maxSimultaneousLights;
  56900. /**
  56901. * Number of Simultaneous lights allowed on the material.
  56902. */
  56903. maxSimultaneousLights: int;
  56904. private _shadowOnly;
  56905. /**
  56906. * Make the material only render shadows
  56907. */
  56908. shadowOnly: boolean;
  56909. /**
  56910. * Default configuration related to image processing available in the Background Material.
  56911. */
  56912. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56913. /**
  56914. * Keep track of the image processing observer to allow dispose and replace.
  56915. */
  56916. private _imageProcessingObserver;
  56917. /**
  56918. * Attaches a new image processing configuration to the PBR Material.
  56919. * @param configuration (if null the scene configuration will be use)
  56920. */
  56921. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56922. /**
  56923. * Gets the image processing configuration used either in this material.
  56924. */
  56925. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  56926. /**
  56927. * Sets the Default image processing configuration used either in the this material.
  56928. *
  56929. * If sets to null, the scene one is in use.
  56930. */
  56931. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  56932. /**
  56933. * Gets wether the color curves effect is enabled.
  56934. */
  56935. get cameraColorCurvesEnabled(): boolean;
  56936. /**
  56937. * Sets wether the color curves effect is enabled.
  56938. */
  56939. set cameraColorCurvesEnabled(value: boolean);
  56940. /**
  56941. * Gets wether the color grading effect is enabled.
  56942. */
  56943. get cameraColorGradingEnabled(): boolean;
  56944. /**
  56945. * Gets wether the color grading effect is enabled.
  56946. */
  56947. set cameraColorGradingEnabled(value: boolean);
  56948. /**
  56949. * Gets wether tonemapping is enabled or not.
  56950. */
  56951. get cameraToneMappingEnabled(): boolean;
  56952. /**
  56953. * Sets wether tonemapping is enabled or not
  56954. */
  56955. set cameraToneMappingEnabled(value: boolean);
  56956. /**
  56957. * The camera exposure used on this material.
  56958. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56959. * This corresponds to a photographic exposure.
  56960. */
  56961. get cameraExposure(): float;
  56962. /**
  56963. * The camera exposure used on this material.
  56964. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56965. * This corresponds to a photographic exposure.
  56966. */
  56967. set cameraExposure(value: float);
  56968. /**
  56969. * Gets The camera contrast used on this material.
  56970. */
  56971. get cameraContrast(): float;
  56972. /**
  56973. * Sets The camera contrast used on this material.
  56974. */
  56975. set cameraContrast(value: float);
  56976. /**
  56977. * Gets the Color Grading 2D Lookup Texture.
  56978. */
  56979. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56980. /**
  56981. * Sets the Color Grading 2D Lookup Texture.
  56982. */
  56983. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56984. /**
  56985. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56986. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56987. * 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;
  56988. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56989. */
  56990. get cameraColorCurves(): Nullable<ColorCurves>;
  56991. /**
  56992. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56993. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56994. * 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;
  56995. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56996. */
  56997. set cameraColorCurves(value: Nullable<ColorCurves>);
  56998. /**
  56999. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  57000. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  57001. */
  57002. switchToBGR: boolean;
  57003. private _renderTargets;
  57004. private _reflectionControls;
  57005. private _white;
  57006. private _primaryShadowColor;
  57007. private _primaryHighlightColor;
  57008. /**
  57009. * Instantiates a Background Material in the given scene
  57010. * @param name The friendly name of the material
  57011. * @param scene The scene to add the material to
  57012. */
  57013. constructor(name: string, scene: Scene);
  57014. /**
  57015. * Gets a boolean indicating that current material needs to register RTT
  57016. */
  57017. get hasRenderTargetTextures(): boolean;
  57018. /**
  57019. * The entire material has been created in order to prevent overdraw.
  57020. * @returns false
  57021. */
  57022. needAlphaTesting(): boolean;
  57023. /**
  57024. * The entire material has been created in order to prevent overdraw.
  57025. * @returns true if blending is enable
  57026. */
  57027. needAlphaBlending(): boolean;
  57028. /**
  57029. * Checks wether the material is ready to be rendered for a given mesh.
  57030. * @param mesh The mesh to render
  57031. * @param subMesh The submesh to check against
  57032. * @param useInstances Specify wether or not the material is used with instances
  57033. * @returns true if all the dependencies are ready (Textures, Effects...)
  57034. */
  57035. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57036. /**
  57037. * Compute the primary color according to the chosen perceptual color.
  57038. */
  57039. private _computePrimaryColorFromPerceptualColor;
  57040. /**
  57041. * Compute the highlights and shadow colors according to their chosen levels.
  57042. */
  57043. private _computePrimaryColors;
  57044. /**
  57045. * Build the uniform buffer used in the material.
  57046. */
  57047. buildUniformLayout(): void;
  57048. /**
  57049. * Unbind the material.
  57050. */
  57051. unbind(): void;
  57052. /**
  57053. * Bind only the world matrix to the material.
  57054. * @param world The world matrix to bind.
  57055. */
  57056. bindOnlyWorldMatrix(world: Matrix): void;
  57057. /**
  57058. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  57059. * @param world The world matrix to bind.
  57060. * @param subMesh The submesh to bind for.
  57061. */
  57062. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57063. /**
  57064. * Checks to see if a texture is used in the material.
  57065. * @param texture - Base texture to use.
  57066. * @returns - Boolean specifying if a texture is used in the material.
  57067. */
  57068. hasTexture(texture: BaseTexture): boolean;
  57069. /**
  57070. * Dispose the material.
  57071. * @param forceDisposeEffect Force disposal of the associated effect.
  57072. * @param forceDisposeTextures Force disposal of the associated textures.
  57073. */
  57074. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57075. /**
  57076. * Clones the material.
  57077. * @param name The cloned name.
  57078. * @returns The cloned material.
  57079. */
  57080. clone(name: string): BackgroundMaterial;
  57081. /**
  57082. * Serializes the current material to its JSON representation.
  57083. * @returns The JSON representation.
  57084. */
  57085. serialize(): any;
  57086. /**
  57087. * Gets the class name of the material
  57088. * @returns "BackgroundMaterial"
  57089. */
  57090. getClassName(): string;
  57091. /**
  57092. * Parse a JSON input to create back a background material.
  57093. * @param source The JSON data to parse
  57094. * @param scene The scene to create the parsed material in
  57095. * @param rootUrl The root url of the assets the material depends upon
  57096. * @returns the instantiated BackgroundMaterial.
  57097. */
  57098. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  57099. }
  57100. }
  57101. declare module "babylonjs/Helpers/environmentHelper" {
  57102. import { Observable } from "babylonjs/Misc/observable";
  57103. import { Nullable } from "babylonjs/types";
  57104. import { Scene } from "babylonjs/scene";
  57105. import { Vector3 } from "babylonjs/Maths/math.vector";
  57106. import { Color3 } from "babylonjs/Maths/math.color";
  57107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57108. import { Mesh } from "babylonjs/Meshes/mesh";
  57109. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57110. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  57111. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57112. import "babylonjs/Meshes/Builders/planeBuilder";
  57113. import "babylonjs/Meshes/Builders/boxBuilder";
  57114. /**
  57115. * Represents the different options available during the creation of
  57116. * a Environment helper.
  57117. *
  57118. * This can control the default ground, skybox and image processing setup of your scene.
  57119. */
  57120. export interface IEnvironmentHelperOptions {
  57121. /**
  57122. * Specifies whether or not to create a ground.
  57123. * True by default.
  57124. */
  57125. createGround: boolean;
  57126. /**
  57127. * Specifies the ground size.
  57128. * 15 by default.
  57129. */
  57130. groundSize: number;
  57131. /**
  57132. * The texture used on the ground for the main color.
  57133. * Comes from the BabylonJS CDN by default.
  57134. *
  57135. * Remarks: Can be either a texture or a url.
  57136. */
  57137. groundTexture: string | BaseTexture;
  57138. /**
  57139. * The color mixed in the ground texture by default.
  57140. * BabylonJS clearColor by default.
  57141. */
  57142. groundColor: Color3;
  57143. /**
  57144. * Specifies the ground opacity.
  57145. * 1 by default.
  57146. */
  57147. groundOpacity: number;
  57148. /**
  57149. * Enables the ground to receive shadows.
  57150. * True by default.
  57151. */
  57152. enableGroundShadow: boolean;
  57153. /**
  57154. * Helps preventing the shadow to be fully black on the ground.
  57155. * 0.5 by default.
  57156. */
  57157. groundShadowLevel: number;
  57158. /**
  57159. * Creates a mirror texture attach to the ground.
  57160. * false by default.
  57161. */
  57162. enableGroundMirror: boolean;
  57163. /**
  57164. * Specifies the ground mirror size ratio.
  57165. * 0.3 by default as the default kernel is 64.
  57166. */
  57167. groundMirrorSizeRatio: number;
  57168. /**
  57169. * Specifies the ground mirror blur kernel size.
  57170. * 64 by default.
  57171. */
  57172. groundMirrorBlurKernel: number;
  57173. /**
  57174. * Specifies the ground mirror visibility amount.
  57175. * 1 by default
  57176. */
  57177. groundMirrorAmount: number;
  57178. /**
  57179. * Specifies the ground mirror reflectance weight.
  57180. * This uses the standard weight of the background material to setup the fresnel effect
  57181. * of the mirror.
  57182. * 1 by default.
  57183. */
  57184. groundMirrorFresnelWeight: number;
  57185. /**
  57186. * Specifies the ground mirror Falloff distance.
  57187. * This can helps reducing the size of the reflection.
  57188. * 0 by Default.
  57189. */
  57190. groundMirrorFallOffDistance: number;
  57191. /**
  57192. * Specifies the ground mirror texture type.
  57193. * Unsigned Int by Default.
  57194. */
  57195. groundMirrorTextureType: number;
  57196. /**
  57197. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  57198. * the shown objects.
  57199. */
  57200. groundYBias: number;
  57201. /**
  57202. * Specifies whether or not to create a skybox.
  57203. * True by default.
  57204. */
  57205. createSkybox: boolean;
  57206. /**
  57207. * Specifies the skybox size.
  57208. * 20 by default.
  57209. */
  57210. skyboxSize: number;
  57211. /**
  57212. * The texture used on the skybox for the main color.
  57213. * Comes from the BabylonJS CDN by default.
  57214. *
  57215. * Remarks: Can be either a texture or a url.
  57216. */
  57217. skyboxTexture: string | BaseTexture;
  57218. /**
  57219. * The color mixed in the skybox texture by default.
  57220. * BabylonJS clearColor by default.
  57221. */
  57222. skyboxColor: Color3;
  57223. /**
  57224. * The background rotation around the Y axis of the scene.
  57225. * This helps aligning the key lights of your scene with the background.
  57226. * 0 by default.
  57227. */
  57228. backgroundYRotation: number;
  57229. /**
  57230. * Compute automatically the size of the elements to best fit with the scene.
  57231. */
  57232. sizeAuto: boolean;
  57233. /**
  57234. * Default position of the rootMesh if autoSize is not true.
  57235. */
  57236. rootPosition: Vector3;
  57237. /**
  57238. * Sets up the image processing in the scene.
  57239. * true by default.
  57240. */
  57241. setupImageProcessing: boolean;
  57242. /**
  57243. * The texture used as your environment texture in the scene.
  57244. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  57245. *
  57246. * Remarks: Can be either a texture or a url.
  57247. */
  57248. environmentTexture: string | BaseTexture;
  57249. /**
  57250. * The value of the exposure to apply to the scene.
  57251. * 0.6 by default if setupImageProcessing is true.
  57252. */
  57253. cameraExposure: number;
  57254. /**
  57255. * The value of the contrast to apply to the scene.
  57256. * 1.6 by default if setupImageProcessing is true.
  57257. */
  57258. cameraContrast: number;
  57259. /**
  57260. * Specifies whether or not tonemapping should be enabled in the scene.
  57261. * true by default if setupImageProcessing is true.
  57262. */
  57263. toneMappingEnabled: boolean;
  57264. }
  57265. /**
  57266. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  57267. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  57268. * It also helps with the default setup of your imageProcessing configuration.
  57269. */
  57270. export class EnvironmentHelper {
  57271. /**
  57272. * Default ground texture URL.
  57273. */
  57274. private static _groundTextureCDNUrl;
  57275. /**
  57276. * Default skybox texture URL.
  57277. */
  57278. private static _skyboxTextureCDNUrl;
  57279. /**
  57280. * Default environment texture URL.
  57281. */
  57282. private static _environmentTextureCDNUrl;
  57283. /**
  57284. * Creates the default options for the helper.
  57285. */
  57286. private static _getDefaultOptions;
  57287. private _rootMesh;
  57288. /**
  57289. * Gets the root mesh created by the helper.
  57290. */
  57291. get rootMesh(): Mesh;
  57292. private _skybox;
  57293. /**
  57294. * Gets the skybox created by the helper.
  57295. */
  57296. get skybox(): Nullable<Mesh>;
  57297. private _skyboxTexture;
  57298. /**
  57299. * Gets the skybox texture created by the helper.
  57300. */
  57301. get skyboxTexture(): Nullable<BaseTexture>;
  57302. private _skyboxMaterial;
  57303. /**
  57304. * Gets the skybox material created by the helper.
  57305. */
  57306. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  57307. private _ground;
  57308. /**
  57309. * Gets the ground mesh created by the helper.
  57310. */
  57311. get ground(): Nullable<Mesh>;
  57312. private _groundTexture;
  57313. /**
  57314. * Gets the ground texture created by the helper.
  57315. */
  57316. get groundTexture(): Nullable<BaseTexture>;
  57317. private _groundMirror;
  57318. /**
  57319. * Gets the ground mirror created by the helper.
  57320. */
  57321. get groundMirror(): Nullable<MirrorTexture>;
  57322. /**
  57323. * Gets the ground mirror render list to helps pushing the meshes
  57324. * you wish in the ground reflection.
  57325. */
  57326. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  57327. private _groundMaterial;
  57328. /**
  57329. * Gets the ground material created by the helper.
  57330. */
  57331. get groundMaterial(): Nullable<BackgroundMaterial>;
  57332. /**
  57333. * Stores the creation options.
  57334. */
  57335. private readonly _scene;
  57336. private _options;
  57337. /**
  57338. * This observable will be notified with any error during the creation of the environment,
  57339. * mainly texture creation errors.
  57340. */
  57341. onErrorObservable: Observable<{
  57342. message?: string;
  57343. exception?: any;
  57344. }>;
  57345. /**
  57346. * constructor
  57347. * @param options Defines the options we want to customize the helper
  57348. * @param scene The scene to add the material to
  57349. */
  57350. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  57351. /**
  57352. * Updates the background according to the new options
  57353. * @param options
  57354. */
  57355. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  57356. /**
  57357. * Sets the primary color of all the available elements.
  57358. * @param color the main color to affect to the ground and the background
  57359. */
  57360. setMainColor(color: Color3): void;
  57361. /**
  57362. * Setup the image processing according to the specified options.
  57363. */
  57364. private _setupImageProcessing;
  57365. /**
  57366. * Setup the environment texture according to the specified options.
  57367. */
  57368. private _setupEnvironmentTexture;
  57369. /**
  57370. * Setup the background according to the specified options.
  57371. */
  57372. private _setupBackground;
  57373. /**
  57374. * Get the scene sizes according to the setup.
  57375. */
  57376. private _getSceneSize;
  57377. /**
  57378. * Setup the ground according to the specified options.
  57379. */
  57380. private _setupGround;
  57381. /**
  57382. * Setup the ground material according to the specified options.
  57383. */
  57384. private _setupGroundMaterial;
  57385. /**
  57386. * Setup the ground diffuse texture according to the specified options.
  57387. */
  57388. private _setupGroundDiffuseTexture;
  57389. /**
  57390. * Setup the ground mirror texture according to the specified options.
  57391. */
  57392. private _setupGroundMirrorTexture;
  57393. /**
  57394. * Setup the ground to receive the mirror texture.
  57395. */
  57396. private _setupMirrorInGroundMaterial;
  57397. /**
  57398. * Setup the skybox according to the specified options.
  57399. */
  57400. private _setupSkybox;
  57401. /**
  57402. * Setup the skybox material according to the specified options.
  57403. */
  57404. private _setupSkyboxMaterial;
  57405. /**
  57406. * Setup the skybox reflection texture according to the specified options.
  57407. */
  57408. private _setupSkyboxReflectionTexture;
  57409. private _errorHandler;
  57410. /**
  57411. * Dispose all the elements created by the Helper.
  57412. */
  57413. dispose(): void;
  57414. }
  57415. }
  57416. declare module "babylonjs/Helpers/textureDome" {
  57417. import { Scene } from "babylonjs/scene";
  57418. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57419. import { Mesh } from "babylonjs/Meshes/mesh";
  57420. import { Texture } from "babylonjs/Materials/Textures/texture";
  57421. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57422. import "babylonjs/Meshes/Builders/sphereBuilder";
  57423. import { Nullable } from "babylonjs/types";
  57424. import { Observable } from "babylonjs/Misc/observable";
  57425. /**
  57426. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  57427. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  57428. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57429. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57430. */
  57431. export abstract class TextureDome<T extends Texture> extends TransformNode {
  57432. protected onError: Nullable<(message?: string, exception?: any) => void>;
  57433. /**
  57434. * Define the source as a Monoscopic panoramic 360/180.
  57435. */
  57436. static readonly MODE_MONOSCOPIC: number;
  57437. /**
  57438. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  57439. */
  57440. static readonly MODE_TOPBOTTOM: number;
  57441. /**
  57442. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  57443. */
  57444. static readonly MODE_SIDEBYSIDE: number;
  57445. private _halfDome;
  57446. protected _useDirectMapping: boolean;
  57447. /**
  57448. * The texture being displayed on the sphere
  57449. */
  57450. protected _texture: T;
  57451. /**
  57452. * Gets the texture being displayed on the sphere
  57453. */
  57454. get texture(): T;
  57455. /**
  57456. * Sets the texture being displayed on the sphere
  57457. */
  57458. set texture(newTexture: T);
  57459. /**
  57460. * The skybox material
  57461. */
  57462. protected _material: BackgroundMaterial;
  57463. /**
  57464. * The surface used for the dome
  57465. */
  57466. protected _mesh: Mesh;
  57467. /**
  57468. * Gets the mesh used for the dome.
  57469. */
  57470. get mesh(): Mesh;
  57471. /**
  57472. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  57473. */
  57474. private _halfDomeMask;
  57475. /**
  57476. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57477. * Also see the options.resolution property.
  57478. */
  57479. get fovMultiplier(): number;
  57480. set fovMultiplier(value: number);
  57481. protected _textureMode: number;
  57482. /**
  57483. * Gets or set the current texture mode for the texture. It can be:
  57484. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57485. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57486. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57487. */
  57488. get textureMode(): number;
  57489. /**
  57490. * Sets the current texture mode for the texture. It can be:
  57491. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57492. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57493. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57494. */
  57495. set textureMode(value: number);
  57496. /**
  57497. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  57498. */
  57499. get halfDome(): boolean;
  57500. /**
  57501. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  57502. */
  57503. set halfDome(enabled: boolean);
  57504. /**
  57505. * Oberserver used in Stereoscopic VR Mode.
  57506. */
  57507. private _onBeforeCameraRenderObserver;
  57508. /**
  57509. * Observable raised when an error occured while loading the 360 image
  57510. */
  57511. onLoadErrorObservable: Observable<string>;
  57512. /**
  57513. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  57514. * @param name Element's name, child elements will append suffixes for their own names.
  57515. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  57516. * @param options An object containing optional or exposed sub element properties
  57517. */
  57518. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  57519. resolution?: number;
  57520. clickToPlay?: boolean;
  57521. autoPlay?: boolean;
  57522. loop?: boolean;
  57523. size?: number;
  57524. poster?: string;
  57525. faceForward?: boolean;
  57526. useDirectMapping?: boolean;
  57527. halfDomeMode?: boolean;
  57528. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  57529. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  57530. protected _changeTextureMode(value: number): void;
  57531. /**
  57532. * Releases resources associated with this node.
  57533. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57534. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57535. */
  57536. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57537. }
  57538. }
  57539. declare module "babylonjs/Helpers/photoDome" {
  57540. import { Scene } from "babylonjs/scene";
  57541. import { Texture } from "babylonjs/Materials/Textures/texture";
  57542. import { TextureDome } from "babylonjs/Helpers/textureDome";
  57543. /**
  57544. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  57545. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  57546. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57547. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57548. */
  57549. export class PhotoDome extends TextureDome<Texture> {
  57550. /**
  57551. * Define the image as a Monoscopic panoramic 360 image.
  57552. */
  57553. static readonly MODE_MONOSCOPIC: number;
  57554. /**
  57555. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57556. */
  57557. static readonly MODE_TOPBOTTOM: number;
  57558. /**
  57559. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57560. */
  57561. static readonly MODE_SIDEBYSIDE: number;
  57562. /**
  57563. * Gets or sets the texture being displayed on the sphere
  57564. */
  57565. get photoTexture(): Texture;
  57566. /**
  57567. * sets the texture being displayed on the sphere
  57568. */
  57569. set photoTexture(value: Texture);
  57570. /**
  57571. * Gets the current video mode for the video. It can be:
  57572. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57573. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57574. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57575. */
  57576. get imageMode(): number;
  57577. /**
  57578. * Sets the current video mode for the video. It can be:
  57579. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57580. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57581. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57582. */
  57583. set imageMode(value: number);
  57584. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  57585. }
  57586. }
  57587. declare module "babylonjs/Misc/rgbdTextureTools" {
  57588. import "babylonjs/Shaders/rgbdDecode.fragment";
  57589. import "babylonjs/Engines/Extensions/engine.renderTarget";
  57590. import { Texture } from "babylonjs/Materials/Textures/texture";
  57591. /**
  57592. * Class used to host RGBD texture specific utilities
  57593. */
  57594. export class RGBDTextureTools {
  57595. /**
  57596. * Expand the RGBD Texture from RGBD to Half Float if possible.
  57597. * @param texture the texture to expand.
  57598. */
  57599. static ExpandRGBDTexture(texture: Texture): void;
  57600. }
  57601. }
  57602. declare module "babylonjs/Misc/brdfTextureTools" {
  57603. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57604. import { Scene } from "babylonjs/scene";
  57605. /**
  57606. * Class used to host texture specific utilities
  57607. */
  57608. export class BRDFTextureTools {
  57609. /**
  57610. * Prevents texture cache collision
  57611. */
  57612. private static _instanceNumber;
  57613. /**
  57614. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  57615. * @param scene defines the hosting scene
  57616. * @returns the environment BRDF texture
  57617. */
  57618. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  57619. private static _environmentBRDFBase64Texture;
  57620. }
  57621. }
  57622. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  57623. import { Nullable } from "babylonjs/types";
  57624. import { Color3 } from "babylonjs/Maths/math.color";
  57625. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57626. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57627. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57628. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57629. import { Engine } from "babylonjs/Engines/engine";
  57630. import { Scene } from "babylonjs/scene";
  57631. /**
  57632. * @hidden
  57633. */
  57634. export interface IMaterialClearCoatDefines {
  57635. CLEARCOAT: boolean;
  57636. CLEARCOAT_DEFAULTIOR: boolean;
  57637. CLEARCOAT_TEXTURE: boolean;
  57638. CLEARCOAT_TEXTUREDIRECTUV: number;
  57639. CLEARCOAT_BUMP: boolean;
  57640. CLEARCOAT_BUMPDIRECTUV: number;
  57641. CLEARCOAT_TINT: boolean;
  57642. CLEARCOAT_TINT_TEXTURE: boolean;
  57643. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57644. /** @hidden */
  57645. _areTexturesDirty: boolean;
  57646. }
  57647. /**
  57648. * Define the code related to the clear coat parameters of the pbr material.
  57649. */
  57650. export class PBRClearCoatConfiguration {
  57651. /**
  57652. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57653. * The default fits with a polyurethane material.
  57654. */
  57655. private static readonly _DefaultIndexOfRefraction;
  57656. private _isEnabled;
  57657. /**
  57658. * Defines if the clear coat is enabled in the material.
  57659. */
  57660. isEnabled: boolean;
  57661. /**
  57662. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  57663. */
  57664. intensity: number;
  57665. /**
  57666. * Defines the clear coat layer roughness.
  57667. */
  57668. roughness: number;
  57669. private _indexOfRefraction;
  57670. /**
  57671. * Defines the index of refraction of the clear coat.
  57672. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57673. * The default fits with a polyurethane material.
  57674. * Changing the default value is more performance intensive.
  57675. */
  57676. indexOfRefraction: number;
  57677. private _texture;
  57678. /**
  57679. * Stores the clear coat values in a texture.
  57680. */
  57681. texture: Nullable<BaseTexture>;
  57682. private _bumpTexture;
  57683. /**
  57684. * Define the clear coat specific bump texture.
  57685. */
  57686. bumpTexture: Nullable<BaseTexture>;
  57687. private _isTintEnabled;
  57688. /**
  57689. * Defines if the clear coat tint is enabled in the material.
  57690. */
  57691. isTintEnabled: boolean;
  57692. /**
  57693. * Defines the clear coat tint of the material.
  57694. * This is only use if tint is enabled
  57695. */
  57696. tintColor: Color3;
  57697. /**
  57698. * Defines the distance at which the tint color should be found in the
  57699. * clear coat media.
  57700. * This is only use if tint is enabled
  57701. */
  57702. tintColorAtDistance: number;
  57703. /**
  57704. * Defines the clear coat layer thickness.
  57705. * This is only use if tint is enabled
  57706. */
  57707. tintThickness: number;
  57708. private _tintTexture;
  57709. /**
  57710. * Stores the clear tint values in a texture.
  57711. * rgb is tint
  57712. * a is a thickness factor
  57713. */
  57714. tintTexture: Nullable<BaseTexture>;
  57715. /** @hidden */
  57716. private _internalMarkAllSubMeshesAsTexturesDirty;
  57717. /** @hidden */
  57718. _markAllSubMeshesAsTexturesDirty(): void;
  57719. /**
  57720. * Instantiate a new istance of clear coat configuration.
  57721. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57722. */
  57723. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57724. /**
  57725. * Gets wehter the submesh is ready to be used or not.
  57726. * @param defines the list of "defines" to update.
  57727. * @param scene defines the scene the material belongs to.
  57728. * @param engine defines the engine the material belongs to.
  57729. * @param disableBumpMap defines wether the material disables bump or not.
  57730. * @returns - boolean indicating that the submesh is ready or not.
  57731. */
  57732. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  57733. /**
  57734. * Checks to see if a texture is used in the material.
  57735. * @param defines the list of "defines" to update.
  57736. * @param scene defines the scene to the material belongs to.
  57737. */
  57738. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  57739. /**
  57740. * Binds the material data.
  57741. * @param uniformBuffer defines the Uniform buffer to fill in.
  57742. * @param scene defines the scene the material belongs to.
  57743. * @param engine defines the engine the material belongs to.
  57744. * @param disableBumpMap defines wether the material disables bump or not.
  57745. * @param isFrozen defines wether the material is frozen or not.
  57746. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57747. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57748. */
  57749. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  57750. /**
  57751. * Checks to see if a texture is used in the material.
  57752. * @param texture - Base texture to use.
  57753. * @returns - Boolean specifying if a texture is used in the material.
  57754. */
  57755. hasTexture(texture: BaseTexture): boolean;
  57756. /**
  57757. * Returns an array of the actively used textures.
  57758. * @param activeTextures Array of BaseTextures
  57759. */
  57760. getActiveTextures(activeTextures: BaseTexture[]): void;
  57761. /**
  57762. * Returns the animatable textures.
  57763. * @param animatables Array of animatable textures.
  57764. */
  57765. getAnimatables(animatables: IAnimatable[]): void;
  57766. /**
  57767. * Disposes the resources of the material.
  57768. * @param forceDisposeTextures - Forces the disposal of all textures.
  57769. */
  57770. dispose(forceDisposeTextures?: boolean): void;
  57771. /**
  57772. * Get the current class name of the texture useful for serialization or dynamic coding.
  57773. * @returns "PBRClearCoatConfiguration"
  57774. */
  57775. getClassName(): string;
  57776. /**
  57777. * Add fallbacks to the effect fallbacks list.
  57778. * @param defines defines the Base texture to use.
  57779. * @param fallbacks defines the current fallback list.
  57780. * @param currentRank defines the current fallback rank.
  57781. * @returns the new fallback rank.
  57782. */
  57783. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57784. /**
  57785. * Add the required uniforms to the current list.
  57786. * @param uniforms defines the current uniform list.
  57787. */
  57788. static AddUniforms(uniforms: string[]): void;
  57789. /**
  57790. * Add the required samplers to the current list.
  57791. * @param samplers defines the current sampler list.
  57792. */
  57793. static AddSamplers(samplers: string[]): void;
  57794. /**
  57795. * Add the required uniforms to the current buffer.
  57796. * @param uniformBuffer defines the current uniform buffer.
  57797. */
  57798. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57799. /**
  57800. * Makes a duplicate of the current configuration into another one.
  57801. * @param clearCoatConfiguration define the config where to copy the info
  57802. */
  57803. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  57804. /**
  57805. * Serializes this clear coat configuration.
  57806. * @returns - An object with the serialized config.
  57807. */
  57808. serialize(): any;
  57809. /**
  57810. * Parses a anisotropy Configuration from a serialized object.
  57811. * @param source - Serialized object.
  57812. * @param scene Defines the scene we are parsing for
  57813. * @param rootUrl Defines the rootUrl to load from
  57814. */
  57815. parse(source: any, scene: Scene, rootUrl: string): void;
  57816. }
  57817. }
  57818. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  57819. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57820. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57821. import { Vector2 } from "babylonjs/Maths/math.vector";
  57822. import { Scene } from "babylonjs/scene";
  57823. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57824. import { Nullable } from "babylonjs/types";
  57825. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57826. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57827. /**
  57828. * @hidden
  57829. */
  57830. export interface IMaterialAnisotropicDefines {
  57831. ANISOTROPIC: boolean;
  57832. ANISOTROPIC_TEXTURE: boolean;
  57833. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57834. MAINUV1: boolean;
  57835. _areTexturesDirty: boolean;
  57836. _needUVs: boolean;
  57837. }
  57838. /**
  57839. * Define the code related to the anisotropic parameters of the pbr material.
  57840. */
  57841. export class PBRAnisotropicConfiguration {
  57842. private _isEnabled;
  57843. /**
  57844. * Defines if the anisotropy is enabled in the material.
  57845. */
  57846. isEnabled: boolean;
  57847. /**
  57848. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  57849. */
  57850. intensity: number;
  57851. /**
  57852. * Defines if the effect is along the tangents, bitangents or in between.
  57853. * By default, the effect is "strectching" the highlights along the tangents.
  57854. */
  57855. direction: Vector2;
  57856. private _texture;
  57857. /**
  57858. * Stores the anisotropy values in a texture.
  57859. * rg is direction (like normal from -1 to 1)
  57860. * b is a intensity
  57861. */
  57862. texture: Nullable<BaseTexture>;
  57863. /** @hidden */
  57864. private _internalMarkAllSubMeshesAsTexturesDirty;
  57865. /** @hidden */
  57866. _markAllSubMeshesAsTexturesDirty(): void;
  57867. /**
  57868. * Instantiate a new istance of anisotropy configuration.
  57869. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57870. */
  57871. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57872. /**
  57873. * Specifies that the submesh is ready to be used.
  57874. * @param defines the list of "defines" to update.
  57875. * @param scene defines the scene the material belongs to.
  57876. * @returns - boolean indicating that the submesh is ready or not.
  57877. */
  57878. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  57879. /**
  57880. * Checks to see if a texture is used in the material.
  57881. * @param defines the list of "defines" to update.
  57882. * @param mesh the mesh we are preparing the defines for.
  57883. * @param scene defines the scene the material belongs to.
  57884. */
  57885. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  57886. /**
  57887. * Binds the material data.
  57888. * @param uniformBuffer defines the Uniform buffer to fill in.
  57889. * @param scene defines the scene the material belongs to.
  57890. * @param isFrozen defines wether the material is frozen or not.
  57891. */
  57892. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  57893. /**
  57894. * Checks to see if a texture is used in the material.
  57895. * @param texture - Base texture to use.
  57896. * @returns - Boolean specifying if a texture is used in the material.
  57897. */
  57898. hasTexture(texture: BaseTexture): boolean;
  57899. /**
  57900. * Returns an array of the actively used textures.
  57901. * @param activeTextures Array of BaseTextures
  57902. */
  57903. getActiveTextures(activeTextures: BaseTexture[]): void;
  57904. /**
  57905. * Returns the animatable textures.
  57906. * @param animatables Array of animatable textures.
  57907. */
  57908. getAnimatables(animatables: IAnimatable[]): void;
  57909. /**
  57910. * Disposes the resources of the material.
  57911. * @param forceDisposeTextures - Forces the disposal of all textures.
  57912. */
  57913. dispose(forceDisposeTextures?: boolean): void;
  57914. /**
  57915. * Get the current class name of the texture useful for serialization or dynamic coding.
  57916. * @returns "PBRAnisotropicConfiguration"
  57917. */
  57918. getClassName(): string;
  57919. /**
  57920. * Add fallbacks to the effect fallbacks list.
  57921. * @param defines defines the Base texture to use.
  57922. * @param fallbacks defines the current fallback list.
  57923. * @param currentRank defines the current fallback rank.
  57924. * @returns the new fallback rank.
  57925. */
  57926. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57927. /**
  57928. * Add the required uniforms to the current list.
  57929. * @param uniforms defines the current uniform list.
  57930. */
  57931. static AddUniforms(uniforms: string[]): void;
  57932. /**
  57933. * Add the required uniforms to the current buffer.
  57934. * @param uniformBuffer defines the current uniform buffer.
  57935. */
  57936. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57937. /**
  57938. * Add the required samplers to the current list.
  57939. * @param samplers defines the current sampler list.
  57940. */
  57941. static AddSamplers(samplers: string[]): void;
  57942. /**
  57943. * Makes a duplicate of the current configuration into another one.
  57944. * @param anisotropicConfiguration define the config where to copy the info
  57945. */
  57946. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  57947. /**
  57948. * Serializes this anisotropy configuration.
  57949. * @returns - An object with the serialized config.
  57950. */
  57951. serialize(): any;
  57952. /**
  57953. * Parses a anisotropy Configuration from a serialized object.
  57954. * @param source - Serialized object.
  57955. * @param scene Defines the scene we are parsing for
  57956. * @param rootUrl Defines the rootUrl to load from
  57957. */
  57958. parse(source: any, scene: Scene, rootUrl: string): void;
  57959. }
  57960. }
  57961. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  57962. import { Scene } from "babylonjs/scene";
  57963. /**
  57964. * @hidden
  57965. */
  57966. export interface IMaterialBRDFDefines {
  57967. BRDF_V_HEIGHT_CORRELATED: boolean;
  57968. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57969. SPHERICAL_HARMONICS: boolean;
  57970. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57971. /** @hidden */
  57972. _areMiscDirty: boolean;
  57973. }
  57974. /**
  57975. * Define the code related to the BRDF parameters of the pbr material.
  57976. */
  57977. export class PBRBRDFConfiguration {
  57978. /**
  57979. * Default value used for the energy conservation.
  57980. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  57981. */
  57982. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  57983. /**
  57984. * Default value used for the Smith Visibility Height Correlated mode.
  57985. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  57986. */
  57987. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  57988. /**
  57989. * Default value used for the IBL diffuse part.
  57990. * This can help switching back to the polynomials mode globally which is a tiny bit
  57991. * less GPU intensive at the drawback of a lower quality.
  57992. */
  57993. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  57994. /**
  57995. * Default value used for activating energy conservation for the specular workflow.
  57996. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  57997. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  57998. */
  57999. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  58000. private _useEnergyConservation;
  58001. /**
  58002. * Defines if the material uses energy conservation.
  58003. */
  58004. useEnergyConservation: boolean;
  58005. private _useSmithVisibilityHeightCorrelated;
  58006. /**
  58007. * LEGACY Mode set to false
  58008. * Defines if the material uses height smith correlated visibility term.
  58009. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  58010. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  58011. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  58012. * Not relying on height correlated will also disable energy conservation.
  58013. */
  58014. useSmithVisibilityHeightCorrelated: boolean;
  58015. private _useSphericalHarmonics;
  58016. /**
  58017. * LEGACY Mode set to false
  58018. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  58019. * diffuse part of the IBL.
  58020. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  58021. * to the ground truth.
  58022. */
  58023. useSphericalHarmonics: boolean;
  58024. private _useSpecularGlossinessInputEnergyConservation;
  58025. /**
  58026. * Defines if the material uses energy conservation, when the specular workflow is active.
  58027. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  58028. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  58029. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  58030. */
  58031. useSpecularGlossinessInputEnergyConservation: boolean;
  58032. /** @hidden */
  58033. private _internalMarkAllSubMeshesAsMiscDirty;
  58034. /** @hidden */
  58035. _markAllSubMeshesAsMiscDirty(): void;
  58036. /**
  58037. * Instantiate a new istance of clear coat configuration.
  58038. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  58039. */
  58040. constructor(markAllSubMeshesAsMiscDirty: () => void);
  58041. /**
  58042. * Checks to see if a texture is used in the material.
  58043. * @param defines the list of "defines" to update.
  58044. */
  58045. prepareDefines(defines: IMaterialBRDFDefines): void;
  58046. /**
  58047. * Get the current class name of the texture useful for serialization or dynamic coding.
  58048. * @returns "PBRClearCoatConfiguration"
  58049. */
  58050. getClassName(): string;
  58051. /**
  58052. * Makes a duplicate of the current configuration into another one.
  58053. * @param brdfConfiguration define the config where to copy the info
  58054. */
  58055. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  58056. /**
  58057. * Serializes this BRDF configuration.
  58058. * @returns - An object with the serialized config.
  58059. */
  58060. serialize(): any;
  58061. /**
  58062. * Parses a anisotropy Configuration from a serialized object.
  58063. * @param source - Serialized object.
  58064. * @param scene Defines the scene we are parsing for
  58065. * @param rootUrl Defines the rootUrl to load from
  58066. */
  58067. parse(source: any, scene: Scene, rootUrl: string): void;
  58068. }
  58069. }
  58070. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  58071. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58072. import { Color3 } from "babylonjs/Maths/math.color";
  58073. import { Scene } from "babylonjs/scene";
  58074. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58075. import { Nullable } from "babylonjs/types";
  58076. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58077. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58078. /**
  58079. * @hidden
  58080. */
  58081. export interface IMaterialSheenDefines {
  58082. SHEEN: boolean;
  58083. SHEEN_TEXTURE: boolean;
  58084. SHEEN_TEXTUREDIRECTUV: number;
  58085. SHEEN_LINKWITHALBEDO: boolean;
  58086. SHEEN_ROUGHNESS: boolean;
  58087. SHEEN_ALBEDOSCALING: boolean;
  58088. /** @hidden */
  58089. _areTexturesDirty: boolean;
  58090. }
  58091. /**
  58092. * Define the code related to the Sheen parameters of the pbr material.
  58093. */
  58094. export class PBRSheenConfiguration {
  58095. private _isEnabled;
  58096. /**
  58097. * Defines if the material uses sheen.
  58098. */
  58099. isEnabled: boolean;
  58100. private _linkSheenWithAlbedo;
  58101. /**
  58102. * Defines if the sheen is linked to the sheen color.
  58103. */
  58104. linkSheenWithAlbedo: boolean;
  58105. /**
  58106. * Defines the sheen intensity.
  58107. */
  58108. intensity: number;
  58109. /**
  58110. * Defines the sheen color.
  58111. */
  58112. color: Color3;
  58113. private _texture;
  58114. /**
  58115. * Stores the sheen tint values in a texture.
  58116. * rgb is tint
  58117. * a is a intensity or roughness if roughness has been defined
  58118. */
  58119. texture: Nullable<BaseTexture>;
  58120. private _roughness;
  58121. /**
  58122. * Defines the sheen roughness.
  58123. * It is not taken into account if linkSheenWithAlbedo is true.
  58124. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  58125. */
  58126. roughness: Nullable<number>;
  58127. private _albedoScaling;
  58128. /**
  58129. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  58130. * It allows the strength of the sheen effect to not depend on the base color of the material,
  58131. * making it easier to setup and tweak the effect
  58132. */
  58133. albedoScaling: boolean;
  58134. /** @hidden */
  58135. private _internalMarkAllSubMeshesAsTexturesDirty;
  58136. /** @hidden */
  58137. _markAllSubMeshesAsTexturesDirty(): void;
  58138. /**
  58139. * Instantiate a new istance of clear coat configuration.
  58140. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58141. */
  58142. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  58143. /**
  58144. * Specifies that the submesh is ready to be used.
  58145. * @param defines the list of "defines" to update.
  58146. * @param scene defines the scene the material belongs to.
  58147. * @returns - boolean indicating that the submesh is ready or not.
  58148. */
  58149. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  58150. /**
  58151. * Checks to see if a texture is used in the material.
  58152. * @param defines the list of "defines" to update.
  58153. * @param scene defines the scene the material belongs to.
  58154. */
  58155. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  58156. /**
  58157. * Binds the material data.
  58158. * @param uniformBuffer defines the Uniform buffer to fill in.
  58159. * @param scene defines the scene the material belongs to.
  58160. * @param isFrozen defines wether the material is frozen or not.
  58161. */
  58162. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  58163. /**
  58164. * Checks to see if a texture is used in the material.
  58165. * @param texture - Base texture to use.
  58166. * @returns - Boolean specifying if a texture is used in the material.
  58167. */
  58168. hasTexture(texture: BaseTexture): boolean;
  58169. /**
  58170. * Returns an array of the actively used textures.
  58171. * @param activeTextures Array of BaseTextures
  58172. */
  58173. getActiveTextures(activeTextures: BaseTexture[]): void;
  58174. /**
  58175. * Returns the animatable textures.
  58176. * @param animatables Array of animatable textures.
  58177. */
  58178. getAnimatables(animatables: IAnimatable[]): void;
  58179. /**
  58180. * Disposes the resources of the material.
  58181. * @param forceDisposeTextures - Forces the disposal of all textures.
  58182. */
  58183. dispose(forceDisposeTextures?: boolean): void;
  58184. /**
  58185. * Get the current class name of the texture useful for serialization or dynamic coding.
  58186. * @returns "PBRSheenConfiguration"
  58187. */
  58188. getClassName(): string;
  58189. /**
  58190. * Add fallbacks to the effect fallbacks list.
  58191. * @param defines defines the Base texture to use.
  58192. * @param fallbacks defines the current fallback list.
  58193. * @param currentRank defines the current fallback rank.
  58194. * @returns the new fallback rank.
  58195. */
  58196. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58197. /**
  58198. * Add the required uniforms to the current list.
  58199. * @param uniforms defines the current uniform list.
  58200. */
  58201. static AddUniforms(uniforms: string[]): void;
  58202. /**
  58203. * Add the required uniforms to the current buffer.
  58204. * @param uniformBuffer defines the current uniform buffer.
  58205. */
  58206. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58207. /**
  58208. * Add the required samplers to the current list.
  58209. * @param samplers defines the current sampler list.
  58210. */
  58211. static AddSamplers(samplers: string[]): void;
  58212. /**
  58213. * Makes a duplicate of the current configuration into another one.
  58214. * @param sheenConfiguration define the config where to copy the info
  58215. */
  58216. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  58217. /**
  58218. * Serializes this BRDF configuration.
  58219. * @returns - An object with the serialized config.
  58220. */
  58221. serialize(): any;
  58222. /**
  58223. * Parses a anisotropy Configuration from a serialized object.
  58224. * @param source - Serialized object.
  58225. * @param scene Defines the scene we are parsing for
  58226. * @param rootUrl Defines the rootUrl to load from
  58227. */
  58228. parse(source: any, scene: Scene, rootUrl: string): void;
  58229. }
  58230. }
  58231. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  58232. import { Nullable } from "babylonjs/types";
  58233. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58234. import { Color3 } from "babylonjs/Maths/math.color";
  58235. import { SmartArray } from "babylonjs/Misc/smartArray";
  58236. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58237. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58238. import { Effect } from "babylonjs/Materials/effect";
  58239. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58240. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58241. import { Engine } from "babylonjs/Engines/engine";
  58242. import { Scene } from "babylonjs/scene";
  58243. /**
  58244. * @hidden
  58245. */
  58246. export interface IMaterialSubSurfaceDefines {
  58247. SUBSURFACE: boolean;
  58248. SS_REFRACTION: boolean;
  58249. SS_TRANSLUCENCY: boolean;
  58250. SS_SCATTERING: boolean;
  58251. SS_THICKNESSANDMASK_TEXTURE: boolean;
  58252. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  58253. SS_REFRACTIONMAP_3D: boolean;
  58254. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  58255. SS_LODINREFRACTIONALPHA: boolean;
  58256. SS_GAMMAREFRACTION: boolean;
  58257. SS_RGBDREFRACTION: boolean;
  58258. SS_LINEARSPECULARREFRACTION: boolean;
  58259. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  58260. SS_ALBEDOFORREFRACTIONTINT: boolean;
  58261. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  58262. /** @hidden */
  58263. _areTexturesDirty: boolean;
  58264. }
  58265. /**
  58266. * Define the code related to the sub surface parameters of the pbr material.
  58267. */
  58268. export class PBRSubSurfaceConfiguration {
  58269. private _isRefractionEnabled;
  58270. /**
  58271. * Defines if the refraction is enabled in the material.
  58272. */
  58273. isRefractionEnabled: boolean;
  58274. private _isTranslucencyEnabled;
  58275. /**
  58276. * Defines if the translucency is enabled in the material.
  58277. */
  58278. isTranslucencyEnabled: boolean;
  58279. private _isScatteringEnabled;
  58280. /**
  58281. * Defines if the sub surface scattering is enabled in the material.
  58282. */
  58283. isScatteringEnabled: boolean;
  58284. private _scatteringDiffusionProfileIndex;
  58285. /**
  58286. * Diffusion profile for subsurface scattering.
  58287. * Useful for better scattering in the skins or foliages.
  58288. */
  58289. get scatteringDiffusionProfile(): Nullable<Color3>;
  58290. set scatteringDiffusionProfile(c: Nullable<Color3>);
  58291. /**
  58292. * Defines the refraction intensity of the material.
  58293. * The refraction when enabled replaces the Diffuse part of the material.
  58294. * The intensity helps transitionning between diffuse and refraction.
  58295. */
  58296. refractionIntensity: number;
  58297. /**
  58298. * Defines the translucency intensity of the material.
  58299. * When translucency has been enabled, this defines how much of the "translucency"
  58300. * is addded to the diffuse part of the material.
  58301. */
  58302. translucencyIntensity: number;
  58303. /**
  58304. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  58305. */
  58306. useAlbedoToTintRefraction: boolean;
  58307. private _thicknessTexture;
  58308. /**
  58309. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  58310. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  58311. * 0 would mean minimumThickness
  58312. * 1 would mean maximumThickness
  58313. * The other channels might be use as a mask to vary the different effects intensity.
  58314. */
  58315. thicknessTexture: Nullable<BaseTexture>;
  58316. private _refractionTexture;
  58317. /**
  58318. * Defines the texture to use for refraction.
  58319. */
  58320. refractionTexture: Nullable<BaseTexture>;
  58321. private _indexOfRefraction;
  58322. /**
  58323. * Index of refraction of the material base layer.
  58324. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58325. *
  58326. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58327. *
  58328. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58329. */
  58330. indexOfRefraction: number;
  58331. private _volumeIndexOfRefraction;
  58332. /**
  58333. * Index of refraction of the material's volume.
  58334. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58335. *
  58336. * This ONLY impacts refraction. If not provided or given a non-valid value,
  58337. * the volume will use the same IOR as the surface.
  58338. */
  58339. get volumeIndexOfRefraction(): number;
  58340. set volumeIndexOfRefraction(value: number);
  58341. private _invertRefractionY;
  58342. /**
  58343. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58344. */
  58345. invertRefractionY: boolean;
  58346. private _linkRefractionWithTransparency;
  58347. /**
  58348. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58349. * Materials half opaque for instance using refraction could benefit from this control.
  58350. */
  58351. linkRefractionWithTransparency: boolean;
  58352. /**
  58353. * Defines the minimum thickness stored in the thickness map.
  58354. * If no thickness map is defined, this value will be used to simulate thickness.
  58355. */
  58356. minimumThickness: number;
  58357. /**
  58358. * Defines the maximum thickness stored in the thickness map.
  58359. */
  58360. maximumThickness: number;
  58361. /**
  58362. * Defines the volume tint of the material.
  58363. * This is used for both translucency and scattering.
  58364. */
  58365. tintColor: Color3;
  58366. /**
  58367. * Defines the distance at which the tint color should be found in the media.
  58368. * This is used for refraction only.
  58369. */
  58370. tintColorAtDistance: number;
  58371. /**
  58372. * Defines how far each channel transmit through the media.
  58373. * It is defined as a color to simplify it selection.
  58374. */
  58375. diffusionDistance: Color3;
  58376. private _useMaskFromThicknessTexture;
  58377. /**
  58378. * Stores the intensity of the different subsurface effects in the thickness texture.
  58379. * * the green channel is the translucency intensity.
  58380. * * the blue channel is the scattering intensity.
  58381. * * the alpha channel is the refraction intensity.
  58382. */
  58383. useMaskFromThicknessTexture: boolean;
  58384. private _scene;
  58385. /** @hidden */
  58386. private _internalMarkAllSubMeshesAsTexturesDirty;
  58387. private _internalMarkScenePrePassDirty;
  58388. /** @hidden */
  58389. _markAllSubMeshesAsTexturesDirty(): void;
  58390. /** @hidden */
  58391. _markScenePrePassDirty(): void;
  58392. /**
  58393. * Instantiate a new istance of sub surface configuration.
  58394. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58395. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  58396. * @param scene The scene
  58397. */
  58398. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  58399. /**
  58400. * Gets wehter the submesh is ready to be used or not.
  58401. * @param defines the list of "defines" to update.
  58402. * @param scene defines the scene the material belongs to.
  58403. * @returns - boolean indicating that the submesh is ready or not.
  58404. */
  58405. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  58406. /**
  58407. * Checks to see if a texture is used in the material.
  58408. * @param defines the list of "defines" to update.
  58409. * @param scene defines the scene to the material belongs to.
  58410. */
  58411. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  58412. /**
  58413. * Binds the material data.
  58414. * @param uniformBuffer defines the Uniform buffer to fill in.
  58415. * @param scene defines the scene the material belongs to.
  58416. * @param engine defines the engine the material belongs to.
  58417. * @param isFrozen defines whether the material is frozen or not.
  58418. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  58419. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  58420. */
  58421. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  58422. /**
  58423. * Unbinds the material from the mesh.
  58424. * @param activeEffect defines the effect that should be unbound from.
  58425. * @returns true if unbound, otherwise false
  58426. */
  58427. unbind(activeEffect: Effect): boolean;
  58428. /**
  58429. * Returns the texture used for refraction or null if none is used.
  58430. * @param scene defines the scene the material belongs to.
  58431. * @returns - Refraction texture if present. If no refraction texture and refraction
  58432. * is linked with transparency, returns environment texture. Otherwise, returns null.
  58433. */
  58434. private _getRefractionTexture;
  58435. /**
  58436. * Returns true if alpha blending should be disabled.
  58437. */
  58438. get disableAlphaBlending(): boolean;
  58439. /**
  58440. * Fills the list of render target textures.
  58441. * @param renderTargets the list of render targets to update
  58442. */
  58443. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  58444. /**
  58445. * Checks to see if a texture is used in the material.
  58446. * @param texture - Base texture to use.
  58447. * @returns - Boolean specifying if a texture is used in the material.
  58448. */
  58449. hasTexture(texture: BaseTexture): boolean;
  58450. /**
  58451. * Gets a boolean indicating that current material needs to register RTT
  58452. * @returns true if this uses a render target otherwise false.
  58453. */
  58454. hasRenderTargetTextures(): boolean;
  58455. /**
  58456. * Returns an array of the actively used textures.
  58457. * @param activeTextures Array of BaseTextures
  58458. */
  58459. getActiveTextures(activeTextures: BaseTexture[]): void;
  58460. /**
  58461. * Returns the animatable textures.
  58462. * @param animatables Array of animatable textures.
  58463. */
  58464. getAnimatables(animatables: IAnimatable[]): void;
  58465. /**
  58466. * Disposes the resources of the material.
  58467. * @param forceDisposeTextures - Forces the disposal of all textures.
  58468. */
  58469. dispose(forceDisposeTextures?: boolean): void;
  58470. /**
  58471. * Get the current class name of the texture useful for serialization or dynamic coding.
  58472. * @returns "PBRSubSurfaceConfiguration"
  58473. */
  58474. getClassName(): string;
  58475. /**
  58476. * Add fallbacks to the effect fallbacks list.
  58477. * @param defines defines the Base texture to use.
  58478. * @param fallbacks defines the current fallback list.
  58479. * @param currentRank defines the current fallback rank.
  58480. * @returns the new fallback rank.
  58481. */
  58482. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58483. /**
  58484. * Add the required uniforms to the current list.
  58485. * @param uniforms defines the current uniform list.
  58486. */
  58487. static AddUniforms(uniforms: string[]): void;
  58488. /**
  58489. * Add the required samplers to the current list.
  58490. * @param samplers defines the current sampler list.
  58491. */
  58492. static AddSamplers(samplers: string[]): void;
  58493. /**
  58494. * Add the required uniforms to the current buffer.
  58495. * @param uniformBuffer defines the current uniform buffer.
  58496. */
  58497. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58498. /**
  58499. * Makes a duplicate of the current configuration into another one.
  58500. * @param configuration define the config where to copy the info
  58501. */
  58502. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  58503. /**
  58504. * Serializes this Sub Surface configuration.
  58505. * @returns - An object with the serialized config.
  58506. */
  58507. serialize(): any;
  58508. /**
  58509. * Parses a anisotropy Configuration from a serialized object.
  58510. * @param source - Serialized object.
  58511. * @param scene Defines the scene we are parsing for
  58512. * @param rootUrl Defines the rootUrl to load from
  58513. */
  58514. parse(source: any, scene: Scene, rootUrl: string): void;
  58515. }
  58516. }
  58517. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  58518. /** @hidden */
  58519. export var pbrFragmentDeclaration: {
  58520. name: string;
  58521. shader: string;
  58522. };
  58523. }
  58524. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  58525. /** @hidden */
  58526. export var pbrUboDeclaration: {
  58527. name: string;
  58528. shader: string;
  58529. };
  58530. }
  58531. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  58532. /** @hidden */
  58533. export var pbrFragmentExtraDeclaration: {
  58534. name: string;
  58535. shader: string;
  58536. };
  58537. }
  58538. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  58539. /** @hidden */
  58540. export var pbrFragmentSamplersDeclaration: {
  58541. name: string;
  58542. shader: string;
  58543. };
  58544. }
  58545. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  58546. /** @hidden */
  58547. export var importanceSampling: {
  58548. name: string;
  58549. shader: string;
  58550. };
  58551. }
  58552. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  58553. /** @hidden */
  58554. export var pbrHelperFunctions: {
  58555. name: string;
  58556. shader: string;
  58557. };
  58558. }
  58559. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  58560. /** @hidden */
  58561. export var harmonicsFunctions: {
  58562. name: string;
  58563. shader: string;
  58564. };
  58565. }
  58566. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  58567. /** @hidden */
  58568. export var pbrDirectLightingSetupFunctions: {
  58569. name: string;
  58570. shader: string;
  58571. };
  58572. }
  58573. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  58574. /** @hidden */
  58575. export var pbrDirectLightingFalloffFunctions: {
  58576. name: string;
  58577. shader: string;
  58578. };
  58579. }
  58580. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  58581. /** @hidden */
  58582. export var pbrBRDFFunctions: {
  58583. name: string;
  58584. shader: string;
  58585. };
  58586. }
  58587. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  58588. /** @hidden */
  58589. export var hdrFilteringFunctions: {
  58590. name: string;
  58591. shader: string;
  58592. };
  58593. }
  58594. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  58595. /** @hidden */
  58596. export var pbrDirectLightingFunctions: {
  58597. name: string;
  58598. shader: string;
  58599. };
  58600. }
  58601. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  58602. /** @hidden */
  58603. export var pbrIBLFunctions: {
  58604. name: string;
  58605. shader: string;
  58606. };
  58607. }
  58608. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  58609. /** @hidden */
  58610. export var pbrBlockAlbedoOpacity: {
  58611. name: string;
  58612. shader: string;
  58613. };
  58614. }
  58615. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  58616. /** @hidden */
  58617. export var pbrBlockReflectivity: {
  58618. name: string;
  58619. shader: string;
  58620. };
  58621. }
  58622. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  58623. /** @hidden */
  58624. export var pbrBlockAmbientOcclusion: {
  58625. name: string;
  58626. shader: string;
  58627. };
  58628. }
  58629. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  58630. /** @hidden */
  58631. export var pbrBlockAlphaFresnel: {
  58632. name: string;
  58633. shader: string;
  58634. };
  58635. }
  58636. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  58637. /** @hidden */
  58638. export var pbrBlockAnisotropic: {
  58639. name: string;
  58640. shader: string;
  58641. };
  58642. }
  58643. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  58644. /** @hidden */
  58645. export var pbrBlockReflection: {
  58646. name: string;
  58647. shader: string;
  58648. };
  58649. }
  58650. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  58651. /** @hidden */
  58652. export var pbrBlockSheen: {
  58653. name: string;
  58654. shader: string;
  58655. };
  58656. }
  58657. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  58658. /** @hidden */
  58659. export var pbrBlockClearcoat: {
  58660. name: string;
  58661. shader: string;
  58662. };
  58663. }
  58664. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  58665. /** @hidden */
  58666. export var pbrBlockSubSurface: {
  58667. name: string;
  58668. shader: string;
  58669. };
  58670. }
  58671. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  58672. /** @hidden */
  58673. export var pbrBlockNormalGeometric: {
  58674. name: string;
  58675. shader: string;
  58676. };
  58677. }
  58678. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  58679. /** @hidden */
  58680. export var pbrBlockNormalFinal: {
  58681. name: string;
  58682. shader: string;
  58683. };
  58684. }
  58685. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  58686. /** @hidden */
  58687. export var pbrBlockLightmapInit: {
  58688. name: string;
  58689. shader: string;
  58690. };
  58691. }
  58692. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  58693. /** @hidden */
  58694. export var pbrBlockGeometryInfo: {
  58695. name: string;
  58696. shader: string;
  58697. };
  58698. }
  58699. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  58700. /** @hidden */
  58701. export var pbrBlockReflectance0: {
  58702. name: string;
  58703. shader: string;
  58704. };
  58705. }
  58706. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  58707. /** @hidden */
  58708. export var pbrBlockReflectance: {
  58709. name: string;
  58710. shader: string;
  58711. };
  58712. }
  58713. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  58714. /** @hidden */
  58715. export var pbrBlockDirectLighting: {
  58716. name: string;
  58717. shader: string;
  58718. };
  58719. }
  58720. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  58721. /** @hidden */
  58722. export var pbrBlockFinalLitComponents: {
  58723. name: string;
  58724. shader: string;
  58725. };
  58726. }
  58727. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  58728. /** @hidden */
  58729. export var pbrBlockFinalUnlitComponents: {
  58730. name: string;
  58731. shader: string;
  58732. };
  58733. }
  58734. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  58735. /** @hidden */
  58736. export var pbrBlockFinalColorComposition: {
  58737. name: string;
  58738. shader: string;
  58739. };
  58740. }
  58741. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  58742. /** @hidden */
  58743. export var pbrBlockImageProcessing: {
  58744. name: string;
  58745. shader: string;
  58746. };
  58747. }
  58748. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  58749. /** @hidden */
  58750. export var pbrDebug: {
  58751. name: string;
  58752. shader: string;
  58753. };
  58754. }
  58755. declare module "babylonjs/Shaders/pbr.fragment" {
  58756. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  58757. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  58758. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58759. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  58760. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58761. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58762. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  58763. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58764. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  58765. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58766. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58767. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58768. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  58769. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  58770. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  58771. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58772. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58773. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58774. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  58775. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  58776. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  58777. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  58778. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  58779. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  58780. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  58781. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  58782. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  58783. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  58784. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  58785. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  58786. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  58787. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  58788. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  58789. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  58790. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  58791. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  58792. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58793. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  58794. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  58795. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  58796. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  58797. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  58798. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  58799. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  58800. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  58801. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  58802. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58803. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  58804. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  58805. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  58806. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  58807. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  58808. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  58809. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  58810. /** @hidden */
  58811. export var pbrPixelShader: {
  58812. name: string;
  58813. shader: string;
  58814. };
  58815. }
  58816. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  58817. /** @hidden */
  58818. export var pbrVertexDeclaration: {
  58819. name: string;
  58820. shader: string;
  58821. };
  58822. }
  58823. declare module "babylonjs/Shaders/pbr.vertex" {
  58824. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  58825. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58826. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58827. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58828. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58829. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58830. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  58831. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  58832. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  58833. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58834. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58835. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58836. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58837. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58838. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58839. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58840. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58841. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  58842. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  58843. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  58844. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  58845. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  58846. /** @hidden */
  58847. export var pbrVertexShader: {
  58848. name: string;
  58849. shader: string;
  58850. };
  58851. }
  58852. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  58853. import { Nullable } from "babylonjs/types";
  58854. import { Scene } from "babylonjs/scene";
  58855. import { Matrix } from "babylonjs/Maths/math.vector";
  58856. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58857. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58858. import { Mesh } from "babylonjs/Meshes/mesh";
  58859. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  58860. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  58861. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  58862. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  58863. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  58864. import { Color3 } from "babylonjs/Maths/math.color";
  58865. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  58866. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  58867. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  58868. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  58869. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58870. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58871. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  58872. import "babylonjs/Shaders/pbr.fragment";
  58873. import "babylonjs/Shaders/pbr.vertex";
  58874. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  58875. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  58876. /**
  58877. * Manages the defines for the PBR Material.
  58878. * @hidden
  58879. */
  58880. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  58881. PBR: boolean;
  58882. NUM_SAMPLES: string;
  58883. REALTIME_FILTERING: boolean;
  58884. MAINUV1: boolean;
  58885. MAINUV2: boolean;
  58886. UV1: boolean;
  58887. UV2: boolean;
  58888. ALBEDO: boolean;
  58889. GAMMAALBEDO: boolean;
  58890. ALBEDODIRECTUV: number;
  58891. VERTEXCOLOR: boolean;
  58892. DETAIL: boolean;
  58893. DETAILDIRECTUV: number;
  58894. DETAIL_NORMALBLENDMETHOD: number;
  58895. AMBIENT: boolean;
  58896. AMBIENTDIRECTUV: number;
  58897. AMBIENTINGRAYSCALE: boolean;
  58898. OPACITY: boolean;
  58899. VERTEXALPHA: boolean;
  58900. OPACITYDIRECTUV: number;
  58901. OPACITYRGB: boolean;
  58902. ALPHATEST: boolean;
  58903. DEPTHPREPASS: boolean;
  58904. ALPHABLEND: boolean;
  58905. ALPHAFROMALBEDO: boolean;
  58906. ALPHATESTVALUE: string;
  58907. SPECULAROVERALPHA: boolean;
  58908. RADIANCEOVERALPHA: boolean;
  58909. ALPHAFRESNEL: boolean;
  58910. LINEARALPHAFRESNEL: boolean;
  58911. PREMULTIPLYALPHA: boolean;
  58912. EMISSIVE: boolean;
  58913. EMISSIVEDIRECTUV: number;
  58914. REFLECTIVITY: boolean;
  58915. REFLECTIVITYDIRECTUV: number;
  58916. SPECULARTERM: boolean;
  58917. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  58918. MICROSURFACEAUTOMATIC: boolean;
  58919. LODBASEDMICROSFURACE: boolean;
  58920. MICROSURFACEMAP: boolean;
  58921. MICROSURFACEMAPDIRECTUV: number;
  58922. METALLICWORKFLOW: boolean;
  58923. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  58924. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  58925. METALLNESSSTOREINMETALMAPBLUE: boolean;
  58926. AOSTOREINMETALMAPRED: boolean;
  58927. METALLIC_REFLECTANCE: boolean;
  58928. METALLIC_REFLECTANCEDIRECTUV: number;
  58929. ENVIRONMENTBRDF: boolean;
  58930. ENVIRONMENTBRDF_RGBD: boolean;
  58931. NORMAL: boolean;
  58932. TANGENT: boolean;
  58933. BUMP: boolean;
  58934. BUMPDIRECTUV: number;
  58935. OBJECTSPACE_NORMALMAP: boolean;
  58936. PARALLAX: boolean;
  58937. PARALLAXOCCLUSION: boolean;
  58938. NORMALXYSCALE: boolean;
  58939. LIGHTMAP: boolean;
  58940. LIGHTMAPDIRECTUV: number;
  58941. USELIGHTMAPASSHADOWMAP: boolean;
  58942. GAMMALIGHTMAP: boolean;
  58943. RGBDLIGHTMAP: boolean;
  58944. REFLECTION: boolean;
  58945. REFLECTIONMAP_3D: boolean;
  58946. REFLECTIONMAP_SPHERICAL: boolean;
  58947. REFLECTIONMAP_PLANAR: boolean;
  58948. REFLECTIONMAP_CUBIC: boolean;
  58949. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  58950. REFLECTIONMAP_PROJECTION: boolean;
  58951. REFLECTIONMAP_SKYBOX: boolean;
  58952. REFLECTIONMAP_EXPLICIT: boolean;
  58953. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  58954. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  58955. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  58956. INVERTCUBICMAP: boolean;
  58957. USESPHERICALFROMREFLECTIONMAP: boolean;
  58958. USEIRRADIANCEMAP: boolean;
  58959. SPHERICAL_HARMONICS: boolean;
  58960. USESPHERICALINVERTEX: boolean;
  58961. REFLECTIONMAP_OPPOSITEZ: boolean;
  58962. LODINREFLECTIONALPHA: boolean;
  58963. GAMMAREFLECTION: boolean;
  58964. RGBDREFLECTION: boolean;
  58965. LINEARSPECULARREFLECTION: boolean;
  58966. RADIANCEOCCLUSION: boolean;
  58967. HORIZONOCCLUSION: boolean;
  58968. INSTANCES: boolean;
  58969. THIN_INSTANCES: boolean;
  58970. PREPASS: boolean;
  58971. SCENE_MRT_COUNT: number;
  58972. NUM_BONE_INFLUENCERS: number;
  58973. BonesPerMesh: number;
  58974. BONETEXTURE: boolean;
  58975. NONUNIFORMSCALING: boolean;
  58976. MORPHTARGETS: boolean;
  58977. MORPHTARGETS_NORMAL: boolean;
  58978. MORPHTARGETS_TANGENT: boolean;
  58979. MORPHTARGETS_UV: boolean;
  58980. NUM_MORPH_INFLUENCERS: number;
  58981. IMAGEPROCESSING: boolean;
  58982. VIGNETTE: boolean;
  58983. VIGNETTEBLENDMODEMULTIPLY: boolean;
  58984. VIGNETTEBLENDMODEOPAQUE: boolean;
  58985. TONEMAPPING: boolean;
  58986. TONEMAPPING_ACES: boolean;
  58987. CONTRAST: boolean;
  58988. COLORCURVES: boolean;
  58989. COLORGRADING: boolean;
  58990. COLORGRADING3D: boolean;
  58991. SAMPLER3DGREENDEPTH: boolean;
  58992. SAMPLER3DBGRMAP: boolean;
  58993. IMAGEPROCESSINGPOSTPROCESS: boolean;
  58994. EXPOSURE: boolean;
  58995. MULTIVIEW: boolean;
  58996. USEPHYSICALLIGHTFALLOFF: boolean;
  58997. USEGLTFLIGHTFALLOFF: boolean;
  58998. TWOSIDEDLIGHTING: boolean;
  58999. SHADOWFLOAT: boolean;
  59000. CLIPPLANE: boolean;
  59001. CLIPPLANE2: boolean;
  59002. CLIPPLANE3: boolean;
  59003. CLIPPLANE4: boolean;
  59004. CLIPPLANE5: boolean;
  59005. CLIPPLANE6: boolean;
  59006. POINTSIZE: boolean;
  59007. FOG: boolean;
  59008. LOGARITHMICDEPTH: boolean;
  59009. FORCENORMALFORWARD: boolean;
  59010. SPECULARAA: boolean;
  59011. CLEARCOAT: boolean;
  59012. CLEARCOAT_DEFAULTIOR: boolean;
  59013. CLEARCOAT_TEXTURE: boolean;
  59014. CLEARCOAT_TEXTUREDIRECTUV: number;
  59015. CLEARCOAT_BUMP: boolean;
  59016. CLEARCOAT_BUMPDIRECTUV: number;
  59017. CLEARCOAT_TINT: boolean;
  59018. CLEARCOAT_TINT_TEXTURE: boolean;
  59019. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  59020. ANISOTROPIC: boolean;
  59021. ANISOTROPIC_TEXTURE: boolean;
  59022. ANISOTROPIC_TEXTUREDIRECTUV: number;
  59023. BRDF_V_HEIGHT_CORRELATED: boolean;
  59024. MS_BRDF_ENERGY_CONSERVATION: boolean;
  59025. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  59026. SHEEN: boolean;
  59027. SHEEN_TEXTURE: boolean;
  59028. SHEEN_TEXTUREDIRECTUV: number;
  59029. SHEEN_LINKWITHALBEDO: boolean;
  59030. SHEEN_ROUGHNESS: boolean;
  59031. SHEEN_ALBEDOSCALING: boolean;
  59032. SUBSURFACE: boolean;
  59033. SS_REFRACTION: boolean;
  59034. SS_TRANSLUCENCY: boolean;
  59035. SS_SCATTERING: boolean;
  59036. SS_THICKNESSANDMASK_TEXTURE: boolean;
  59037. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  59038. SS_REFRACTIONMAP_3D: boolean;
  59039. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  59040. SS_LODINREFRACTIONALPHA: boolean;
  59041. SS_GAMMAREFRACTION: boolean;
  59042. SS_RGBDREFRACTION: boolean;
  59043. SS_LINEARSPECULARREFRACTION: boolean;
  59044. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  59045. SS_ALBEDOFORREFRACTIONTINT: boolean;
  59046. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  59047. UNLIT: boolean;
  59048. DEBUGMODE: number;
  59049. /**
  59050. * Initializes the PBR Material defines.
  59051. */
  59052. constructor();
  59053. /**
  59054. * Resets the PBR Material defines.
  59055. */
  59056. reset(): void;
  59057. }
  59058. /**
  59059. * The Physically based material base class of BJS.
  59060. *
  59061. * This offers the main features of a standard PBR material.
  59062. * For more information, please refer to the documentation :
  59063. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59064. */
  59065. export abstract class PBRBaseMaterial extends PushMaterial {
  59066. /**
  59067. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59068. */
  59069. static readonly PBRMATERIAL_OPAQUE: number;
  59070. /**
  59071. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59072. */
  59073. static readonly PBRMATERIAL_ALPHATEST: number;
  59074. /**
  59075. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59076. */
  59077. static readonly PBRMATERIAL_ALPHABLEND: number;
  59078. /**
  59079. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59080. * They are also discarded below the alpha cutoff threshold to improve performances.
  59081. */
  59082. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59083. /**
  59084. * Defines the default value of how much AO map is occluding the analytical lights
  59085. * (point spot...).
  59086. */
  59087. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59088. /**
  59089. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  59090. */
  59091. static readonly LIGHTFALLOFF_PHYSICAL: number;
  59092. /**
  59093. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  59094. * to enhance interoperability with other engines.
  59095. */
  59096. static readonly LIGHTFALLOFF_GLTF: number;
  59097. /**
  59098. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  59099. * to enhance interoperability with other materials.
  59100. */
  59101. static readonly LIGHTFALLOFF_STANDARD: number;
  59102. /**
  59103. * Intensity of the direct lights e.g. the four lights available in your scene.
  59104. * This impacts both the direct diffuse and specular highlights.
  59105. */
  59106. protected _directIntensity: number;
  59107. /**
  59108. * Intensity of the emissive part of the material.
  59109. * This helps controlling the emissive effect without modifying the emissive color.
  59110. */
  59111. protected _emissiveIntensity: number;
  59112. /**
  59113. * Intensity of the environment e.g. how much the environment will light the object
  59114. * either through harmonics for rough material or through the refelction for shiny ones.
  59115. */
  59116. protected _environmentIntensity: number;
  59117. /**
  59118. * This is a special control allowing the reduction of the specular highlights coming from the
  59119. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59120. */
  59121. protected _specularIntensity: number;
  59122. /**
  59123. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  59124. */
  59125. private _lightingInfos;
  59126. /**
  59127. * Debug Control allowing disabling the bump map on this material.
  59128. */
  59129. protected _disableBumpMap: boolean;
  59130. /**
  59131. * AKA Diffuse Texture in standard nomenclature.
  59132. */
  59133. protected _albedoTexture: Nullable<BaseTexture>;
  59134. /**
  59135. * AKA Occlusion Texture in other nomenclature.
  59136. */
  59137. protected _ambientTexture: Nullable<BaseTexture>;
  59138. /**
  59139. * AKA Occlusion Texture Intensity in other nomenclature.
  59140. */
  59141. protected _ambientTextureStrength: number;
  59142. /**
  59143. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59144. * 1 means it completely occludes it
  59145. * 0 mean it has no impact
  59146. */
  59147. protected _ambientTextureImpactOnAnalyticalLights: number;
  59148. /**
  59149. * Stores the alpha values in a texture.
  59150. */
  59151. protected _opacityTexture: Nullable<BaseTexture>;
  59152. /**
  59153. * Stores the reflection values in a texture.
  59154. */
  59155. protected _reflectionTexture: Nullable<BaseTexture>;
  59156. /**
  59157. * Stores the emissive values in a texture.
  59158. */
  59159. protected _emissiveTexture: Nullable<BaseTexture>;
  59160. /**
  59161. * AKA Specular texture in other nomenclature.
  59162. */
  59163. protected _reflectivityTexture: Nullable<BaseTexture>;
  59164. /**
  59165. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59166. */
  59167. protected _metallicTexture: Nullable<BaseTexture>;
  59168. /**
  59169. * Specifies the metallic scalar of the metallic/roughness workflow.
  59170. * Can also be used to scale the metalness values of the metallic texture.
  59171. */
  59172. protected _metallic: Nullable<number>;
  59173. /**
  59174. * Specifies the roughness scalar of the metallic/roughness workflow.
  59175. * Can also be used to scale the roughness values of the metallic texture.
  59176. */
  59177. protected _roughness: Nullable<number>;
  59178. /**
  59179. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59180. * By default the indexOfrefraction is used to compute F0;
  59181. *
  59182. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59183. *
  59184. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59185. * F90 = metallicReflectanceColor;
  59186. */
  59187. protected _metallicF0Factor: number;
  59188. /**
  59189. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59190. * By default the F90 is always 1;
  59191. *
  59192. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59193. *
  59194. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59195. * F90 = metallicReflectanceColor;
  59196. */
  59197. protected _metallicReflectanceColor: Color3;
  59198. /**
  59199. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59200. * This is multiply against the scalar values defined in the material.
  59201. */
  59202. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  59203. /**
  59204. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59205. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59206. */
  59207. protected _microSurfaceTexture: Nullable<BaseTexture>;
  59208. /**
  59209. * Stores surface normal data used to displace a mesh in a texture.
  59210. */
  59211. protected _bumpTexture: Nullable<BaseTexture>;
  59212. /**
  59213. * Stores the pre-calculated light information of a mesh in a texture.
  59214. */
  59215. protected _lightmapTexture: Nullable<BaseTexture>;
  59216. /**
  59217. * The color of a material in ambient lighting.
  59218. */
  59219. protected _ambientColor: Color3;
  59220. /**
  59221. * AKA Diffuse Color in other nomenclature.
  59222. */
  59223. protected _albedoColor: Color3;
  59224. /**
  59225. * AKA Specular Color in other nomenclature.
  59226. */
  59227. protected _reflectivityColor: Color3;
  59228. /**
  59229. * The color applied when light is reflected from a material.
  59230. */
  59231. protected _reflectionColor: Color3;
  59232. /**
  59233. * The color applied when light is emitted from a material.
  59234. */
  59235. protected _emissiveColor: Color3;
  59236. /**
  59237. * AKA Glossiness in other nomenclature.
  59238. */
  59239. protected _microSurface: number;
  59240. /**
  59241. * Specifies that the material will use the light map as a show map.
  59242. */
  59243. protected _useLightmapAsShadowmap: boolean;
  59244. /**
  59245. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59246. * makes the reflect vector face the model (under horizon).
  59247. */
  59248. protected _useHorizonOcclusion: boolean;
  59249. /**
  59250. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59251. * too much the area relying on ambient texture to define their ambient occlusion.
  59252. */
  59253. protected _useRadianceOcclusion: boolean;
  59254. /**
  59255. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59256. */
  59257. protected _useAlphaFromAlbedoTexture: boolean;
  59258. /**
  59259. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  59260. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59261. */
  59262. protected _useSpecularOverAlpha: boolean;
  59263. /**
  59264. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59265. */
  59266. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59267. /**
  59268. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59269. */
  59270. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  59271. /**
  59272. * Specifies if the metallic texture contains the roughness information in its green channel.
  59273. */
  59274. protected _useRoughnessFromMetallicTextureGreen: boolean;
  59275. /**
  59276. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59277. */
  59278. protected _useMetallnessFromMetallicTextureBlue: boolean;
  59279. /**
  59280. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59281. */
  59282. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  59283. /**
  59284. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59285. */
  59286. protected _useAmbientInGrayScale: boolean;
  59287. /**
  59288. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59289. * The material will try to infer what glossiness each pixel should be.
  59290. */
  59291. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  59292. /**
  59293. * Defines the falloff type used in this material.
  59294. * It by default is Physical.
  59295. */
  59296. protected _lightFalloff: number;
  59297. /**
  59298. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59299. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59300. */
  59301. protected _useRadianceOverAlpha: boolean;
  59302. /**
  59303. * Allows using an object space normal map (instead of tangent space).
  59304. */
  59305. protected _useObjectSpaceNormalMap: boolean;
  59306. /**
  59307. * Allows using the bump map in parallax mode.
  59308. */
  59309. protected _useParallax: boolean;
  59310. /**
  59311. * Allows using the bump map in parallax occlusion mode.
  59312. */
  59313. protected _useParallaxOcclusion: boolean;
  59314. /**
  59315. * Controls the scale bias of the parallax mode.
  59316. */
  59317. protected _parallaxScaleBias: number;
  59318. /**
  59319. * If sets to true, disables all the lights affecting the material.
  59320. */
  59321. protected _disableLighting: boolean;
  59322. /**
  59323. * Number of Simultaneous lights allowed on the material.
  59324. */
  59325. protected _maxSimultaneousLights: number;
  59326. /**
  59327. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  59328. */
  59329. protected _invertNormalMapX: boolean;
  59330. /**
  59331. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  59332. */
  59333. protected _invertNormalMapY: boolean;
  59334. /**
  59335. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59336. */
  59337. protected _twoSidedLighting: boolean;
  59338. /**
  59339. * Defines the alpha limits in alpha test mode.
  59340. */
  59341. protected _alphaCutOff: number;
  59342. /**
  59343. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59344. */
  59345. protected _forceAlphaTest: boolean;
  59346. /**
  59347. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59348. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59349. */
  59350. protected _useAlphaFresnel: boolean;
  59351. /**
  59352. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59353. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59354. */
  59355. protected _useLinearAlphaFresnel: boolean;
  59356. /**
  59357. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  59358. * from cos thetav and roughness:
  59359. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  59360. */
  59361. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  59362. /**
  59363. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59364. */
  59365. protected _forceIrradianceInFragment: boolean;
  59366. private _realTimeFiltering;
  59367. /**
  59368. * Enables realtime filtering on the texture.
  59369. */
  59370. get realTimeFiltering(): boolean;
  59371. set realTimeFiltering(b: boolean);
  59372. private _realTimeFilteringQuality;
  59373. /**
  59374. * Quality switch for realtime filtering
  59375. */
  59376. get realTimeFilteringQuality(): number;
  59377. set realTimeFilteringQuality(n: number);
  59378. /**
  59379. * Can this material render to several textures at once
  59380. */
  59381. get canRenderToMRT(): boolean;
  59382. /**
  59383. * Force normal to face away from face.
  59384. */
  59385. protected _forceNormalForward: boolean;
  59386. /**
  59387. * Enables specular anti aliasing in the PBR shader.
  59388. * It will both interacts on the Geometry for analytical and IBL lighting.
  59389. * It also prefilter the roughness map based on the bump values.
  59390. */
  59391. protected _enableSpecularAntiAliasing: boolean;
  59392. /**
  59393. * Default configuration related to image processing available in the PBR Material.
  59394. */
  59395. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59396. /**
  59397. * Keep track of the image processing observer to allow dispose and replace.
  59398. */
  59399. private _imageProcessingObserver;
  59400. /**
  59401. * Attaches a new image processing configuration to the PBR Material.
  59402. * @param configuration
  59403. */
  59404. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59405. /**
  59406. * Stores the available render targets.
  59407. */
  59408. private _renderTargets;
  59409. /**
  59410. * Sets the global ambient color for the material used in lighting calculations.
  59411. */
  59412. private _globalAmbientColor;
  59413. /**
  59414. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  59415. */
  59416. private _useLogarithmicDepth;
  59417. /**
  59418. * If set to true, no lighting calculations will be applied.
  59419. */
  59420. private _unlit;
  59421. private _debugMode;
  59422. /**
  59423. * @hidden
  59424. * This is reserved for the inspector.
  59425. * Defines the material debug mode.
  59426. * It helps seeing only some components of the material while troubleshooting.
  59427. */
  59428. debugMode: number;
  59429. /**
  59430. * @hidden
  59431. * This is reserved for the inspector.
  59432. * Specify from where on screen the debug mode should start.
  59433. * The value goes from -1 (full screen) to 1 (not visible)
  59434. * It helps with side by side comparison against the final render
  59435. * This defaults to -1
  59436. */
  59437. private debugLimit;
  59438. /**
  59439. * @hidden
  59440. * This is reserved for the inspector.
  59441. * As the default viewing range might not be enough (if the ambient is really small for instance)
  59442. * You can use the factor to better multiply the final value.
  59443. */
  59444. private debugFactor;
  59445. /**
  59446. * Defines the clear coat layer parameters for the material.
  59447. */
  59448. readonly clearCoat: PBRClearCoatConfiguration;
  59449. /**
  59450. * Defines the anisotropic parameters for the material.
  59451. */
  59452. readonly anisotropy: PBRAnisotropicConfiguration;
  59453. /**
  59454. * Defines the BRDF parameters for the material.
  59455. */
  59456. readonly brdf: PBRBRDFConfiguration;
  59457. /**
  59458. * Defines the Sheen parameters for the material.
  59459. */
  59460. readonly sheen: PBRSheenConfiguration;
  59461. /**
  59462. * Defines the SubSurface parameters for the material.
  59463. */
  59464. readonly subSurface: PBRSubSurfaceConfiguration;
  59465. /**
  59466. * Defines the detail map parameters for the material.
  59467. */
  59468. readonly detailMap: DetailMapConfiguration;
  59469. protected _rebuildInParallel: boolean;
  59470. /**
  59471. * Instantiates a new PBRMaterial instance.
  59472. *
  59473. * @param name The material name
  59474. * @param scene The scene the material will be use in.
  59475. */
  59476. constructor(name: string, scene: Scene);
  59477. /**
  59478. * Gets a boolean indicating that current material needs to register RTT
  59479. */
  59480. get hasRenderTargetTextures(): boolean;
  59481. /**
  59482. * Gets the name of the material class.
  59483. */
  59484. getClassName(): string;
  59485. /**
  59486. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59487. */
  59488. get useLogarithmicDepth(): boolean;
  59489. /**
  59490. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59491. */
  59492. set useLogarithmicDepth(value: boolean);
  59493. /**
  59494. * Returns true if alpha blending should be disabled.
  59495. */
  59496. protected get _disableAlphaBlending(): boolean;
  59497. /**
  59498. * Specifies whether or not this material should be rendered in alpha blend mode.
  59499. */
  59500. needAlphaBlending(): boolean;
  59501. /**
  59502. * Specifies whether or not this material should be rendered in alpha test mode.
  59503. */
  59504. needAlphaTesting(): boolean;
  59505. /**
  59506. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  59507. */
  59508. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  59509. /**
  59510. * Gets the texture used for the alpha test.
  59511. */
  59512. getAlphaTestTexture(): Nullable<BaseTexture>;
  59513. /**
  59514. * Specifies that the submesh is ready to be used.
  59515. * @param mesh - BJS mesh.
  59516. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  59517. * @param useInstances - Specifies that instances should be used.
  59518. * @returns - boolean indicating that the submesh is ready or not.
  59519. */
  59520. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59521. /**
  59522. * Specifies if the material uses metallic roughness workflow.
  59523. * @returns boolean specifiying if the material uses metallic roughness workflow.
  59524. */
  59525. isMetallicWorkflow(): boolean;
  59526. private _prepareEffect;
  59527. private _prepareDefines;
  59528. /**
  59529. * Force shader compilation
  59530. */
  59531. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  59532. /**
  59533. * Initializes the uniform buffer layout for the shader.
  59534. */
  59535. buildUniformLayout(): void;
  59536. /**
  59537. * Unbinds the material from the mesh
  59538. */
  59539. unbind(): void;
  59540. /**
  59541. * Binds the submesh data.
  59542. * @param world - The world matrix.
  59543. * @param mesh - The BJS mesh.
  59544. * @param subMesh - A submesh of the BJS mesh.
  59545. */
  59546. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59547. /**
  59548. * Returns the animatable textures.
  59549. * @returns - Array of animatable textures.
  59550. */
  59551. getAnimatables(): IAnimatable[];
  59552. /**
  59553. * Returns the texture used for reflections.
  59554. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  59555. */
  59556. private _getReflectionTexture;
  59557. /**
  59558. * Returns an array of the actively used textures.
  59559. * @returns - Array of BaseTextures
  59560. */
  59561. getActiveTextures(): BaseTexture[];
  59562. /**
  59563. * Checks to see if a texture is used in the material.
  59564. * @param texture - Base texture to use.
  59565. * @returns - Boolean specifying if a texture is used in the material.
  59566. */
  59567. hasTexture(texture: BaseTexture): boolean;
  59568. /**
  59569. * Sets the required values to the prepass renderer.
  59570. * @param prePassRenderer defines the prepass renderer to setup
  59571. */
  59572. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  59573. /**
  59574. * Disposes the resources of the material.
  59575. * @param forceDisposeEffect - Forces the disposal of effects.
  59576. * @param forceDisposeTextures - Forces the disposal of all textures.
  59577. */
  59578. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  59579. }
  59580. }
  59581. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  59582. import { Nullable } from "babylonjs/types";
  59583. import { Scene } from "babylonjs/scene";
  59584. import { Color3 } from "babylonjs/Maths/math.color";
  59585. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59586. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59587. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59588. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59589. /**
  59590. * The Physically based material of BJS.
  59591. *
  59592. * This offers the main features of a standard PBR material.
  59593. * For more information, please refer to the documentation :
  59594. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59595. */
  59596. export class PBRMaterial extends PBRBaseMaterial {
  59597. /**
  59598. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59599. */
  59600. static readonly PBRMATERIAL_OPAQUE: number;
  59601. /**
  59602. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59603. */
  59604. static readonly PBRMATERIAL_ALPHATEST: number;
  59605. /**
  59606. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59607. */
  59608. static readonly PBRMATERIAL_ALPHABLEND: number;
  59609. /**
  59610. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59611. * They are also discarded below the alpha cutoff threshold to improve performances.
  59612. */
  59613. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59614. /**
  59615. * Defines the default value of how much AO map is occluding the analytical lights
  59616. * (point spot...).
  59617. */
  59618. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59619. /**
  59620. * Intensity of the direct lights e.g. the four lights available in your scene.
  59621. * This impacts both the direct diffuse and specular highlights.
  59622. */
  59623. directIntensity: number;
  59624. /**
  59625. * Intensity of the emissive part of the material.
  59626. * This helps controlling the emissive effect without modifying the emissive color.
  59627. */
  59628. emissiveIntensity: number;
  59629. /**
  59630. * Intensity of the environment e.g. how much the environment will light the object
  59631. * either through harmonics for rough material or through the refelction for shiny ones.
  59632. */
  59633. environmentIntensity: number;
  59634. /**
  59635. * This is a special control allowing the reduction of the specular highlights coming from the
  59636. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59637. */
  59638. specularIntensity: number;
  59639. /**
  59640. * Debug Control allowing disabling the bump map on this material.
  59641. */
  59642. disableBumpMap: boolean;
  59643. /**
  59644. * AKA Diffuse Texture in standard nomenclature.
  59645. */
  59646. albedoTexture: BaseTexture;
  59647. /**
  59648. * AKA Occlusion Texture in other nomenclature.
  59649. */
  59650. ambientTexture: BaseTexture;
  59651. /**
  59652. * AKA Occlusion Texture Intensity in other nomenclature.
  59653. */
  59654. ambientTextureStrength: number;
  59655. /**
  59656. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59657. * 1 means it completely occludes it
  59658. * 0 mean it has no impact
  59659. */
  59660. ambientTextureImpactOnAnalyticalLights: number;
  59661. /**
  59662. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  59663. */
  59664. opacityTexture: BaseTexture;
  59665. /**
  59666. * Stores the reflection values in a texture.
  59667. */
  59668. reflectionTexture: Nullable<BaseTexture>;
  59669. /**
  59670. * Stores the emissive values in a texture.
  59671. */
  59672. emissiveTexture: BaseTexture;
  59673. /**
  59674. * AKA Specular texture in other nomenclature.
  59675. */
  59676. reflectivityTexture: BaseTexture;
  59677. /**
  59678. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59679. */
  59680. metallicTexture: BaseTexture;
  59681. /**
  59682. * Specifies the metallic scalar of the metallic/roughness workflow.
  59683. * Can also be used to scale the metalness values of the metallic texture.
  59684. */
  59685. metallic: Nullable<number>;
  59686. /**
  59687. * Specifies the roughness scalar of the metallic/roughness workflow.
  59688. * Can also be used to scale the roughness values of the metallic texture.
  59689. */
  59690. roughness: Nullable<number>;
  59691. /**
  59692. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59693. * By default the indexOfrefraction is used to compute F0;
  59694. *
  59695. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59696. *
  59697. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59698. * F90 = metallicReflectanceColor;
  59699. */
  59700. metallicF0Factor: number;
  59701. /**
  59702. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59703. * By default the F90 is always 1;
  59704. *
  59705. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59706. *
  59707. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59708. * F90 = metallicReflectanceColor;
  59709. */
  59710. metallicReflectanceColor: Color3;
  59711. /**
  59712. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59713. * This is multiply against the scalar values defined in the material.
  59714. */
  59715. metallicReflectanceTexture: Nullable<BaseTexture>;
  59716. /**
  59717. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59718. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59719. */
  59720. microSurfaceTexture: BaseTexture;
  59721. /**
  59722. * Stores surface normal data used to displace a mesh in a texture.
  59723. */
  59724. bumpTexture: BaseTexture;
  59725. /**
  59726. * Stores the pre-calculated light information of a mesh in a texture.
  59727. */
  59728. lightmapTexture: BaseTexture;
  59729. /**
  59730. * Stores the refracted light information in a texture.
  59731. */
  59732. get refractionTexture(): Nullable<BaseTexture>;
  59733. set refractionTexture(value: Nullable<BaseTexture>);
  59734. /**
  59735. * The color of a material in ambient lighting.
  59736. */
  59737. ambientColor: Color3;
  59738. /**
  59739. * AKA Diffuse Color in other nomenclature.
  59740. */
  59741. albedoColor: Color3;
  59742. /**
  59743. * AKA Specular Color in other nomenclature.
  59744. */
  59745. reflectivityColor: Color3;
  59746. /**
  59747. * The color reflected from the material.
  59748. */
  59749. reflectionColor: Color3;
  59750. /**
  59751. * The color emitted from the material.
  59752. */
  59753. emissiveColor: Color3;
  59754. /**
  59755. * AKA Glossiness in other nomenclature.
  59756. */
  59757. microSurface: number;
  59758. /**
  59759. * Index of refraction of the material base layer.
  59760. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  59761. *
  59762. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  59763. *
  59764. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  59765. */
  59766. get indexOfRefraction(): number;
  59767. set indexOfRefraction(value: number);
  59768. /**
  59769. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  59770. */
  59771. get invertRefractionY(): boolean;
  59772. set invertRefractionY(value: boolean);
  59773. /**
  59774. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  59775. * Materials half opaque for instance using refraction could benefit from this control.
  59776. */
  59777. get linkRefractionWithTransparency(): boolean;
  59778. set linkRefractionWithTransparency(value: boolean);
  59779. /**
  59780. * If true, the light map contains occlusion information instead of lighting info.
  59781. */
  59782. useLightmapAsShadowmap: boolean;
  59783. /**
  59784. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59785. */
  59786. useAlphaFromAlbedoTexture: boolean;
  59787. /**
  59788. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59789. */
  59790. forceAlphaTest: boolean;
  59791. /**
  59792. * Defines the alpha limits in alpha test mode.
  59793. */
  59794. alphaCutOff: number;
  59795. /**
  59796. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  59797. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59798. */
  59799. useSpecularOverAlpha: boolean;
  59800. /**
  59801. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59802. */
  59803. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59804. /**
  59805. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59806. */
  59807. useRoughnessFromMetallicTextureAlpha: boolean;
  59808. /**
  59809. * Specifies if the metallic texture contains the roughness information in its green channel.
  59810. */
  59811. useRoughnessFromMetallicTextureGreen: boolean;
  59812. /**
  59813. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59814. */
  59815. useMetallnessFromMetallicTextureBlue: boolean;
  59816. /**
  59817. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59818. */
  59819. useAmbientOcclusionFromMetallicTextureRed: boolean;
  59820. /**
  59821. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59822. */
  59823. useAmbientInGrayScale: boolean;
  59824. /**
  59825. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59826. * The material will try to infer what glossiness each pixel should be.
  59827. */
  59828. useAutoMicroSurfaceFromReflectivityMap: boolean;
  59829. /**
  59830. * BJS is using an harcoded light falloff based on a manually sets up range.
  59831. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59832. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59833. */
  59834. get usePhysicalLightFalloff(): boolean;
  59835. /**
  59836. * BJS is using an harcoded light falloff based on a manually sets up range.
  59837. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59838. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59839. */
  59840. set usePhysicalLightFalloff(value: boolean);
  59841. /**
  59842. * In order to support the falloff compatibility with gltf, a special mode has been added
  59843. * to reproduce the gltf light falloff.
  59844. */
  59845. get useGLTFLightFalloff(): boolean;
  59846. /**
  59847. * In order to support the falloff compatibility with gltf, a special mode has been added
  59848. * to reproduce the gltf light falloff.
  59849. */
  59850. set useGLTFLightFalloff(value: boolean);
  59851. /**
  59852. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59853. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59854. */
  59855. useRadianceOverAlpha: boolean;
  59856. /**
  59857. * Allows using an object space normal map (instead of tangent space).
  59858. */
  59859. useObjectSpaceNormalMap: boolean;
  59860. /**
  59861. * Allows using the bump map in parallax mode.
  59862. */
  59863. useParallax: boolean;
  59864. /**
  59865. * Allows using the bump map in parallax occlusion mode.
  59866. */
  59867. useParallaxOcclusion: boolean;
  59868. /**
  59869. * Controls the scale bias of the parallax mode.
  59870. */
  59871. parallaxScaleBias: number;
  59872. /**
  59873. * If sets to true, disables all the lights affecting the material.
  59874. */
  59875. disableLighting: boolean;
  59876. /**
  59877. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59878. */
  59879. forceIrradianceInFragment: boolean;
  59880. /**
  59881. * Number of Simultaneous lights allowed on the material.
  59882. */
  59883. maxSimultaneousLights: number;
  59884. /**
  59885. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59886. */
  59887. invertNormalMapX: boolean;
  59888. /**
  59889. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59890. */
  59891. invertNormalMapY: boolean;
  59892. /**
  59893. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59894. */
  59895. twoSidedLighting: boolean;
  59896. /**
  59897. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59898. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59899. */
  59900. useAlphaFresnel: boolean;
  59901. /**
  59902. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59903. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59904. */
  59905. useLinearAlphaFresnel: boolean;
  59906. /**
  59907. * Let user defines the brdf lookup texture used for IBL.
  59908. * A default 8bit version is embedded but you could point at :
  59909. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  59910. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  59911. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  59912. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  59913. */
  59914. environmentBRDFTexture: Nullable<BaseTexture>;
  59915. /**
  59916. * Force normal to face away from face.
  59917. */
  59918. forceNormalForward: boolean;
  59919. /**
  59920. * Enables specular anti aliasing in the PBR shader.
  59921. * It will both interacts on the Geometry for analytical and IBL lighting.
  59922. * It also prefilter the roughness map based on the bump values.
  59923. */
  59924. enableSpecularAntiAliasing: boolean;
  59925. /**
  59926. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59927. * makes the reflect vector face the model (under horizon).
  59928. */
  59929. useHorizonOcclusion: boolean;
  59930. /**
  59931. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59932. * too much the area relying on ambient texture to define their ambient occlusion.
  59933. */
  59934. useRadianceOcclusion: boolean;
  59935. /**
  59936. * If set to true, no lighting calculations will be applied.
  59937. */
  59938. unlit: boolean;
  59939. /**
  59940. * Gets the image processing configuration used either in this material.
  59941. */
  59942. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59943. /**
  59944. * Sets the Default image processing configuration used either in the this material.
  59945. *
  59946. * If sets to null, the scene one is in use.
  59947. */
  59948. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59949. /**
  59950. * Gets wether the color curves effect is enabled.
  59951. */
  59952. get cameraColorCurvesEnabled(): boolean;
  59953. /**
  59954. * Sets wether the color curves effect is enabled.
  59955. */
  59956. set cameraColorCurvesEnabled(value: boolean);
  59957. /**
  59958. * Gets wether the color grading effect is enabled.
  59959. */
  59960. get cameraColorGradingEnabled(): boolean;
  59961. /**
  59962. * Gets wether the color grading effect is enabled.
  59963. */
  59964. set cameraColorGradingEnabled(value: boolean);
  59965. /**
  59966. * Gets wether tonemapping is enabled or not.
  59967. */
  59968. get cameraToneMappingEnabled(): boolean;
  59969. /**
  59970. * Sets wether tonemapping is enabled or not
  59971. */
  59972. set cameraToneMappingEnabled(value: boolean);
  59973. /**
  59974. * The camera exposure used on this material.
  59975. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  59976. * This corresponds to a photographic exposure.
  59977. */
  59978. get cameraExposure(): number;
  59979. /**
  59980. * The camera exposure used on this material.
  59981. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  59982. * This corresponds to a photographic exposure.
  59983. */
  59984. set cameraExposure(value: number);
  59985. /**
  59986. * Gets The camera contrast used on this material.
  59987. */
  59988. get cameraContrast(): number;
  59989. /**
  59990. * Sets The camera contrast used on this material.
  59991. */
  59992. set cameraContrast(value: number);
  59993. /**
  59994. * Gets the Color Grading 2D Lookup Texture.
  59995. */
  59996. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  59997. /**
  59998. * Sets the Color Grading 2D Lookup Texture.
  59999. */
  60000. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  60001. /**
  60002. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60003. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60004. * 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;
  60005. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60006. */
  60007. get cameraColorCurves(): Nullable<ColorCurves>;
  60008. /**
  60009. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60010. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60011. * 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;
  60012. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60013. */
  60014. set cameraColorCurves(value: Nullable<ColorCurves>);
  60015. /**
  60016. * Instantiates a new PBRMaterial instance.
  60017. *
  60018. * @param name The material name
  60019. * @param scene The scene the material will be use in.
  60020. */
  60021. constructor(name: string, scene: Scene);
  60022. /**
  60023. * Returns the name of this material class.
  60024. */
  60025. getClassName(): string;
  60026. /**
  60027. * Makes a duplicate of the current material.
  60028. * @param name - name to use for the new material.
  60029. */
  60030. clone(name: string): PBRMaterial;
  60031. /**
  60032. * Serializes this PBR Material.
  60033. * @returns - An object with the serialized material.
  60034. */
  60035. serialize(): any;
  60036. /**
  60037. * Parses a PBR Material from a serialized object.
  60038. * @param source - Serialized object.
  60039. * @param scene - BJS scene instance.
  60040. * @param rootUrl - url for the scene object
  60041. * @returns - PBRMaterial
  60042. */
  60043. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  60044. }
  60045. }
  60046. declare module "babylonjs/Misc/dds" {
  60047. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  60048. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60049. import { Nullable } from "babylonjs/types";
  60050. import { Scene } from "babylonjs/scene";
  60051. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  60052. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60053. /**
  60054. * Direct draw surface info
  60055. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  60056. */
  60057. export interface DDSInfo {
  60058. /**
  60059. * Width of the texture
  60060. */
  60061. width: number;
  60062. /**
  60063. * Width of the texture
  60064. */
  60065. height: number;
  60066. /**
  60067. * Number of Mipmaps for the texture
  60068. * @see https://en.wikipedia.org/wiki/Mipmap
  60069. */
  60070. mipmapCount: number;
  60071. /**
  60072. * If the textures format is a known fourCC format
  60073. * @see https://www.fourcc.org/
  60074. */
  60075. isFourCC: boolean;
  60076. /**
  60077. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  60078. */
  60079. isRGB: boolean;
  60080. /**
  60081. * If the texture is a lumincance format
  60082. */
  60083. isLuminance: boolean;
  60084. /**
  60085. * If this is a cube texture
  60086. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  60087. */
  60088. isCube: boolean;
  60089. /**
  60090. * If the texture is a compressed format eg. FOURCC_DXT1
  60091. */
  60092. isCompressed: boolean;
  60093. /**
  60094. * The dxgiFormat of the texture
  60095. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  60096. */
  60097. dxgiFormat: number;
  60098. /**
  60099. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  60100. */
  60101. textureType: number;
  60102. /**
  60103. * Sphericle polynomial created for the dds texture
  60104. */
  60105. sphericalPolynomial?: SphericalPolynomial;
  60106. }
  60107. /**
  60108. * Class used to provide DDS decompression tools
  60109. */
  60110. export class DDSTools {
  60111. /**
  60112. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  60113. */
  60114. static StoreLODInAlphaChannel: boolean;
  60115. /**
  60116. * Gets DDS information from an array buffer
  60117. * @param data defines the array buffer view to read data from
  60118. * @returns the DDS information
  60119. */
  60120. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  60121. private static _FloatView;
  60122. private static _Int32View;
  60123. private static _ToHalfFloat;
  60124. private static _FromHalfFloat;
  60125. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  60126. private static _GetHalfFloatRGBAArrayBuffer;
  60127. private static _GetFloatRGBAArrayBuffer;
  60128. private static _GetFloatAsUIntRGBAArrayBuffer;
  60129. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  60130. private static _GetRGBAArrayBuffer;
  60131. private static _ExtractLongWordOrder;
  60132. private static _GetRGBArrayBuffer;
  60133. private static _GetLuminanceArrayBuffer;
  60134. /**
  60135. * Uploads DDS Levels to a Babylon Texture
  60136. * @hidden
  60137. */
  60138. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  60139. }
  60140. module "babylonjs/Engines/thinEngine" {
  60141. interface ThinEngine {
  60142. /**
  60143. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  60144. * @param rootUrl defines the url where the file to load is located
  60145. * @param scene defines the current scene
  60146. * @param lodScale defines scale to apply to the mip map selection
  60147. * @param lodOffset defines offset to apply to the mip map selection
  60148. * @param onLoad defines an optional callback raised when the texture is loaded
  60149. * @param onError defines an optional callback raised if there is an issue to load the texture
  60150. * @param format defines the format of the data
  60151. * @param forcedExtension defines the extension to use to pick the right loader
  60152. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  60153. * @returns the cube texture as an InternalTexture
  60154. */
  60155. 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;
  60156. }
  60157. }
  60158. }
  60159. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  60160. import { Nullable } from "babylonjs/types";
  60161. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60162. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60163. /**
  60164. * Implementation of the DDS Texture Loader.
  60165. * @hidden
  60166. */
  60167. export class _DDSTextureLoader implements IInternalTextureLoader {
  60168. /**
  60169. * Defines wether the loader supports cascade loading the different faces.
  60170. */
  60171. readonly supportCascades: boolean;
  60172. /**
  60173. * This returns if the loader support the current file information.
  60174. * @param extension defines the file extension of the file being loaded
  60175. * @returns true if the loader can load the specified file
  60176. */
  60177. canLoad(extension: string): boolean;
  60178. /**
  60179. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60180. * @param data contains the texture data
  60181. * @param texture defines the BabylonJS internal texture
  60182. * @param createPolynomials will be true if polynomials have been requested
  60183. * @param onLoad defines the callback to trigger once the texture is ready
  60184. * @param onError defines the callback to trigger in case of error
  60185. */
  60186. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60187. /**
  60188. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60189. * @param data contains the texture data
  60190. * @param texture defines the BabylonJS internal texture
  60191. * @param callback defines the method to call once ready to upload
  60192. */
  60193. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60194. }
  60195. }
  60196. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  60197. import { Nullable } from "babylonjs/types";
  60198. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60199. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60200. /**
  60201. * Implementation of the ENV Texture Loader.
  60202. * @hidden
  60203. */
  60204. export class _ENVTextureLoader implements IInternalTextureLoader {
  60205. /**
  60206. * Defines wether the loader supports cascade loading the different faces.
  60207. */
  60208. readonly supportCascades: boolean;
  60209. /**
  60210. * This returns if the loader support the current file information.
  60211. * @param extension defines the file extension of the file being loaded
  60212. * @returns true if the loader can load the specified file
  60213. */
  60214. canLoad(extension: string): boolean;
  60215. /**
  60216. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60217. * @param data contains the texture data
  60218. * @param texture defines the BabylonJS internal texture
  60219. * @param createPolynomials will be true if polynomials have been requested
  60220. * @param onLoad defines the callback to trigger once the texture is ready
  60221. * @param onError defines the callback to trigger in case of error
  60222. */
  60223. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60224. /**
  60225. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60226. * @param data contains the texture data
  60227. * @param texture defines the BabylonJS internal texture
  60228. * @param callback defines the method to call once ready to upload
  60229. */
  60230. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60231. }
  60232. }
  60233. declare module "babylonjs/Misc/khronosTextureContainer" {
  60234. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60235. /**
  60236. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60237. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60238. */
  60239. export class KhronosTextureContainer {
  60240. /** contents of the KTX container file */
  60241. data: ArrayBufferView;
  60242. private static HEADER_LEN;
  60243. private static COMPRESSED_2D;
  60244. private static COMPRESSED_3D;
  60245. private static TEX_2D;
  60246. private static TEX_3D;
  60247. /**
  60248. * Gets the openGL type
  60249. */
  60250. glType: number;
  60251. /**
  60252. * Gets the openGL type size
  60253. */
  60254. glTypeSize: number;
  60255. /**
  60256. * Gets the openGL format
  60257. */
  60258. glFormat: number;
  60259. /**
  60260. * Gets the openGL internal format
  60261. */
  60262. glInternalFormat: number;
  60263. /**
  60264. * Gets the base internal format
  60265. */
  60266. glBaseInternalFormat: number;
  60267. /**
  60268. * Gets image width in pixel
  60269. */
  60270. pixelWidth: number;
  60271. /**
  60272. * Gets image height in pixel
  60273. */
  60274. pixelHeight: number;
  60275. /**
  60276. * Gets image depth in pixels
  60277. */
  60278. pixelDepth: number;
  60279. /**
  60280. * Gets the number of array elements
  60281. */
  60282. numberOfArrayElements: number;
  60283. /**
  60284. * Gets the number of faces
  60285. */
  60286. numberOfFaces: number;
  60287. /**
  60288. * Gets the number of mipmap levels
  60289. */
  60290. numberOfMipmapLevels: number;
  60291. /**
  60292. * Gets the bytes of key value data
  60293. */
  60294. bytesOfKeyValueData: number;
  60295. /**
  60296. * Gets the load type
  60297. */
  60298. loadType: number;
  60299. /**
  60300. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  60301. */
  60302. isInvalid: boolean;
  60303. /**
  60304. * Creates a new KhronosTextureContainer
  60305. * @param data contents of the KTX container file
  60306. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  60307. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  60308. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  60309. */
  60310. constructor(
  60311. /** contents of the KTX container file */
  60312. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  60313. /**
  60314. * Uploads KTX content to a Babylon Texture.
  60315. * It is assumed that the texture has already been created & is currently bound
  60316. * @hidden
  60317. */
  60318. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  60319. private _upload2DCompressedLevels;
  60320. /**
  60321. * Checks if the given data starts with a KTX file identifier.
  60322. * @param data the data to check
  60323. * @returns true if the data is a KTX file or false otherwise
  60324. */
  60325. static IsValid(data: ArrayBufferView): boolean;
  60326. }
  60327. }
  60328. declare module "babylonjs/Misc/workerPool" {
  60329. import { IDisposable } from "babylonjs/scene";
  60330. /**
  60331. * Helper class to push actions to a pool of workers.
  60332. */
  60333. export class WorkerPool implements IDisposable {
  60334. private _workerInfos;
  60335. private _pendingActions;
  60336. /**
  60337. * Constructor
  60338. * @param workers Array of workers to use for actions
  60339. */
  60340. constructor(workers: Array<Worker>);
  60341. /**
  60342. * Terminates all workers and clears any pending actions.
  60343. */
  60344. dispose(): void;
  60345. /**
  60346. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60347. * pended until a worker has completed its action.
  60348. * @param action The action to perform. Call onComplete when the action is complete.
  60349. */
  60350. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60351. private _execute;
  60352. }
  60353. }
  60354. declare module "babylonjs/Misc/khronosTextureContainer2" {
  60355. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60356. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60357. /**
  60358. * Class for loading KTX2 files
  60359. * @hidden
  60360. */
  60361. export class KhronosTextureContainer2 {
  60362. private static _WorkerPoolPromise?;
  60363. private static _Initialized;
  60364. private static _Ktx2Decoder;
  60365. /**
  60366. * URL to use when loading the KTX2 decoder module
  60367. */
  60368. static JSModuleURL: string;
  60369. /**
  60370. * Default number of workers used to handle data decoding
  60371. */
  60372. static DefaultNumWorkers: number;
  60373. private static GetDefaultNumWorkers;
  60374. private _engine;
  60375. private static _CreateWorkerPool;
  60376. /**
  60377. * Constructor
  60378. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60379. */
  60380. constructor(engine: ThinEngine, numWorkers?: number);
  60381. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  60382. /**
  60383. * Stop all async operations and release resources.
  60384. */
  60385. dispose(): void;
  60386. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  60387. /**
  60388. * Checks if the given data starts with a KTX2 file identifier.
  60389. * @param data the data to check
  60390. * @returns true if the data is a KTX2 file or false otherwise
  60391. */
  60392. static IsValid(data: ArrayBufferView): boolean;
  60393. }
  60394. export function workerFunc(): void;
  60395. }
  60396. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  60397. import { Nullable } from "babylonjs/types";
  60398. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60399. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60400. /**
  60401. * Implementation of the KTX Texture Loader.
  60402. * @hidden
  60403. */
  60404. export class _KTXTextureLoader implements IInternalTextureLoader {
  60405. /**
  60406. * Defines wether the loader supports cascade loading the different faces.
  60407. */
  60408. readonly supportCascades: boolean;
  60409. /**
  60410. * This returns if the loader support the current file information.
  60411. * @param extension defines the file extension of the file being loaded
  60412. * @param mimeType defines the optional mime type of the file being loaded
  60413. * @returns true if the loader can load the specified file
  60414. */
  60415. canLoad(extension: string, mimeType?: string): boolean;
  60416. /**
  60417. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60418. * @param data contains the texture data
  60419. * @param texture defines the BabylonJS internal texture
  60420. * @param createPolynomials will be true if polynomials have been requested
  60421. * @param onLoad defines the callback to trigger once the texture is ready
  60422. * @param onError defines the callback to trigger in case of error
  60423. */
  60424. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60425. /**
  60426. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60427. * @param data contains the texture data
  60428. * @param texture defines the BabylonJS internal texture
  60429. * @param callback defines the method to call once ready to upload
  60430. */
  60431. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  60432. }
  60433. }
  60434. declare module "babylonjs/Helpers/sceneHelpers" {
  60435. import { Nullable } from "babylonjs/types";
  60436. import { Mesh } from "babylonjs/Meshes/mesh";
  60437. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60438. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  60439. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  60440. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  60441. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  60442. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  60443. import "babylonjs/Meshes/Builders/boxBuilder";
  60444. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  60445. /** @hidden */
  60446. export var _forceSceneHelpersToBundle: boolean;
  60447. module "babylonjs/scene" {
  60448. interface Scene {
  60449. /**
  60450. * Creates a default light for the scene.
  60451. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  60452. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  60453. */
  60454. createDefaultLight(replace?: boolean): void;
  60455. /**
  60456. * Creates a default camera for the scene.
  60457. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  60458. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60459. * @param replace has default false, when true replaces the active camera in the scene
  60460. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  60461. */
  60462. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60463. /**
  60464. * Creates a default camera and a default light.
  60465. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  60466. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60467. * @param replace has the default false, when true replaces the active camera/light in the scene
  60468. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  60469. */
  60470. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60471. /**
  60472. * Creates a new sky box
  60473. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  60474. * @param environmentTexture defines the texture to use as environment texture
  60475. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  60476. * @param scale defines the overall scale of the skybox
  60477. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  60478. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  60479. * @returns a new mesh holding the sky box
  60480. */
  60481. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  60482. /**
  60483. * Creates a new environment
  60484. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  60485. * @param options defines the options you can use to configure the environment
  60486. * @returns the new EnvironmentHelper
  60487. */
  60488. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  60489. /**
  60490. * Creates a new VREXperienceHelper
  60491. * @see https://doc.babylonjs.com/how_to/webvr_helper
  60492. * @param webVROptions defines the options used to create the new VREXperienceHelper
  60493. * @returns a new VREXperienceHelper
  60494. */
  60495. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  60496. /**
  60497. * Creates a new WebXRDefaultExperience
  60498. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  60499. * @param options experience options
  60500. * @returns a promise for a new WebXRDefaultExperience
  60501. */
  60502. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  60503. }
  60504. }
  60505. }
  60506. declare module "babylonjs/Helpers/videoDome" {
  60507. import { Scene } from "babylonjs/scene";
  60508. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  60509. import { TextureDome } from "babylonjs/Helpers/textureDome";
  60510. /**
  60511. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  60512. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  60513. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  60514. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60515. */
  60516. export class VideoDome extends TextureDome<VideoTexture> {
  60517. /**
  60518. * Define the video source as a Monoscopic panoramic 360 video.
  60519. */
  60520. static readonly MODE_MONOSCOPIC: number;
  60521. /**
  60522. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  60523. */
  60524. static readonly MODE_TOPBOTTOM: number;
  60525. /**
  60526. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  60527. */
  60528. static readonly MODE_SIDEBYSIDE: number;
  60529. /**
  60530. * Get the video texture associated with this video dome
  60531. */
  60532. get videoTexture(): VideoTexture;
  60533. /**
  60534. * Get the video mode of this dome
  60535. */
  60536. get videoMode(): number;
  60537. /**
  60538. * Set the video mode of this dome.
  60539. * @see textureMode
  60540. */
  60541. set videoMode(value: number);
  60542. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  60543. }
  60544. }
  60545. declare module "babylonjs/Helpers/index" {
  60546. export * from "babylonjs/Helpers/environmentHelper";
  60547. export * from "babylonjs/Helpers/photoDome";
  60548. export * from "babylonjs/Helpers/sceneHelpers";
  60549. export * from "babylonjs/Helpers/videoDome";
  60550. }
  60551. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  60552. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60553. import { IDisposable } from "babylonjs/scene";
  60554. import { Engine } from "babylonjs/Engines/engine";
  60555. /**
  60556. * This class can be used to get instrumentation data from a Babylon engine
  60557. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60558. */
  60559. export class EngineInstrumentation implements IDisposable {
  60560. /**
  60561. * Define the instrumented engine.
  60562. */
  60563. engine: Engine;
  60564. private _captureGPUFrameTime;
  60565. private _gpuFrameTimeToken;
  60566. private _gpuFrameTime;
  60567. private _captureShaderCompilationTime;
  60568. private _shaderCompilationTime;
  60569. private _onBeginFrameObserver;
  60570. private _onEndFrameObserver;
  60571. private _onBeforeShaderCompilationObserver;
  60572. private _onAfterShaderCompilationObserver;
  60573. /**
  60574. * Gets the perf counter used for GPU frame time
  60575. */
  60576. get gpuFrameTimeCounter(): PerfCounter;
  60577. /**
  60578. * Gets the GPU frame time capture status
  60579. */
  60580. get captureGPUFrameTime(): boolean;
  60581. /**
  60582. * Enable or disable the GPU frame time capture
  60583. */
  60584. set captureGPUFrameTime(value: boolean);
  60585. /**
  60586. * Gets the perf counter used for shader compilation time
  60587. */
  60588. get shaderCompilationTimeCounter(): PerfCounter;
  60589. /**
  60590. * Gets the shader compilation time capture status
  60591. */
  60592. get captureShaderCompilationTime(): boolean;
  60593. /**
  60594. * Enable or disable the shader compilation time capture
  60595. */
  60596. set captureShaderCompilationTime(value: boolean);
  60597. /**
  60598. * Instantiates a new engine instrumentation.
  60599. * This class can be used to get instrumentation data from a Babylon engine
  60600. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60601. * @param engine Defines the engine to instrument
  60602. */
  60603. constructor(
  60604. /**
  60605. * Define the instrumented engine.
  60606. */
  60607. engine: Engine);
  60608. /**
  60609. * Dispose and release associated resources.
  60610. */
  60611. dispose(): void;
  60612. }
  60613. }
  60614. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  60615. import { Scene, IDisposable } from "babylonjs/scene";
  60616. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60617. /**
  60618. * This class can be used to get instrumentation data from a Babylon engine
  60619. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60620. */
  60621. export class SceneInstrumentation implements IDisposable {
  60622. /**
  60623. * Defines the scene to instrument
  60624. */
  60625. scene: Scene;
  60626. private _captureActiveMeshesEvaluationTime;
  60627. private _activeMeshesEvaluationTime;
  60628. private _captureRenderTargetsRenderTime;
  60629. private _renderTargetsRenderTime;
  60630. private _captureFrameTime;
  60631. private _frameTime;
  60632. private _captureRenderTime;
  60633. private _renderTime;
  60634. private _captureInterFrameTime;
  60635. private _interFrameTime;
  60636. private _captureParticlesRenderTime;
  60637. private _particlesRenderTime;
  60638. private _captureSpritesRenderTime;
  60639. private _spritesRenderTime;
  60640. private _capturePhysicsTime;
  60641. private _physicsTime;
  60642. private _captureAnimationsTime;
  60643. private _animationsTime;
  60644. private _captureCameraRenderTime;
  60645. private _cameraRenderTime;
  60646. private _onBeforeActiveMeshesEvaluationObserver;
  60647. private _onAfterActiveMeshesEvaluationObserver;
  60648. private _onBeforeRenderTargetsRenderObserver;
  60649. private _onAfterRenderTargetsRenderObserver;
  60650. private _onAfterRenderObserver;
  60651. private _onBeforeDrawPhaseObserver;
  60652. private _onAfterDrawPhaseObserver;
  60653. private _onBeforeAnimationsObserver;
  60654. private _onBeforeParticlesRenderingObserver;
  60655. private _onAfterParticlesRenderingObserver;
  60656. private _onBeforeSpritesRenderingObserver;
  60657. private _onAfterSpritesRenderingObserver;
  60658. private _onBeforePhysicsObserver;
  60659. private _onAfterPhysicsObserver;
  60660. private _onAfterAnimationsObserver;
  60661. private _onBeforeCameraRenderObserver;
  60662. private _onAfterCameraRenderObserver;
  60663. /**
  60664. * Gets the perf counter used for active meshes evaluation time
  60665. */
  60666. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  60667. /**
  60668. * Gets the active meshes evaluation time capture status
  60669. */
  60670. get captureActiveMeshesEvaluationTime(): boolean;
  60671. /**
  60672. * Enable or disable the active meshes evaluation time capture
  60673. */
  60674. set captureActiveMeshesEvaluationTime(value: boolean);
  60675. /**
  60676. * Gets the perf counter used for render targets render time
  60677. */
  60678. get renderTargetsRenderTimeCounter(): PerfCounter;
  60679. /**
  60680. * Gets the render targets render time capture status
  60681. */
  60682. get captureRenderTargetsRenderTime(): boolean;
  60683. /**
  60684. * Enable or disable the render targets render time capture
  60685. */
  60686. set captureRenderTargetsRenderTime(value: boolean);
  60687. /**
  60688. * Gets the perf counter used for particles render time
  60689. */
  60690. get particlesRenderTimeCounter(): PerfCounter;
  60691. /**
  60692. * Gets the particles render time capture status
  60693. */
  60694. get captureParticlesRenderTime(): boolean;
  60695. /**
  60696. * Enable or disable the particles render time capture
  60697. */
  60698. set captureParticlesRenderTime(value: boolean);
  60699. /**
  60700. * Gets the perf counter used for sprites render time
  60701. */
  60702. get spritesRenderTimeCounter(): PerfCounter;
  60703. /**
  60704. * Gets the sprites render time capture status
  60705. */
  60706. get captureSpritesRenderTime(): boolean;
  60707. /**
  60708. * Enable or disable the sprites render time capture
  60709. */
  60710. set captureSpritesRenderTime(value: boolean);
  60711. /**
  60712. * Gets the perf counter used for physics time
  60713. */
  60714. get physicsTimeCounter(): PerfCounter;
  60715. /**
  60716. * Gets the physics time capture status
  60717. */
  60718. get capturePhysicsTime(): boolean;
  60719. /**
  60720. * Enable or disable the physics time capture
  60721. */
  60722. set capturePhysicsTime(value: boolean);
  60723. /**
  60724. * Gets the perf counter used for animations time
  60725. */
  60726. get animationsTimeCounter(): PerfCounter;
  60727. /**
  60728. * Gets the animations time capture status
  60729. */
  60730. get captureAnimationsTime(): boolean;
  60731. /**
  60732. * Enable or disable the animations time capture
  60733. */
  60734. set captureAnimationsTime(value: boolean);
  60735. /**
  60736. * Gets the perf counter used for frame time capture
  60737. */
  60738. get frameTimeCounter(): PerfCounter;
  60739. /**
  60740. * Gets the frame time capture status
  60741. */
  60742. get captureFrameTime(): boolean;
  60743. /**
  60744. * Enable or disable the frame time capture
  60745. */
  60746. set captureFrameTime(value: boolean);
  60747. /**
  60748. * Gets the perf counter used for inter-frames time capture
  60749. */
  60750. get interFrameTimeCounter(): PerfCounter;
  60751. /**
  60752. * Gets the inter-frames time capture status
  60753. */
  60754. get captureInterFrameTime(): boolean;
  60755. /**
  60756. * Enable or disable the inter-frames time capture
  60757. */
  60758. set captureInterFrameTime(value: boolean);
  60759. /**
  60760. * Gets the perf counter used for render time capture
  60761. */
  60762. get renderTimeCounter(): PerfCounter;
  60763. /**
  60764. * Gets the render time capture status
  60765. */
  60766. get captureRenderTime(): boolean;
  60767. /**
  60768. * Enable or disable the render time capture
  60769. */
  60770. set captureRenderTime(value: boolean);
  60771. /**
  60772. * Gets the perf counter used for camera render time capture
  60773. */
  60774. get cameraRenderTimeCounter(): PerfCounter;
  60775. /**
  60776. * Gets the camera render time capture status
  60777. */
  60778. get captureCameraRenderTime(): boolean;
  60779. /**
  60780. * Enable or disable the camera render time capture
  60781. */
  60782. set captureCameraRenderTime(value: boolean);
  60783. /**
  60784. * Gets the perf counter used for draw calls
  60785. */
  60786. get drawCallsCounter(): PerfCounter;
  60787. /**
  60788. * Instantiates a new scene instrumentation.
  60789. * This class can be used to get instrumentation data from a Babylon engine
  60790. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60791. * @param scene Defines the scene to instrument
  60792. */
  60793. constructor(
  60794. /**
  60795. * Defines the scene to instrument
  60796. */
  60797. scene: Scene);
  60798. /**
  60799. * Dispose and release associated resources.
  60800. */
  60801. dispose(): void;
  60802. }
  60803. }
  60804. declare module "babylonjs/Instrumentation/index" {
  60805. export * from "babylonjs/Instrumentation/engineInstrumentation";
  60806. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  60807. export * from "babylonjs/Instrumentation/timeToken";
  60808. }
  60809. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  60810. /** @hidden */
  60811. export var glowMapGenerationPixelShader: {
  60812. name: string;
  60813. shader: string;
  60814. };
  60815. }
  60816. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  60817. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60818. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60819. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60820. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60821. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60822. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60823. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60824. /** @hidden */
  60825. export var glowMapGenerationVertexShader: {
  60826. name: string;
  60827. shader: string;
  60828. };
  60829. }
  60830. declare module "babylonjs/Layers/effectLayer" {
  60831. import { Observable } from "babylonjs/Misc/observable";
  60832. import { Nullable } from "babylonjs/types";
  60833. import { Camera } from "babylonjs/Cameras/camera";
  60834. import { Scene } from "babylonjs/scene";
  60835. import { ISize } from "babylonjs/Maths/math.size";
  60836. import { Color4 } from "babylonjs/Maths/math.color";
  60837. import { Engine } from "babylonjs/Engines/engine";
  60838. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60839. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60840. import { Mesh } from "babylonjs/Meshes/mesh";
  60841. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60842. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60843. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60844. import { Effect } from "babylonjs/Materials/effect";
  60845. import { Material } from "babylonjs/Materials/material";
  60846. import "babylonjs/Shaders/glowMapGeneration.fragment";
  60847. import "babylonjs/Shaders/glowMapGeneration.vertex";
  60848. /**
  60849. * Effect layer options. This helps customizing the behaviour
  60850. * of the effect layer.
  60851. */
  60852. export interface IEffectLayerOptions {
  60853. /**
  60854. * Multiplication factor apply to the canvas size to compute the render target size
  60855. * used to generated the objects (the smaller the faster).
  60856. */
  60857. mainTextureRatio: number;
  60858. /**
  60859. * Enforces a fixed size texture to ensure effect stability across devices.
  60860. */
  60861. mainTextureFixedSize?: number;
  60862. /**
  60863. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  60864. */
  60865. alphaBlendingMode: number;
  60866. /**
  60867. * The camera attached to the layer.
  60868. */
  60869. camera: Nullable<Camera>;
  60870. /**
  60871. * The rendering group to draw the layer in.
  60872. */
  60873. renderingGroupId: number;
  60874. }
  60875. /**
  60876. * The effect layer Helps adding post process effect blended with the main pass.
  60877. *
  60878. * This can be for instance use to generate glow or higlight effects on the scene.
  60879. *
  60880. * The effect layer class can not be used directly and is intented to inherited from to be
  60881. * customized per effects.
  60882. */
  60883. export abstract class EffectLayer {
  60884. private _vertexBuffers;
  60885. private _indexBuffer;
  60886. private _cachedDefines;
  60887. private _effectLayerMapGenerationEffect;
  60888. private _effectLayerOptions;
  60889. private _mergeEffect;
  60890. protected _scene: Scene;
  60891. protected _engine: Engine;
  60892. protected _maxSize: number;
  60893. protected _mainTextureDesiredSize: ISize;
  60894. protected _mainTexture: RenderTargetTexture;
  60895. protected _shouldRender: boolean;
  60896. protected _postProcesses: PostProcess[];
  60897. protected _textures: BaseTexture[];
  60898. protected _emissiveTextureAndColor: {
  60899. texture: Nullable<BaseTexture>;
  60900. color: Color4;
  60901. };
  60902. /**
  60903. * The name of the layer
  60904. */
  60905. name: string;
  60906. /**
  60907. * The clear color of the texture used to generate the glow map.
  60908. */
  60909. neutralColor: Color4;
  60910. /**
  60911. * Specifies whether the highlight layer is enabled or not.
  60912. */
  60913. isEnabled: boolean;
  60914. /**
  60915. * Gets the camera attached to the layer.
  60916. */
  60917. get camera(): Nullable<Camera>;
  60918. /**
  60919. * Gets the rendering group id the layer should render in.
  60920. */
  60921. get renderingGroupId(): number;
  60922. set renderingGroupId(renderingGroupId: number);
  60923. /**
  60924. * An event triggered when the effect layer has been disposed.
  60925. */
  60926. onDisposeObservable: Observable<EffectLayer>;
  60927. /**
  60928. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  60929. */
  60930. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  60931. /**
  60932. * An event triggered when the generated texture is being merged in the scene.
  60933. */
  60934. onBeforeComposeObservable: Observable<EffectLayer>;
  60935. /**
  60936. * An event triggered when the mesh is rendered into the effect render target.
  60937. */
  60938. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  60939. /**
  60940. * An event triggered after the mesh has been rendered into the effect render target.
  60941. */
  60942. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  60943. /**
  60944. * An event triggered when the generated texture has been merged in the scene.
  60945. */
  60946. onAfterComposeObservable: Observable<EffectLayer>;
  60947. /**
  60948. * An event triggered when the efffect layer changes its size.
  60949. */
  60950. onSizeChangedObservable: Observable<EffectLayer>;
  60951. /** @hidden */
  60952. static _SceneComponentInitialization: (scene: Scene) => void;
  60953. /**
  60954. * Instantiates a new effect Layer and references it in the scene.
  60955. * @param name The name of the layer
  60956. * @param scene The scene to use the layer in
  60957. */
  60958. constructor(
  60959. /** The Friendly of the effect in the scene */
  60960. name: string, scene: Scene);
  60961. /**
  60962. * Get the effect name of the layer.
  60963. * @return The effect name
  60964. */
  60965. abstract getEffectName(): string;
  60966. /**
  60967. * Checks for the readiness of the element composing the layer.
  60968. * @param subMesh the mesh to check for
  60969. * @param useInstances specify whether or not to use instances to render the mesh
  60970. * @return true if ready otherwise, false
  60971. */
  60972. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60973. /**
  60974. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60975. * @returns true if the effect requires stencil during the main canvas render pass.
  60976. */
  60977. abstract needStencil(): boolean;
  60978. /**
  60979. * Create the merge effect. This is the shader use to blit the information back
  60980. * to the main canvas at the end of the scene rendering.
  60981. * @returns The effect containing the shader used to merge the effect on the main canvas
  60982. */
  60983. protected abstract _createMergeEffect(): Effect;
  60984. /**
  60985. * Creates the render target textures and post processes used in the effect layer.
  60986. */
  60987. protected abstract _createTextureAndPostProcesses(): void;
  60988. /**
  60989. * Implementation specific of rendering the generating effect on the main canvas.
  60990. * @param effect The effect used to render through
  60991. */
  60992. protected abstract _internalRender(effect: Effect): void;
  60993. /**
  60994. * Sets the required values for both the emissive texture and and the main color.
  60995. */
  60996. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60997. /**
  60998. * Free any resources and references associated to a mesh.
  60999. * Internal use
  61000. * @param mesh The mesh to free.
  61001. */
  61002. abstract _disposeMesh(mesh: Mesh): void;
  61003. /**
  61004. * Serializes this layer (Glow or Highlight for example)
  61005. * @returns a serialized layer object
  61006. */
  61007. abstract serialize?(): any;
  61008. /**
  61009. * Initializes the effect layer with the required options.
  61010. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  61011. */
  61012. protected _init(options: Partial<IEffectLayerOptions>): void;
  61013. /**
  61014. * Generates the index buffer of the full screen quad blending to the main canvas.
  61015. */
  61016. private _generateIndexBuffer;
  61017. /**
  61018. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  61019. */
  61020. private _generateVertexBuffer;
  61021. /**
  61022. * Sets the main texture desired size which is the closest power of two
  61023. * of the engine canvas size.
  61024. */
  61025. private _setMainTextureSize;
  61026. /**
  61027. * Creates the main texture for the effect layer.
  61028. */
  61029. protected _createMainTexture(): void;
  61030. /**
  61031. * Adds specific effects defines.
  61032. * @param defines The defines to add specifics to.
  61033. */
  61034. protected _addCustomEffectDefines(defines: string[]): void;
  61035. /**
  61036. * Checks for the readiness of the element composing the layer.
  61037. * @param subMesh the mesh to check for
  61038. * @param useInstances specify whether or not to use instances to render the mesh
  61039. * @param emissiveTexture the associated emissive texture used to generate the glow
  61040. * @return true if ready otherwise, false
  61041. */
  61042. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  61043. /**
  61044. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  61045. */
  61046. render(): void;
  61047. /**
  61048. * Determine if a given mesh will be used in the current effect.
  61049. * @param mesh mesh to test
  61050. * @returns true if the mesh will be used
  61051. */
  61052. hasMesh(mesh: AbstractMesh): boolean;
  61053. /**
  61054. * Returns true if the layer contains information to display, otherwise false.
  61055. * @returns true if the glow layer should be rendered
  61056. */
  61057. shouldRender(): boolean;
  61058. /**
  61059. * Returns true if the mesh should render, otherwise false.
  61060. * @param mesh The mesh to render
  61061. * @returns true if it should render otherwise false
  61062. */
  61063. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  61064. /**
  61065. * Returns true if the mesh can be rendered, otherwise false.
  61066. * @param mesh The mesh to render
  61067. * @param material The material used on the mesh
  61068. * @returns true if it can be rendered otherwise false
  61069. */
  61070. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61071. /**
  61072. * Returns true if the mesh should render, otherwise false.
  61073. * @param mesh The mesh to render
  61074. * @returns true if it should render otherwise false
  61075. */
  61076. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  61077. /**
  61078. * Renders the submesh passed in parameter to the generation map.
  61079. */
  61080. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  61081. /**
  61082. * Defines whether the current material of the mesh should be use to render the effect.
  61083. * @param mesh defines the current mesh to render
  61084. */
  61085. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61086. /**
  61087. * Rebuild the required buffers.
  61088. * @hidden Internal use only.
  61089. */
  61090. _rebuild(): void;
  61091. /**
  61092. * Dispose only the render target textures and post process.
  61093. */
  61094. private _disposeTextureAndPostProcesses;
  61095. /**
  61096. * Dispose the highlight layer and free resources.
  61097. */
  61098. dispose(): void;
  61099. /**
  61100. * Gets the class name of the effect layer
  61101. * @returns the string with the class name of the effect layer
  61102. */
  61103. getClassName(): string;
  61104. /**
  61105. * Creates an effect layer from parsed effect layer data
  61106. * @param parsedEffectLayer defines effect layer data
  61107. * @param scene defines the current scene
  61108. * @param rootUrl defines the root URL containing the effect layer information
  61109. * @returns a parsed effect Layer
  61110. */
  61111. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  61112. }
  61113. }
  61114. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  61115. import { Scene } from "babylonjs/scene";
  61116. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61117. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61118. import { AbstractScene } from "babylonjs/abstractScene";
  61119. module "babylonjs/abstractScene" {
  61120. interface AbstractScene {
  61121. /**
  61122. * The list of effect layers (highlights/glow) added to the scene
  61123. * @see https://doc.babylonjs.com/how_to/highlight_layer
  61124. * @see https://doc.babylonjs.com/how_to/glow_layer
  61125. */
  61126. effectLayers: Array<EffectLayer>;
  61127. /**
  61128. * Removes the given effect layer from this scene.
  61129. * @param toRemove defines the effect layer to remove
  61130. * @returns the index of the removed effect layer
  61131. */
  61132. removeEffectLayer(toRemove: EffectLayer): number;
  61133. /**
  61134. * Adds the given effect layer to this scene
  61135. * @param newEffectLayer defines the effect layer to add
  61136. */
  61137. addEffectLayer(newEffectLayer: EffectLayer): void;
  61138. }
  61139. }
  61140. /**
  61141. * Defines the layer scene component responsible to manage any effect layers
  61142. * in a given scene.
  61143. */
  61144. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  61145. /**
  61146. * The component name helpfull to identify the component in the list of scene components.
  61147. */
  61148. readonly name: string;
  61149. /**
  61150. * The scene the component belongs to.
  61151. */
  61152. scene: Scene;
  61153. private _engine;
  61154. private _renderEffects;
  61155. private _needStencil;
  61156. private _previousStencilState;
  61157. /**
  61158. * Creates a new instance of the component for the given scene
  61159. * @param scene Defines the scene to register the component in
  61160. */
  61161. constructor(scene: Scene);
  61162. /**
  61163. * Registers the component in a given scene
  61164. */
  61165. register(): void;
  61166. /**
  61167. * Rebuilds the elements related to this component in case of
  61168. * context lost for instance.
  61169. */
  61170. rebuild(): void;
  61171. /**
  61172. * Serializes the component data to the specified json object
  61173. * @param serializationObject The object to serialize to
  61174. */
  61175. serialize(serializationObject: any): void;
  61176. /**
  61177. * Adds all the elements from the container to the scene
  61178. * @param container the container holding the elements
  61179. */
  61180. addFromContainer(container: AbstractScene): void;
  61181. /**
  61182. * Removes all the elements in the container from the scene
  61183. * @param container contains the elements to remove
  61184. * @param dispose if the removed element should be disposed (default: false)
  61185. */
  61186. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61187. /**
  61188. * Disposes the component and the associated ressources.
  61189. */
  61190. dispose(): void;
  61191. private _isReadyForMesh;
  61192. private _renderMainTexture;
  61193. private _setStencil;
  61194. private _setStencilBack;
  61195. private _draw;
  61196. private _drawCamera;
  61197. private _drawRenderingGroup;
  61198. }
  61199. }
  61200. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  61201. /** @hidden */
  61202. export var glowMapMergePixelShader: {
  61203. name: string;
  61204. shader: string;
  61205. };
  61206. }
  61207. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  61208. /** @hidden */
  61209. export var glowMapMergeVertexShader: {
  61210. name: string;
  61211. shader: string;
  61212. };
  61213. }
  61214. declare module "babylonjs/Layers/glowLayer" {
  61215. import { Nullable } from "babylonjs/types";
  61216. import { Camera } from "babylonjs/Cameras/camera";
  61217. import { Scene } from "babylonjs/scene";
  61218. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61219. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61220. import { Mesh } from "babylonjs/Meshes/mesh";
  61221. import { Texture } from "babylonjs/Materials/Textures/texture";
  61222. import { Effect } from "babylonjs/Materials/effect";
  61223. import { Material } from "babylonjs/Materials/material";
  61224. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61225. import { Color4 } from "babylonjs/Maths/math.color";
  61226. import "babylonjs/Shaders/glowMapMerge.fragment";
  61227. import "babylonjs/Shaders/glowMapMerge.vertex";
  61228. import "babylonjs/Layers/effectLayerSceneComponent";
  61229. module "babylonjs/abstractScene" {
  61230. interface AbstractScene {
  61231. /**
  61232. * Return a the first highlight layer of the scene with a given name.
  61233. * @param name The name of the highlight layer to look for.
  61234. * @return The highlight layer if found otherwise null.
  61235. */
  61236. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  61237. }
  61238. }
  61239. /**
  61240. * Glow layer options. This helps customizing the behaviour
  61241. * of the glow layer.
  61242. */
  61243. export interface IGlowLayerOptions {
  61244. /**
  61245. * Multiplication factor apply to the canvas size to compute the render target size
  61246. * used to generated the glowing objects (the smaller the faster).
  61247. */
  61248. mainTextureRatio: number;
  61249. /**
  61250. * Enforces a fixed size texture to ensure resize independant blur.
  61251. */
  61252. mainTextureFixedSize?: number;
  61253. /**
  61254. * How big is the kernel of the blur texture.
  61255. */
  61256. blurKernelSize: number;
  61257. /**
  61258. * The camera attached to the layer.
  61259. */
  61260. camera: Nullable<Camera>;
  61261. /**
  61262. * Enable MSAA by chosing the number of samples.
  61263. */
  61264. mainTextureSamples?: number;
  61265. /**
  61266. * The rendering group to draw the layer in.
  61267. */
  61268. renderingGroupId: number;
  61269. }
  61270. /**
  61271. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  61272. *
  61273. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  61274. *
  61275. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  61276. */
  61277. export class GlowLayer extends EffectLayer {
  61278. /**
  61279. * Effect Name of the layer.
  61280. */
  61281. static readonly EffectName: string;
  61282. /**
  61283. * The default blur kernel size used for the glow.
  61284. */
  61285. static DefaultBlurKernelSize: number;
  61286. /**
  61287. * The default texture size ratio used for the glow.
  61288. */
  61289. static DefaultTextureRatio: number;
  61290. /**
  61291. * Sets the kernel size of the blur.
  61292. */
  61293. set blurKernelSize(value: number);
  61294. /**
  61295. * Gets the kernel size of the blur.
  61296. */
  61297. get blurKernelSize(): number;
  61298. /**
  61299. * Sets the glow intensity.
  61300. */
  61301. set intensity(value: number);
  61302. /**
  61303. * Gets the glow intensity.
  61304. */
  61305. get intensity(): number;
  61306. private _options;
  61307. private _intensity;
  61308. private _horizontalBlurPostprocess1;
  61309. private _verticalBlurPostprocess1;
  61310. private _horizontalBlurPostprocess2;
  61311. private _verticalBlurPostprocess2;
  61312. private _blurTexture1;
  61313. private _blurTexture2;
  61314. private _postProcesses1;
  61315. private _postProcesses2;
  61316. private _includedOnlyMeshes;
  61317. private _excludedMeshes;
  61318. private _meshesUsingTheirOwnMaterials;
  61319. /**
  61320. * Callback used to let the user override the color selection on a per mesh basis
  61321. */
  61322. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  61323. /**
  61324. * Callback used to let the user override the texture selection on a per mesh basis
  61325. */
  61326. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  61327. /**
  61328. * Instantiates a new glow Layer and references it to the scene.
  61329. * @param name The name of the layer
  61330. * @param scene The scene to use the layer in
  61331. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  61332. */
  61333. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  61334. /**
  61335. * Get the effect name of the layer.
  61336. * @return The effect name
  61337. */
  61338. getEffectName(): string;
  61339. /**
  61340. * Create the merge effect. This is the shader use to blit the information back
  61341. * to the main canvas at the end of the scene rendering.
  61342. */
  61343. protected _createMergeEffect(): Effect;
  61344. /**
  61345. * Creates the render target textures and post processes used in the glow layer.
  61346. */
  61347. protected _createTextureAndPostProcesses(): void;
  61348. /**
  61349. * Checks for the readiness of the element composing the layer.
  61350. * @param subMesh the mesh to check for
  61351. * @param useInstances specify wether or not to use instances to render the mesh
  61352. * @param emissiveTexture the associated emissive texture used to generate the glow
  61353. * @return true if ready otherwise, false
  61354. */
  61355. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61356. /**
  61357. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61358. */
  61359. needStencil(): boolean;
  61360. /**
  61361. * Returns true if the mesh can be rendered, otherwise false.
  61362. * @param mesh The mesh to render
  61363. * @param material The material used on the mesh
  61364. * @returns true if it can be rendered otherwise false
  61365. */
  61366. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61367. /**
  61368. * Implementation specific of rendering the generating effect on the main canvas.
  61369. * @param effect The effect used to render through
  61370. */
  61371. protected _internalRender(effect: Effect): void;
  61372. /**
  61373. * Sets the required values for both the emissive texture and and the main color.
  61374. */
  61375. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61376. /**
  61377. * Returns true if the mesh should render, otherwise false.
  61378. * @param mesh The mesh to render
  61379. * @returns true if it should render otherwise false
  61380. */
  61381. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61382. /**
  61383. * Adds specific effects defines.
  61384. * @param defines The defines to add specifics to.
  61385. */
  61386. protected _addCustomEffectDefines(defines: string[]): void;
  61387. /**
  61388. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  61389. * @param mesh The mesh to exclude from the glow layer
  61390. */
  61391. addExcludedMesh(mesh: Mesh): void;
  61392. /**
  61393. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  61394. * @param mesh The mesh to remove
  61395. */
  61396. removeExcludedMesh(mesh: Mesh): void;
  61397. /**
  61398. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  61399. * @param mesh The mesh to include in the glow layer
  61400. */
  61401. addIncludedOnlyMesh(mesh: Mesh): void;
  61402. /**
  61403. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  61404. * @param mesh The mesh to remove
  61405. */
  61406. removeIncludedOnlyMesh(mesh: Mesh): void;
  61407. /**
  61408. * Determine if a given mesh will be used in the glow layer
  61409. * @param mesh The mesh to test
  61410. * @returns true if the mesh will be highlighted by the current glow layer
  61411. */
  61412. hasMesh(mesh: AbstractMesh): boolean;
  61413. /**
  61414. * Defines whether the current material of the mesh should be use to render the effect.
  61415. * @param mesh defines the current mesh to render
  61416. */
  61417. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61418. /**
  61419. * Add a mesh to be rendered through its own material and not with emissive only.
  61420. * @param mesh The mesh for which we need to use its material
  61421. */
  61422. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  61423. /**
  61424. * Remove a mesh from being rendered through its own material and not with emissive only.
  61425. * @param mesh The mesh for which we need to not use its material
  61426. */
  61427. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  61428. /**
  61429. * Free any resources and references associated to a mesh.
  61430. * Internal use
  61431. * @param mesh The mesh to free.
  61432. * @hidden
  61433. */
  61434. _disposeMesh(mesh: Mesh): void;
  61435. /**
  61436. * Gets the class name of the effect layer
  61437. * @returns the string with the class name of the effect layer
  61438. */
  61439. getClassName(): string;
  61440. /**
  61441. * Serializes this glow layer
  61442. * @returns a serialized glow layer object
  61443. */
  61444. serialize(): any;
  61445. /**
  61446. * Creates a Glow Layer from parsed glow layer data
  61447. * @param parsedGlowLayer defines glow layer data
  61448. * @param scene defines the current scene
  61449. * @param rootUrl defines the root URL containing the glow layer information
  61450. * @returns a parsed Glow Layer
  61451. */
  61452. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  61453. }
  61454. }
  61455. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  61456. /** @hidden */
  61457. export var glowBlurPostProcessPixelShader: {
  61458. name: string;
  61459. shader: string;
  61460. };
  61461. }
  61462. declare module "babylonjs/Layers/highlightLayer" {
  61463. import { Observable } from "babylonjs/Misc/observable";
  61464. import { Nullable } from "babylonjs/types";
  61465. import { Camera } from "babylonjs/Cameras/camera";
  61466. import { Scene } from "babylonjs/scene";
  61467. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61469. import { Mesh } from "babylonjs/Meshes/mesh";
  61470. import { Effect } from "babylonjs/Materials/effect";
  61471. import { Material } from "babylonjs/Materials/material";
  61472. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61473. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61474. import "babylonjs/Shaders/glowMapMerge.fragment";
  61475. import "babylonjs/Shaders/glowMapMerge.vertex";
  61476. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  61477. module "babylonjs/abstractScene" {
  61478. interface AbstractScene {
  61479. /**
  61480. * Return a the first highlight layer of the scene with a given name.
  61481. * @param name The name of the highlight layer to look for.
  61482. * @return The highlight layer if found otherwise null.
  61483. */
  61484. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  61485. }
  61486. }
  61487. /**
  61488. * Highlight layer options. This helps customizing the behaviour
  61489. * of the highlight layer.
  61490. */
  61491. export interface IHighlightLayerOptions {
  61492. /**
  61493. * Multiplication factor apply to the canvas size to compute the render target size
  61494. * used to generated the glowing objects (the smaller the faster).
  61495. */
  61496. mainTextureRatio: number;
  61497. /**
  61498. * Enforces a fixed size texture to ensure resize independant blur.
  61499. */
  61500. mainTextureFixedSize?: number;
  61501. /**
  61502. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  61503. * of the picture to blur (the smaller the faster).
  61504. */
  61505. blurTextureSizeRatio: number;
  61506. /**
  61507. * How big in texel of the blur texture is the vertical blur.
  61508. */
  61509. blurVerticalSize: number;
  61510. /**
  61511. * How big in texel of the blur texture is the horizontal blur.
  61512. */
  61513. blurHorizontalSize: number;
  61514. /**
  61515. * Alpha blending mode used to apply the blur. Default is combine.
  61516. */
  61517. alphaBlendingMode: number;
  61518. /**
  61519. * The camera attached to the layer.
  61520. */
  61521. camera: Nullable<Camera>;
  61522. /**
  61523. * Should we display highlight as a solid stroke?
  61524. */
  61525. isStroke?: boolean;
  61526. /**
  61527. * The rendering group to draw the layer in.
  61528. */
  61529. renderingGroupId: number;
  61530. }
  61531. /**
  61532. * The highlight layer Helps adding a glow effect around a mesh.
  61533. *
  61534. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  61535. * glowy meshes to your scene.
  61536. *
  61537. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  61538. */
  61539. export class HighlightLayer extends EffectLayer {
  61540. name: string;
  61541. /**
  61542. * Effect Name of the highlight layer.
  61543. */
  61544. static readonly EffectName: string;
  61545. /**
  61546. * The neutral color used during the preparation of the glow effect.
  61547. * This is black by default as the blend operation is a blend operation.
  61548. */
  61549. static NeutralColor: Color4;
  61550. /**
  61551. * Stencil value used for glowing meshes.
  61552. */
  61553. static GlowingMeshStencilReference: number;
  61554. /**
  61555. * Stencil value used for the other meshes in the scene.
  61556. */
  61557. static NormalMeshStencilReference: number;
  61558. /**
  61559. * Specifies whether or not the inner glow is ACTIVE in the layer.
  61560. */
  61561. innerGlow: boolean;
  61562. /**
  61563. * Specifies whether or not the outer glow is ACTIVE in the layer.
  61564. */
  61565. outerGlow: boolean;
  61566. /**
  61567. * Specifies the horizontal size of the blur.
  61568. */
  61569. set blurHorizontalSize(value: number);
  61570. /**
  61571. * Specifies the vertical size of the blur.
  61572. */
  61573. set blurVerticalSize(value: number);
  61574. /**
  61575. * Gets the horizontal size of the blur.
  61576. */
  61577. get blurHorizontalSize(): number;
  61578. /**
  61579. * Gets the vertical size of the blur.
  61580. */
  61581. get blurVerticalSize(): number;
  61582. /**
  61583. * An event triggered when the highlight layer is being blurred.
  61584. */
  61585. onBeforeBlurObservable: Observable<HighlightLayer>;
  61586. /**
  61587. * An event triggered when the highlight layer has been blurred.
  61588. */
  61589. onAfterBlurObservable: Observable<HighlightLayer>;
  61590. private _instanceGlowingMeshStencilReference;
  61591. private _options;
  61592. private _downSamplePostprocess;
  61593. private _horizontalBlurPostprocess;
  61594. private _verticalBlurPostprocess;
  61595. private _blurTexture;
  61596. private _meshes;
  61597. private _excludedMeshes;
  61598. /**
  61599. * Instantiates a new highlight Layer and references it to the scene..
  61600. * @param name The name of the layer
  61601. * @param scene The scene to use the layer in
  61602. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  61603. */
  61604. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  61605. /**
  61606. * Get the effect name of the layer.
  61607. * @return The effect name
  61608. */
  61609. getEffectName(): string;
  61610. /**
  61611. * Create the merge effect. This is the shader use to blit the information back
  61612. * to the main canvas at the end of the scene rendering.
  61613. */
  61614. protected _createMergeEffect(): Effect;
  61615. /**
  61616. * Creates the render target textures and post processes used in the highlight layer.
  61617. */
  61618. protected _createTextureAndPostProcesses(): void;
  61619. /**
  61620. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  61621. */
  61622. needStencil(): boolean;
  61623. /**
  61624. * Checks for the readiness of the element composing the layer.
  61625. * @param subMesh the mesh to check for
  61626. * @param useInstances specify wether or not to use instances to render the mesh
  61627. * @param emissiveTexture the associated emissive texture used to generate the glow
  61628. * @return true if ready otherwise, false
  61629. */
  61630. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61631. /**
  61632. * Implementation specific of rendering the generating effect on the main canvas.
  61633. * @param effect The effect used to render through
  61634. */
  61635. protected _internalRender(effect: Effect): void;
  61636. /**
  61637. * Returns true if the layer contains information to display, otherwise false.
  61638. */
  61639. shouldRender(): boolean;
  61640. /**
  61641. * Returns true if the mesh should render, otherwise false.
  61642. * @param mesh The mesh to render
  61643. * @returns true if it should render otherwise false
  61644. */
  61645. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61646. /**
  61647. * Returns true if the mesh can be rendered, otherwise false.
  61648. * @param mesh The mesh to render
  61649. * @param material The material used on the mesh
  61650. * @returns true if it can be rendered otherwise false
  61651. */
  61652. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61653. /**
  61654. * Adds specific effects defines.
  61655. * @param defines The defines to add specifics to.
  61656. */
  61657. protected _addCustomEffectDefines(defines: string[]): void;
  61658. /**
  61659. * Sets the required values for both the emissive texture and and the main color.
  61660. */
  61661. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61662. /**
  61663. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  61664. * @param mesh The mesh to exclude from the highlight layer
  61665. */
  61666. addExcludedMesh(mesh: Mesh): void;
  61667. /**
  61668. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  61669. * @param mesh The mesh to highlight
  61670. */
  61671. removeExcludedMesh(mesh: Mesh): void;
  61672. /**
  61673. * Determine if a given mesh will be highlighted by the current HighlightLayer
  61674. * @param mesh mesh to test
  61675. * @returns true if the mesh will be highlighted by the current HighlightLayer
  61676. */
  61677. hasMesh(mesh: AbstractMesh): boolean;
  61678. /**
  61679. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  61680. * @param mesh The mesh to highlight
  61681. * @param color The color of the highlight
  61682. * @param glowEmissiveOnly Extract the glow from the emissive texture
  61683. */
  61684. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  61685. /**
  61686. * Remove a mesh from the highlight layer in order to make it stop glowing.
  61687. * @param mesh The mesh to highlight
  61688. */
  61689. removeMesh(mesh: Mesh): void;
  61690. /**
  61691. * Remove all the meshes currently referenced in the highlight layer
  61692. */
  61693. removeAllMeshes(): void;
  61694. /**
  61695. * Force the stencil to the normal expected value for none glowing parts
  61696. */
  61697. private _defaultStencilReference;
  61698. /**
  61699. * Free any resources and references associated to a mesh.
  61700. * Internal use
  61701. * @param mesh The mesh to free.
  61702. * @hidden
  61703. */
  61704. _disposeMesh(mesh: Mesh): void;
  61705. /**
  61706. * Dispose the highlight layer and free resources.
  61707. */
  61708. dispose(): void;
  61709. /**
  61710. * Gets the class name of the effect layer
  61711. * @returns the string with the class name of the effect layer
  61712. */
  61713. getClassName(): string;
  61714. /**
  61715. * Serializes this Highlight layer
  61716. * @returns a serialized Highlight layer object
  61717. */
  61718. serialize(): any;
  61719. /**
  61720. * Creates a Highlight layer from parsed Highlight layer data
  61721. * @param parsedHightlightLayer defines the Highlight layer data
  61722. * @param scene defines the current scene
  61723. * @param rootUrl defines the root URL containing the Highlight layer information
  61724. * @returns a parsed Highlight layer
  61725. */
  61726. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  61727. }
  61728. }
  61729. declare module "babylonjs/Layers/layerSceneComponent" {
  61730. import { Scene } from "babylonjs/scene";
  61731. import { ISceneComponent } from "babylonjs/sceneComponent";
  61732. import { Layer } from "babylonjs/Layers/layer";
  61733. import { AbstractScene } from "babylonjs/abstractScene";
  61734. module "babylonjs/abstractScene" {
  61735. interface AbstractScene {
  61736. /**
  61737. * The list of layers (background and foreground) of the scene
  61738. */
  61739. layers: Array<Layer>;
  61740. }
  61741. }
  61742. /**
  61743. * Defines the layer scene component responsible to manage any layers
  61744. * in a given scene.
  61745. */
  61746. export class LayerSceneComponent implements ISceneComponent {
  61747. /**
  61748. * The component name helpfull to identify the component in the list of scene components.
  61749. */
  61750. readonly name: string;
  61751. /**
  61752. * The scene the component belongs to.
  61753. */
  61754. scene: Scene;
  61755. private _engine;
  61756. /**
  61757. * Creates a new instance of the component for the given scene
  61758. * @param scene Defines the scene to register the component in
  61759. */
  61760. constructor(scene: Scene);
  61761. /**
  61762. * Registers the component in a given scene
  61763. */
  61764. register(): void;
  61765. /**
  61766. * Rebuilds the elements related to this component in case of
  61767. * context lost for instance.
  61768. */
  61769. rebuild(): void;
  61770. /**
  61771. * Disposes the component and the associated ressources.
  61772. */
  61773. dispose(): void;
  61774. private _draw;
  61775. private _drawCameraPredicate;
  61776. private _drawCameraBackground;
  61777. private _drawCameraForeground;
  61778. private _drawRenderTargetPredicate;
  61779. private _drawRenderTargetBackground;
  61780. private _drawRenderTargetForeground;
  61781. /**
  61782. * Adds all the elements from the container to the scene
  61783. * @param container the container holding the elements
  61784. */
  61785. addFromContainer(container: AbstractScene): void;
  61786. /**
  61787. * Removes all the elements in the container from the scene
  61788. * @param container contains the elements to remove
  61789. * @param dispose if the removed element should be disposed (default: false)
  61790. */
  61791. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61792. }
  61793. }
  61794. declare module "babylonjs/Shaders/layer.fragment" {
  61795. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61796. /** @hidden */
  61797. export var layerPixelShader: {
  61798. name: string;
  61799. shader: string;
  61800. };
  61801. }
  61802. declare module "babylonjs/Shaders/layer.vertex" {
  61803. /** @hidden */
  61804. export var layerVertexShader: {
  61805. name: string;
  61806. shader: string;
  61807. };
  61808. }
  61809. declare module "babylonjs/Layers/layer" {
  61810. import { Observable } from "babylonjs/Misc/observable";
  61811. import { Nullable } from "babylonjs/types";
  61812. import { Scene } from "babylonjs/scene";
  61813. import { Vector2 } from "babylonjs/Maths/math.vector";
  61814. import { Color4 } from "babylonjs/Maths/math.color";
  61815. import { Texture } from "babylonjs/Materials/Textures/texture";
  61816. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61817. import "babylonjs/Shaders/layer.fragment";
  61818. import "babylonjs/Shaders/layer.vertex";
  61819. /**
  61820. * This represents a full screen 2d layer.
  61821. * This can be useful to display a picture in the background of your scene for instance.
  61822. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61823. */
  61824. export class Layer {
  61825. /**
  61826. * Define the name of the layer.
  61827. */
  61828. name: string;
  61829. /**
  61830. * Define the texture the layer should display.
  61831. */
  61832. texture: Nullable<Texture>;
  61833. /**
  61834. * Is the layer in background or foreground.
  61835. */
  61836. isBackground: boolean;
  61837. /**
  61838. * Define the color of the layer (instead of texture).
  61839. */
  61840. color: Color4;
  61841. /**
  61842. * Define the scale of the layer in order to zoom in out of the texture.
  61843. */
  61844. scale: Vector2;
  61845. /**
  61846. * Define an offset for the layer in order to shift the texture.
  61847. */
  61848. offset: Vector2;
  61849. /**
  61850. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  61851. */
  61852. alphaBlendingMode: number;
  61853. /**
  61854. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  61855. * Alpha test will not mix with the background color in case of transparency.
  61856. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  61857. */
  61858. alphaTest: boolean;
  61859. /**
  61860. * Define a mask to restrict the layer to only some of the scene cameras.
  61861. */
  61862. layerMask: number;
  61863. /**
  61864. * Define the list of render target the layer is visible into.
  61865. */
  61866. renderTargetTextures: RenderTargetTexture[];
  61867. /**
  61868. * Define if the layer is only used in renderTarget or if it also
  61869. * renders in the main frame buffer of the canvas.
  61870. */
  61871. renderOnlyInRenderTargetTextures: boolean;
  61872. private _scene;
  61873. private _vertexBuffers;
  61874. private _indexBuffer;
  61875. private _effect;
  61876. private _previousDefines;
  61877. /**
  61878. * An event triggered when the layer is disposed.
  61879. */
  61880. onDisposeObservable: Observable<Layer>;
  61881. private _onDisposeObserver;
  61882. /**
  61883. * Back compatibility with callback before the onDisposeObservable existed.
  61884. * The set callback will be triggered when the layer has been disposed.
  61885. */
  61886. set onDispose(callback: () => void);
  61887. /**
  61888. * An event triggered before rendering the scene
  61889. */
  61890. onBeforeRenderObservable: Observable<Layer>;
  61891. private _onBeforeRenderObserver;
  61892. /**
  61893. * Back compatibility with callback before the onBeforeRenderObservable existed.
  61894. * The set callback will be triggered just before rendering the layer.
  61895. */
  61896. set onBeforeRender(callback: () => void);
  61897. /**
  61898. * An event triggered after rendering the scene
  61899. */
  61900. onAfterRenderObservable: Observable<Layer>;
  61901. private _onAfterRenderObserver;
  61902. /**
  61903. * Back compatibility with callback before the onAfterRenderObservable existed.
  61904. * The set callback will be triggered just after rendering the layer.
  61905. */
  61906. set onAfterRender(callback: () => void);
  61907. /**
  61908. * Instantiates a new layer.
  61909. * This represents a full screen 2d layer.
  61910. * This can be useful to display a picture in the background of your scene for instance.
  61911. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61912. * @param name Define the name of the layer in the scene
  61913. * @param imgUrl Define the url of the texture to display in the layer
  61914. * @param scene Define the scene the layer belongs to
  61915. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  61916. * @param color Defines a color for the layer
  61917. */
  61918. constructor(
  61919. /**
  61920. * Define the name of the layer.
  61921. */
  61922. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  61923. private _createIndexBuffer;
  61924. /** @hidden */
  61925. _rebuild(): void;
  61926. /**
  61927. * Renders the layer in the scene.
  61928. */
  61929. render(): void;
  61930. /**
  61931. * Disposes and releases the associated ressources.
  61932. */
  61933. dispose(): void;
  61934. }
  61935. }
  61936. declare module "babylonjs/Layers/index" {
  61937. export * from "babylonjs/Layers/effectLayer";
  61938. export * from "babylonjs/Layers/effectLayerSceneComponent";
  61939. export * from "babylonjs/Layers/glowLayer";
  61940. export * from "babylonjs/Layers/highlightLayer";
  61941. export * from "babylonjs/Layers/layer";
  61942. export * from "babylonjs/Layers/layerSceneComponent";
  61943. }
  61944. declare module "babylonjs/Shaders/lensFlare.fragment" {
  61945. /** @hidden */
  61946. export var lensFlarePixelShader: {
  61947. name: string;
  61948. shader: string;
  61949. };
  61950. }
  61951. declare module "babylonjs/Shaders/lensFlare.vertex" {
  61952. /** @hidden */
  61953. export var lensFlareVertexShader: {
  61954. name: string;
  61955. shader: string;
  61956. };
  61957. }
  61958. declare module "babylonjs/LensFlares/lensFlareSystem" {
  61959. import { Scene } from "babylonjs/scene";
  61960. import { Vector3 } from "babylonjs/Maths/math.vector";
  61961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61962. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  61963. import "babylonjs/Shaders/lensFlare.fragment";
  61964. import "babylonjs/Shaders/lensFlare.vertex";
  61965. import { Viewport } from "babylonjs/Maths/math.viewport";
  61966. /**
  61967. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  61968. * It is usually composed of several `lensFlare`.
  61969. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61970. */
  61971. export class LensFlareSystem {
  61972. /**
  61973. * Define the name of the lens flare system
  61974. */
  61975. name: string;
  61976. /**
  61977. * List of lens flares used in this system.
  61978. */
  61979. lensFlares: LensFlare[];
  61980. /**
  61981. * Define a limit from the border the lens flare can be visible.
  61982. */
  61983. borderLimit: number;
  61984. /**
  61985. * Define a viewport border we do not want to see the lens flare in.
  61986. */
  61987. viewportBorder: number;
  61988. /**
  61989. * Define a predicate which could limit the list of meshes able to occlude the effect.
  61990. */
  61991. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  61992. /**
  61993. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  61994. */
  61995. layerMask: number;
  61996. /**
  61997. * Define the id of the lens flare system in the scene.
  61998. * (equal to name by default)
  61999. */
  62000. id: string;
  62001. private _scene;
  62002. private _emitter;
  62003. private _vertexBuffers;
  62004. private _indexBuffer;
  62005. private _effect;
  62006. private _positionX;
  62007. private _positionY;
  62008. private _isEnabled;
  62009. /** @hidden */
  62010. static _SceneComponentInitialization: (scene: Scene) => void;
  62011. /**
  62012. * Instantiates a lens flare system.
  62013. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62014. * It is usually composed of several `lensFlare`.
  62015. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62016. * @param name Define the name of the lens flare system in the scene
  62017. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  62018. * @param scene Define the scene the lens flare system belongs to
  62019. */
  62020. constructor(
  62021. /**
  62022. * Define the name of the lens flare system
  62023. */
  62024. name: string, emitter: any, scene: Scene);
  62025. /**
  62026. * Define if the lens flare system is enabled.
  62027. */
  62028. get isEnabled(): boolean;
  62029. set isEnabled(value: boolean);
  62030. /**
  62031. * Get the scene the effects belongs to.
  62032. * @returns the scene holding the lens flare system
  62033. */
  62034. getScene(): Scene;
  62035. /**
  62036. * Get the emitter of the lens flare system.
  62037. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62038. * @returns the emitter of the lens flare system
  62039. */
  62040. getEmitter(): any;
  62041. /**
  62042. * Set the emitter of the lens flare system.
  62043. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62044. * @param newEmitter Define the new emitter of the system
  62045. */
  62046. setEmitter(newEmitter: any): void;
  62047. /**
  62048. * Get the lens flare system emitter position.
  62049. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  62050. * @returns the position
  62051. */
  62052. getEmitterPosition(): Vector3;
  62053. /**
  62054. * @hidden
  62055. */
  62056. computeEffectivePosition(globalViewport: Viewport): boolean;
  62057. /** @hidden */
  62058. _isVisible(): boolean;
  62059. /**
  62060. * @hidden
  62061. */
  62062. render(): boolean;
  62063. /**
  62064. * Dispose and release the lens flare with its associated resources.
  62065. */
  62066. dispose(): void;
  62067. /**
  62068. * Parse a lens flare system from a JSON repressentation
  62069. * @param parsedLensFlareSystem Define the JSON to parse
  62070. * @param scene Define the scene the parsed system should be instantiated in
  62071. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  62072. * @returns the parsed system
  62073. */
  62074. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  62075. /**
  62076. * Serialize the current Lens Flare System into a JSON representation.
  62077. * @returns the serialized JSON
  62078. */
  62079. serialize(): any;
  62080. }
  62081. }
  62082. declare module "babylonjs/LensFlares/lensFlare" {
  62083. import { Nullable } from "babylonjs/types";
  62084. import { Color3 } from "babylonjs/Maths/math.color";
  62085. import { Texture } from "babylonjs/Materials/Textures/texture";
  62086. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62087. /**
  62088. * This represents one of the lens effect in a `lensFlareSystem`.
  62089. * It controls one of the indiviual texture used in the effect.
  62090. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62091. */
  62092. export class LensFlare {
  62093. /**
  62094. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62095. */
  62096. size: number;
  62097. /**
  62098. * 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.
  62099. */
  62100. position: number;
  62101. /**
  62102. * Define the lens color.
  62103. */
  62104. color: Color3;
  62105. /**
  62106. * Define the lens texture.
  62107. */
  62108. texture: Nullable<Texture>;
  62109. /**
  62110. * Define the alpha mode to render this particular lens.
  62111. */
  62112. alphaMode: number;
  62113. private _system;
  62114. /**
  62115. * Creates a new Lens Flare.
  62116. * This represents one of the lens effect in a `lensFlareSystem`.
  62117. * It controls one of the indiviual texture used in the effect.
  62118. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62119. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  62120. * @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.
  62121. * @param color Define the lens color
  62122. * @param imgUrl Define the lens texture url
  62123. * @param system Define the `lensFlareSystem` this flare is part of
  62124. * @returns The newly created Lens Flare
  62125. */
  62126. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  62127. /**
  62128. * Instantiates a new Lens Flare.
  62129. * This represents one of the lens effect in a `lensFlareSystem`.
  62130. * It controls one of the indiviual texture used in the effect.
  62131. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62132. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  62133. * @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.
  62134. * @param color Define the lens color
  62135. * @param imgUrl Define the lens texture url
  62136. * @param system Define the `lensFlareSystem` this flare is part of
  62137. */
  62138. constructor(
  62139. /**
  62140. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62141. */
  62142. size: number,
  62143. /**
  62144. * 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.
  62145. */
  62146. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  62147. /**
  62148. * Dispose and release the lens flare with its associated resources.
  62149. */
  62150. dispose(): void;
  62151. }
  62152. }
  62153. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  62154. import { Nullable } from "babylonjs/types";
  62155. import { Scene } from "babylonjs/scene";
  62156. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62157. import { AbstractScene } from "babylonjs/abstractScene";
  62158. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62159. module "babylonjs/abstractScene" {
  62160. interface AbstractScene {
  62161. /**
  62162. * The list of lens flare system added to the scene
  62163. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62164. */
  62165. lensFlareSystems: Array<LensFlareSystem>;
  62166. /**
  62167. * Removes the given lens flare system from this scene.
  62168. * @param toRemove The lens flare system to remove
  62169. * @returns The index of the removed lens flare system
  62170. */
  62171. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  62172. /**
  62173. * Adds the given lens flare system to this scene
  62174. * @param newLensFlareSystem The lens flare system to add
  62175. */
  62176. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  62177. /**
  62178. * Gets a lens flare system using its name
  62179. * @param name defines the name to look for
  62180. * @returns the lens flare system or null if not found
  62181. */
  62182. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  62183. /**
  62184. * Gets a lens flare system using its id
  62185. * @param id defines the id to look for
  62186. * @returns the lens flare system or null if not found
  62187. */
  62188. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  62189. }
  62190. }
  62191. /**
  62192. * Defines the lens flare scene component responsible to manage any lens flares
  62193. * in a given scene.
  62194. */
  62195. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  62196. /**
  62197. * The component name helpfull to identify the component in the list of scene components.
  62198. */
  62199. readonly name: string;
  62200. /**
  62201. * The scene the component belongs to.
  62202. */
  62203. scene: Scene;
  62204. /**
  62205. * Creates a new instance of the component for the given scene
  62206. * @param scene Defines the scene to register the component in
  62207. */
  62208. constructor(scene: Scene);
  62209. /**
  62210. * Registers the component in a given scene
  62211. */
  62212. register(): void;
  62213. /**
  62214. * Rebuilds the elements related to this component in case of
  62215. * context lost for instance.
  62216. */
  62217. rebuild(): void;
  62218. /**
  62219. * Adds all the elements from the container to the scene
  62220. * @param container the container holding the elements
  62221. */
  62222. addFromContainer(container: AbstractScene): void;
  62223. /**
  62224. * Removes all the elements in the container from the scene
  62225. * @param container contains the elements to remove
  62226. * @param dispose if the removed element should be disposed (default: false)
  62227. */
  62228. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62229. /**
  62230. * Serializes the component data to the specified json object
  62231. * @param serializationObject The object to serialize to
  62232. */
  62233. serialize(serializationObject: any): void;
  62234. /**
  62235. * Disposes the component and the associated ressources.
  62236. */
  62237. dispose(): void;
  62238. private _draw;
  62239. }
  62240. }
  62241. declare module "babylonjs/LensFlares/index" {
  62242. export * from "babylonjs/LensFlares/lensFlare";
  62243. export * from "babylonjs/LensFlares/lensFlareSystem";
  62244. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  62245. }
  62246. declare module "babylonjs/Shaders/depth.fragment" {
  62247. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62248. /** @hidden */
  62249. export var depthPixelShader: {
  62250. name: string;
  62251. shader: string;
  62252. };
  62253. }
  62254. declare module "babylonjs/Shaders/depth.vertex" {
  62255. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62256. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62257. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62258. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62259. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62260. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62261. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62262. /** @hidden */
  62263. export var depthVertexShader: {
  62264. name: string;
  62265. shader: string;
  62266. };
  62267. }
  62268. declare module "babylonjs/Rendering/depthRenderer" {
  62269. import { Nullable } from "babylonjs/types";
  62270. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62271. import { Scene } from "babylonjs/scene";
  62272. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62273. import { Camera } from "babylonjs/Cameras/camera";
  62274. import "babylonjs/Shaders/depth.fragment";
  62275. import "babylonjs/Shaders/depth.vertex";
  62276. /**
  62277. * This represents a depth renderer in Babylon.
  62278. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62279. */
  62280. export class DepthRenderer {
  62281. private _scene;
  62282. private _depthMap;
  62283. private _effect;
  62284. private readonly _storeNonLinearDepth;
  62285. private readonly _clearColor;
  62286. /** Get if the depth renderer is using packed depth or not */
  62287. readonly isPacked: boolean;
  62288. private _cachedDefines;
  62289. private _camera;
  62290. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  62291. enabled: boolean;
  62292. /**
  62293. * Specifiess that the depth renderer will only be used within
  62294. * the camera it is created for.
  62295. * This can help forcing its rendering during the camera processing.
  62296. */
  62297. useOnlyInActiveCamera: boolean;
  62298. /** @hidden */
  62299. static _SceneComponentInitialization: (scene: Scene) => void;
  62300. /**
  62301. * Instantiates a depth renderer
  62302. * @param scene The scene the renderer belongs to
  62303. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62304. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62305. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62306. */
  62307. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62308. /**
  62309. * Creates the depth rendering effect and checks if the effect is ready.
  62310. * @param subMesh The submesh to be used to render the depth map of
  62311. * @param useInstances If multiple world instances should be used
  62312. * @returns if the depth renderer is ready to render the depth map
  62313. */
  62314. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62315. /**
  62316. * Gets the texture which the depth map will be written to.
  62317. * @returns The depth map texture
  62318. */
  62319. getDepthMap(): RenderTargetTexture;
  62320. /**
  62321. * Disposes of the depth renderer.
  62322. */
  62323. dispose(): void;
  62324. }
  62325. }
  62326. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  62327. /** @hidden */
  62328. export var minmaxReduxPixelShader: {
  62329. name: string;
  62330. shader: string;
  62331. };
  62332. }
  62333. declare module "babylonjs/Misc/minMaxReducer" {
  62334. import { Nullable } from "babylonjs/types";
  62335. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62336. import { Camera } from "babylonjs/Cameras/camera";
  62337. import { Observer } from "babylonjs/Misc/observable";
  62338. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62339. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  62340. import { Observable } from "babylonjs/Misc/observable";
  62341. import "babylonjs/Shaders/minmaxRedux.fragment";
  62342. /**
  62343. * This class computes a min/max reduction from a texture: it means it computes the minimum
  62344. * and maximum values from all values of the texture.
  62345. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  62346. * The source values are read from the red channel of the texture.
  62347. */
  62348. export class MinMaxReducer {
  62349. /**
  62350. * Observable triggered when the computation has been performed
  62351. */
  62352. onAfterReductionPerformed: Observable<{
  62353. min: number;
  62354. max: number;
  62355. }>;
  62356. protected _camera: Camera;
  62357. protected _sourceTexture: Nullable<RenderTargetTexture>;
  62358. protected _reductionSteps: Nullable<Array<PostProcess>>;
  62359. protected _postProcessManager: PostProcessManager;
  62360. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  62361. protected _forceFullscreenViewport: boolean;
  62362. /**
  62363. * Creates a min/max reducer
  62364. * @param camera The camera to use for the post processes
  62365. */
  62366. constructor(camera: Camera);
  62367. /**
  62368. * Gets the texture used to read the values from.
  62369. */
  62370. get sourceTexture(): Nullable<RenderTargetTexture>;
  62371. /**
  62372. * Sets the source texture to read the values from.
  62373. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  62374. * because in such textures '1' value must not be taken into account to compute the maximum
  62375. * as this value is used to clear the texture.
  62376. * Note that the computation is not activated by calling this function, you must call activate() for that!
  62377. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  62378. * @param depthRedux Indicates if the texture is a depth texture or not
  62379. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  62380. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62381. */
  62382. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62383. /**
  62384. * Defines the refresh rate of the computation.
  62385. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62386. */
  62387. get refreshRate(): number;
  62388. set refreshRate(value: number);
  62389. protected _activated: boolean;
  62390. /**
  62391. * Gets the activation status of the reducer
  62392. */
  62393. get activated(): boolean;
  62394. /**
  62395. * Activates the reduction computation.
  62396. * When activated, the observers registered in onAfterReductionPerformed are
  62397. * called after the compuation is performed
  62398. */
  62399. activate(): void;
  62400. /**
  62401. * Deactivates the reduction computation.
  62402. */
  62403. deactivate(): void;
  62404. /**
  62405. * Disposes the min/max reducer
  62406. * @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.
  62407. */
  62408. dispose(disposeAll?: boolean): void;
  62409. }
  62410. }
  62411. declare module "babylonjs/Misc/depthReducer" {
  62412. import { Nullable } from "babylonjs/types";
  62413. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62414. import { Camera } from "babylonjs/Cameras/camera";
  62415. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62416. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  62417. /**
  62418. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  62419. */
  62420. export class DepthReducer extends MinMaxReducer {
  62421. private _depthRenderer;
  62422. private _depthRendererId;
  62423. /**
  62424. * Gets the depth renderer used for the computation.
  62425. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  62426. */
  62427. get depthRenderer(): Nullable<DepthRenderer>;
  62428. /**
  62429. * Creates a depth reducer
  62430. * @param camera The camera used to render the depth texture
  62431. */
  62432. constructor(camera: Camera);
  62433. /**
  62434. * Sets the depth renderer to use to generate the depth map
  62435. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  62436. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  62437. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62438. */
  62439. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  62440. /** @hidden */
  62441. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62442. /**
  62443. * Activates the reduction computation.
  62444. * When activated, the observers registered in onAfterReductionPerformed are
  62445. * called after the compuation is performed
  62446. */
  62447. activate(): void;
  62448. /**
  62449. * Deactivates the reduction computation.
  62450. */
  62451. deactivate(): void;
  62452. /**
  62453. * Disposes the depth reducer
  62454. * @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.
  62455. */
  62456. dispose(disposeAll?: boolean): void;
  62457. }
  62458. }
  62459. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  62460. import { Nullable } from "babylonjs/types";
  62461. import { Scene } from "babylonjs/scene";
  62462. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62463. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62464. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62465. import { Effect } from "babylonjs/Materials/effect";
  62466. import "babylonjs/Shaders/shadowMap.fragment";
  62467. import "babylonjs/Shaders/shadowMap.vertex";
  62468. import "babylonjs/Shaders/depthBoxBlur.fragment";
  62469. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  62470. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62471. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62472. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62473. /**
  62474. * A CSM implementation allowing casting shadows on large scenes.
  62475. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62476. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  62477. */
  62478. export class CascadedShadowGenerator extends ShadowGenerator {
  62479. private static readonly frustumCornersNDCSpace;
  62480. /**
  62481. * Name of the CSM class
  62482. */
  62483. static CLASSNAME: string;
  62484. /**
  62485. * Defines the default number of cascades used by the CSM.
  62486. */
  62487. static readonly DEFAULT_CASCADES_COUNT: number;
  62488. /**
  62489. * Defines the minimum number of cascades used by the CSM.
  62490. */
  62491. static readonly MIN_CASCADES_COUNT: number;
  62492. /**
  62493. * Defines the maximum number of cascades used by the CSM.
  62494. */
  62495. static readonly MAX_CASCADES_COUNT: number;
  62496. protected _validateFilter(filter: number): number;
  62497. /**
  62498. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  62499. */
  62500. penumbraDarkness: number;
  62501. private _numCascades;
  62502. /**
  62503. * Gets or set the number of cascades used by the CSM.
  62504. */
  62505. get numCascades(): number;
  62506. set numCascades(value: number);
  62507. /**
  62508. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  62509. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  62510. */
  62511. stabilizeCascades: boolean;
  62512. private _freezeShadowCastersBoundingInfo;
  62513. private _freezeShadowCastersBoundingInfoObservable;
  62514. /**
  62515. * Enables or disables the shadow casters bounding info computation.
  62516. * If your shadow casters don't move, you can disable this feature.
  62517. * If it is enabled, the bounding box computation is done every frame.
  62518. */
  62519. get freezeShadowCastersBoundingInfo(): boolean;
  62520. set freezeShadowCastersBoundingInfo(freeze: boolean);
  62521. private _scbiMin;
  62522. private _scbiMax;
  62523. protected _computeShadowCastersBoundingInfo(): void;
  62524. protected _shadowCastersBoundingInfo: BoundingInfo;
  62525. /**
  62526. * Gets or sets the shadow casters bounding info.
  62527. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  62528. * so that the system won't overwrite the bounds you provide
  62529. */
  62530. get shadowCastersBoundingInfo(): BoundingInfo;
  62531. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  62532. protected _breaksAreDirty: boolean;
  62533. protected _minDistance: number;
  62534. protected _maxDistance: number;
  62535. /**
  62536. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  62537. *
  62538. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  62539. * If you don't know these values, simply leave them to their defaults and don't call this function.
  62540. * @param min minimal distance for the breaks (default to 0.)
  62541. * @param max maximal distance for the breaks (default to 1.)
  62542. */
  62543. setMinMaxDistance(min: number, max: number): void;
  62544. /** Gets the minimal distance used in the cascade break computation */
  62545. get minDistance(): number;
  62546. /** Gets the maximal distance used in the cascade break computation */
  62547. get maxDistance(): number;
  62548. /**
  62549. * Gets the class name of that object
  62550. * @returns "CascadedShadowGenerator"
  62551. */
  62552. getClassName(): string;
  62553. private _cascadeMinExtents;
  62554. private _cascadeMaxExtents;
  62555. /**
  62556. * Gets a cascade minimum extents
  62557. * @param cascadeIndex index of the cascade
  62558. * @returns the minimum cascade extents
  62559. */
  62560. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  62561. /**
  62562. * Gets a cascade maximum extents
  62563. * @param cascadeIndex index of the cascade
  62564. * @returns the maximum cascade extents
  62565. */
  62566. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  62567. private _cascades;
  62568. private _currentLayer;
  62569. private _viewSpaceFrustumsZ;
  62570. private _viewMatrices;
  62571. private _projectionMatrices;
  62572. private _transformMatrices;
  62573. private _transformMatricesAsArray;
  62574. private _frustumLengths;
  62575. private _lightSizeUVCorrection;
  62576. private _depthCorrection;
  62577. private _frustumCornersWorldSpace;
  62578. private _frustumCenter;
  62579. private _shadowCameraPos;
  62580. private _shadowMaxZ;
  62581. /**
  62582. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  62583. * It defaults to camera.maxZ
  62584. */
  62585. get shadowMaxZ(): number;
  62586. /**
  62587. * Sets the shadow max z distance.
  62588. */
  62589. set shadowMaxZ(value: number);
  62590. protected _debug: boolean;
  62591. /**
  62592. * Gets or sets the debug flag.
  62593. * When enabled, the cascades are materialized by different colors on the screen.
  62594. */
  62595. get debug(): boolean;
  62596. set debug(dbg: boolean);
  62597. private _depthClamp;
  62598. /**
  62599. * Gets or sets the depth clamping value.
  62600. *
  62601. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  62602. * to account for the shadow casters far away.
  62603. *
  62604. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  62605. */
  62606. get depthClamp(): boolean;
  62607. set depthClamp(value: boolean);
  62608. private _cascadeBlendPercentage;
  62609. /**
  62610. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  62611. * It defaults to 0.1 (10% blending).
  62612. */
  62613. get cascadeBlendPercentage(): number;
  62614. set cascadeBlendPercentage(value: number);
  62615. private _lambda;
  62616. /**
  62617. * Gets or set the lambda parameter.
  62618. * This parameter is used to split the camera frustum and create the cascades.
  62619. * 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.
  62620. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  62621. */
  62622. get lambda(): number;
  62623. set lambda(value: number);
  62624. /**
  62625. * Gets the view matrix corresponding to a given cascade
  62626. * @param cascadeNum cascade to retrieve the view matrix from
  62627. * @returns the cascade view matrix
  62628. */
  62629. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  62630. /**
  62631. * Gets the projection matrix corresponding to a given cascade
  62632. * @param cascadeNum cascade to retrieve the projection matrix from
  62633. * @returns the cascade projection matrix
  62634. */
  62635. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  62636. /**
  62637. * Gets the transformation matrix corresponding to a given cascade
  62638. * @param cascadeNum cascade to retrieve the transformation matrix from
  62639. * @returns the cascade transformation matrix
  62640. */
  62641. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  62642. private _depthRenderer;
  62643. /**
  62644. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  62645. *
  62646. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  62647. *
  62648. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  62649. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  62650. * @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
  62651. */
  62652. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  62653. private _depthReducer;
  62654. private _autoCalcDepthBounds;
  62655. /**
  62656. * Gets or sets the autoCalcDepthBounds property.
  62657. *
  62658. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  62659. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  62660. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  62661. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  62662. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  62663. */
  62664. get autoCalcDepthBounds(): boolean;
  62665. set autoCalcDepthBounds(value: boolean);
  62666. /**
  62667. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  62668. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62669. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  62670. * for setting the refresh rate on the renderer yourself!
  62671. */
  62672. get autoCalcDepthBoundsRefreshRate(): number;
  62673. set autoCalcDepthBoundsRefreshRate(value: number);
  62674. /**
  62675. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  62676. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  62677. * you change the camera near/far planes!
  62678. */
  62679. splitFrustum(): void;
  62680. private _splitFrustum;
  62681. private _computeMatrices;
  62682. private _computeFrustumInWorldSpace;
  62683. private _computeCascadeFrustum;
  62684. /**
  62685. * Support test.
  62686. */
  62687. static get IsSupported(): boolean;
  62688. /** @hidden */
  62689. static _SceneComponentInitialization: (scene: Scene) => void;
  62690. /**
  62691. * Creates a Cascaded Shadow Generator object.
  62692. * A ShadowGenerator is the required tool to use the shadows.
  62693. * Each directional light casting shadows needs to use its own ShadowGenerator.
  62694. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62695. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  62696. * @param light The directional light object generating the shadows.
  62697. * @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.
  62698. */
  62699. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  62700. protected _initializeGenerator(): void;
  62701. protected _createTargetRenderTexture(): void;
  62702. protected _initializeShadowMap(): void;
  62703. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  62704. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  62705. /**
  62706. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  62707. * @param defines Defines of the material we want to update
  62708. * @param lightIndex Index of the light in the enabled light list of the material
  62709. */
  62710. prepareDefines(defines: any, lightIndex: number): void;
  62711. /**
  62712. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  62713. * defined in the generator but impacting the effect).
  62714. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  62715. * @param effect The effect we are binfing the information for
  62716. */
  62717. bindShadowLight(lightIndex: string, effect: Effect): void;
  62718. /**
  62719. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  62720. * (eq to view projection * shadow projection matrices)
  62721. * @returns The transform matrix used to create the shadow map
  62722. */
  62723. getTransformMatrix(): Matrix;
  62724. /**
  62725. * Disposes the ShadowGenerator.
  62726. * Returns nothing.
  62727. */
  62728. dispose(): void;
  62729. /**
  62730. * Serializes the shadow generator setup to a json object.
  62731. * @returns The serialized JSON object
  62732. */
  62733. serialize(): any;
  62734. /**
  62735. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  62736. * @param parsedShadowGenerator The JSON object to parse
  62737. * @param scene The scene to create the shadow map for
  62738. * @returns The parsed shadow generator
  62739. */
  62740. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  62741. }
  62742. }
  62743. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  62744. import { Scene } from "babylonjs/scene";
  62745. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62746. import { AbstractScene } from "babylonjs/abstractScene";
  62747. /**
  62748. * Defines the shadow generator component responsible to manage any shadow generators
  62749. * in a given scene.
  62750. */
  62751. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  62752. /**
  62753. * The component name helpfull to identify the component in the list of scene components.
  62754. */
  62755. readonly name: string;
  62756. /**
  62757. * The scene the component belongs to.
  62758. */
  62759. scene: Scene;
  62760. /**
  62761. * Creates a new instance of the component for the given scene
  62762. * @param scene Defines the scene to register the component in
  62763. */
  62764. constructor(scene: Scene);
  62765. /**
  62766. * Registers the component in a given scene
  62767. */
  62768. register(): void;
  62769. /**
  62770. * Rebuilds the elements related to this component in case of
  62771. * context lost for instance.
  62772. */
  62773. rebuild(): void;
  62774. /**
  62775. * Serializes the component data to the specified json object
  62776. * @param serializationObject The object to serialize to
  62777. */
  62778. serialize(serializationObject: any): void;
  62779. /**
  62780. * Adds all the elements from the container to the scene
  62781. * @param container the container holding the elements
  62782. */
  62783. addFromContainer(container: AbstractScene): void;
  62784. /**
  62785. * Removes all the elements in the container from the scene
  62786. * @param container contains the elements to remove
  62787. * @param dispose if the removed element should be disposed (default: false)
  62788. */
  62789. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62790. /**
  62791. * Rebuilds the elements related to this component in case of
  62792. * context lost for instance.
  62793. */
  62794. dispose(): void;
  62795. private _gatherRenderTargets;
  62796. }
  62797. }
  62798. declare module "babylonjs/Lights/Shadows/index" {
  62799. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  62800. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  62801. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  62802. }
  62803. declare module "babylonjs/Lights/pointLight" {
  62804. import { Scene } from "babylonjs/scene";
  62805. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62807. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  62808. import { Effect } from "babylonjs/Materials/effect";
  62809. /**
  62810. * A point light is a light defined by an unique point in world space.
  62811. * The light is emitted in every direction from this point.
  62812. * A good example of a point light is a standard light bulb.
  62813. * Documentation: https://doc.babylonjs.com/babylon101/lights
  62814. */
  62815. export class PointLight extends ShadowLight {
  62816. private _shadowAngle;
  62817. /**
  62818. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62819. * This specifies what angle the shadow will use to be created.
  62820. *
  62821. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62822. */
  62823. get shadowAngle(): number;
  62824. /**
  62825. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62826. * This specifies what angle the shadow will use to be created.
  62827. *
  62828. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62829. */
  62830. set shadowAngle(value: number);
  62831. /**
  62832. * Gets the direction if it has been set.
  62833. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62834. */
  62835. get direction(): Vector3;
  62836. /**
  62837. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62838. */
  62839. set direction(value: Vector3);
  62840. /**
  62841. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  62842. * A PointLight emits the light in every direction.
  62843. * It can cast shadows.
  62844. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  62845. * ```javascript
  62846. * var pointLight = new PointLight("pl", camera.position, scene);
  62847. * ```
  62848. * Documentation : https://doc.babylonjs.com/babylon101/lights
  62849. * @param name The light friendly name
  62850. * @param position The position of the point light in the scene
  62851. * @param scene The scene the lights belongs to
  62852. */
  62853. constructor(name: string, position: Vector3, scene: Scene);
  62854. /**
  62855. * Returns the string "PointLight"
  62856. * @returns the class name
  62857. */
  62858. getClassName(): string;
  62859. /**
  62860. * Returns the integer 0.
  62861. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  62862. */
  62863. getTypeID(): number;
  62864. /**
  62865. * Specifies wether or not the shadowmap should be a cube texture.
  62866. * @returns true if the shadowmap needs to be a cube texture.
  62867. */
  62868. needCube(): boolean;
  62869. /**
  62870. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  62871. * @param faceIndex The index of the face we are computed the direction to generate shadow
  62872. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  62873. */
  62874. getShadowDirection(faceIndex?: number): Vector3;
  62875. /**
  62876. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  62877. * - fov = PI / 2
  62878. * - aspect ratio : 1.0
  62879. * - z-near and far equal to the active camera minZ and maxZ.
  62880. * Returns the PointLight.
  62881. */
  62882. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  62883. protected _buildUniformLayout(): void;
  62884. /**
  62885. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  62886. * @param effect The effect to update
  62887. * @param lightIndex The index of the light in the effect to update
  62888. * @returns The point light
  62889. */
  62890. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  62891. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  62892. /**
  62893. * Prepares the list of defines specific to the light type.
  62894. * @param defines the list of defines
  62895. * @param lightIndex defines the index of the light for the effect
  62896. */
  62897. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  62898. }
  62899. }
  62900. declare module "babylonjs/Lights/index" {
  62901. export * from "babylonjs/Lights/light";
  62902. export * from "babylonjs/Lights/shadowLight";
  62903. export * from "babylonjs/Lights/Shadows/index";
  62904. export * from "babylonjs/Lights/directionalLight";
  62905. export * from "babylonjs/Lights/hemisphericLight";
  62906. export * from "babylonjs/Lights/pointLight";
  62907. export * from "babylonjs/Lights/spotLight";
  62908. }
  62909. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  62910. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  62911. /**
  62912. * Header information of HDR texture files.
  62913. */
  62914. export interface HDRInfo {
  62915. /**
  62916. * The height of the texture in pixels.
  62917. */
  62918. height: number;
  62919. /**
  62920. * The width of the texture in pixels.
  62921. */
  62922. width: number;
  62923. /**
  62924. * The index of the beginning of the data in the binary file.
  62925. */
  62926. dataPosition: number;
  62927. }
  62928. /**
  62929. * This groups tools to convert HDR texture to native colors array.
  62930. */
  62931. export class HDRTools {
  62932. private static Ldexp;
  62933. private static Rgbe2float;
  62934. private static readStringLine;
  62935. /**
  62936. * Reads header information from an RGBE texture stored in a native array.
  62937. * More information on this format are available here:
  62938. * https://en.wikipedia.org/wiki/RGBE_image_format
  62939. *
  62940. * @param uint8array The binary file stored in native array.
  62941. * @return The header information.
  62942. */
  62943. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  62944. /**
  62945. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  62946. * This RGBE texture needs to store the information as a panorama.
  62947. *
  62948. * More information on this format are available here:
  62949. * https://en.wikipedia.org/wiki/RGBE_image_format
  62950. *
  62951. * @param buffer The binary file stored in an array buffer.
  62952. * @param size The expected size of the extracted cubemap.
  62953. * @return The Cube Map information.
  62954. */
  62955. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  62956. /**
  62957. * Returns the pixels data extracted from an RGBE texture.
  62958. * This pixels will be stored left to right up to down in the R G B order in one array.
  62959. *
  62960. * More information on this format are available here:
  62961. * https://en.wikipedia.org/wiki/RGBE_image_format
  62962. *
  62963. * @param uint8array The binary file stored in an array buffer.
  62964. * @param hdrInfo The header information of the file.
  62965. * @return The pixels data in RGB right to left up to down order.
  62966. */
  62967. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  62968. private static RGBE_ReadPixels_RLE;
  62969. private static RGBE_ReadPixels_NOT_RLE;
  62970. }
  62971. }
  62972. declare module "babylonjs/Materials/effectRenderer" {
  62973. import { Nullable } from "babylonjs/types";
  62974. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62975. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62976. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62977. import { Viewport } from "babylonjs/Maths/math.viewport";
  62978. import { Observable } from "babylonjs/Misc/observable";
  62979. import { Effect } from "babylonjs/Materials/effect";
  62980. import "babylonjs/Shaders/postprocess.vertex";
  62981. /**
  62982. * Effect Render Options
  62983. */
  62984. export interface IEffectRendererOptions {
  62985. /**
  62986. * Defines the vertices positions.
  62987. */
  62988. positions?: number[];
  62989. /**
  62990. * Defines the indices.
  62991. */
  62992. indices?: number[];
  62993. }
  62994. /**
  62995. * Helper class to render one or more effects.
  62996. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  62997. */
  62998. export class EffectRenderer {
  62999. private engine;
  63000. private static _DefaultOptions;
  63001. private _vertexBuffers;
  63002. private _indexBuffer;
  63003. private _fullscreenViewport;
  63004. /**
  63005. * Creates an effect renderer
  63006. * @param engine the engine to use for rendering
  63007. * @param options defines the options of the effect renderer
  63008. */
  63009. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63010. /**
  63011. * Sets the current viewport in normalized coordinates 0-1
  63012. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63013. */
  63014. setViewport(viewport?: Viewport): void;
  63015. /**
  63016. * Binds the embedded attributes buffer to the effect.
  63017. * @param effect Defines the effect to bind the attributes for
  63018. */
  63019. bindBuffers(effect: Effect): void;
  63020. /**
  63021. * Sets the current effect wrapper to use during draw.
  63022. * The effect needs to be ready before calling this api.
  63023. * This also sets the default full screen position attribute.
  63024. * @param effectWrapper Defines the effect to draw with
  63025. */
  63026. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63027. /**
  63028. * Restores engine states
  63029. */
  63030. restoreStates(): void;
  63031. /**
  63032. * Draws a full screen quad.
  63033. */
  63034. draw(): void;
  63035. private isRenderTargetTexture;
  63036. /**
  63037. * renders one or more effects to a specified texture
  63038. * @param effectWrapper the effect to renderer
  63039. * @param outputTexture texture to draw to, if null it will render to the screen.
  63040. */
  63041. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  63042. /**
  63043. * Disposes of the effect renderer
  63044. */
  63045. dispose(): void;
  63046. }
  63047. /**
  63048. * Options to create an EffectWrapper
  63049. */
  63050. interface EffectWrapperCreationOptions {
  63051. /**
  63052. * Engine to use to create the effect
  63053. */
  63054. engine: ThinEngine;
  63055. /**
  63056. * Fragment shader for the effect
  63057. */
  63058. fragmentShader: string;
  63059. /**
  63060. * Use the shader store instead of direct source code
  63061. */
  63062. useShaderStore?: boolean;
  63063. /**
  63064. * Vertex shader for the effect
  63065. */
  63066. vertexShader?: string;
  63067. /**
  63068. * Attributes to use in the shader
  63069. */
  63070. attributeNames?: Array<string>;
  63071. /**
  63072. * Uniforms to use in the shader
  63073. */
  63074. uniformNames?: Array<string>;
  63075. /**
  63076. * Texture sampler names to use in the shader
  63077. */
  63078. samplerNames?: Array<string>;
  63079. /**
  63080. * Defines to use in the shader
  63081. */
  63082. defines?: Array<string>;
  63083. /**
  63084. * Callback when effect is compiled
  63085. */
  63086. onCompiled?: Nullable<(effect: Effect) => void>;
  63087. /**
  63088. * The friendly name of the effect displayed in Spector.
  63089. */
  63090. name?: string;
  63091. }
  63092. /**
  63093. * Wraps an effect to be used for rendering
  63094. */
  63095. export class EffectWrapper {
  63096. /**
  63097. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63098. */
  63099. onApplyObservable: Observable<{}>;
  63100. /**
  63101. * The underlying effect
  63102. */
  63103. effect: Effect;
  63104. /**
  63105. * Creates an effect to be renderer
  63106. * @param creationOptions options to create the effect
  63107. */
  63108. constructor(creationOptions: EffectWrapperCreationOptions);
  63109. /**
  63110. * Disposes of the effect wrapper
  63111. */
  63112. dispose(): void;
  63113. }
  63114. }
  63115. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  63116. /** @hidden */
  63117. export var hdrFilteringVertexShader: {
  63118. name: string;
  63119. shader: string;
  63120. };
  63121. }
  63122. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  63123. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63124. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  63125. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  63126. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  63127. /** @hidden */
  63128. export var hdrFilteringPixelShader: {
  63129. name: string;
  63130. shader: string;
  63131. };
  63132. }
  63133. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  63134. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63135. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63136. import { Nullable } from "babylonjs/types";
  63137. import "babylonjs/Shaders/hdrFiltering.vertex";
  63138. import "babylonjs/Shaders/hdrFiltering.fragment";
  63139. /**
  63140. * Options for texture filtering
  63141. */
  63142. interface IHDRFilteringOptions {
  63143. /**
  63144. * Scales pixel intensity for the input HDR map.
  63145. */
  63146. hdrScale?: number;
  63147. /**
  63148. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  63149. */
  63150. quality?: number;
  63151. }
  63152. /**
  63153. * Filters HDR maps to get correct renderings of PBR reflections
  63154. */
  63155. export class HDRFiltering {
  63156. private _engine;
  63157. private _effectRenderer;
  63158. private _effectWrapper;
  63159. private _lodGenerationOffset;
  63160. private _lodGenerationScale;
  63161. /**
  63162. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  63163. * you care about baking speed.
  63164. */
  63165. quality: number;
  63166. /**
  63167. * Scales pixel intensity for the input HDR map.
  63168. */
  63169. hdrScale: number;
  63170. /**
  63171. * Instantiates HDR filter for reflection maps
  63172. *
  63173. * @param engine Thin engine
  63174. * @param options Options
  63175. */
  63176. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  63177. private _createRenderTarget;
  63178. private _prefilterInternal;
  63179. private _createEffect;
  63180. /**
  63181. * Get a value indicating if the filter is ready to be used
  63182. * @param texture Texture to filter
  63183. * @returns true if the filter is ready
  63184. */
  63185. isReady(texture: BaseTexture): boolean;
  63186. /**
  63187. * Prefilters a cube texture to have mipmap levels representing roughness values.
  63188. * Prefiltering will be invoked at the end of next rendering pass.
  63189. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  63190. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  63191. * @param texture Texture to filter
  63192. * @param onFinished Callback when filtering is done
  63193. * @return Promise called when prefiltering is done
  63194. */
  63195. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  63196. }
  63197. }
  63198. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  63199. import { Nullable } from "babylonjs/types";
  63200. import { Scene } from "babylonjs/scene";
  63201. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63202. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63203. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63204. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63205. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  63206. /**
  63207. * This represents a texture coming from an HDR input.
  63208. *
  63209. * The only supported format is currently panorama picture stored in RGBE format.
  63210. * Example of such files can be found on HDRLib: http://hdrlib.com/
  63211. */
  63212. export class HDRCubeTexture extends BaseTexture {
  63213. private static _facesMapping;
  63214. private _generateHarmonics;
  63215. private _noMipmap;
  63216. private _prefilterOnLoad;
  63217. private _textureMatrix;
  63218. private _size;
  63219. private _onLoad;
  63220. private _onError;
  63221. /**
  63222. * The texture URL.
  63223. */
  63224. url: string;
  63225. protected _isBlocking: boolean;
  63226. /**
  63227. * Sets wether or not the texture is blocking during loading.
  63228. */
  63229. set isBlocking(value: boolean);
  63230. /**
  63231. * Gets wether or not the texture is blocking during loading.
  63232. */
  63233. get isBlocking(): boolean;
  63234. protected _rotationY: number;
  63235. /**
  63236. * Sets texture matrix rotation angle around Y axis in radians.
  63237. */
  63238. set rotationY(value: number);
  63239. /**
  63240. * Gets texture matrix rotation angle around Y axis radians.
  63241. */
  63242. get rotationY(): number;
  63243. /**
  63244. * Gets or sets the center of the bounding box associated with the cube texture
  63245. * It must define where the camera used to render the texture was set
  63246. */
  63247. boundingBoxPosition: Vector3;
  63248. private _boundingBoxSize;
  63249. /**
  63250. * Gets or sets the size of the bounding box associated with the cube texture
  63251. * When defined, the cubemap will switch to local mode
  63252. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  63253. * @example https://www.babylonjs-playground.com/#RNASML
  63254. */
  63255. set boundingBoxSize(value: Vector3);
  63256. get boundingBoxSize(): Vector3;
  63257. /**
  63258. * Instantiates an HDRTexture from the following parameters.
  63259. *
  63260. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  63261. * @param sceneOrEngine The scene or engine the texture will be used in
  63262. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63263. * @param noMipmap Forces to not generate the mipmap if true
  63264. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  63265. * @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)
  63266. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  63267. */
  63268. 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>);
  63269. /**
  63270. * Get the current class name of the texture useful for serialization or dynamic coding.
  63271. * @returns "HDRCubeTexture"
  63272. */
  63273. getClassName(): string;
  63274. /**
  63275. * Occurs when the file is raw .hdr file.
  63276. */
  63277. private loadTexture;
  63278. clone(): HDRCubeTexture;
  63279. delayLoad(): void;
  63280. /**
  63281. * Get the texture reflection matrix used to rotate/transform the reflection.
  63282. * @returns the reflection matrix
  63283. */
  63284. getReflectionTextureMatrix(): Matrix;
  63285. /**
  63286. * Set the texture reflection matrix used to rotate/transform the reflection.
  63287. * @param value Define the reflection matrix to set
  63288. */
  63289. setReflectionTextureMatrix(value: Matrix): void;
  63290. /**
  63291. * Parses a JSON representation of an HDR Texture in order to create the texture
  63292. * @param parsedTexture Define the JSON representation
  63293. * @param scene Define the scene the texture should be created in
  63294. * @param rootUrl Define the root url in case we need to load relative dependencies
  63295. * @returns the newly created texture after parsing
  63296. */
  63297. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  63298. serialize(): any;
  63299. }
  63300. }
  63301. declare module "babylonjs/Physics/physicsEngine" {
  63302. import { Nullable } from "babylonjs/types";
  63303. import { Vector3 } from "babylonjs/Maths/math.vector";
  63304. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63305. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  63306. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  63307. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63308. /**
  63309. * Class used to control physics engine
  63310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63311. */
  63312. export class PhysicsEngine implements IPhysicsEngine {
  63313. private _physicsPlugin;
  63314. /**
  63315. * Global value used to control the smallest number supported by the simulation
  63316. */
  63317. static Epsilon: number;
  63318. private _impostors;
  63319. private _joints;
  63320. private _subTimeStep;
  63321. /**
  63322. * Gets the gravity vector used by the simulation
  63323. */
  63324. gravity: Vector3;
  63325. /**
  63326. * Factory used to create the default physics plugin.
  63327. * @returns The default physics plugin
  63328. */
  63329. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  63330. /**
  63331. * Creates a new Physics Engine
  63332. * @param gravity defines the gravity vector used by the simulation
  63333. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  63334. */
  63335. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  63336. /**
  63337. * Sets the gravity vector used by the simulation
  63338. * @param gravity defines the gravity vector to use
  63339. */
  63340. setGravity(gravity: Vector3): void;
  63341. /**
  63342. * Set the time step of the physics engine.
  63343. * Default is 1/60.
  63344. * To slow it down, enter 1/600 for example.
  63345. * To speed it up, 1/30
  63346. * @param newTimeStep defines the new timestep to apply to this world.
  63347. */
  63348. setTimeStep(newTimeStep?: number): void;
  63349. /**
  63350. * Get the time step of the physics engine.
  63351. * @returns the current time step
  63352. */
  63353. getTimeStep(): number;
  63354. /**
  63355. * Set the sub time step of the physics engine.
  63356. * Default is 0 meaning there is no sub steps
  63357. * To increase physics resolution precision, set a small value (like 1 ms)
  63358. * @param subTimeStep defines the new sub timestep used for physics resolution.
  63359. */
  63360. setSubTimeStep(subTimeStep?: number): void;
  63361. /**
  63362. * Get the sub time step of the physics engine.
  63363. * @returns the current sub time step
  63364. */
  63365. getSubTimeStep(): number;
  63366. /**
  63367. * Release all resources
  63368. */
  63369. dispose(): void;
  63370. /**
  63371. * Gets the name of the current physics plugin
  63372. * @returns the name of the plugin
  63373. */
  63374. getPhysicsPluginName(): string;
  63375. /**
  63376. * Adding a new impostor for the impostor tracking.
  63377. * This will be done by the impostor itself.
  63378. * @param impostor the impostor to add
  63379. */
  63380. addImpostor(impostor: PhysicsImpostor): void;
  63381. /**
  63382. * Remove an impostor from the engine.
  63383. * This impostor and its mesh will not longer be updated by the physics engine.
  63384. * @param impostor the impostor to remove
  63385. */
  63386. removeImpostor(impostor: PhysicsImpostor): void;
  63387. /**
  63388. * Add a joint to the physics engine
  63389. * @param mainImpostor defines the main impostor to which the joint is added.
  63390. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  63391. * @param joint defines the joint that will connect both impostors.
  63392. */
  63393. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63394. /**
  63395. * Removes a joint from the simulation
  63396. * @param mainImpostor defines the impostor used with the joint
  63397. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  63398. * @param joint defines the joint to remove
  63399. */
  63400. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63401. /**
  63402. * Called by the scene. No need to call it.
  63403. * @param delta defines the timespam between frames
  63404. */
  63405. _step(delta: number): void;
  63406. /**
  63407. * Gets the current plugin used to run the simulation
  63408. * @returns current plugin
  63409. */
  63410. getPhysicsPlugin(): IPhysicsEnginePlugin;
  63411. /**
  63412. * Gets the list of physic impostors
  63413. * @returns an array of PhysicsImpostor
  63414. */
  63415. getImpostors(): Array<PhysicsImpostor>;
  63416. /**
  63417. * Gets the impostor for a physics enabled object
  63418. * @param object defines the object impersonated by the impostor
  63419. * @returns the PhysicsImpostor or null if not found
  63420. */
  63421. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  63422. /**
  63423. * Gets the impostor for a physics body object
  63424. * @param body defines physics body used by the impostor
  63425. * @returns the PhysicsImpostor or null if not found
  63426. */
  63427. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  63428. /**
  63429. * Does a raycast in the physics world
  63430. * @param from when should the ray start?
  63431. * @param to when should the ray end?
  63432. * @returns PhysicsRaycastResult
  63433. */
  63434. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63435. }
  63436. }
  63437. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  63438. import { Nullable } from "babylonjs/types";
  63439. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63440. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63441. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63442. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63443. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63444. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63445. /** @hidden */
  63446. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  63447. private _useDeltaForWorldStep;
  63448. world: any;
  63449. name: string;
  63450. private _physicsMaterials;
  63451. private _fixedTimeStep;
  63452. private _cannonRaycastResult;
  63453. private _raycastResult;
  63454. private _physicsBodysToRemoveAfterStep;
  63455. private _firstFrame;
  63456. BJSCANNON: any;
  63457. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  63458. setGravity(gravity: Vector3): void;
  63459. setTimeStep(timeStep: number): void;
  63460. getTimeStep(): number;
  63461. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63462. private _removeMarkedPhysicsBodiesFromWorld;
  63463. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63464. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63465. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63466. private _processChildMeshes;
  63467. removePhysicsBody(impostor: PhysicsImpostor): void;
  63468. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63469. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63470. private _addMaterial;
  63471. private _checkWithEpsilon;
  63472. private _createShape;
  63473. private _createHeightmap;
  63474. private _minus90X;
  63475. private _plus90X;
  63476. private _tmpPosition;
  63477. private _tmpDeltaPosition;
  63478. private _tmpUnityRotation;
  63479. private _updatePhysicsBodyTransformation;
  63480. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63481. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63482. isSupported(): boolean;
  63483. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63484. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63485. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63486. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63487. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63488. getBodyMass(impostor: PhysicsImpostor): number;
  63489. getBodyFriction(impostor: PhysicsImpostor): number;
  63490. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63491. getBodyRestitution(impostor: PhysicsImpostor): number;
  63492. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63493. sleepBody(impostor: PhysicsImpostor): void;
  63494. wakeUpBody(impostor: PhysicsImpostor): void;
  63495. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  63496. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63497. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63498. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63499. getRadius(impostor: PhysicsImpostor): number;
  63500. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63501. dispose(): void;
  63502. private _extendNamespace;
  63503. /**
  63504. * Does a raycast in the physics world
  63505. * @param from when should the ray start?
  63506. * @param to when should the ray end?
  63507. * @returns PhysicsRaycastResult
  63508. */
  63509. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63510. }
  63511. }
  63512. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  63513. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63514. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63515. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63517. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63518. import { Nullable } from "babylonjs/types";
  63519. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63520. /** @hidden */
  63521. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  63522. private _useDeltaForWorldStep;
  63523. world: any;
  63524. name: string;
  63525. BJSOIMO: any;
  63526. private _raycastResult;
  63527. private _fixedTimeStep;
  63528. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  63529. setGravity(gravity: Vector3): void;
  63530. setTimeStep(timeStep: number): void;
  63531. getTimeStep(): number;
  63532. private _tmpImpostorsArray;
  63533. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63534. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63535. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63536. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63537. private _tmpPositionVector;
  63538. removePhysicsBody(impostor: PhysicsImpostor): void;
  63539. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63540. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63541. isSupported(): boolean;
  63542. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63543. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63544. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63545. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63546. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63547. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63548. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63549. getBodyMass(impostor: PhysicsImpostor): number;
  63550. getBodyFriction(impostor: PhysicsImpostor): number;
  63551. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63552. getBodyRestitution(impostor: PhysicsImpostor): number;
  63553. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63554. sleepBody(impostor: PhysicsImpostor): void;
  63555. wakeUpBody(impostor: PhysicsImpostor): void;
  63556. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63557. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  63558. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  63559. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63560. getRadius(impostor: PhysicsImpostor): number;
  63561. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63562. dispose(): void;
  63563. /**
  63564. * Does a raycast in the physics world
  63565. * @param from when should the ray start?
  63566. * @param to when should the ray end?
  63567. * @returns PhysicsRaycastResult
  63568. */
  63569. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63570. }
  63571. }
  63572. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  63573. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  63574. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63575. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63576. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63577. import { Nullable } from "babylonjs/types";
  63578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63579. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63580. /**
  63581. * AmmoJS Physics plugin
  63582. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63583. * @see https://github.com/kripken/ammo.js/
  63584. */
  63585. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  63586. private _useDeltaForWorldStep;
  63587. /**
  63588. * Reference to the Ammo library
  63589. */
  63590. bjsAMMO: any;
  63591. /**
  63592. * Created ammoJS world which physics bodies are added to
  63593. */
  63594. world: any;
  63595. /**
  63596. * Name of the plugin
  63597. */
  63598. name: string;
  63599. private _timeStep;
  63600. private _fixedTimeStep;
  63601. private _maxSteps;
  63602. private _tmpQuaternion;
  63603. private _tmpAmmoTransform;
  63604. private _tmpAmmoQuaternion;
  63605. private _tmpAmmoConcreteContactResultCallback;
  63606. private _collisionConfiguration;
  63607. private _dispatcher;
  63608. private _overlappingPairCache;
  63609. private _solver;
  63610. private _softBodySolver;
  63611. private _tmpAmmoVectorA;
  63612. private _tmpAmmoVectorB;
  63613. private _tmpAmmoVectorC;
  63614. private _tmpAmmoVectorD;
  63615. private _tmpContactCallbackResult;
  63616. private _tmpAmmoVectorRCA;
  63617. private _tmpAmmoVectorRCB;
  63618. private _raycastResult;
  63619. private static readonly DISABLE_COLLISION_FLAG;
  63620. private static readonly KINEMATIC_FLAG;
  63621. private static readonly DISABLE_DEACTIVATION_FLAG;
  63622. /**
  63623. * Initializes the ammoJS plugin
  63624. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  63625. * @param ammoInjection can be used to inject your own ammo reference
  63626. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  63627. */
  63628. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  63629. /**
  63630. * Sets the gravity of the physics world (m/(s^2))
  63631. * @param gravity Gravity to set
  63632. */
  63633. setGravity(gravity: Vector3): void;
  63634. /**
  63635. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  63636. * @param timeStep timestep to use in seconds
  63637. */
  63638. setTimeStep(timeStep: number): void;
  63639. /**
  63640. * 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)
  63641. * @param fixedTimeStep fixedTimeStep to use in seconds
  63642. */
  63643. setFixedTimeStep(fixedTimeStep: number): void;
  63644. /**
  63645. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  63646. * @param maxSteps the maximum number of steps by the physics engine per frame
  63647. */
  63648. setMaxSteps(maxSteps: number): void;
  63649. /**
  63650. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  63651. * @returns the current timestep in seconds
  63652. */
  63653. getTimeStep(): number;
  63654. /**
  63655. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  63656. */
  63657. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  63658. private _isImpostorInContact;
  63659. private _isImpostorPairInContact;
  63660. private _stepSimulation;
  63661. /**
  63662. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  63663. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  63664. * After the step the babylon meshes are set to the position of the physics imposters
  63665. * @param delta amount of time to step forward
  63666. * @param impostors array of imposters to update before/after the step
  63667. */
  63668. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63669. /**
  63670. * Update babylon mesh to match physics world object
  63671. * @param impostor imposter to match
  63672. */
  63673. private _afterSoftStep;
  63674. /**
  63675. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63676. * @param impostor imposter to match
  63677. */
  63678. private _ropeStep;
  63679. /**
  63680. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63681. * @param impostor imposter to match
  63682. */
  63683. private _softbodyOrClothStep;
  63684. private _tmpMatrix;
  63685. /**
  63686. * Applies an impulse on the imposter
  63687. * @param impostor imposter to apply impulse to
  63688. * @param force amount of force to be applied to the imposter
  63689. * @param contactPoint the location to apply the impulse on the imposter
  63690. */
  63691. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63692. /**
  63693. * Applies a force on the imposter
  63694. * @param impostor imposter to apply force
  63695. * @param force amount of force to be applied to the imposter
  63696. * @param contactPoint the location to apply the force on the imposter
  63697. */
  63698. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63699. /**
  63700. * Creates a physics body using the plugin
  63701. * @param impostor the imposter to create the physics body on
  63702. */
  63703. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63704. /**
  63705. * Removes the physics body from the imposter and disposes of the body's memory
  63706. * @param impostor imposter to remove the physics body from
  63707. */
  63708. removePhysicsBody(impostor: PhysicsImpostor): void;
  63709. /**
  63710. * Generates a joint
  63711. * @param impostorJoint the imposter joint to create the joint with
  63712. */
  63713. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63714. /**
  63715. * Removes a joint
  63716. * @param impostorJoint the imposter joint to remove the joint from
  63717. */
  63718. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63719. private _addMeshVerts;
  63720. /**
  63721. * Initialise the soft body vertices to match its object's (mesh) vertices
  63722. * Softbody vertices (nodes) are in world space and to match this
  63723. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  63724. * @param impostor to create the softbody for
  63725. */
  63726. private _softVertexData;
  63727. /**
  63728. * Create an impostor's soft body
  63729. * @param impostor to create the softbody for
  63730. */
  63731. private _createSoftbody;
  63732. /**
  63733. * Create cloth for an impostor
  63734. * @param impostor to create the softbody for
  63735. */
  63736. private _createCloth;
  63737. /**
  63738. * Create rope for an impostor
  63739. * @param impostor to create the softbody for
  63740. */
  63741. private _createRope;
  63742. /**
  63743. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  63744. * @param impostor to create the custom physics shape for
  63745. */
  63746. private _createCustom;
  63747. private _addHullVerts;
  63748. private _createShape;
  63749. /**
  63750. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  63751. * @param impostor imposter containing the physics body and babylon object
  63752. */
  63753. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63754. /**
  63755. * Sets the babylon object's position/rotation from the physics body's position/rotation
  63756. * @param impostor imposter containing the physics body and babylon object
  63757. * @param newPosition new position
  63758. * @param newRotation new rotation
  63759. */
  63760. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63761. /**
  63762. * If this plugin is supported
  63763. * @returns true if its supported
  63764. */
  63765. isSupported(): boolean;
  63766. /**
  63767. * Sets the linear velocity of the physics body
  63768. * @param impostor imposter to set the velocity on
  63769. * @param velocity velocity to set
  63770. */
  63771. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63772. /**
  63773. * Sets the angular velocity of the physics body
  63774. * @param impostor imposter to set the velocity on
  63775. * @param velocity velocity to set
  63776. */
  63777. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63778. /**
  63779. * gets the linear velocity
  63780. * @param impostor imposter to get linear velocity from
  63781. * @returns linear velocity
  63782. */
  63783. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63784. /**
  63785. * gets the angular velocity
  63786. * @param impostor imposter to get angular velocity from
  63787. * @returns angular velocity
  63788. */
  63789. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63790. /**
  63791. * Sets the mass of physics body
  63792. * @param impostor imposter to set the mass on
  63793. * @param mass mass to set
  63794. */
  63795. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63796. /**
  63797. * Gets the mass of the physics body
  63798. * @param impostor imposter to get the mass from
  63799. * @returns mass
  63800. */
  63801. getBodyMass(impostor: PhysicsImpostor): number;
  63802. /**
  63803. * Gets friction of the impostor
  63804. * @param impostor impostor to get friction from
  63805. * @returns friction value
  63806. */
  63807. getBodyFriction(impostor: PhysicsImpostor): number;
  63808. /**
  63809. * Sets friction of the impostor
  63810. * @param impostor impostor to set friction on
  63811. * @param friction friction value
  63812. */
  63813. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63814. /**
  63815. * Gets restitution of the impostor
  63816. * @param impostor impostor to get restitution from
  63817. * @returns restitution value
  63818. */
  63819. getBodyRestitution(impostor: PhysicsImpostor): number;
  63820. /**
  63821. * Sets resitution of the impostor
  63822. * @param impostor impostor to set resitution on
  63823. * @param restitution resitution value
  63824. */
  63825. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63826. /**
  63827. * Gets pressure inside the impostor
  63828. * @param impostor impostor to get pressure from
  63829. * @returns pressure value
  63830. */
  63831. getBodyPressure(impostor: PhysicsImpostor): number;
  63832. /**
  63833. * Sets pressure inside a soft body impostor
  63834. * Cloth and rope must remain 0 pressure
  63835. * @param impostor impostor to set pressure on
  63836. * @param pressure pressure value
  63837. */
  63838. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  63839. /**
  63840. * Gets stiffness of the impostor
  63841. * @param impostor impostor to get stiffness from
  63842. * @returns pressure value
  63843. */
  63844. getBodyStiffness(impostor: PhysicsImpostor): number;
  63845. /**
  63846. * Sets stiffness of the impostor
  63847. * @param impostor impostor to set stiffness on
  63848. * @param stiffness stiffness value from 0 to 1
  63849. */
  63850. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  63851. /**
  63852. * Gets velocityIterations of the impostor
  63853. * @param impostor impostor to get velocity iterations from
  63854. * @returns velocityIterations value
  63855. */
  63856. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  63857. /**
  63858. * Sets velocityIterations of the impostor
  63859. * @param impostor impostor to set velocity iterations on
  63860. * @param velocityIterations velocityIterations value
  63861. */
  63862. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  63863. /**
  63864. * Gets positionIterations of the impostor
  63865. * @param impostor impostor to get position iterations from
  63866. * @returns positionIterations value
  63867. */
  63868. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  63869. /**
  63870. * Sets positionIterations of the impostor
  63871. * @param impostor impostor to set position on
  63872. * @param positionIterations positionIterations value
  63873. */
  63874. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  63875. /**
  63876. * Append an anchor to a cloth object
  63877. * @param impostor is the cloth impostor to add anchor to
  63878. * @param otherImpostor is the rigid impostor to anchor to
  63879. * @param width ratio across width from 0 to 1
  63880. * @param height ratio up height from 0 to 1
  63881. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  63882. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  63883. */
  63884. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  63885. /**
  63886. * Append an hook to a rope object
  63887. * @param impostor is the rope impostor to add hook to
  63888. * @param otherImpostor is the rigid impostor to hook to
  63889. * @param length ratio along the rope from 0 to 1
  63890. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  63891. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  63892. */
  63893. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  63894. /**
  63895. * Sleeps the physics body and stops it from being active
  63896. * @param impostor impostor to sleep
  63897. */
  63898. sleepBody(impostor: PhysicsImpostor): void;
  63899. /**
  63900. * Activates the physics body
  63901. * @param impostor impostor to activate
  63902. */
  63903. wakeUpBody(impostor: PhysicsImpostor): void;
  63904. /**
  63905. * Updates the distance parameters of the joint
  63906. * @param joint joint to update
  63907. * @param maxDistance maximum distance of the joint
  63908. * @param minDistance minimum distance of the joint
  63909. */
  63910. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63911. /**
  63912. * Sets a motor on the joint
  63913. * @param joint joint to set motor on
  63914. * @param speed speed of the motor
  63915. * @param maxForce maximum force of the motor
  63916. * @param motorIndex index of the motor
  63917. */
  63918. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63919. /**
  63920. * Sets the motors limit
  63921. * @param joint joint to set limit on
  63922. * @param upperLimit upper limit
  63923. * @param lowerLimit lower limit
  63924. */
  63925. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63926. /**
  63927. * Syncs the position and rotation of a mesh with the impostor
  63928. * @param mesh mesh to sync
  63929. * @param impostor impostor to update the mesh with
  63930. */
  63931. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63932. /**
  63933. * Gets the radius of the impostor
  63934. * @param impostor impostor to get radius from
  63935. * @returns the radius
  63936. */
  63937. getRadius(impostor: PhysicsImpostor): number;
  63938. /**
  63939. * Gets the box size of the impostor
  63940. * @param impostor impostor to get box size from
  63941. * @param result the resulting box size
  63942. */
  63943. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63944. /**
  63945. * Disposes of the impostor
  63946. */
  63947. dispose(): void;
  63948. /**
  63949. * Does a raycast in the physics world
  63950. * @param from when should the ray start?
  63951. * @param to when should the ray end?
  63952. * @returns PhysicsRaycastResult
  63953. */
  63954. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63955. }
  63956. }
  63957. declare module "babylonjs/Probes/reflectionProbe" {
  63958. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63959. import { Vector3 } from "babylonjs/Maths/math.vector";
  63960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63961. import { Nullable } from "babylonjs/types";
  63962. import { Scene } from "babylonjs/scene";
  63963. module "babylonjs/abstractScene" {
  63964. interface AbstractScene {
  63965. /**
  63966. * The list of reflection probes added to the scene
  63967. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  63968. */
  63969. reflectionProbes: Array<ReflectionProbe>;
  63970. /**
  63971. * Removes the given reflection probe from this scene.
  63972. * @param toRemove The reflection probe to remove
  63973. * @returns The index of the removed reflection probe
  63974. */
  63975. removeReflectionProbe(toRemove: ReflectionProbe): number;
  63976. /**
  63977. * Adds the given reflection probe to this scene.
  63978. * @param newReflectionProbe The reflection probe to add
  63979. */
  63980. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  63981. }
  63982. }
  63983. /**
  63984. * Class used to generate realtime reflection / refraction cube textures
  63985. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  63986. */
  63987. export class ReflectionProbe {
  63988. /** defines the name of the probe */
  63989. name: string;
  63990. private _scene;
  63991. private _renderTargetTexture;
  63992. private _projectionMatrix;
  63993. private _viewMatrix;
  63994. private _target;
  63995. private _add;
  63996. private _attachedMesh;
  63997. private _invertYAxis;
  63998. /** Gets or sets probe position (center of the cube map) */
  63999. position: Vector3;
  64000. /**
  64001. * Creates a new reflection probe
  64002. * @param name defines the name of the probe
  64003. * @param size defines the texture resolution (for each face)
  64004. * @param scene defines the hosting scene
  64005. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  64006. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  64007. */
  64008. constructor(
  64009. /** defines the name of the probe */
  64010. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  64011. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  64012. get samples(): number;
  64013. set samples(value: number);
  64014. /** Gets or sets the refresh rate to use (on every frame by default) */
  64015. get refreshRate(): number;
  64016. set refreshRate(value: number);
  64017. /**
  64018. * Gets the hosting scene
  64019. * @returns a Scene
  64020. */
  64021. getScene(): Scene;
  64022. /** Gets the internal CubeTexture used to render to */
  64023. get cubeTexture(): RenderTargetTexture;
  64024. /** Gets the list of meshes to render */
  64025. get renderList(): Nullable<AbstractMesh[]>;
  64026. /**
  64027. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  64028. * @param mesh defines the mesh to attach to
  64029. */
  64030. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  64031. /**
  64032. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  64033. * @param renderingGroupId The rendering group id corresponding to its index
  64034. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  64035. */
  64036. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  64037. /**
  64038. * Clean all associated resources
  64039. */
  64040. dispose(): void;
  64041. /**
  64042. * Converts the reflection probe information to a readable string for debug purpose.
  64043. * @param fullDetails Supports for multiple levels of logging within scene loading
  64044. * @returns the human readable reflection probe info
  64045. */
  64046. toString(fullDetails?: boolean): string;
  64047. /**
  64048. * Get the class name of the relfection probe.
  64049. * @returns "ReflectionProbe"
  64050. */
  64051. getClassName(): string;
  64052. /**
  64053. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  64054. * @returns The JSON representation of the texture
  64055. */
  64056. serialize(): any;
  64057. /**
  64058. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  64059. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  64060. * @param scene Define the scene the parsed reflection probe should be instantiated in
  64061. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  64062. * @returns The parsed reflection probe if successful
  64063. */
  64064. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  64065. }
  64066. }
  64067. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  64068. /** @hidden */
  64069. export var _BabylonLoaderRegistered: boolean;
  64070. /**
  64071. * Helps setting up some configuration for the babylon file loader.
  64072. */
  64073. export class BabylonFileLoaderConfiguration {
  64074. /**
  64075. * The loader does not allow injecting custom physix engine into the plugins.
  64076. * Unfortunately in ES6, we need to manually inject them into the plugin.
  64077. * So you could set this variable to your engine import to make it work.
  64078. */
  64079. static LoaderInjectedPhysicsEngine: any;
  64080. }
  64081. }
  64082. declare module "babylonjs/Loading/Plugins/index" {
  64083. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  64084. }
  64085. declare module "babylonjs/Loading/index" {
  64086. export * from "babylonjs/Loading/loadingScreen";
  64087. export * from "babylonjs/Loading/Plugins/index";
  64088. export * from "babylonjs/Loading/sceneLoader";
  64089. export * from "babylonjs/Loading/sceneLoaderFlags";
  64090. }
  64091. declare module "babylonjs/Materials/Background/index" {
  64092. export * from "babylonjs/Materials/Background/backgroundMaterial";
  64093. }
  64094. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  64095. import { Scene } from "babylonjs/scene";
  64096. import { Color3 } from "babylonjs/Maths/math.color";
  64097. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64098. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64099. /**
  64100. * The Physically based simple base material of BJS.
  64101. *
  64102. * This enables better naming and convention enforcements on top of the pbrMaterial.
  64103. * It is used as the base class for both the specGloss and metalRough conventions.
  64104. */
  64105. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  64106. /**
  64107. * Number of Simultaneous lights allowed on the material.
  64108. */
  64109. maxSimultaneousLights: number;
  64110. /**
  64111. * If sets to true, disables all the lights affecting the material.
  64112. */
  64113. disableLighting: boolean;
  64114. /**
  64115. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  64116. */
  64117. environmentTexture: BaseTexture;
  64118. /**
  64119. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  64120. */
  64121. invertNormalMapX: boolean;
  64122. /**
  64123. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  64124. */
  64125. invertNormalMapY: boolean;
  64126. /**
  64127. * Normal map used in the model.
  64128. */
  64129. normalTexture: BaseTexture;
  64130. /**
  64131. * Emissivie color used to self-illuminate the model.
  64132. */
  64133. emissiveColor: Color3;
  64134. /**
  64135. * Emissivie texture used to self-illuminate the model.
  64136. */
  64137. emissiveTexture: BaseTexture;
  64138. /**
  64139. * Occlusion Channel Strenght.
  64140. */
  64141. occlusionStrength: number;
  64142. /**
  64143. * Occlusion Texture of the material (adding extra occlusion effects).
  64144. */
  64145. occlusionTexture: BaseTexture;
  64146. /**
  64147. * Defines the alpha limits in alpha test mode.
  64148. */
  64149. alphaCutOff: number;
  64150. /**
  64151. * Gets the current double sided mode.
  64152. */
  64153. get doubleSided(): boolean;
  64154. /**
  64155. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  64156. */
  64157. set doubleSided(value: boolean);
  64158. /**
  64159. * Stores the pre-calculated light information of a mesh in a texture.
  64160. */
  64161. lightmapTexture: BaseTexture;
  64162. /**
  64163. * If true, the light map contains occlusion information instead of lighting info.
  64164. */
  64165. useLightmapAsShadowmap: boolean;
  64166. /**
  64167. * Instantiates a new PBRMaterial instance.
  64168. *
  64169. * @param name The material name
  64170. * @param scene The scene the material will be use in.
  64171. */
  64172. constructor(name: string, scene: Scene);
  64173. getClassName(): string;
  64174. }
  64175. }
  64176. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  64177. import { Scene } from "babylonjs/scene";
  64178. import { Color3 } from "babylonjs/Maths/math.color";
  64179. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64180. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64181. /**
  64182. * The PBR material of BJS following the metal roughness convention.
  64183. *
  64184. * This fits to the PBR convention in the GLTF definition:
  64185. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  64186. */
  64187. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  64188. /**
  64189. * The base color has two different interpretations depending on the value of metalness.
  64190. * When the material is a metal, the base color is the specific measured reflectance value
  64191. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  64192. * of the material.
  64193. */
  64194. baseColor: Color3;
  64195. /**
  64196. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  64197. * well as opacity information in the alpha channel.
  64198. */
  64199. baseTexture: BaseTexture;
  64200. /**
  64201. * Specifies the metallic scalar value of the material.
  64202. * Can also be used to scale the metalness values of the metallic texture.
  64203. */
  64204. metallic: number;
  64205. /**
  64206. * Specifies the roughness scalar value of the material.
  64207. * Can also be used to scale the roughness values of the metallic texture.
  64208. */
  64209. roughness: number;
  64210. /**
  64211. * Texture containing both the metallic value in the B channel and the
  64212. * roughness value in the G channel to keep better precision.
  64213. */
  64214. metallicRoughnessTexture: BaseTexture;
  64215. /**
  64216. * Instantiates a new PBRMetalRoughnessMaterial instance.
  64217. *
  64218. * @param name The material name
  64219. * @param scene The scene the material will be use in.
  64220. */
  64221. constructor(name: string, scene: Scene);
  64222. /**
  64223. * Return the currrent class name of the material.
  64224. */
  64225. getClassName(): string;
  64226. /**
  64227. * Makes a duplicate of the current material.
  64228. * @param name - name to use for the new material.
  64229. */
  64230. clone(name: string): PBRMetallicRoughnessMaterial;
  64231. /**
  64232. * Serialize the material to a parsable JSON object.
  64233. */
  64234. serialize(): any;
  64235. /**
  64236. * Parses a JSON object correponding to the serialize function.
  64237. */
  64238. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  64239. }
  64240. }
  64241. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  64242. import { Scene } from "babylonjs/scene";
  64243. import { Color3 } from "babylonjs/Maths/math.color";
  64244. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64245. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64246. /**
  64247. * The PBR material of BJS following the specular glossiness convention.
  64248. *
  64249. * This fits to the PBR convention in the GLTF definition:
  64250. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  64251. */
  64252. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  64253. /**
  64254. * Specifies the diffuse color of the material.
  64255. */
  64256. diffuseColor: Color3;
  64257. /**
  64258. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  64259. * channel.
  64260. */
  64261. diffuseTexture: BaseTexture;
  64262. /**
  64263. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  64264. */
  64265. specularColor: Color3;
  64266. /**
  64267. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  64268. */
  64269. glossiness: number;
  64270. /**
  64271. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  64272. */
  64273. specularGlossinessTexture: BaseTexture;
  64274. /**
  64275. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  64276. *
  64277. * @param name The material name
  64278. * @param scene The scene the material will be use in.
  64279. */
  64280. constructor(name: string, scene: Scene);
  64281. /**
  64282. * Return the currrent class name of the material.
  64283. */
  64284. getClassName(): string;
  64285. /**
  64286. * Makes a duplicate of the current material.
  64287. * @param name - name to use for the new material.
  64288. */
  64289. clone(name: string): PBRSpecularGlossinessMaterial;
  64290. /**
  64291. * Serialize the material to a parsable JSON object.
  64292. */
  64293. serialize(): any;
  64294. /**
  64295. * Parses a JSON object correponding to the serialize function.
  64296. */
  64297. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  64298. }
  64299. }
  64300. declare module "babylonjs/Materials/PBR/index" {
  64301. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64302. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64303. export * from "babylonjs/Materials/PBR/pbrMaterial";
  64304. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  64305. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  64306. }
  64307. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  64308. import { Nullable } from "babylonjs/types";
  64309. import { Scene } from "babylonjs/scene";
  64310. import { Matrix } from "babylonjs/Maths/math.vector";
  64311. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64312. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64313. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64314. /**
  64315. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  64316. * It can help converting any input color in a desired output one. This can then be used to create effects
  64317. * from sepia, black and white to sixties or futuristic rendering...
  64318. *
  64319. * The only supported format is currently 3dl.
  64320. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  64321. */
  64322. export class ColorGradingTexture extends BaseTexture {
  64323. /**
  64324. * The texture URL.
  64325. */
  64326. url: string;
  64327. /**
  64328. * Empty line regex stored for GC.
  64329. */
  64330. private static _noneEmptyLineRegex;
  64331. private _textureMatrix;
  64332. private _onLoad;
  64333. /**
  64334. * Instantiates a ColorGradingTexture from the following parameters.
  64335. *
  64336. * @param url The location of the color gradind data (currently only supporting 3dl)
  64337. * @param sceneOrEngine The scene or engine the texture will be used in
  64338. * @param onLoad defines a callback triggered when the texture has been loaded
  64339. */
  64340. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  64341. /**
  64342. * Fires the onload event from the constructor if requested.
  64343. */
  64344. private _triggerOnLoad;
  64345. /**
  64346. * Returns the texture matrix used in most of the material.
  64347. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  64348. */
  64349. getTextureMatrix(): Matrix;
  64350. /**
  64351. * Occurs when the file being loaded is a .3dl LUT file.
  64352. */
  64353. private load3dlTexture;
  64354. /**
  64355. * Starts the loading process of the texture.
  64356. */
  64357. private loadTexture;
  64358. /**
  64359. * Clones the color gradind texture.
  64360. */
  64361. clone(): ColorGradingTexture;
  64362. /**
  64363. * Called during delayed load for textures.
  64364. */
  64365. delayLoad(): void;
  64366. /**
  64367. * Parses a color grading texture serialized by Babylon.
  64368. * @param parsedTexture The texture information being parsedTexture
  64369. * @param scene The scene to load the texture in
  64370. * @param rootUrl The root url of the data assets to load
  64371. * @return A color gradind texture
  64372. */
  64373. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  64374. /**
  64375. * Serializes the LUT texture to json format.
  64376. */
  64377. serialize(): any;
  64378. }
  64379. }
  64380. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  64381. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64382. import { Scene } from "babylonjs/scene";
  64383. import { Nullable } from "babylonjs/types";
  64384. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64385. /**
  64386. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  64387. */
  64388. export class EquiRectangularCubeTexture extends BaseTexture {
  64389. /** The six faces of the cube. */
  64390. private static _FacesMapping;
  64391. private _noMipmap;
  64392. private _onLoad;
  64393. private _onError;
  64394. /** The size of the cubemap. */
  64395. private _size;
  64396. /** The buffer of the image. */
  64397. private _buffer;
  64398. /** The width of the input image. */
  64399. private _width;
  64400. /** The height of the input image. */
  64401. private _height;
  64402. /** The URL to the image. */
  64403. url: string;
  64404. /**
  64405. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  64406. * @param url The location of the image
  64407. * @param scene The scene the texture will be used in
  64408. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64409. * @param noMipmap Forces to not generate the mipmap if true
  64410. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64411. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64412. * @param onLoad — defines a callback called when texture is loaded
  64413. * @param onError — defines a callback called if there is an error
  64414. */
  64415. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  64416. /**
  64417. * Load the image data, by putting the image on a canvas and extracting its buffer.
  64418. */
  64419. private loadImage;
  64420. /**
  64421. * Convert the image buffer into a cubemap and create a CubeTexture.
  64422. */
  64423. private loadTexture;
  64424. /**
  64425. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  64426. * @param buffer The ArrayBuffer that should be converted.
  64427. * @returns The buffer as Float32Array.
  64428. */
  64429. private getFloat32ArrayFromArrayBuffer;
  64430. /**
  64431. * Get the current class name of the texture useful for serialization or dynamic coding.
  64432. * @returns "EquiRectangularCubeTexture"
  64433. */
  64434. getClassName(): string;
  64435. /**
  64436. * Create a clone of the current EquiRectangularCubeTexture and return it.
  64437. * @returns A clone of the current EquiRectangularCubeTexture.
  64438. */
  64439. clone(): EquiRectangularCubeTexture;
  64440. }
  64441. }
  64442. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  64443. import { Nullable } from "babylonjs/types";
  64444. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64445. import { Matrix } from "babylonjs/Maths/math.vector";
  64446. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  64447. import "babylonjs/Engines/Extensions/engine.videoTexture";
  64448. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64449. import { Scene } from "babylonjs/scene";
  64450. /**
  64451. * Defines the options related to the creation of an HtmlElementTexture
  64452. */
  64453. export interface IHtmlElementTextureOptions {
  64454. /**
  64455. * Defines wether mip maps should be created or not.
  64456. */
  64457. generateMipMaps?: boolean;
  64458. /**
  64459. * Defines the sampling mode of the texture.
  64460. */
  64461. samplingMode?: number;
  64462. /**
  64463. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  64464. */
  64465. engine: Nullable<ThinEngine>;
  64466. /**
  64467. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  64468. */
  64469. scene: Nullable<Scene>;
  64470. }
  64471. /**
  64472. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  64473. * To be as efficient as possible depending on your constraints nothing aside the first upload
  64474. * is automatically managed.
  64475. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  64476. * in your application.
  64477. *
  64478. * As the update is not automatic, you need to call them manually.
  64479. */
  64480. export class HtmlElementTexture extends BaseTexture {
  64481. /**
  64482. * The texture URL.
  64483. */
  64484. element: HTMLVideoElement | HTMLCanvasElement;
  64485. private static readonly DefaultOptions;
  64486. private _textureMatrix;
  64487. private _isVideo;
  64488. private _generateMipMaps;
  64489. private _samplingMode;
  64490. /**
  64491. * Instantiates a HtmlElementTexture from the following parameters.
  64492. *
  64493. * @param name Defines the name of the texture
  64494. * @param element Defines the video or canvas the texture is filled with
  64495. * @param options Defines the other none mandatory texture creation options
  64496. */
  64497. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  64498. private _createInternalTexture;
  64499. /**
  64500. * Returns the texture matrix used in most of the material.
  64501. */
  64502. getTextureMatrix(): Matrix;
  64503. /**
  64504. * Updates the content of the texture.
  64505. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  64506. */
  64507. update(invertY?: Nullable<boolean>): void;
  64508. }
  64509. }
  64510. declare module "babylonjs/Misc/tga" {
  64511. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64512. /**
  64513. * Based on jsTGALoader - Javascript loader for TGA file
  64514. * By Vincent Thibault
  64515. * @see http://blog.robrowser.com/javascript-tga-loader.html
  64516. */
  64517. export class TGATools {
  64518. private static _TYPE_INDEXED;
  64519. private static _TYPE_RGB;
  64520. private static _TYPE_GREY;
  64521. private static _TYPE_RLE_INDEXED;
  64522. private static _TYPE_RLE_RGB;
  64523. private static _TYPE_RLE_GREY;
  64524. private static _ORIGIN_MASK;
  64525. private static _ORIGIN_SHIFT;
  64526. private static _ORIGIN_BL;
  64527. private static _ORIGIN_BR;
  64528. private static _ORIGIN_UL;
  64529. private static _ORIGIN_UR;
  64530. /**
  64531. * Gets the header of a TGA file
  64532. * @param data defines the TGA data
  64533. * @returns the header
  64534. */
  64535. static GetTGAHeader(data: Uint8Array): any;
  64536. /**
  64537. * Uploads TGA content to a Babylon Texture
  64538. * @hidden
  64539. */
  64540. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  64541. /** @hidden */
  64542. 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;
  64543. /** @hidden */
  64544. 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;
  64545. /** @hidden */
  64546. 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;
  64547. /** @hidden */
  64548. 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;
  64549. /** @hidden */
  64550. 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;
  64551. /** @hidden */
  64552. 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;
  64553. }
  64554. }
  64555. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  64556. import { Nullable } from "babylonjs/types";
  64557. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64558. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64559. /**
  64560. * Implementation of the TGA Texture Loader.
  64561. * @hidden
  64562. */
  64563. export class _TGATextureLoader implements IInternalTextureLoader {
  64564. /**
  64565. * Defines wether the loader supports cascade loading the different faces.
  64566. */
  64567. readonly supportCascades: boolean;
  64568. /**
  64569. * This returns if the loader support the current file information.
  64570. * @param extension defines the file extension of the file being loaded
  64571. * @returns true if the loader can load the specified file
  64572. */
  64573. canLoad(extension: string): boolean;
  64574. /**
  64575. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64576. * @param data contains the texture data
  64577. * @param texture defines the BabylonJS internal texture
  64578. * @param createPolynomials will be true if polynomials have been requested
  64579. * @param onLoad defines the callback to trigger once the texture is ready
  64580. * @param onError defines the callback to trigger in case of error
  64581. */
  64582. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64583. /**
  64584. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64585. * @param data contains the texture data
  64586. * @param texture defines the BabylonJS internal texture
  64587. * @param callback defines the method to call once ready to upload
  64588. */
  64589. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64590. }
  64591. }
  64592. declare module "babylonjs/Misc/basis" {
  64593. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64594. /**
  64595. * Info about the .basis files
  64596. */
  64597. class BasisFileInfo {
  64598. /**
  64599. * If the file has alpha
  64600. */
  64601. hasAlpha: boolean;
  64602. /**
  64603. * Info about each image of the basis file
  64604. */
  64605. images: Array<{
  64606. levels: Array<{
  64607. width: number;
  64608. height: number;
  64609. transcodedPixels: ArrayBufferView;
  64610. }>;
  64611. }>;
  64612. }
  64613. /**
  64614. * Result of transcoding a basis file
  64615. */
  64616. class TranscodeResult {
  64617. /**
  64618. * Info about the .basis file
  64619. */
  64620. fileInfo: BasisFileInfo;
  64621. /**
  64622. * Format to use when loading the file
  64623. */
  64624. format: number;
  64625. }
  64626. /**
  64627. * Configuration options for the Basis transcoder
  64628. */
  64629. export class BasisTranscodeConfiguration {
  64630. /**
  64631. * Supported compression formats used to determine the supported output format of the transcoder
  64632. */
  64633. supportedCompressionFormats?: {
  64634. /**
  64635. * etc1 compression format
  64636. */
  64637. etc1?: boolean;
  64638. /**
  64639. * s3tc compression format
  64640. */
  64641. s3tc?: boolean;
  64642. /**
  64643. * pvrtc compression format
  64644. */
  64645. pvrtc?: boolean;
  64646. /**
  64647. * etc2 compression format
  64648. */
  64649. etc2?: boolean;
  64650. };
  64651. /**
  64652. * If mipmap levels should be loaded for transcoded images (Default: true)
  64653. */
  64654. loadMipmapLevels?: boolean;
  64655. /**
  64656. * Index of a single image to load (Default: all images)
  64657. */
  64658. loadSingleImage?: number;
  64659. }
  64660. /**
  64661. * Used to load .Basis files
  64662. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  64663. */
  64664. export class BasisTools {
  64665. private static _IgnoreSupportedFormats;
  64666. /**
  64667. * URL to use when loading the basis transcoder
  64668. */
  64669. static JSModuleURL: string;
  64670. /**
  64671. * URL to use when loading the wasm module for the transcoder
  64672. */
  64673. static WasmModuleURL: string;
  64674. /**
  64675. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  64676. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  64677. * @returns internal format corresponding to the Basis format
  64678. */
  64679. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  64680. private static _WorkerPromise;
  64681. private static _Worker;
  64682. private static _actionId;
  64683. private static _CreateWorkerAsync;
  64684. /**
  64685. * Transcodes a loaded image file to compressed pixel data
  64686. * @param data image data to transcode
  64687. * @param config configuration options for the transcoding
  64688. * @returns a promise resulting in the transcoded image
  64689. */
  64690. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  64691. /**
  64692. * Loads a texture from the transcode result
  64693. * @param texture texture load to
  64694. * @param transcodeResult the result of transcoding the basis file to load from
  64695. */
  64696. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  64697. }
  64698. }
  64699. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  64700. import { Nullable } from "babylonjs/types";
  64701. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64702. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64703. /**
  64704. * Loader for .basis file format
  64705. */
  64706. export class _BasisTextureLoader implements IInternalTextureLoader {
  64707. /**
  64708. * Defines whether the loader supports cascade loading the different faces.
  64709. */
  64710. readonly supportCascades: boolean;
  64711. /**
  64712. * This returns if the loader support the current file information.
  64713. * @param extension defines the file extension of the file being loaded
  64714. * @returns true if the loader can load the specified file
  64715. */
  64716. canLoad(extension: string): boolean;
  64717. /**
  64718. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64719. * @param data contains the texture data
  64720. * @param texture defines the BabylonJS internal texture
  64721. * @param createPolynomials will be true if polynomials have been requested
  64722. * @param onLoad defines the callback to trigger once the texture is ready
  64723. * @param onError defines the callback to trigger in case of error
  64724. */
  64725. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64726. /**
  64727. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64728. * @param data contains the texture data
  64729. * @param texture defines the BabylonJS internal texture
  64730. * @param callback defines the method to call once ready to upload
  64731. */
  64732. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64733. }
  64734. }
  64735. declare module "babylonjs/Materials/Textures/Loaders/index" {
  64736. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  64737. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  64738. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  64739. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  64740. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  64741. }
  64742. declare module "babylonjs/Materials/Textures/Packer/frame" {
  64743. import { Vector2 } from "babylonjs/Maths/math.vector";
  64744. /**
  64745. * Defines the basic options interface of a TexturePacker Frame
  64746. */
  64747. export interface ITexturePackerFrame {
  64748. /**
  64749. * The frame ID
  64750. */
  64751. id: number;
  64752. /**
  64753. * The frames Scale
  64754. */
  64755. scale: Vector2;
  64756. /**
  64757. * The Frames offset
  64758. */
  64759. offset: Vector2;
  64760. }
  64761. /**
  64762. * This is a support class for frame Data on texture packer sets.
  64763. */
  64764. export class TexturePackerFrame implements ITexturePackerFrame {
  64765. /**
  64766. * The frame ID
  64767. */
  64768. id: number;
  64769. /**
  64770. * The frames Scale
  64771. */
  64772. scale: Vector2;
  64773. /**
  64774. * The Frames offset
  64775. */
  64776. offset: Vector2;
  64777. /**
  64778. * Initializes a texture package frame.
  64779. * @param id The numerical frame identifier
  64780. * @param scale Scalar Vector2 for UV frame
  64781. * @param offset Vector2 for the frame position in UV units.
  64782. * @returns TexturePackerFrame
  64783. */
  64784. constructor(id: number, scale: Vector2, offset: Vector2);
  64785. }
  64786. }
  64787. declare module "babylonjs/Materials/Textures/Packer/packer" {
  64788. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64789. import { Scene } from "babylonjs/scene";
  64790. import { Nullable } from "babylonjs/types";
  64791. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  64792. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  64793. /**
  64794. * Defines the basic options interface of a TexturePacker
  64795. */
  64796. export interface ITexturePackerOptions {
  64797. /**
  64798. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  64799. */
  64800. map?: string[];
  64801. /**
  64802. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64803. */
  64804. uvsIn?: string;
  64805. /**
  64806. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64807. */
  64808. uvsOut?: string;
  64809. /**
  64810. * number representing the layout style. Defaults to LAYOUT_STRIP
  64811. */
  64812. layout?: number;
  64813. /**
  64814. * number of columns if using custom column count layout(2). This defaults to 4.
  64815. */
  64816. colnum?: number;
  64817. /**
  64818. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  64819. */
  64820. updateInputMeshes?: boolean;
  64821. /**
  64822. * boolean flag to dispose all the source textures. Defaults to true.
  64823. */
  64824. disposeSources?: boolean;
  64825. /**
  64826. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  64827. */
  64828. fillBlanks?: boolean;
  64829. /**
  64830. * string value representing the context fill style color. Defaults to 'black'.
  64831. */
  64832. customFillColor?: string;
  64833. /**
  64834. * Width and Height Value of each Frame in the TexturePacker Sets
  64835. */
  64836. frameSize?: number;
  64837. /**
  64838. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  64839. */
  64840. paddingRatio?: number;
  64841. /**
  64842. * Number that declares the fill method for the padding gutter.
  64843. */
  64844. paddingMode?: number;
  64845. /**
  64846. * If in SUBUV_COLOR padding mode what color to use.
  64847. */
  64848. paddingColor?: Color3 | Color4;
  64849. }
  64850. /**
  64851. * Defines the basic interface of a TexturePacker JSON File
  64852. */
  64853. export interface ITexturePackerJSON {
  64854. /**
  64855. * The frame ID
  64856. */
  64857. name: string;
  64858. /**
  64859. * The base64 channel data
  64860. */
  64861. sets: any;
  64862. /**
  64863. * The options of the Packer
  64864. */
  64865. options: ITexturePackerOptions;
  64866. /**
  64867. * The frame data of the Packer
  64868. */
  64869. frames: Array<number>;
  64870. }
  64871. /**
  64872. * This is a support class that generates a series of packed texture sets.
  64873. * @see https://doc.babylonjs.com/babylon101/materials
  64874. */
  64875. export class TexturePacker {
  64876. /** Packer Layout Constant 0 */
  64877. static readonly LAYOUT_STRIP: number;
  64878. /** Packer Layout Constant 1 */
  64879. static readonly LAYOUT_POWER2: number;
  64880. /** Packer Layout Constant 2 */
  64881. static readonly LAYOUT_COLNUM: number;
  64882. /** Packer Layout Constant 0 */
  64883. static readonly SUBUV_WRAP: number;
  64884. /** Packer Layout Constant 1 */
  64885. static readonly SUBUV_EXTEND: number;
  64886. /** Packer Layout Constant 2 */
  64887. static readonly SUBUV_COLOR: number;
  64888. /** The Name of the Texture Package */
  64889. name: string;
  64890. /** The scene scope of the TexturePacker */
  64891. scene: Scene;
  64892. /** The Meshes to target */
  64893. meshes: AbstractMesh[];
  64894. /** Arguments passed with the Constructor */
  64895. options: ITexturePackerOptions;
  64896. /** The promise that is started upon initialization */
  64897. promise: Nullable<Promise<TexturePacker | string>>;
  64898. /** The Container object for the channel sets that are generated */
  64899. sets: object;
  64900. /** The Container array for the frames that are generated */
  64901. frames: TexturePackerFrame[];
  64902. /** The expected number of textures the system is parsing. */
  64903. private _expecting;
  64904. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  64905. private _paddingValue;
  64906. /**
  64907. * Initializes a texture package series from an array of meshes or a single mesh.
  64908. * @param name The name of the package
  64909. * @param meshes The target meshes to compose the package from
  64910. * @param options The arguments that texture packer should follow while building.
  64911. * @param scene The scene which the textures are scoped to.
  64912. * @returns TexturePacker
  64913. */
  64914. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  64915. /**
  64916. * Starts the package process
  64917. * @param resolve The promises resolution function
  64918. * @returns TexturePacker
  64919. */
  64920. private _createFrames;
  64921. /**
  64922. * Calculates the Size of the Channel Sets
  64923. * @returns Vector2
  64924. */
  64925. private _calculateSize;
  64926. /**
  64927. * Calculates the UV data for the frames.
  64928. * @param baseSize the base frameSize
  64929. * @param padding the base frame padding
  64930. * @param dtSize size of the Dynamic Texture for that channel
  64931. * @param dtUnits is 1/dtSize
  64932. * @param update flag to update the input meshes
  64933. */
  64934. private _calculateMeshUVFrames;
  64935. /**
  64936. * Calculates the frames Offset.
  64937. * @param index of the frame
  64938. * @returns Vector2
  64939. */
  64940. private _getFrameOffset;
  64941. /**
  64942. * Updates a Mesh to the frame data
  64943. * @param mesh that is the target
  64944. * @param frameID or the frame index
  64945. */
  64946. private _updateMeshUV;
  64947. /**
  64948. * Updates a Meshes materials to use the texture packer channels
  64949. * @param m is the mesh to target
  64950. * @param force all channels on the packer to be set.
  64951. */
  64952. private _updateTextureReferences;
  64953. /**
  64954. * Public method to set a Mesh to a frame
  64955. * @param m that is the target
  64956. * @param frameID or the frame index
  64957. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  64958. */
  64959. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  64960. /**
  64961. * Starts the async promise to compile the texture packer.
  64962. * @returns Promise<void>
  64963. */
  64964. processAsync(): Promise<void>;
  64965. /**
  64966. * Disposes all textures associated with this packer
  64967. */
  64968. dispose(): void;
  64969. /**
  64970. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  64971. * @param imageType is the image type to use.
  64972. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  64973. */
  64974. download(imageType?: string, quality?: number): void;
  64975. /**
  64976. * Public method to load a texturePacker JSON file.
  64977. * @param data of the JSON file in string format.
  64978. */
  64979. updateFromJSON(data: string): void;
  64980. }
  64981. }
  64982. declare module "babylonjs/Materials/Textures/Packer/index" {
  64983. export * from "babylonjs/Materials/Textures/Packer/packer";
  64984. export * from "babylonjs/Materials/Textures/Packer/frame";
  64985. }
  64986. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  64987. import { Scene } from "babylonjs/scene";
  64988. import { Texture } from "babylonjs/Materials/Textures/texture";
  64989. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64990. /**
  64991. * 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.
  64992. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  64993. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  64994. */
  64995. export class CustomProceduralTexture extends ProceduralTexture {
  64996. private _animate;
  64997. private _time;
  64998. private _config;
  64999. private _texturePath;
  65000. /**
  65001. * Instantiates a new Custom Procedural Texture.
  65002. * 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.
  65003. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65004. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65005. * @param name Define the name of the texture
  65006. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  65007. * @param size Define the size of the texture to create
  65008. * @param scene Define the scene the texture belongs to
  65009. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  65010. * @param generateMipMaps Define if the texture should creates mip maps or not
  65011. */
  65012. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65013. private _loadJson;
  65014. /**
  65015. * Is the texture ready to be used ? (rendered at least once)
  65016. * @returns true if ready, otherwise, false.
  65017. */
  65018. isReady(): boolean;
  65019. /**
  65020. * Render the texture to its associated render target.
  65021. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  65022. */
  65023. render(useCameraPostProcess?: boolean): void;
  65024. /**
  65025. * Update the list of dependant textures samplers in the shader.
  65026. */
  65027. updateTextures(): void;
  65028. /**
  65029. * Update the uniform values of the procedural texture in the shader.
  65030. */
  65031. updateShaderUniforms(): void;
  65032. /**
  65033. * Define if the texture animates or not.
  65034. */
  65035. get animate(): boolean;
  65036. set animate(value: boolean);
  65037. }
  65038. }
  65039. declare module "babylonjs/Shaders/noise.fragment" {
  65040. /** @hidden */
  65041. export var noisePixelShader: {
  65042. name: string;
  65043. shader: string;
  65044. };
  65045. }
  65046. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  65047. import { Nullable } from "babylonjs/types";
  65048. import { Scene } from "babylonjs/scene";
  65049. import { Texture } from "babylonjs/Materials/Textures/texture";
  65050. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65051. import "babylonjs/Shaders/noise.fragment";
  65052. /**
  65053. * Class used to generate noise procedural textures
  65054. */
  65055. export class NoiseProceduralTexture extends ProceduralTexture {
  65056. /** Gets or sets the start time (default is 0) */
  65057. time: number;
  65058. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  65059. brightness: number;
  65060. /** Defines the number of octaves to process */
  65061. octaves: number;
  65062. /** Defines the level of persistence (0.8 by default) */
  65063. persistence: number;
  65064. /** Gets or sets animation speed factor (default is 1) */
  65065. animationSpeedFactor: number;
  65066. /**
  65067. * Creates a new NoiseProceduralTexture
  65068. * @param name defines the name fo the texture
  65069. * @param size defines the size of the texture (default is 256)
  65070. * @param scene defines the hosting scene
  65071. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  65072. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  65073. */
  65074. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65075. private _updateShaderUniforms;
  65076. protected _getDefines(): string;
  65077. /** Generate the current state of the procedural texture */
  65078. render(useCameraPostProcess?: boolean): void;
  65079. /**
  65080. * Serializes this noise procedural texture
  65081. * @returns a serialized noise procedural texture object
  65082. */
  65083. serialize(): any;
  65084. /**
  65085. * Clone the texture.
  65086. * @returns the cloned texture
  65087. */
  65088. clone(): NoiseProceduralTexture;
  65089. /**
  65090. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  65091. * @param parsedTexture defines parsed texture data
  65092. * @param scene defines the current scene
  65093. * @param rootUrl defines the root URL containing noise procedural texture information
  65094. * @returns a parsed NoiseProceduralTexture
  65095. */
  65096. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  65097. }
  65098. }
  65099. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  65100. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  65101. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  65102. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65103. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  65104. }
  65105. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  65106. import { Nullable } from "babylonjs/types";
  65107. import { Scene } from "babylonjs/scene";
  65108. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  65109. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65110. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65111. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65112. /**
  65113. * Raw cube texture where the raw buffers are passed in
  65114. */
  65115. export class RawCubeTexture extends CubeTexture {
  65116. /**
  65117. * Creates a cube texture where the raw buffers are passed in.
  65118. * @param scene defines the scene the texture is attached to
  65119. * @param data defines the array of data to use to create each face
  65120. * @param size defines the size of the textures
  65121. * @param format defines the format of the data
  65122. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  65123. * @param generateMipMaps defines if the engine should generate the mip levels
  65124. * @param invertY defines if data must be stored with Y axis inverted
  65125. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  65126. * @param compression defines the compression used (null by default)
  65127. */
  65128. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  65129. /**
  65130. * Updates the raw cube texture.
  65131. * @param data defines the data to store
  65132. * @param format defines the data format
  65133. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65134. * @param invertY defines if data must be stored with Y axis inverted
  65135. * @param compression defines the compression used (null by default)
  65136. * @param level defines which level of the texture to update
  65137. */
  65138. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  65139. /**
  65140. * Updates a raw cube texture with RGBD encoded data.
  65141. * @param data defines the array of data [mipmap][face] to use to create each face
  65142. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  65143. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65144. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65145. * @returns a promsie that resolves when the operation is complete
  65146. */
  65147. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  65148. /**
  65149. * Clones the raw cube texture.
  65150. * @return a new cube texture
  65151. */
  65152. clone(): CubeTexture;
  65153. /** @hidden */
  65154. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  65155. }
  65156. }
  65157. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  65158. import { Scene } from "babylonjs/scene";
  65159. import { Texture } from "babylonjs/Materials/Textures/texture";
  65160. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65161. /**
  65162. * Class used to store 2D array textures containing user data
  65163. */
  65164. export class RawTexture2DArray extends Texture {
  65165. /** Gets or sets the texture format to use */
  65166. format: number;
  65167. /**
  65168. * Create a new RawTexture2DArray
  65169. * @param data defines the data of the texture
  65170. * @param width defines the width of the texture
  65171. * @param height defines the height of the texture
  65172. * @param depth defines the number of layers of the texture
  65173. * @param format defines the texture format to use
  65174. * @param scene defines the hosting scene
  65175. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65176. * @param invertY defines if texture must be stored with Y axis inverted
  65177. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65178. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65179. */
  65180. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65181. /** Gets or sets the texture format to use */
  65182. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65183. /**
  65184. * Update the texture with new data
  65185. * @param data defines the data to store in the texture
  65186. */
  65187. update(data: ArrayBufferView): void;
  65188. }
  65189. }
  65190. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  65191. import { Scene } from "babylonjs/scene";
  65192. import { Texture } from "babylonjs/Materials/Textures/texture";
  65193. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65194. /**
  65195. * Class used to store 3D textures containing user data
  65196. */
  65197. export class RawTexture3D extends Texture {
  65198. /** Gets or sets the texture format to use */
  65199. format: number;
  65200. /**
  65201. * Create a new RawTexture3D
  65202. * @param data defines the data of the texture
  65203. * @param width defines the width of the texture
  65204. * @param height defines the height of the texture
  65205. * @param depth defines the depth of the texture
  65206. * @param format defines the texture format to use
  65207. * @param scene defines the hosting scene
  65208. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65209. * @param invertY defines if texture must be stored with Y axis inverted
  65210. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65211. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65212. */
  65213. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65214. /** Gets or sets the texture format to use */
  65215. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65216. /**
  65217. * Update the texture with new data
  65218. * @param data defines the data to store in the texture
  65219. */
  65220. update(data: ArrayBufferView): void;
  65221. }
  65222. }
  65223. declare module "babylonjs/Materials/Textures/refractionTexture" {
  65224. import { Scene } from "babylonjs/scene";
  65225. import { Plane } from "babylonjs/Maths/math.plane";
  65226. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65227. /**
  65228. * Creates a refraction texture used by refraction channel of the standard material.
  65229. * It is like a mirror but to see through a material.
  65230. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65231. */
  65232. export class RefractionTexture extends RenderTargetTexture {
  65233. /**
  65234. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  65235. * 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.
  65236. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65237. */
  65238. refractionPlane: Plane;
  65239. /**
  65240. * Define how deep under the surface we should see.
  65241. */
  65242. depth: number;
  65243. /**
  65244. * Creates a refraction texture used by refraction channel of the standard material.
  65245. * It is like a mirror but to see through a material.
  65246. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65247. * @param name Define the texture name
  65248. * @param size Define the size of the underlying texture
  65249. * @param scene Define the scene the refraction belongs to
  65250. * @param generateMipMaps Define if we need to generate mips level for the refraction
  65251. */
  65252. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  65253. /**
  65254. * Clone the refraction texture.
  65255. * @returns the cloned texture
  65256. */
  65257. clone(): RefractionTexture;
  65258. /**
  65259. * Serialize the texture to a JSON representation you could use in Parse later on
  65260. * @returns the serialized JSON representation
  65261. */
  65262. serialize(): any;
  65263. }
  65264. }
  65265. declare module "babylonjs/Materials/Textures/index" {
  65266. export * from "babylonjs/Materials/Textures/baseTexture";
  65267. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  65268. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  65269. export * from "babylonjs/Materials/Textures/cubeTexture";
  65270. export * from "babylonjs/Materials/Textures/dynamicTexture";
  65271. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65272. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  65273. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  65274. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  65275. export * from "babylonjs/Materials/Textures/internalTexture";
  65276. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  65277. export * from "babylonjs/Materials/Textures/Loaders/index";
  65278. export * from "babylonjs/Materials/Textures/mirrorTexture";
  65279. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  65280. export * from "babylonjs/Materials/Textures/Packer/index";
  65281. export * from "babylonjs/Materials/Textures/Procedurals/index";
  65282. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  65283. export * from "babylonjs/Materials/Textures/rawTexture";
  65284. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  65285. export * from "babylonjs/Materials/Textures/rawTexture3D";
  65286. export * from "babylonjs/Materials/Textures/refractionTexture";
  65287. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  65288. export * from "babylonjs/Materials/Textures/texture";
  65289. export * from "babylonjs/Materials/Textures/videoTexture";
  65290. }
  65291. declare module "babylonjs/Materials/Node/Enums/index" {
  65292. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  65293. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  65294. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  65295. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  65296. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  65297. }
  65298. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  65299. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65300. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65302. import { Mesh } from "babylonjs/Meshes/mesh";
  65303. import { Effect } from "babylonjs/Materials/effect";
  65304. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65305. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65306. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65307. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65308. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  65309. /**
  65310. * Block used to add support for vertex skinning (bones)
  65311. */
  65312. export class BonesBlock extends NodeMaterialBlock {
  65313. /**
  65314. * Creates a new BonesBlock
  65315. * @param name defines the block name
  65316. */
  65317. constructor(name: string);
  65318. /**
  65319. * Initialize the block and prepare the context for build
  65320. * @param state defines the state that will be used for the build
  65321. */
  65322. initialize(state: NodeMaterialBuildState): void;
  65323. /**
  65324. * Gets the current class name
  65325. * @returns the class name
  65326. */
  65327. getClassName(): string;
  65328. /**
  65329. * Gets the matrix indices input component
  65330. */
  65331. get matricesIndices(): NodeMaterialConnectionPoint;
  65332. /**
  65333. * Gets the matrix weights input component
  65334. */
  65335. get matricesWeights(): NodeMaterialConnectionPoint;
  65336. /**
  65337. * Gets the extra matrix indices input component
  65338. */
  65339. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  65340. /**
  65341. * Gets the extra matrix weights input component
  65342. */
  65343. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  65344. /**
  65345. * Gets the world input component
  65346. */
  65347. get world(): NodeMaterialConnectionPoint;
  65348. /**
  65349. * Gets the output component
  65350. */
  65351. get output(): NodeMaterialConnectionPoint;
  65352. autoConfigure(material: NodeMaterial): void;
  65353. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  65354. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65355. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65356. protected _buildBlock(state: NodeMaterialBuildState): this;
  65357. }
  65358. }
  65359. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  65360. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65361. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65362. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65364. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65365. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65366. /**
  65367. * Block used to add support for instances
  65368. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  65369. */
  65370. export class InstancesBlock extends NodeMaterialBlock {
  65371. /**
  65372. * Creates a new InstancesBlock
  65373. * @param name defines the block name
  65374. */
  65375. constructor(name: string);
  65376. /**
  65377. * Gets the current class name
  65378. * @returns the class name
  65379. */
  65380. getClassName(): string;
  65381. /**
  65382. * Gets the first world row input component
  65383. */
  65384. get world0(): NodeMaterialConnectionPoint;
  65385. /**
  65386. * Gets the second world row input component
  65387. */
  65388. get world1(): NodeMaterialConnectionPoint;
  65389. /**
  65390. * Gets the third world row input component
  65391. */
  65392. get world2(): NodeMaterialConnectionPoint;
  65393. /**
  65394. * Gets the forth world row input component
  65395. */
  65396. get world3(): NodeMaterialConnectionPoint;
  65397. /**
  65398. * Gets the world input component
  65399. */
  65400. get world(): NodeMaterialConnectionPoint;
  65401. /**
  65402. * Gets the output component
  65403. */
  65404. get output(): NodeMaterialConnectionPoint;
  65405. /**
  65406. * Gets the isntanceID component
  65407. */
  65408. get instanceID(): NodeMaterialConnectionPoint;
  65409. autoConfigure(material: NodeMaterial): void;
  65410. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  65411. protected _buildBlock(state: NodeMaterialBuildState): this;
  65412. }
  65413. }
  65414. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  65415. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65416. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65417. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65418. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65419. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65420. import { Effect } from "babylonjs/Materials/effect";
  65421. import { Mesh } from "babylonjs/Meshes/mesh";
  65422. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65423. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65424. /**
  65425. * Block used to add morph targets support to vertex shader
  65426. */
  65427. export class MorphTargetsBlock extends NodeMaterialBlock {
  65428. private _repeatableContentAnchor;
  65429. /**
  65430. * Create a new MorphTargetsBlock
  65431. * @param name defines the block name
  65432. */
  65433. constructor(name: string);
  65434. /**
  65435. * Gets the current class name
  65436. * @returns the class name
  65437. */
  65438. getClassName(): string;
  65439. /**
  65440. * Gets the position input component
  65441. */
  65442. get position(): NodeMaterialConnectionPoint;
  65443. /**
  65444. * Gets the normal input component
  65445. */
  65446. get normal(): NodeMaterialConnectionPoint;
  65447. /**
  65448. * Gets the tangent input component
  65449. */
  65450. get tangent(): NodeMaterialConnectionPoint;
  65451. /**
  65452. * Gets the tangent input component
  65453. */
  65454. get uv(): NodeMaterialConnectionPoint;
  65455. /**
  65456. * Gets the position output component
  65457. */
  65458. get positionOutput(): NodeMaterialConnectionPoint;
  65459. /**
  65460. * Gets the normal output component
  65461. */
  65462. get normalOutput(): NodeMaterialConnectionPoint;
  65463. /**
  65464. * Gets the tangent output component
  65465. */
  65466. get tangentOutput(): NodeMaterialConnectionPoint;
  65467. /**
  65468. * Gets the tangent output component
  65469. */
  65470. get uvOutput(): NodeMaterialConnectionPoint;
  65471. initialize(state: NodeMaterialBuildState): void;
  65472. autoConfigure(material: NodeMaterial): void;
  65473. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65474. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65475. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  65476. protected _buildBlock(state: NodeMaterialBuildState): this;
  65477. }
  65478. }
  65479. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  65480. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65481. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65482. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65483. import { Nullable } from "babylonjs/types";
  65484. import { Scene } from "babylonjs/scene";
  65485. import { Effect } from "babylonjs/Materials/effect";
  65486. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65487. import { Mesh } from "babylonjs/Meshes/mesh";
  65488. import { Light } from "babylonjs/Lights/light";
  65489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65490. /**
  65491. * Block used to get data information from a light
  65492. */
  65493. export class LightInformationBlock extends NodeMaterialBlock {
  65494. private _lightDataUniformName;
  65495. private _lightColorUniformName;
  65496. private _lightTypeDefineName;
  65497. /**
  65498. * Gets or sets the light associated with this block
  65499. */
  65500. light: Nullable<Light>;
  65501. /**
  65502. * Creates a new LightInformationBlock
  65503. * @param name defines the block name
  65504. */
  65505. constructor(name: string);
  65506. /**
  65507. * Gets the current class name
  65508. * @returns the class name
  65509. */
  65510. getClassName(): string;
  65511. /**
  65512. * Gets the world position input component
  65513. */
  65514. get worldPosition(): NodeMaterialConnectionPoint;
  65515. /**
  65516. * Gets the direction output component
  65517. */
  65518. get direction(): NodeMaterialConnectionPoint;
  65519. /**
  65520. * Gets the direction output component
  65521. */
  65522. get color(): NodeMaterialConnectionPoint;
  65523. /**
  65524. * Gets the direction output component
  65525. */
  65526. get intensity(): NodeMaterialConnectionPoint;
  65527. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65528. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65529. protected _buildBlock(state: NodeMaterialBuildState): this;
  65530. serialize(): any;
  65531. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65532. }
  65533. }
  65534. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  65535. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  65536. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  65537. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  65538. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  65539. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  65540. }
  65541. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  65542. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65543. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65544. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65545. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65546. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65547. import { Effect } from "babylonjs/Materials/effect";
  65548. import { Mesh } from "babylonjs/Meshes/mesh";
  65549. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65550. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65551. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65552. /**
  65553. * Block used to add image processing support to fragment shader
  65554. */
  65555. export class ImageProcessingBlock extends NodeMaterialBlock {
  65556. /**
  65557. * Create a new ImageProcessingBlock
  65558. * @param name defines the block name
  65559. */
  65560. constructor(name: string);
  65561. /**
  65562. * Gets the current class name
  65563. * @returns the class name
  65564. */
  65565. getClassName(): string;
  65566. /**
  65567. * Gets the color input component
  65568. */
  65569. get color(): NodeMaterialConnectionPoint;
  65570. /**
  65571. * Gets the output component
  65572. */
  65573. get output(): NodeMaterialConnectionPoint;
  65574. /**
  65575. * Initialize the block and prepare the context for build
  65576. * @param state defines the state that will be used for the build
  65577. */
  65578. initialize(state: NodeMaterialBuildState): void;
  65579. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  65580. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65581. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65582. protected _buildBlock(state: NodeMaterialBuildState): this;
  65583. }
  65584. }
  65585. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  65586. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65587. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65588. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65589. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65591. import { Effect } from "babylonjs/Materials/effect";
  65592. import { Mesh } from "babylonjs/Meshes/mesh";
  65593. import { Scene } from "babylonjs/scene";
  65594. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  65595. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  65596. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  65597. /**
  65598. * Block used to pertub normals based on a normal map
  65599. */
  65600. export class PerturbNormalBlock extends NodeMaterialBlock {
  65601. private _tangentSpaceParameterName;
  65602. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65603. invertX: boolean;
  65604. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  65605. invertY: boolean;
  65606. /**
  65607. * Create a new PerturbNormalBlock
  65608. * @param name defines the block name
  65609. */
  65610. constructor(name: string);
  65611. /**
  65612. * Gets the current class name
  65613. * @returns the class name
  65614. */
  65615. getClassName(): string;
  65616. /**
  65617. * Gets the world position input component
  65618. */
  65619. get worldPosition(): NodeMaterialConnectionPoint;
  65620. /**
  65621. * Gets the world normal input component
  65622. */
  65623. get worldNormal(): NodeMaterialConnectionPoint;
  65624. /**
  65625. * Gets the world tangent input component
  65626. */
  65627. get worldTangent(): NodeMaterialConnectionPoint;
  65628. /**
  65629. * Gets the uv input component
  65630. */
  65631. get uv(): NodeMaterialConnectionPoint;
  65632. /**
  65633. * Gets the normal map color input component
  65634. */
  65635. get normalMapColor(): NodeMaterialConnectionPoint;
  65636. /**
  65637. * Gets the strength input component
  65638. */
  65639. get strength(): NodeMaterialConnectionPoint;
  65640. /**
  65641. * Gets the output component
  65642. */
  65643. get output(): NodeMaterialConnectionPoint;
  65644. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65645. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65646. autoConfigure(material: NodeMaterial): void;
  65647. protected _buildBlock(state: NodeMaterialBuildState): this;
  65648. protected _dumpPropertiesCode(): string;
  65649. serialize(): any;
  65650. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65651. }
  65652. }
  65653. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  65654. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65655. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65656. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65657. /**
  65658. * Block used to discard a pixel if a value is smaller than a cutoff
  65659. */
  65660. export class DiscardBlock extends NodeMaterialBlock {
  65661. /**
  65662. * Create a new DiscardBlock
  65663. * @param name defines the block name
  65664. */
  65665. constructor(name: string);
  65666. /**
  65667. * Gets the current class name
  65668. * @returns the class name
  65669. */
  65670. getClassName(): string;
  65671. /**
  65672. * Gets the color input component
  65673. */
  65674. get value(): NodeMaterialConnectionPoint;
  65675. /**
  65676. * Gets the cutoff input component
  65677. */
  65678. get cutoff(): NodeMaterialConnectionPoint;
  65679. protected _buildBlock(state: NodeMaterialBuildState): this;
  65680. }
  65681. }
  65682. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  65683. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65684. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65685. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65686. /**
  65687. * Block used to test if the fragment shader is front facing
  65688. */
  65689. export class FrontFacingBlock extends NodeMaterialBlock {
  65690. /**
  65691. * Creates a new FrontFacingBlock
  65692. * @param name defines the block name
  65693. */
  65694. constructor(name: string);
  65695. /**
  65696. * Gets the current class name
  65697. * @returns the class name
  65698. */
  65699. getClassName(): string;
  65700. /**
  65701. * Gets the output component
  65702. */
  65703. get output(): NodeMaterialConnectionPoint;
  65704. protected _buildBlock(state: NodeMaterialBuildState): this;
  65705. }
  65706. }
  65707. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  65708. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65709. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65710. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65711. /**
  65712. * Block used to get the derivative value on x and y of a given input
  65713. */
  65714. export class DerivativeBlock extends NodeMaterialBlock {
  65715. /**
  65716. * Create a new DerivativeBlock
  65717. * @param name defines the block name
  65718. */
  65719. constructor(name: string);
  65720. /**
  65721. * Gets the current class name
  65722. * @returns the class name
  65723. */
  65724. getClassName(): string;
  65725. /**
  65726. * Gets the input component
  65727. */
  65728. get input(): NodeMaterialConnectionPoint;
  65729. /**
  65730. * Gets the derivative output on x
  65731. */
  65732. get dx(): NodeMaterialConnectionPoint;
  65733. /**
  65734. * Gets the derivative output on y
  65735. */
  65736. get dy(): NodeMaterialConnectionPoint;
  65737. protected _buildBlock(state: NodeMaterialBuildState): this;
  65738. }
  65739. }
  65740. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  65741. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65742. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65743. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65744. /**
  65745. * Block used to make gl_FragCoord available
  65746. */
  65747. export class FragCoordBlock extends NodeMaterialBlock {
  65748. /**
  65749. * Creates a new FragCoordBlock
  65750. * @param name defines the block name
  65751. */
  65752. constructor(name: string);
  65753. /**
  65754. * Gets the current class name
  65755. * @returns the class name
  65756. */
  65757. getClassName(): string;
  65758. /**
  65759. * Gets the xy component
  65760. */
  65761. get xy(): NodeMaterialConnectionPoint;
  65762. /**
  65763. * Gets the xyz component
  65764. */
  65765. get xyz(): NodeMaterialConnectionPoint;
  65766. /**
  65767. * Gets the xyzw component
  65768. */
  65769. get xyzw(): NodeMaterialConnectionPoint;
  65770. /**
  65771. * Gets the x component
  65772. */
  65773. get x(): NodeMaterialConnectionPoint;
  65774. /**
  65775. * Gets the y component
  65776. */
  65777. get y(): NodeMaterialConnectionPoint;
  65778. /**
  65779. * Gets the z component
  65780. */
  65781. get z(): NodeMaterialConnectionPoint;
  65782. /**
  65783. * Gets the w component
  65784. */
  65785. get output(): NodeMaterialConnectionPoint;
  65786. protected writeOutputs(state: NodeMaterialBuildState): string;
  65787. protected _buildBlock(state: NodeMaterialBuildState): this;
  65788. }
  65789. }
  65790. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  65791. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65792. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65793. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65794. import { Effect } from "babylonjs/Materials/effect";
  65795. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65796. import { Mesh } from "babylonjs/Meshes/mesh";
  65797. /**
  65798. * Block used to get the screen sizes
  65799. */
  65800. export class ScreenSizeBlock extends NodeMaterialBlock {
  65801. private _varName;
  65802. private _scene;
  65803. /**
  65804. * Creates a new ScreenSizeBlock
  65805. * @param name defines the block name
  65806. */
  65807. constructor(name: string);
  65808. /**
  65809. * Gets the current class name
  65810. * @returns the class name
  65811. */
  65812. getClassName(): string;
  65813. /**
  65814. * Gets the xy component
  65815. */
  65816. get xy(): NodeMaterialConnectionPoint;
  65817. /**
  65818. * Gets the x component
  65819. */
  65820. get x(): NodeMaterialConnectionPoint;
  65821. /**
  65822. * Gets the y component
  65823. */
  65824. get y(): NodeMaterialConnectionPoint;
  65825. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65826. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  65827. protected _buildBlock(state: NodeMaterialBuildState): this;
  65828. }
  65829. }
  65830. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  65831. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  65832. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  65833. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  65834. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  65835. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  65836. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  65837. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  65838. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  65839. }
  65840. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  65841. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65842. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65843. import { Mesh } from "babylonjs/Meshes/mesh";
  65844. import { Effect } from "babylonjs/Materials/effect";
  65845. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65846. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65847. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65848. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  65849. /**
  65850. * Block used to add support for scene fog
  65851. */
  65852. export class FogBlock extends NodeMaterialBlock {
  65853. private _fogDistanceName;
  65854. private _fogParameters;
  65855. /**
  65856. * Create a new FogBlock
  65857. * @param name defines the block name
  65858. */
  65859. constructor(name: string);
  65860. /**
  65861. * Gets the current class name
  65862. * @returns the class name
  65863. */
  65864. getClassName(): string;
  65865. /**
  65866. * Gets the world position input component
  65867. */
  65868. get worldPosition(): NodeMaterialConnectionPoint;
  65869. /**
  65870. * Gets the view input component
  65871. */
  65872. get view(): NodeMaterialConnectionPoint;
  65873. /**
  65874. * Gets the color input component
  65875. */
  65876. get input(): NodeMaterialConnectionPoint;
  65877. /**
  65878. * Gets the fog color input component
  65879. */
  65880. get fogColor(): NodeMaterialConnectionPoint;
  65881. /**
  65882. * Gets the output component
  65883. */
  65884. get output(): NodeMaterialConnectionPoint;
  65885. autoConfigure(material: NodeMaterial): void;
  65886. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65887. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65888. protected _buildBlock(state: NodeMaterialBuildState): this;
  65889. }
  65890. }
  65891. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  65892. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65893. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65894. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65895. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65896. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65897. import { Effect } from "babylonjs/Materials/effect";
  65898. import { Mesh } from "babylonjs/Meshes/mesh";
  65899. import { Light } from "babylonjs/Lights/light";
  65900. import { Nullable } from "babylonjs/types";
  65901. import { Scene } from "babylonjs/scene";
  65902. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  65903. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  65904. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  65905. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65906. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  65907. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  65908. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  65909. /**
  65910. * Block used to add light in the fragment shader
  65911. */
  65912. export class LightBlock extends NodeMaterialBlock {
  65913. private _lightId;
  65914. /**
  65915. * Gets or sets the light associated with this block
  65916. */
  65917. light: Nullable<Light>;
  65918. /**
  65919. * Create a new LightBlock
  65920. * @param name defines the block name
  65921. */
  65922. constructor(name: string);
  65923. /**
  65924. * Gets the current class name
  65925. * @returns the class name
  65926. */
  65927. getClassName(): string;
  65928. /**
  65929. * Gets the world position input component
  65930. */
  65931. get worldPosition(): NodeMaterialConnectionPoint;
  65932. /**
  65933. * Gets the world normal input component
  65934. */
  65935. get worldNormal(): NodeMaterialConnectionPoint;
  65936. /**
  65937. * Gets the camera (or eye) position component
  65938. */
  65939. get cameraPosition(): NodeMaterialConnectionPoint;
  65940. /**
  65941. * Gets the glossiness component
  65942. */
  65943. get glossiness(): NodeMaterialConnectionPoint;
  65944. /**
  65945. * Gets the glossinness power component
  65946. */
  65947. get glossPower(): NodeMaterialConnectionPoint;
  65948. /**
  65949. * Gets the diffuse color component
  65950. */
  65951. get diffuseColor(): NodeMaterialConnectionPoint;
  65952. /**
  65953. * Gets the specular color component
  65954. */
  65955. get specularColor(): NodeMaterialConnectionPoint;
  65956. /**
  65957. * Gets the diffuse output component
  65958. */
  65959. get diffuseOutput(): NodeMaterialConnectionPoint;
  65960. /**
  65961. * Gets the specular output component
  65962. */
  65963. get specularOutput(): NodeMaterialConnectionPoint;
  65964. /**
  65965. * Gets the shadow output component
  65966. */
  65967. get shadow(): NodeMaterialConnectionPoint;
  65968. autoConfigure(material: NodeMaterial): void;
  65969. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65970. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65971. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65972. private _injectVertexCode;
  65973. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65974. serialize(): any;
  65975. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65976. }
  65977. }
  65978. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  65979. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65980. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65981. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65982. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  65983. /**
  65984. * Block used to read a reflection texture from a sampler
  65985. */
  65986. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  65987. /**
  65988. * Create a new ReflectionTextureBlock
  65989. * @param name defines the block name
  65990. */
  65991. constructor(name: string);
  65992. /**
  65993. * Gets the current class name
  65994. * @returns the class name
  65995. */
  65996. getClassName(): string;
  65997. /**
  65998. * Gets the world position input component
  65999. */
  66000. get position(): NodeMaterialConnectionPoint;
  66001. /**
  66002. * Gets the world position input component
  66003. */
  66004. get worldPosition(): NodeMaterialConnectionPoint;
  66005. /**
  66006. * Gets the world normal input component
  66007. */
  66008. get worldNormal(): NodeMaterialConnectionPoint;
  66009. /**
  66010. * Gets the world input component
  66011. */
  66012. get world(): NodeMaterialConnectionPoint;
  66013. /**
  66014. * Gets the camera (or eye) position component
  66015. */
  66016. get cameraPosition(): NodeMaterialConnectionPoint;
  66017. /**
  66018. * Gets the view input component
  66019. */
  66020. get view(): NodeMaterialConnectionPoint;
  66021. /**
  66022. * Gets the rgb output component
  66023. */
  66024. get rgb(): NodeMaterialConnectionPoint;
  66025. /**
  66026. * Gets the rgba output component
  66027. */
  66028. get rgba(): NodeMaterialConnectionPoint;
  66029. /**
  66030. * Gets the r output component
  66031. */
  66032. get r(): NodeMaterialConnectionPoint;
  66033. /**
  66034. * Gets the g output component
  66035. */
  66036. get g(): NodeMaterialConnectionPoint;
  66037. /**
  66038. * Gets the b output component
  66039. */
  66040. get b(): NodeMaterialConnectionPoint;
  66041. /**
  66042. * Gets the a output component
  66043. */
  66044. get a(): NodeMaterialConnectionPoint;
  66045. autoConfigure(material: NodeMaterial): void;
  66046. protected _buildBlock(state: NodeMaterialBuildState): this;
  66047. }
  66048. }
  66049. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  66050. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  66051. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  66052. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  66053. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  66054. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  66055. }
  66056. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  66057. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  66058. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  66059. }
  66060. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  66061. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66062. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66063. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66064. /**
  66065. * Block used to add 2 vectors
  66066. */
  66067. export class AddBlock extends NodeMaterialBlock {
  66068. /**
  66069. * Creates a new AddBlock
  66070. * @param name defines the block name
  66071. */
  66072. constructor(name: string);
  66073. /**
  66074. * Gets the current class name
  66075. * @returns the class name
  66076. */
  66077. getClassName(): string;
  66078. /**
  66079. * Gets the left operand input component
  66080. */
  66081. get left(): NodeMaterialConnectionPoint;
  66082. /**
  66083. * Gets the right operand input component
  66084. */
  66085. get right(): NodeMaterialConnectionPoint;
  66086. /**
  66087. * Gets the output component
  66088. */
  66089. get output(): NodeMaterialConnectionPoint;
  66090. protected _buildBlock(state: NodeMaterialBuildState): this;
  66091. }
  66092. }
  66093. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  66094. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66095. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66096. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66097. /**
  66098. * Block used to scale a vector by a float
  66099. */
  66100. export class ScaleBlock extends NodeMaterialBlock {
  66101. /**
  66102. * Creates a new ScaleBlock
  66103. * @param name defines the block name
  66104. */
  66105. constructor(name: string);
  66106. /**
  66107. * Gets the current class name
  66108. * @returns the class name
  66109. */
  66110. getClassName(): string;
  66111. /**
  66112. * Gets the input component
  66113. */
  66114. get input(): NodeMaterialConnectionPoint;
  66115. /**
  66116. * Gets the factor input component
  66117. */
  66118. get factor(): NodeMaterialConnectionPoint;
  66119. /**
  66120. * Gets the output component
  66121. */
  66122. get output(): NodeMaterialConnectionPoint;
  66123. protected _buildBlock(state: NodeMaterialBuildState): this;
  66124. }
  66125. }
  66126. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  66127. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66128. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66129. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66130. import { Scene } from "babylonjs/scene";
  66131. /**
  66132. * Block used to clamp a float
  66133. */
  66134. export class ClampBlock extends NodeMaterialBlock {
  66135. /** Gets or sets the minimum range */
  66136. minimum: number;
  66137. /** Gets or sets the maximum range */
  66138. maximum: number;
  66139. /**
  66140. * Creates a new ClampBlock
  66141. * @param name defines the block name
  66142. */
  66143. constructor(name: string);
  66144. /**
  66145. * Gets the current class name
  66146. * @returns the class name
  66147. */
  66148. getClassName(): string;
  66149. /**
  66150. * Gets the value input component
  66151. */
  66152. get value(): NodeMaterialConnectionPoint;
  66153. /**
  66154. * Gets the output component
  66155. */
  66156. get output(): NodeMaterialConnectionPoint;
  66157. protected _buildBlock(state: NodeMaterialBuildState): this;
  66158. protected _dumpPropertiesCode(): string;
  66159. serialize(): any;
  66160. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66161. }
  66162. }
  66163. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  66164. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66165. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66166. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66167. /**
  66168. * Block used to apply a cross product between 2 vectors
  66169. */
  66170. export class CrossBlock extends NodeMaterialBlock {
  66171. /**
  66172. * Creates a new CrossBlock
  66173. * @param name defines the block name
  66174. */
  66175. constructor(name: string);
  66176. /**
  66177. * Gets the current class name
  66178. * @returns the class name
  66179. */
  66180. getClassName(): string;
  66181. /**
  66182. * Gets the left operand input component
  66183. */
  66184. get left(): NodeMaterialConnectionPoint;
  66185. /**
  66186. * Gets the right operand input component
  66187. */
  66188. get right(): NodeMaterialConnectionPoint;
  66189. /**
  66190. * Gets the output component
  66191. */
  66192. get output(): NodeMaterialConnectionPoint;
  66193. protected _buildBlock(state: NodeMaterialBuildState): this;
  66194. }
  66195. }
  66196. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  66197. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66198. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66199. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66200. /**
  66201. * Block used to apply a dot product between 2 vectors
  66202. */
  66203. export class DotBlock extends NodeMaterialBlock {
  66204. /**
  66205. * Creates a new DotBlock
  66206. * @param name defines the block name
  66207. */
  66208. constructor(name: string);
  66209. /**
  66210. * Gets the current class name
  66211. * @returns the class name
  66212. */
  66213. getClassName(): string;
  66214. /**
  66215. * Gets the left operand input component
  66216. */
  66217. get left(): NodeMaterialConnectionPoint;
  66218. /**
  66219. * Gets the right operand input component
  66220. */
  66221. get right(): NodeMaterialConnectionPoint;
  66222. /**
  66223. * Gets the output component
  66224. */
  66225. get output(): NodeMaterialConnectionPoint;
  66226. protected _buildBlock(state: NodeMaterialBuildState): this;
  66227. }
  66228. }
  66229. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  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. /**
  66234. * Block used to normalize a vector
  66235. */
  66236. export class NormalizeBlock extends NodeMaterialBlock {
  66237. /**
  66238. * Creates a new NormalizeBlock
  66239. * @param name defines the block name
  66240. */
  66241. constructor(name: string);
  66242. /**
  66243. * Gets the current class name
  66244. * @returns the class name
  66245. */
  66246. getClassName(): string;
  66247. /**
  66248. * Gets the input component
  66249. */
  66250. get input(): NodeMaterialConnectionPoint;
  66251. /**
  66252. * Gets the output component
  66253. */
  66254. get output(): NodeMaterialConnectionPoint;
  66255. protected _buildBlock(state: NodeMaterialBuildState): this;
  66256. }
  66257. }
  66258. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  66259. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66260. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66261. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66262. import { Scene } from "babylonjs/scene";
  66263. /**
  66264. * Operations supported by the Trigonometry block
  66265. */
  66266. export enum TrigonometryBlockOperations {
  66267. /** Cos */
  66268. Cos = 0,
  66269. /** Sin */
  66270. Sin = 1,
  66271. /** Abs */
  66272. Abs = 2,
  66273. /** Exp */
  66274. Exp = 3,
  66275. /** Exp2 */
  66276. Exp2 = 4,
  66277. /** Round */
  66278. Round = 5,
  66279. /** Floor */
  66280. Floor = 6,
  66281. /** Ceiling */
  66282. Ceiling = 7,
  66283. /** Square root */
  66284. Sqrt = 8,
  66285. /** Log */
  66286. Log = 9,
  66287. /** Tangent */
  66288. Tan = 10,
  66289. /** Arc tangent */
  66290. ArcTan = 11,
  66291. /** Arc cosinus */
  66292. ArcCos = 12,
  66293. /** Arc sinus */
  66294. ArcSin = 13,
  66295. /** Fraction */
  66296. Fract = 14,
  66297. /** Sign */
  66298. Sign = 15,
  66299. /** To radians (from degrees) */
  66300. Radians = 16,
  66301. /** To degrees (from radians) */
  66302. Degrees = 17
  66303. }
  66304. /**
  66305. * Block used to apply trigonometry operation to floats
  66306. */
  66307. export class TrigonometryBlock extends NodeMaterialBlock {
  66308. /**
  66309. * Gets or sets the operation applied by the block
  66310. */
  66311. operation: TrigonometryBlockOperations;
  66312. /**
  66313. * Creates a new TrigonometryBlock
  66314. * @param name defines the block name
  66315. */
  66316. constructor(name: string);
  66317. /**
  66318. * Gets the current class name
  66319. * @returns the class name
  66320. */
  66321. getClassName(): string;
  66322. /**
  66323. * Gets the input component
  66324. */
  66325. get input(): NodeMaterialConnectionPoint;
  66326. /**
  66327. * Gets the output component
  66328. */
  66329. get output(): NodeMaterialConnectionPoint;
  66330. protected _buildBlock(state: NodeMaterialBuildState): this;
  66331. serialize(): any;
  66332. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66333. protected _dumpPropertiesCode(): string;
  66334. }
  66335. }
  66336. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  66337. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66338. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66339. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66340. /**
  66341. * Block used to create a Color3/4 out of individual inputs (one for each component)
  66342. */
  66343. export class ColorMergerBlock extends NodeMaterialBlock {
  66344. /**
  66345. * Create a new ColorMergerBlock
  66346. * @param name defines the block name
  66347. */
  66348. constructor(name: string);
  66349. /**
  66350. * Gets the current class name
  66351. * @returns the class name
  66352. */
  66353. getClassName(): string;
  66354. /**
  66355. * Gets the rgb component (input)
  66356. */
  66357. get rgbIn(): NodeMaterialConnectionPoint;
  66358. /**
  66359. * Gets the r component (input)
  66360. */
  66361. get r(): NodeMaterialConnectionPoint;
  66362. /**
  66363. * Gets the g component (input)
  66364. */
  66365. get g(): NodeMaterialConnectionPoint;
  66366. /**
  66367. * Gets the b component (input)
  66368. */
  66369. get b(): NodeMaterialConnectionPoint;
  66370. /**
  66371. * Gets the a component (input)
  66372. */
  66373. get a(): NodeMaterialConnectionPoint;
  66374. /**
  66375. * Gets the rgba component (output)
  66376. */
  66377. get rgba(): NodeMaterialConnectionPoint;
  66378. /**
  66379. * Gets the rgb component (output)
  66380. */
  66381. get rgbOut(): NodeMaterialConnectionPoint;
  66382. /**
  66383. * Gets the rgb component (output)
  66384. * @deprecated Please use rgbOut instead.
  66385. */
  66386. get rgb(): NodeMaterialConnectionPoint;
  66387. protected _buildBlock(state: NodeMaterialBuildState): this;
  66388. }
  66389. }
  66390. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  66391. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66392. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66393. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66394. /**
  66395. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  66396. */
  66397. export class VectorSplitterBlock extends NodeMaterialBlock {
  66398. /**
  66399. * Create a new VectorSplitterBlock
  66400. * @param name defines the block name
  66401. */
  66402. constructor(name: string);
  66403. /**
  66404. * Gets the current class name
  66405. * @returns the class name
  66406. */
  66407. getClassName(): string;
  66408. /**
  66409. * Gets the xyzw component (input)
  66410. */
  66411. get xyzw(): NodeMaterialConnectionPoint;
  66412. /**
  66413. * Gets the xyz component (input)
  66414. */
  66415. get xyzIn(): NodeMaterialConnectionPoint;
  66416. /**
  66417. * Gets the xy component (input)
  66418. */
  66419. get xyIn(): NodeMaterialConnectionPoint;
  66420. /**
  66421. * Gets the xyz component (output)
  66422. */
  66423. get xyzOut(): NodeMaterialConnectionPoint;
  66424. /**
  66425. * Gets the xy component (output)
  66426. */
  66427. get xyOut(): NodeMaterialConnectionPoint;
  66428. /**
  66429. * Gets the x component (output)
  66430. */
  66431. get x(): NodeMaterialConnectionPoint;
  66432. /**
  66433. * Gets the y component (output)
  66434. */
  66435. get y(): NodeMaterialConnectionPoint;
  66436. /**
  66437. * Gets the z component (output)
  66438. */
  66439. get z(): NodeMaterialConnectionPoint;
  66440. /**
  66441. * Gets the w component (output)
  66442. */
  66443. get w(): NodeMaterialConnectionPoint;
  66444. protected _inputRename(name: string): string;
  66445. protected _outputRename(name: string): string;
  66446. protected _buildBlock(state: NodeMaterialBuildState): this;
  66447. }
  66448. }
  66449. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  66450. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66451. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66452. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66453. /**
  66454. * Block used to lerp between 2 values
  66455. */
  66456. export class LerpBlock extends NodeMaterialBlock {
  66457. /**
  66458. * Creates a new LerpBlock
  66459. * @param name defines the block name
  66460. */
  66461. constructor(name: string);
  66462. /**
  66463. * Gets the current class name
  66464. * @returns the class name
  66465. */
  66466. getClassName(): string;
  66467. /**
  66468. * Gets the left operand input component
  66469. */
  66470. get left(): NodeMaterialConnectionPoint;
  66471. /**
  66472. * Gets the right operand input component
  66473. */
  66474. get right(): NodeMaterialConnectionPoint;
  66475. /**
  66476. * Gets the gradient operand input component
  66477. */
  66478. get gradient(): NodeMaterialConnectionPoint;
  66479. /**
  66480. * Gets the output component
  66481. */
  66482. get output(): NodeMaterialConnectionPoint;
  66483. protected _buildBlock(state: NodeMaterialBuildState): this;
  66484. }
  66485. }
  66486. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  66487. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66488. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66489. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66490. /**
  66491. * Block used to divide 2 vectors
  66492. */
  66493. export class DivideBlock extends NodeMaterialBlock {
  66494. /**
  66495. * Creates a new DivideBlock
  66496. * @param name defines the block name
  66497. */
  66498. constructor(name: string);
  66499. /**
  66500. * Gets the current class name
  66501. * @returns the class name
  66502. */
  66503. getClassName(): string;
  66504. /**
  66505. * Gets the left operand input component
  66506. */
  66507. get left(): NodeMaterialConnectionPoint;
  66508. /**
  66509. * Gets the right operand input component
  66510. */
  66511. get right(): NodeMaterialConnectionPoint;
  66512. /**
  66513. * Gets the output component
  66514. */
  66515. get output(): NodeMaterialConnectionPoint;
  66516. protected _buildBlock(state: NodeMaterialBuildState): this;
  66517. }
  66518. }
  66519. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  66520. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66521. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66522. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66523. /**
  66524. * Block used to subtract 2 vectors
  66525. */
  66526. export class SubtractBlock extends NodeMaterialBlock {
  66527. /**
  66528. * Creates a new SubtractBlock
  66529. * @param name defines the block name
  66530. */
  66531. constructor(name: string);
  66532. /**
  66533. * Gets the current class name
  66534. * @returns the class name
  66535. */
  66536. getClassName(): string;
  66537. /**
  66538. * Gets the left operand input component
  66539. */
  66540. get left(): NodeMaterialConnectionPoint;
  66541. /**
  66542. * Gets the right operand input component
  66543. */
  66544. get right(): NodeMaterialConnectionPoint;
  66545. /**
  66546. * Gets the output component
  66547. */
  66548. get output(): NodeMaterialConnectionPoint;
  66549. protected _buildBlock(state: NodeMaterialBuildState): this;
  66550. }
  66551. }
  66552. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  66553. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66554. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66555. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66556. /**
  66557. * Block used to step a value
  66558. */
  66559. export class StepBlock extends NodeMaterialBlock {
  66560. /**
  66561. * Creates a new StepBlock
  66562. * @param name defines the block name
  66563. */
  66564. constructor(name: string);
  66565. /**
  66566. * Gets the current class name
  66567. * @returns the class name
  66568. */
  66569. getClassName(): string;
  66570. /**
  66571. * Gets the value operand input component
  66572. */
  66573. get value(): NodeMaterialConnectionPoint;
  66574. /**
  66575. * Gets the edge operand input component
  66576. */
  66577. get edge(): NodeMaterialConnectionPoint;
  66578. /**
  66579. * Gets the output component
  66580. */
  66581. get output(): NodeMaterialConnectionPoint;
  66582. protected _buildBlock(state: NodeMaterialBuildState): this;
  66583. }
  66584. }
  66585. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  66586. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66587. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66588. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66589. /**
  66590. * Block used to get the opposite (1 - x) of a value
  66591. */
  66592. export class OneMinusBlock extends NodeMaterialBlock {
  66593. /**
  66594. * Creates a new OneMinusBlock
  66595. * @param name defines the block name
  66596. */
  66597. constructor(name: string);
  66598. /**
  66599. * Gets the current class name
  66600. * @returns the class name
  66601. */
  66602. getClassName(): string;
  66603. /**
  66604. * Gets the input component
  66605. */
  66606. get input(): NodeMaterialConnectionPoint;
  66607. /**
  66608. * Gets the output component
  66609. */
  66610. get output(): NodeMaterialConnectionPoint;
  66611. protected _buildBlock(state: NodeMaterialBuildState): this;
  66612. }
  66613. }
  66614. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  66615. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66616. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66617. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66618. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66619. /**
  66620. * Block used to get the view direction
  66621. */
  66622. export class ViewDirectionBlock extends NodeMaterialBlock {
  66623. /**
  66624. * Creates a new ViewDirectionBlock
  66625. * @param name defines the block name
  66626. */
  66627. constructor(name: string);
  66628. /**
  66629. * Gets the current class name
  66630. * @returns the class name
  66631. */
  66632. getClassName(): string;
  66633. /**
  66634. * Gets the world position component
  66635. */
  66636. get worldPosition(): NodeMaterialConnectionPoint;
  66637. /**
  66638. * Gets the camera position component
  66639. */
  66640. get cameraPosition(): NodeMaterialConnectionPoint;
  66641. /**
  66642. * Gets the output component
  66643. */
  66644. get output(): NodeMaterialConnectionPoint;
  66645. autoConfigure(material: NodeMaterial): void;
  66646. protected _buildBlock(state: NodeMaterialBuildState): this;
  66647. }
  66648. }
  66649. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  66650. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66651. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66652. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66653. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66654. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  66655. /**
  66656. * Block used to compute fresnel value
  66657. */
  66658. export class FresnelBlock extends NodeMaterialBlock {
  66659. /**
  66660. * Create a new FresnelBlock
  66661. * @param name defines the block name
  66662. */
  66663. constructor(name: string);
  66664. /**
  66665. * Gets the current class name
  66666. * @returns the class name
  66667. */
  66668. getClassName(): string;
  66669. /**
  66670. * Gets the world normal input component
  66671. */
  66672. get worldNormal(): NodeMaterialConnectionPoint;
  66673. /**
  66674. * Gets the view direction input component
  66675. */
  66676. get viewDirection(): NodeMaterialConnectionPoint;
  66677. /**
  66678. * Gets the bias input component
  66679. */
  66680. get bias(): NodeMaterialConnectionPoint;
  66681. /**
  66682. * Gets the camera (or eye) position component
  66683. */
  66684. get power(): NodeMaterialConnectionPoint;
  66685. /**
  66686. * Gets the fresnel output component
  66687. */
  66688. get fresnel(): NodeMaterialConnectionPoint;
  66689. autoConfigure(material: NodeMaterial): void;
  66690. protected _buildBlock(state: NodeMaterialBuildState): this;
  66691. }
  66692. }
  66693. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  66694. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66695. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66696. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66697. /**
  66698. * Block used to get the max of 2 values
  66699. */
  66700. export class MaxBlock extends NodeMaterialBlock {
  66701. /**
  66702. * Creates a new MaxBlock
  66703. * @param name defines the block name
  66704. */
  66705. constructor(name: string);
  66706. /**
  66707. * Gets the current class name
  66708. * @returns the class name
  66709. */
  66710. getClassName(): string;
  66711. /**
  66712. * Gets the left operand input component
  66713. */
  66714. get left(): NodeMaterialConnectionPoint;
  66715. /**
  66716. * Gets the right operand input component
  66717. */
  66718. get right(): NodeMaterialConnectionPoint;
  66719. /**
  66720. * Gets the output component
  66721. */
  66722. get output(): NodeMaterialConnectionPoint;
  66723. protected _buildBlock(state: NodeMaterialBuildState): this;
  66724. }
  66725. }
  66726. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  66727. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66728. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66729. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66730. /**
  66731. * Block used to get the min of 2 values
  66732. */
  66733. export class MinBlock extends NodeMaterialBlock {
  66734. /**
  66735. * Creates a new MinBlock
  66736. * @param name defines the block name
  66737. */
  66738. constructor(name: string);
  66739. /**
  66740. * Gets the current class name
  66741. * @returns the class name
  66742. */
  66743. getClassName(): string;
  66744. /**
  66745. * Gets the left operand input component
  66746. */
  66747. get left(): NodeMaterialConnectionPoint;
  66748. /**
  66749. * Gets the right operand input component
  66750. */
  66751. get right(): NodeMaterialConnectionPoint;
  66752. /**
  66753. * Gets the output component
  66754. */
  66755. get output(): NodeMaterialConnectionPoint;
  66756. protected _buildBlock(state: NodeMaterialBuildState): this;
  66757. }
  66758. }
  66759. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  66760. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66761. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66762. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66763. /**
  66764. * Block used to get the distance between 2 values
  66765. */
  66766. export class DistanceBlock extends NodeMaterialBlock {
  66767. /**
  66768. * Creates a new DistanceBlock
  66769. * @param name defines the block name
  66770. */
  66771. constructor(name: string);
  66772. /**
  66773. * Gets the current class name
  66774. * @returns the class name
  66775. */
  66776. getClassName(): string;
  66777. /**
  66778. * Gets the left operand input component
  66779. */
  66780. get left(): NodeMaterialConnectionPoint;
  66781. /**
  66782. * Gets the right operand input component
  66783. */
  66784. get right(): NodeMaterialConnectionPoint;
  66785. /**
  66786. * Gets the output component
  66787. */
  66788. get output(): NodeMaterialConnectionPoint;
  66789. protected _buildBlock(state: NodeMaterialBuildState): this;
  66790. }
  66791. }
  66792. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  66793. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66794. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66795. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66796. /**
  66797. * Block used to get the length of a vector
  66798. */
  66799. export class LengthBlock extends NodeMaterialBlock {
  66800. /**
  66801. * Creates a new LengthBlock
  66802. * @param name defines the block name
  66803. */
  66804. constructor(name: string);
  66805. /**
  66806. * Gets the current class name
  66807. * @returns the class name
  66808. */
  66809. getClassName(): string;
  66810. /**
  66811. * Gets the value input component
  66812. */
  66813. get value(): NodeMaterialConnectionPoint;
  66814. /**
  66815. * Gets the output component
  66816. */
  66817. get output(): NodeMaterialConnectionPoint;
  66818. protected _buildBlock(state: NodeMaterialBuildState): this;
  66819. }
  66820. }
  66821. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  66822. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66823. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66824. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66825. /**
  66826. * Block used to get negative version of a value (i.e. x * -1)
  66827. */
  66828. export class NegateBlock extends NodeMaterialBlock {
  66829. /**
  66830. * Creates a new NegateBlock
  66831. * @param name defines the block name
  66832. */
  66833. constructor(name: string);
  66834. /**
  66835. * Gets the current class name
  66836. * @returns the class name
  66837. */
  66838. getClassName(): string;
  66839. /**
  66840. * Gets the value input component
  66841. */
  66842. get value(): NodeMaterialConnectionPoint;
  66843. /**
  66844. * Gets the output component
  66845. */
  66846. get output(): NodeMaterialConnectionPoint;
  66847. protected _buildBlock(state: NodeMaterialBuildState): this;
  66848. }
  66849. }
  66850. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  66851. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66852. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66853. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66854. /**
  66855. * Block used to get the value of the first parameter raised to the power of the second
  66856. */
  66857. export class PowBlock extends NodeMaterialBlock {
  66858. /**
  66859. * Creates a new PowBlock
  66860. * @param name defines the block name
  66861. */
  66862. constructor(name: string);
  66863. /**
  66864. * Gets the current class name
  66865. * @returns the class name
  66866. */
  66867. getClassName(): string;
  66868. /**
  66869. * Gets the value operand input component
  66870. */
  66871. get value(): NodeMaterialConnectionPoint;
  66872. /**
  66873. * Gets the power operand input component
  66874. */
  66875. get power(): NodeMaterialConnectionPoint;
  66876. /**
  66877. * Gets the output component
  66878. */
  66879. get output(): NodeMaterialConnectionPoint;
  66880. protected _buildBlock(state: NodeMaterialBuildState): this;
  66881. }
  66882. }
  66883. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  66884. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66885. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66886. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66887. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66888. /**
  66889. * Block used to get a random number
  66890. */
  66891. export class RandomNumberBlock extends NodeMaterialBlock {
  66892. /**
  66893. * Creates a new RandomNumberBlock
  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 seed input component
  66904. */
  66905. get seed(): NodeMaterialConnectionPoint;
  66906. /**
  66907. * Gets the output component
  66908. */
  66909. get output(): NodeMaterialConnectionPoint;
  66910. protected _buildBlock(state: NodeMaterialBuildState): this;
  66911. }
  66912. }
  66913. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  66914. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66915. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66916. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66917. /**
  66918. * Block used to compute arc tangent of 2 values
  66919. */
  66920. export class ArcTan2Block extends NodeMaterialBlock {
  66921. /**
  66922. * Creates a new ArcTan2Block
  66923. * @param name defines the block name
  66924. */
  66925. constructor(name: string);
  66926. /**
  66927. * Gets the current class name
  66928. * @returns the class name
  66929. */
  66930. getClassName(): string;
  66931. /**
  66932. * Gets the x operand input component
  66933. */
  66934. get x(): NodeMaterialConnectionPoint;
  66935. /**
  66936. * Gets the y operand input component
  66937. */
  66938. get y(): 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/smoothStepBlock" {
  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 smooth step a value
  66952. */
  66953. export class SmoothStepBlock extends NodeMaterialBlock {
  66954. /**
  66955. * Creates a new SmoothStepBlock
  66956. * @param name defines the block name
  66957. */
  66958. constructor(name: string);
  66959. /**
  66960. * Gets the current class name
  66961. * @returns the class name
  66962. */
  66963. getClassName(): string;
  66964. /**
  66965. * Gets the value operand input component
  66966. */
  66967. get value(): NodeMaterialConnectionPoint;
  66968. /**
  66969. * Gets the first edge operand input component
  66970. */
  66971. get edge0(): NodeMaterialConnectionPoint;
  66972. /**
  66973. * Gets the second edge operand input component
  66974. */
  66975. get edge1(): NodeMaterialConnectionPoint;
  66976. /**
  66977. * Gets the output component
  66978. */
  66979. get output(): NodeMaterialConnectionPoint;
  66980. protected _buildBlock(state: NodeMaterialBuildState): this;
  66981. }
  66982. }
  66983. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  66984. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66985. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66986. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66987. /**
  66988. * Block used to get the reciprocal (1 / x) of a value
  66989. */
  66990. export class ReciprocalBlock extends NodeMaterialBlock {
  66991. /**
  66992. * Creates a new ReciprocalBlock
  66993. * @param name defines the block name
  66994. */
  66995. constructor(name: string);
  66996. /**
  66997. * Gets the current class name
  66998. * @returns the class name
  66999. */
  67000. getClassName(): string;
  67001. /**
  67002. * Gets the input component
  67003. */
  67004. get input(): NodeMaterialConnectionPoint;
  67005. /**
  67006. * Gets the output component
  67007. */
  67008. get output(): NodeMaterialConnectionPoint;
  67009. protected _buildBlock(state: NodeMaterialBuildState): this;
  67010. }
  67011. }
  67012. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  67013. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67014. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67015. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67016. /**
  67017. * Block used to replace a color by another one
  67018. */
  67019. export class ReplaceColorBlock extends NodeMaterialBlock {
  67020. /**
  67021. * Creates a new ReplaceColorBlock
  67022. * @param name defines the block name
  67023. */
  67024. constructor(name: string);
  67025. /**
  67026. * Gets the current class name
  67027. * @returns the class name
  67028. */
  67029. getClassName(): string;
  67030. /**
  67031. * Gets the value input component
  67032. */
  67033. get value(): NodeMaterialConnectionPoint;
  67034. /**
  67035. * Gets the reference input component
  67036. */
  67037. get reference(): NodeMaterialConnectionPoint;
  67038. /**
  67039. * Gets the distance input component
  67040. */
  67041. get distance(): NodeMaterialConnectionPoint;
  67042. /**
  67043. * Gets the replacement input component
  67044. */
  67045. get replacement(): NodeMaterialConnectionPoint;
  67046. /**
  67047. * Gets the output component
  67048. */
  67049. get output(): NodeMaterialConnectionPoint;
  67050. protected _buildBlock(state: NodeMaterialBuildState): this;
  67051. }
  67052. }
  67053. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  67054. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67055. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67056. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67057. /**
  67058. * Block used to posterize a value
  67059. * @see https://en.wikipedia.org/wiki/Posterization
  67060. */
  67061. export class PosterizeBlock extends NodeMaterialBlock {
  67062. /**
  67063. * Creates a new PosterizeBlock
  67064. * @param name defines the block name
  67065. */
  67066. constructor(name: string);
  67067. /**
  67068. * Gets the current class name
  67069. * @returns the class name
  67070. */
  67071. getClassName(): string;
  67072. /**
  67073. * Gets the value input component
  67074. */
  67075. get value(): NodeMaterialConnectionPoint;
  67076. /**
  67077. * Gets the steps input component
  67078. */
  67079. get steps(): NodeMaterialConnectionPoint;
  67080. /**
  67081. * Gets the output component
  67082. */
  67083. get output(): NodeMaterialConnectionPoint;
  67084. protected _buildBlock(state: NodeMaterialBuildState): this;
  67085. }
  67086. }
  67087. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  67088. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67089. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67090. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67091. import { Scene } from "babylonjs/scene";
  67092. /**
  67093. * Operations supported by the Wave block
  67094. */
  67095. export enum WaveBlockKind {
  67096. /** SawTooth */
  67097. SawTooth = 0,
  67098. /** Square */
  67099. Square = 1,
  67100. /** Triangle */
  67101. Triangle = 2
  67102. }
  67103. /**
  67104. * Block used to apply wave operation to floats
  67105. */
  67106. export class WaveBlock extends NodeMaterialBlock {
  67107. /**
  67108. * Gets or sets the kibnd of wave to be applied by the block
  67109. */
  67110. kind: WaveBlockKind;
  67111. /**
  67112. * Creates a new WaveBlock
  67113. * @param name defines the block name
  67114. */
  67115. constructor(name: string);
  67116. /**
  67117. * Gets the current class name
  67118. * @returns the class name
  67119. */
  67120. getClassName(): string;
  67121. /**
  67122. * Gets the input component
  67123. */
  67124. get input(): NodeMaterialConnectionPoint;
  67125. /**
  67126. * Gets the output component
  67127. */
  67128. get output(): NodeMaterialConnectionPoint;
  67129. protected _buildBlock(state: NodeMaterialBuildState): this;
  67130. serialize(): any;
  67131. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67132. }
  67133. }
  67134. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  67135. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67136. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67137. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67138. import { Color3 } from "babylonjs/Maths/math.color";
  67139. import { Scene } from "babylonjs/scene";
  67140. import { Observable } from "babylonjs/Misc/observable";
  67141. /**
  67142. * Class used to store a color step for the GradientBlock
  67143. */
  67144. export class GradientBlockColorStep {
  67145. private _parent;
  67146. private _step;
  67147. /**
  67148. * Gets value indicating which step this color is associated with (between 0 and 1)
  67149. */
  67150. get step(): number;
  67151. /**
  67152. * Sets a value indicating which step this color is associated with (between 0 and 1)
  67153. */
  67154. set step(val: number);
  67155. private _color;
  67156. /**
  67157. * Gets the color associated with this step
  67158. */
  67159. get color(): Color3;
  67160. /**
  67161. * Sets the color associated with this step
  67162. */
  67163. set color(val: Color3);
  67164. /**
  67165. * Creates a new GradientBlockColorStep
  67166. * @param parent defines the parent gradient for this block
  67167. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  67168. * @param color defines the color associated with this step
  67169. */
  67170. constructor(parent: GradientBlock, step: number, color: Color3);
  67171. }
  67172. /**
  67173. * Block used to return a color from a gradient based on an input value between 0 and 1
  67174. */
  67175. export class GradientBlock extends NodeMaterialBlock {
  67176. /**
  67177. * Gets or sets the list of color steps
  67178. */
  67179. colorSteps: GradientBlockColorStep[];
  67180. /** Gets an observable raised when the value is changed */
  67181. onValueChangedObservable: Observable<GradientBlock>;
  67182. /** calls observable when the value is changed*/
  67183. colorStepsUpdated(): void;
  67184. /**
  67185. * Creates a new GradientBlock
  67186. * @param name defines the block name
  67187. */
  67188. constructor(name: string);
  67189. /**
  67190. * Gets the current class name
  67191. * @returns the class name
  67192. */
  67193. getClassName(): string;
  67194. /**
  67195. * Gets the gradient input component
  67196. */
  67197. get gradient(): NodeMaterialConnectionPoint;
  67198. /**
  67199. * Gets the output component
  67200. */
  67201. get output(): NodeMaterialConnectionPoint;
  67202. private _writeColorConstant;
  67203. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67204. serialize(): any;
  67205. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67206. protected _dumpPropertiesCode(): string;
  67207. }
  67208. }
  67209. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  67210. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67211. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67212. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67213. /**
  67214. * Block used to normalize lerp between 2 values
  67215. */
  67216. export class NLerpBlock extends NodeMaterialBlock {
  67217. /**
  67218. * Creates a new NLerpBlock
  67219. * @param name defines the block name
  67220. */
  67221. constructor(name: string);
  67222. /**
  67223. * Gets the current class name
  67224. * @returns the class name
  67225. */
  67226. getClassName(): string;
  67227. /**
  67228. * Gets the left operand input component
  67229. */
  67230. get left(): NodeMaterialConnectionPoint;
  67231. /**
  67232. * Gets the right operand input component
  67233. */
  67234. get right(): NodeMaterialConnectionPoint;
  67235. /**
  67236. * Gets the gradient operand input component
  67237. */
  67238. get gradient(): NodeMaterialConnectionPoint;
  67239. /**
  67240. * Gets the output component
  67241. */
  67242. get output(): NodeMaterialConnectionPoint;
  67243. protected _buildBlock(state: NodeMaterialBuildState): this;
  67244. }
  67245. }
  67246. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  67247. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67248. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67249. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67250. import { Scene } from "babylonjs/scene";
  67251. /**
  67252. * block used to Generate a Worley Noise 3D Noise Pattern
  67253. */
  67254. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  67255. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67256. manhattanDistance: boolean;
  67257. /**
  67258. * Creates a new WorleyNoise3DBlock
  67259. * @param name defines the block name
  67260. */
  67261. constructor(name: string);
  67262. /**
  67263. * Gets the current class name
  67264. * @returns the class name
  67265. */
  67266. getClassName(): string;
  67267. /**
  67268. * Gets the seed input component
  67269. */
  67270. get seed(): NodeMaterialConnectionPoint;
  67271. /**
  67272. * Gets the jitter input component
  67273. */
  67274. get jitter(): NodeMaterialConnectionPoint;
  67275. /**
  67276. * Gets the output component
  67277. */
  67278. get output(): NodeMaterialConnectionPoint;
  67279. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67280. /**
  67281. * Exposes the properties to the UI?
  67282. */
  67283. protected _dumpPropertiesCode(): string;
  67284. /**
  67285. * Exposes the properties to the Seralize?
  67286. */
  67287. serialize(): any;
  67288. /**
  67289. * Exposes the properties to the deseralize?
  67290. */
  67291. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67292. }
  67293. }
  67294. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  67295. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67296. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67297. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67298. /**
  67299. * block used to Generate a Simplex Perlin 3d Noise Pattern
  67300. */
  67301. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  67302. /**
  67303. * Creates a new SimplexPerlin3DBlock
  67304. * @param name defines the block name
  67305. */
  67306. constructor(name: string);
  67307. /**
  67308. * Gets the current class name
  67309. * @returns the class name
  67310. */
  67311. getClassName(): string;
  67312. /**
  67313. * Gets the seed operand input component
  67314. */
  67315. get seed(): NodeMaterialConnectionPoint;
  67316. /**
  67317. * Gets the output component
  67318. */
  67319. get output(): NodeMaterialConnectionPoint;
  67320. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67321. }
  67322. }
  67323. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  67324. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67325. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67326. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67327. /**
  67328. * Block used to blend normals
  67329. */
  67330. export class NormalBlendBlock extends NodeMaterialBlock {
  67331. /**
  67332. * Creates a new NormalBlendBlock
  67333. * @param name defines the block name
  67334. */
  67335. constructor(name: string);
  67336. /**
  67337. * Gets the current class name
  67338. * @returns the class name
  67339. */
  67340. getClassName(): string;
  67341. /**
  67342. * Gets the first input component
  67343. */
  67344. get normalMap0(): NodeMaterialConnectionPoint;
  67345. /**
  67346. * Gets the second input component
  67347. */
  67348. get normalMap1(): NodeMaterialConnectionPoint;
  67349. /**
  67350. * Gets the output component
  67351. */
  67352. get output(): NodeMaterialConnectionPoint;
  67353. protected _buildBlock(state: NodeMaterialBuildState): this;
  67354. }
  67355. }
  67356. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  67357. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67358. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67359. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67360. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67361. /**
  67362. * Block used to rotate a 2d vector by a given angle
  67363. */
  67364. export class Rotate2dBlock extends NodeMaterialBlock {
  67365. /**
  67366. * Creates a new Rotate2dBlock
  67367. * @param name defines the block name
  67368. */
  67369. constructor(name: string);
  67370. /**
  67371. * Gets the current class name
  67372. * @returns the class name
  67373. */
  67374. getClassName(): string;
  67375. /**
  67376. * Gets the input vector
  67377. */
  67378. get input(): NodeMaterialConnectionPoint;
  67379. /**
  67380. * Gets the input angle
  67381. */
  67382. get angle(): NodeMaterialConnectionPoint;
  67383. /**
  67384. * Gets the output component
  67385. */
  67386. get output(): NodeMaterialConnectionPoint;
  67387. autoConfigure(material: NodeMaterial): void;
  67388. protected _buildBlock(state: NodeMaterialBuildState): this;
  67389. }
  67390. }
  67391. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  67392. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67393. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67394. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67395. /**
  67396. * Block used to get the reflected vector from a direction and a normal
  67397. */
  67398. export class ReflectBlock extends NodeMaterialBlock {
  67399. /**
  67400. * Creates a new ReflectBlock
  67401. * @param name defines the block name
  67402. */
  67403. constructor(name: string);
  67404. /**
  67405. * Gets the current class name
  67406. * @returns the class name
  67407. */
  67408. getClassName(): string;
  67409. /**
  67410. * Gets the incident component
  67411. */
  67412. get incident(): NodeMaterialConnectionPoint;
  67413. /**
  67414. * Gets the normal component
  67415. */
  67416. get normal(): NodeMaterialConnectionPoint;
  67417. /**
  67418. * Gets the output component
  67419. */
  67420. get output(): NodeMaterialConnectionPoint;
  67421. protected _buildBlock(state: NodeMaterialBuildState): this;
  67422. }
  67423. }
  67424. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  67425. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67426. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67427. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67428. /**
  67429. * Block used to get the refracted vector from a direction and a normal
  67430. */
  67431. export class RefractBlock extends NodeMaterialBlock {
  67432. /**
  67433. * Creates a new RefractBlock
  67434. * @param name defines the block name
  67435. */
  67436. constructor(name: string);
  67437. /**
  67438. * Gets the current class name
  67439. * @returns the class name
  67440. */
  67441. getClassName(): string;
  67442. /**
  67443. * Gets the incident component
  67444. */
  67445. get incident(): NodeMaterialConnectionPoint;
  67446. /**
  67447. * Gets the normal component
  67448. */
  67449. get normal(): NodeMaterialConnectionPoint;
  67450. /**
  67451. * Gets the index of refraction component
  67452. */
  67453. get ior(): NodeMaterialConnectionPoint;
  67454. /**
  67455. * Gets the output component
  67456. */
  67457. get output(): NodeMaterialConnectionPoint;
  67458. protected _buildBlock(state: NodeMaterialBuildState): this;
  67459. }
  67460. }
  67461. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  67462. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67463. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67464. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67465. /**
  67466. * Block used to desaturate a color
  67467. */
  67468. export class DesaturateBlock extends NodeMaterialBlock {
  67469. /**
  67470. * Creates a new DesaturateBlock
  67471. * @param name defines the block name
  67472. */
  67473. constructor(name: string);
  67474. /**
  67475. * Gets the current class name
  67476. * @returns the class name
  67477. */
  67478. getClassName(): string;
  67479. /**
  67480. * Gets the color operand input component
  67481. */
  67482. get color(): NodeMaterialConnectionPoint;
  67483. /**
  67484. * Gets the level operand input component
  67485. */
  67486. get level(): NodeMaterialConnectionPoint;
  67487. /**
  67488. * Gets the output component
  67489. */
  67490. get output(): NodeMaterialConnectionPoint;
  67491. protected _buildBlock(state: NodeMaterialBuildState): this;
  67492. }
  67493. }
  67494. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  67495. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67496. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67497. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67498. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67499. import { Nullable } from "babylonjs/types";
  67500. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67501. import { Scene } from "babylonjs/scene";
  67502. /**
  67503. * Block used to implement the ambient occlusion module of the PBR material
  67504. */
  67505. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  67506. /**
  67507. * Create a new AmbientOcclusionBlock
  67508. * @param name defines the block name
  67509. */
  67510. constructor(name: string);
  67511. /**
  67512. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  67513. */
  67514. useAmbientInGrayScale: boolean;
  67515. /**
  67516. * Initialize the block and prepare the context for build
  67517. * @param state defines the state that will be used for the build
  67518. */
  67519. initialize(state: NodeMaterialBuildState): void;
  67520. /**
  67521. * Gets the current class name
  67522. * @returns the class name
  67523. */
  67524. getClassName(): string;
  67525. /**
  67526. * Gets the texture input component
  67527. */
  67528. get texture(): NodeMaterialConnectionPoint;
  67529. /**
  67530. * Gets the texture intensity component
  67531. */
  67532. get intensity(): NodeMaterialConnectionPoint;
  67533. /**
  67534. * Gets the direct light intensity input component
  67535. */
  67536. get directLightIntensity(): NodeMaterialConnectionPoint;
  67537. /**
  67538. * Gets the ambient occlusion object output component
  67539. */
  67540. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67541. /**
  67542. * Gets the main code of the block (fragment side)
  67543. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  67544. * @returns the shader code
  67545. */
  67546. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  67547. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67548. protected _buildBlock(state: NodeMaterialBuildState): this;
  67549. protected _dumpPropertiesCode(): string;
  67550. serialize(): any;
  67551. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67552. }
  67553. }
  67554. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  67555. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67556. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67557. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67558. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67560. import { Nullable } from "babylonjs/types";
  67561. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67562. import { Mesh } from "babylonjs/Meshes/mesh";
  67563. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67564. import { Effect } from "babylonjs/Materials/effect";
  67565. import { Scene } from "babylonjs/scene";
  67566. /**
  67567. * Block used to implement the reflection module of the PBR material
  67568. */
  67569. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  67570. /** @hidden */
  67571. _defineLODReflectionAlpha: string;
  67572. /** @hidden */
  67573. _defineLinearSpecularReflection: string;
  67574. private _vEnvironmentIrradianceName;
  67575. /** @hidden */
  67576. _vReflectionMicrosurfaceInfosName: string;
  67577. /** @hidden */
  67578. _vReflectionInfosName: string;
  67579. /** @hidden */
  67580. _vReflectionFilteringInfoName: string;
  67581. private _scene;
  67582. /**
  67583. * The three properties below are set by the main PBR block prior to calling methods of this class.
  67584. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67585. * It's less burden on the user side in the editor part.
  67586. */
  67587. /** @hidden */
  67588. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67589. /** @hidden */
  67590. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67591. /** @hidden */
  67592. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  67593. /**
  67594. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  67595. * diffuse part of the IBL.
  67596. */
  67597. useSphericalHarmonics: boolean;
  67598. /**
  67599. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  67600. */
  67601. forceIrradianceInFragment: boolean;
  67602. /**
  67603. * Create a new ReflectionBlock
  67604. * @param name defines the block name
  67605. */
  67606. constructor(name: string);
  67607. /**
  67608. * Gets the current class name
  67609. * @returns the class name
  67610. */
  67611. getClassName(): string;
  67612. /**
  67613. * Gets the position input component
  67614. */
  67615. get position(): NodeMaterialConnectionPoint;
  67616. /**
  67617. * Gets the world position input component
  67618. */
  67619. get worldPosition(): NodeMaterialConnectionPoint;
  67620. /**
  67621. * Gets the world normal input component
  67622. */
  67623. get worldNormal(): NodeMaterialConnectionPoint;
  67624. /**
  67625. * Gets the world input component
  67626. */
  67627. get world(): NodeMaterialConnectionPoint;
  67628. /**
  67629. * Gets the camera (or eye) position component
  67630. */
  67631. get cameraPosition(): NodeMaterialConnectionPoint;
  67632. /**
  67633. * Gets the view input component
  67634. */
  67635. get view(): NodeMaterialConnectionPoint;
  67636. /**
  67637. * Gets the color input component
  67638. */
  67639. get color(): NodeMaterialConnectionPoint;
  67640. /**
  67641. * Gets the reflection object output component
  67642. */
  67643. get reflection(): NodeMaterialConnectionPoint;
  67644. /**
  67645. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  67646. */
  67647. get hasTexture(): boolean;
  67648. /**
  67649. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  67650. */
  67651. get reflectionColor(): string;
  67652. protected _getTexture(): Nullable<BaseTexture>;
  67653. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67654. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67655. /**
  67656. * Gets the code to inject in the vertex shader
  67657. * @param state current state of the node material building
  67658. * @returns the shader code
  67659. */
  67660. handleVertexSide(state: NodeMaterialBuildState): string;
  67661. /**
  67662. * Gets the main code of the block (fragment side)
  67663. * @param state current state of the node material building
  67664. * @param normalVarName name of the existing variable corresponding to the normal
  67665. * @returns the shader code
  67666. */
  67667. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  67668. protected _buildBlock(state: NodeMaterialBuildState): this;
  67669. protected _dumpPropertiesCode(): string;
  67670. serialize(): any;
  67671. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67672. }
  67673. }
  67674. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  67675. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67676. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67677. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67678. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67679. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67680. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67681. import { Scene } from "babylonjs/scene";
  67682. import { Nullable } from "babylonjs/types";
  67683. /**
  67684. * Block used to implement the sheen module of the PBR material
  67685. */
  67686. export class SheenBlock extends NodeMaterialBlock {
  67687. /**
  67688. * Create a new SheenBlock
  67689. * @param name defines the block name
  67690. */
  67691. constructor(name: string);
  67692. /**
  67693. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  67694. * It allows the strength of the sheen effect to not depend on the base color of the material,
  67695. * making it easier to setup and tweak the effect
  67696. */
  67697. albedoScaling: boolean;
  67698. /**
  67699. * Defines if the sheen is linked to the sheen color.
  67700. */
  67701. linkSheenWithAlbedo: boolean;
  67702. /**
  67703. * Initialize the block and prepare the context for build
  67704. * @param state defines the state that will be used for the build
  67705. */
  67706. initialize(state: NodeMaterialBuildState): void;
  67707. /**
  67708. * Gets the current class name
  67709. * @returns the class name
  67710. */
  67711. getClassName(): string;
  67712. /**
  67713. * Gets the intensity input component
  67714. */
  67715. get intensity(): NodeMaterialConnectionPoint;
  67716. /**
  67717. * Gets the color input component
  67718. */
  67719. get color(): NodeMaterialConnectionPoint;
  67720. /**
  67721. * Gets the roughness input component
  67722. */
  67723. get roughness(): NodeMaterialConnectionPoint;
  67724. /**
  67725. * Gets the sheen object output component
  67726. */
  67727. get sheen(): NodeMaterialConnectionPoint;
  67728. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67729. /**
  67730. * Gets the main code of the block (fragment side)
  67731. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67732. * @returns the shader code
  67733. */
  67734. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  67735. protected _buildBlock(state: NodeMaterialBuildState): this;
  67736. protected _dumpPropertiesCode(): string;
  67737. serialize(): any;
  67738. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67739. }
  67740. }
  67741. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  67742. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67743. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67744. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67745. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67746. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67747. import { Scene } from "babylonjs/scene";
  67748. import { Nullable } from "babylonjs/types";
  67749. import { Mesh } from "babylonjs/Meshes/mesh";
  67750. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67751. import { Effect } from "babylonjs/Materials/effect";
  67752. /**
  67753. * Block used to implement the reflectivity module of the PBR material
  67754. */
  67755. export class ReflectivityBlock extends NodeMaterialBlock {
  67756. private _metallicReflectanceColor;
  67757. private _metallicF0Factor;
  67758. /** @hidden */
  67759. _vMetallicReflectanceFactorsName: string;
  67760. /**
  67761. * The property below is set by the main PBR block prior to calling methods of this class.
  67762. */
  67763. /** @hidden */
  67764. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  67765. /**
  67766. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  67767. */
  67768. useAmbientOcclusionFromMetallicTextureRed: boolean;
  67769. /**
  67770. * Specifies if the metallic texture contains the metallness information in its blue channel.
  67771. */
  67772. useMetallnessFromMetallicTextureBlue: boolean;
  67773. /**
  67774. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  67775. */
  67776. useRoughnessFromMetallicTextureAlpha: boolean;
  67777. /**
  67778. * Specifies if the metallic texture contains the roughness information in its green channel.
  67779. */
  67780. useRoughnessFromMetallicTextureGreen: boolean;
  67781. /**
  67782. * Create a new ReflectivityBlock
  67783. * @param name defines the block name
  67784. */
  67785. constructor(name: string);
  67786. /**
  67787. * Initialize the block and prepare the context for build
  67788. * @param state defines the state that will be used for the build
  67789. */
  67790. initialize(state: NodeMaterialBuildState): void;
  67791. /**
  67792. * Gets the current class name
  67793. * @returns the class name
  67794. */
  67795. getClassName(): string;
  67796. /**
  67797. * Gets the metallic input component
  67798. */
  67799. get metallic(): NodeMaterialConnectionPoint;
  67800. /**
  67801. * Gets the roughness input component
  67802. */
  67803. get roughness(): NodeMaterialConnectionPoint;
  67804. /**
  67805. * Gets the texture input component
  67806. */
  67807. get texture(): NodeMaterialConnectionPoint;
  67808. /**
  67809. * Gets the reflectivity object output component
  67810. */
  67811. get reflectivity(): NodeMaterialConnectionPoint;
  67812. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67813. /**
  67814. * Gets the main code of the block (fragment side)
  67815. * @param state current state of the node material building
  67816. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  67817. * @returns the shader code
  67818. */
  67819. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  67820. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67821. protected _buildBlock(state: NodeMaterialBuildState): this;
  67822. protected _dumpPropertiesCode(): string;
  67823. serialize(): any;
  67824. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67825. }
  67826. }
  67827. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  67828. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67829. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67830. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67831. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67833. /**
  67834. * Block used to implement the anisotropy module of the PBR material
  67835. */
  67836. export class AnisotropyBlock extends NodeMaterialBlock {
  67837. /**
  67838. * The two properties below are set by the main PBR block prior to calling methods of this class.
  67839. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67840. * It's less burden on the user side in the editor part.
  67841. */
  67842. /** @hidden */
  67843. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67844. /** @hidden */
  67845. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67846. /**
  67847. * Create a new AnisotropyBlock
  67848. * @param name defines the block name
  67849. */
  67850. constructor(name: string);
  67851. /**
  67852. * Initialize the block and prepare the context for build
  67853. * @param state defines the state that will be used for the build
  67854. */
  67855. initialize(state: NodeMaterialBuildState): void;
  67856. /**
  67857. * Gets the current class name
  67858. * @returns the class name
  67859. */
  67860. getClassName(): string;
  67861. /**
  67862. * Gets the intensity input component
  67863. */
  67864. get intensity(): NodeMaterialConnectionPoint;
  67865. /**
  67866. * Gets the direction input component
  67867. */
  67868. get direction(): NodeMaterialConnectionPoint;
  67869. /**
  67870. * Gets the texture input component
  67871. */
  67872. get texture(): NodeMaterialConnectionPoint;
  67873. /**
  67874. * Gets the uv input component
  67875. */
  67876. get uv(): NodeMaterialConnectionPoint;
  67877. /**
  67878. * Gets the worldTangent input component
  67879. */
  67880. get worldTangent(): NodeMaterialConnectionPoint;
  67881. /**
  67882. * Gets the anisotropy object output component
  67883. */
  67884. get anisotropy(): NodeMaterialConnectionPoint;
  67885. private _generateTBNSpace;
  67886. /**
  67887. * Gets the main code of the block (fragment side)
  67888. * @param state current state of the node material building
  67889. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67890. * @returns the shader code
  67891. */
  67892. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  67893. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67894. protected _buildBlock(state: NodeMaterialBuildState): this;
  67895. }
  67896. }
  67897. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  67898. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67899. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67900. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67901. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67902. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67903. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67904. import { Nullable } from "babylonjs/types";
  67905. import { Mesh } from "babylonjs/Meshes/mesh";
  67906. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67907. import { Effect } from "babylonjs/Materials/effect";
  67908. /**
  67909. * Block used to implement the clear coat module of the PBR material
  67910. */
  67911. export class ClearCoatBlock extends NodeMaterialBlock {
  67912. private _scene;
  67913. /**
  67914. * Create a new ClearCoatBlock
  67915. * @param name defines the block name
  67916. */
  67917. constructor(name: string);
  67918. /**
  67919. * Initialize the block and prepare the context for build
  67920. * @param state defines the state that will be used for the build
  67921. */
  67922. initialize(state: NodeMaterialBuildState): void;
  67923. /**
  67924. * Gets the current class name
  67925. * @returns the class name
  67926. */
  67927. getClassName(): string;
  67928. /**
  67929. * Gets the intensity input component
  67930. */
  67931. get intensity(): NodeMaterialConnectionPoint;
  67932. /**
  67933. * Gets the roughness input component
  67934. */
  67935. get roughness(): NodeMaterialConnectionPoint;
  67936. /**
  67937. * Gets the ior input component
  67938. */
  67939. get ior(): NodeMaterialConnectionPoint;
  67940. /**
  67941. * Gets the texture input component
  67942. */
  67943. get texture(): NodeMaterialConnectionPoint;
  67944. /**
  67945. * Gets the bump texture input component
  67946. */
  67947. get bumpTexture(): NodeMaterialConnectionPoint;
  67948. /**
  67949. * Gets the uv input component
  67950. */
  67951. get uv(): NodeMaterialConnectionPoint;
  67952. /**
  67953. * Gets the tint color input component
  67954. */
  67955. get tintColor(): NodeMaterialConnectionPoint;
  67956. /**
  67957. * Gets the tint "at distance" input component
  67958. */
  67959. get tintAtDistance(): NodeMaterialConnectionPoint;
  67960. /**
  67961. * Gets the tint thickness input component
  67962. */
  67963. get tintThickness(): NodeMaterialConnectionPoint;
  67964. /**
  67965. * Gets the world tangent input component
  67966. */
  67967. get worldTangent(): NodeMaterialConnectionPoint;
  67968. /**
  67969. * Gets the clear coat object output component
  67970. */
  67971. get clearcoat(): NodeMaterialConnectionPoint;
  67972. autoConfigure(material: NodeMaterial): void;
  67973. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67974. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67975. private _generateTBNSpace;
  67976. /**
  67977. * Gets the main code of the block (fragment side)
  67978. * @param state current state of the node material building
  67979. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  67980. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67981. * @param worldPosVarName name of the variable holding the world position
  67982. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67983. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  67984. * @param worldNormalVarName name of the variable holding the world normal
  67985. * @returns the shader code
  67986. */
  67987. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  67988. protected _buildBlock(state: NodeMaterialBuildState): this;
  67989. }
  67990. }
  67991. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  67992. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67993. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67994. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67995. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67997. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67998. import { Nullable } from "babylonjs/types";
  67999. /**
  68000. * Block used to implement the sub surface module of the PBR material
  68001. */
  68002. export class SubSurfaceBlock extends NodeMaterialBlock {
  68003. /**
  68004. * Create a new SubSurfaceBlock
  68005. * @param name defines the block name
  68006. */
  68007. constructor(name: string);
  68008. /**
  68009. * Stores the intensity of the different subsurface effects in the thickness texture.
  68010. * * the green channel is the translucency intensity.
  68011. * * the blue channel is the scattering intensity.
  68012. * * the alpha channel is the refraction intensity.
  68013. */
  68014. useMaskFromThicknessTexture: boolean;
  68015. /**
  68016. * Initialize the block and prepare the context for build
  68017. * @param state defines the state that will be used for the build
  68018. */
  68019. initialize(state: NodeMaterialBuildState): void;
  68020. /**
  68021. * Gets the current class name
  68022. * @returns the class name
  68023. */
  68024. getClassName(): string;
  68025. /**
  68026. * Gets the min thickness input component
  68027. */
  68028. get minThickness(): NodeMaterialConnectionPoint;
  68029. /**
  68030. * Gets the max thickness input component
  68031. */
  68032. get maxThickness(): NodeMaterialConnectionPoint;
  68033. /**
  68034. * Gets the thickness texture component
  68035. */
  68036. get thicknessTexture(): NodeMaterialConnectionPoint;
  68037. /**
  68038. * Gets the tint color input component
  68039. */
  68040. get tintColor(): NodeMaterialConnectionPoint;
  68041. /**
  68042. * Gets the translucency intensity input component
  68043. */
  68044. get translucencyIntensity(): NodeMaterialConnectionPoint;
  68045. /**
  68046. * Gets the translucency diffusion distance input component
  68047. */
  68048. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  68049. /**
  68050. * Gets the refraction object parameters
  68051. */
  68052. get refraction(): NodeMaterialConnectionPoint;
  68053. /**
  68054. * Gets the sub surface object output component
  68055. */
  68056. get subsurface(): NodeMaterialConnectionPoint;
  68057. autoConfigure(material: NodeMaterial): void;
  68058. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68059. /**
  68060. * Gets the main code of the block (fragment side)
  68061. * @param state current state of the node material building
  68062. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  68063. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68064. * @param worldPosVarName name of the variable holding the world position
  68065. * @returns the shader code
  68066. */
  68067. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  68068. protected _buildBlock(state: NodeMaterialBuildState): this;
  68069. }
  68070. }
  68071. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  68072. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68073. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68074. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68075. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68076. import { Light } from "babylonjs/Lights/light";
  68077. import { Nullable } from "babylonjs/types";
  68078. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68079. import { Effect } from "babylonjs/Materials/effect";
  68080. import { Mesh } from "babylonjs/Meshes/mesh";
  68081. import { Scene } from "babylonjs/scene";
  68082. /**
  68083. * Block used to implement the PBR metallic/roughness model
  68084. */
  68085. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  68086. /**
  68087. * Gets or sets the light associated with this block
  68088. */
  68089. light: Nullable<Light>;
  68090. private _lightId;
  68091. private _scene;
  68092. private _environmentBRDFTexture;
  68093. private _environmentBrdfSamplerName;
  68094. private _vNormalWName;
  68095. private _invertNormalName;
  68096. /**
  68097. * Create a new ReflectionBlock
  68098. * @param name defines the block name
  68099. */
  68100. constructor(name: string);
  68101. /**
  68102. * Intensity of the direct lights e.g. the four lights available in your scene.
  68103. * This impacts both the direct diffuse and specular highlights.
  68104. */
  68105. directIntensity: number;
  68106. /**
  68107. * Intensity of the environment e.g. how much the environment will light the object
  68108. * either through harmonics for rough material or through the refelction for shiny ones.
  68109. */
  68110. environmentIntensity: number;
  68111. /**
  68112. * This is a special control allowing the reduction of the specular highlights coming from the
  68113. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  68114. */
  68115. specularIntensity: number;
  68116. /**
  68117. * Defines the falloff type used in this material.
  68118. * It by default is Physical.
  68119. */
  68120. lightFalloff: number;
  68121. /**
  68122. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  68123. */
  68124. useAlphaFromAlbedoTexture: boolean;
  68125. /**
  68126. * Specifies that alpha test should be used
  68127. */
  68128. useAlphaTest: boolean;
  68129. /**
  68130. * Defines the alpha limits in alpha test mode.
  68131. */
  68132. alphaTestCutoff: number;
  68133. /**
  68134. * Specifies that alpha blending should be used
  68135. */
  68136. useAlphaBlending: boolean;
  68137. /**
  68138. * Defines if the alpha value should be determined via the rgb values.
  68139. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  68140. */
  68141. opacityRGB: boolean;
  68142. /**
  68143. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  68144. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  68145. */
  68146. useRadianceOverAlpha: boolean;
  68147. /**
  68148. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  68149. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  68150. */
  68151. useSpecularOverAlpha: boolean;
  68152. /**
  68153. * Enables specular anti aliasing in the PBR shader.
  68154. * It will both interacts on the Geometry for analytical and IBL lighting.
  68155. * It also prefilter the roughness map based on the bump values.
  68156. */
  68157. enableSpecularAntiAliasing: boolean;
  68158. /**
  68159. * Enables realtime filtering on the texture.
  68160. */
  68161. realTimeFiltering: boolean;
  68162. /**
  68163. * Quality switch for realtime filtering
  68164. */
  68165. realTimeFilteringQuality: number;
  68166. /**
  68167. * Defines if the material uses energy conservation.
  68168. */
  68169. useEnergyConservation: boolean;
  68170. /**
  68171. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  68172. * too much the area relying on ambient texture to define their ambient occlusion.
  68173. */
  68174. useRadianceOcclusion: boolean;
  68175. /**
  68176. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  68177. * makes the reflect vector face the model (under horizon).
  68178. */
  68179. useHorizonOcclusion: boolean;
  68180. /**
  68181. * If set to true, no lighting calculations will be applied.
  68182. */
  68183. unlit: boolean;
  68184. /**
  68185. * Force normal to face away from face.
  68186. */
  68187. forceNormalForward: boolean;
  68188. /**
  68189. * Defines the material debug mode.
  68190. * It helps seeing only some components of the material while troubleshooting.
  68191. */
  68192. debugMode: number;
  68193. /**
  68194. * Specify from where on screen the debug mode should start.
  68195. * The value goes from -1 (full screen) to 1 (not visible)
  68196. * It helps with side by side comparison against the final render
  68197. * This defaults to 0
  68198. */
  68199. debugLimit: number;
  68200. /**
  68201. * As the default viewing range might not be enough (if the ambient is really small for instance)
  68202. * You can use the factor to better multiply the final value.
  68203. */
  68204. debugFactor: number;
  68205. /**
  68206. * Initialize the block and prepare the context for build
  68207. * @param state defines the state that will be used for the build
  68208. */
  68209. initialize(state: NodeMaterialBuildState): void;
  68210. /**
  68211. * Gets the current class name
  68212. * @returns the class name
  68213. */
  68214. getClassName(): string;
  68215. /**
  68216. * Gets the world position input component
  68217. */
  68218. get worldPosition(): NodeMaterialConnectionPoint;
  68219. /**
  68220. * Gets the world normal input component
  68221. */
  68222. get worldNormal(): NodeMaterialConnectionPoint;
  68223. /**
  68224. * Gets the perturbed normal input component
  68225. */
  68226. get perturbedNormal(): NodeMaterialConnectionPoint;
  68227. /**
  68228. * Gets the camera position input component
  68229. */
  68230. get cameraPosition(): NodeMaterialConnectionPoint;
  68231. /**
  68232. * Gets the base color input component
  68233. */
  68234. get baseColor(): NodeMaterialConnectionPoint;
  68235. /**
  68236. * Gets the opacity texture input component
  68237. */
  68238. get opacityTexture(): NodeMaterialConnectionPoint;
  68239. /**
  68240. * Gets the ambient color input component
  68241. */
  68242. get ambientColor(): NodeMaterialConnectionPoint;
  68243. /**
  68244. * Gets the reflectivity object parameters
  68245. */
  68246. get reflectivity(): NodeMaterialConnectionPoint;
  68247. /**
  68248. * Gets the ambient occlusion object parameters
  68249. */
  68250. get ambientOcclusion(): NodeMaterialConnectionPoint;
  68251. /**
  68252. * Gets the reflection object parameters
  68253. */
  68254. get reflection(): NodeMaterialConnectionPoint;
  68255. /**
  68256. * Gets the sheen object parameters
  68257. */
  68258. get sheen(): NodeMaterialConnectionPoint;
  68259. /**
  68260. * Gets the clear coat object parameters
  68261. */
  68262. get clearcoat(): NodeMaterialConnectionPoint;
  68263. /**
  68264. * Gets the sub surface object parameters
  68265. */
  68266. get subsurface(): NodeMaterialConnectionPoint;
  68267. /**
  68268. * Gets the anisotropy object parameters
  68269. */
  68270. get anisotropy(): NodeMaterialConnectionPoint;
  68271. /**
  68272. * Gets the ambient output component
  68273. */
  68274. get ambient(): NodeMaterialConnectionPoint;
  68275. /**
  68276. * Gets the diffuse output component
  68277. */
  68278. get diffuse(): NodeMaterialConnectionPoint;
  68279. /**
  68280. * Gets the specular output component
  68281. */
  68282. get specular(): NodeMaterialConnectionPoint;
  68283. /**
  68284. * Gets the sheen output component
  68285. */
  68286. get sheenDir(): NodeMaterialConnectionPoint;
  68287. /**
  68288. * Gets the clear coat output component
  68289. */
  68290. get clearcoatDir(): NodeMaterialConnectionPoint;
  68291. /**
  68292. * Gets the indirect diffuse output component
  68293. */
  68294. get diffuseIndirect(): NodeMaterialConnectionPoint;
  68295. /**
  68296. * Gets the indirect specular output component
  68297. */
  68298. get specularIndirect(): NodeMaterialConnectionPoint;
  68299. /**
  68300. * Gets the indirect sheen output component
  68301. */
  68302. get sheenIndirect(): NodeMaterialConnectionPoint;
  68303. /**
  68304. * Gets the indirect clear coat output component
  68305. */
  68306. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  68307. /**
  68308. * Gets the refraction output component
  68309. */
  68310. get refraction(): NodeMaterialConnectionPoint;
  68311. /**
  68312. * Gets the global lighting output component
  68313. */
  68314. get lighting(): NodeMaterialConnectionPoint;
  68315. /**
  68316. * Gets the shadow output component
  68317. */
  68318. get shadow(): NodeMaterialConnectionPoint;
  68319. /**
  68320. * Gets the alpha output component
  68321. */
  68322. get alpha(): NodeMaterialConnectionPoint;
  68323. autoConfigure(material: NodeMaterial): void;
  68324. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68325. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  68326. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68327. private _injectVertexCode;
  68328. /**
  68329. * Gets the code corresponding to the albedo/opacity module
  68330. * @returns the shader code
  68331. */
  68332. getAlbedoOpacityCode(): string;
  68333. protected _buildBlock(state: NodeMaterialBuildState): this;
  68334. protected _dumpPropertiesCode(): string;
  68335. serialize(): any;
  68336. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68337. }
  68338. }
  68339. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  68340. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  68341. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  68342. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  68343. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  68344. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  68345. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68346. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  68347. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  68348. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  68349. }
  68350. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  68351. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  68352. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  68353. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  68354. }
  68355. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  68356. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68357. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68358. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68359. /**
  68360. * Block used to compute value of one parameter modulo another
  68361. */
  68362. export class ModBlock extends NodeMaterialBlock {
  68363. /**
  68364. * Creates a new ModBlock
  68365. * @param name defines the block name
  68366. */
  68367. constructor(name: string);
  68368. /**
  68369. * Gets the current class name
  68370. * @returns the class name
  68371. */
  68372. getClassName(): string;
  68373. /**
  68374. * Gets the left operand input component
  68375. */
  68376. get left(): NodeMaterialConnectionPoint;
  68377. /**
  68378. * Gets the right operand input component
  68379. */
  68380. get right(): NodeMaterialConnectionPoint;
  68381. /**
  68382. * Gets the output component
  68383. */
  68384. get output(): NodeMaterialConnectionPoint;
  68385. protected _buildBlock(state: NodeMaterialBuildState): this;
  68386. }
  68387. }
  68388. declare module "babylonjs/Materials/Node/Blocks/index" {
  68389. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  68390. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  68391. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  68392. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  68393. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  68394. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  68395. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  68396. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  68397. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  68398. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  68399. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  68400. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  68401. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  68402. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  68403. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  68404. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  68405. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  68406. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  68407. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  68408. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  68409. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  68410. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  68411. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  68412. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  68413. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  68414. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  68415. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  68416. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  68417. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  68418. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  68419. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  68420. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  68421. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  68422. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  68423. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  68424. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  68425. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  68426. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  68427. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  68428. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  68429. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  68430. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  68431. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  68432. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  68433. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  68434. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  68435. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  68436. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  68437. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  68438. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  68439. }
  68440. declare module "babylonjs/Materials/Node/Optimizers/index" {
  68441. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  68442. }
  68443. declare module "babylonjs/Materials/Node/index" {
  68444. export * from "babylonjs/Materials/Node/Enums/index";
  68445. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68446. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  68447. export * from "babylonjs/Materials/Node/nodeMaterial";
  68448. export * from "babylonjs/Materials/Node/Blocks/index";
  68449. export * from "babylonjs/Materials/Node/Optimizers/index";
  68450. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  68451. }
  68452. declare module "babylonjs/Materials/index" {
  68453. export * from "babylonjs/Materials/Background/index";
  68454. export * from "babylonjs/Materials/colorCurves";
  68455. export * from "babylonjs/Materials/iEffectFallbacks";
  68456. export * from "babylonjs/Materials/effectFallbacks";
  68457. export * from "babylonjs/Materials/effect";
  68458. export * from "babylonjs/Materials/fresnelParameters";
  68459. export * from "babylonjs/Materials/imageProcessingConfiguration";
  68460. export * from "babylonjs/Materials/material";
  68461. export * from "babylonjs/Materials/materialDefines";
  68462. export * from "babylonjs/Materials/thinMaterialHelper";
  68463. export * from "babylonjs/Materials/materialHelper";
  68464. export * from "babylonjs/Materials/multiMaterial";
  68465. export * from "babylonjs/Materials/PBR/index";
  68466. export * from "babylonjs/Materials/pushMaterial";
  68467. export * from "babylonjs/Materials/shaderMaterial";
  68468. export * from "babylonjs/Materials/standardMaterial";
  68469. export * from "babylonjs/Materials/Textures/index";
  68470. export * from "babylonjs/Materials/uniformBuffer";
  68471. export * from "babylonjs/Materials/materialFlags";
  68472. export * from "babylonjs/Materials/Node/index";
  68473. export * from "babylonjs/Materials/effectRenderer";
  68474. export * from "babylonjs/Materials/shadowDepthWrapper";
  68475. }
  68476. declare module "babylonjs/Maths/index" {
  68477. export * from "babylonjs/Maths/math.scalar";
  68478. export * from "babylonjs/Maths/math";
  68479. export * from "babylonjs/Maths/sphericalPolynomial";
  68480. }
  68481. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  68482. import { IDisposable } from "babylonjs/scene";
  68483. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68484. /**
  68485. * Configuration for Draco compression
  68486. */
  68487. export interface IDracoCompressionConfiguration {
  68488. /**
  68489. * Configuration for the decoder.
  68490. */
  68491. decoder: {
  68492. /**
  68493. * The url to the WebAssembly module.
  68494. */
  68495. wasmUrl?: string;
  68496. /**
  68497. * The url to the WebAssembly binary.
  68498. */
  68499. wasmBinaryUrl?: string;
  68500. /**
  68501. * The url to the fallback JavaScript module.
  68502. */
  68503. fallbackUrl?: string;
  68504. };
  68505. }
  68506. /**
  68507. * Draco compression (https://google.github.io/draco/)
  68508. *
  68509. * This class wraps the Draco module.
  68510. *
  68511. * **Encoder**
  68512. *
  68513. * The encoder is not currently implemented.
  68514. *
  68515. * **Decoder**
  68516. *
  68517. * 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.
  68518. *
  68519. * To update the configuration, use the following code:
  68520. * ```javascript
  68521. * DracoCompression.Configuration = {
  68522. * decoder: {
  68523. * wasmUrl: "<url to the WebAssembly library>",
  68524. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  68525. * fallbackUrl: "<url to the fallback JavaScript library>",
  68526. * }
  68527. * };
  68528. * ```
  68529. *
  68530. * 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.
  68531. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  68532. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  68533. *
  68534. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  68535. * ```javascript
  68536. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  68537. * ```
  68538. *
  68539. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  68540. */
  68541. export class DracoCompression implements IDisposable {
  68542. private _workerPoolPromise?;
  68543. private _decoderModulePromise?;
  68544. /**
  68545. * The configuration. Defaults to the following urls:
  68546. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  68547. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  68548. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  68549. */
  68550. static Configuration: IDracoCompressionConfiguration;
  68551. /**
  68552. * Returns true if the decoder configuration is available.
  68553. */
  68554. static get DecoderAvailable(): boolean;
  68555. /**
  68556. * Default number of workers to create when creating the draco compression object.
  68557. */
  68558. static DefaultNumWorkers: number;
  68559. private static GetDefaultNumWorkers;
  68560. private static _Default;
  68561. /**
  68562. * Default instance for the draco compression object.
  68563. */
  68564. static get Default(): DracoCompression;
  68565. /**
  68566. * Constructor
  68567. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  68568. */
  68569. constructor(numWorkers?: number);
  68570. /**
  68571. * Stop all async operations and release resources.
  68572. */
  68573. dispose(): void;
  68574. /**
  68575. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  68576. * @returns a promise that resolves when ready
  68577. */
  68578. whenReadyAsync(): Promise<void>;
  68579. /**
  68580. * Decode Draco compressed mesh data to vertex data.
  68581. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  68582. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  68583. * @returns A promise that resolves with the decoded vertex data
  68584. */
  68585. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  68586. [kind: string]: number;
  68587. }): Promise<VertexData>;
  68588. }
  68589. }
  68590. declare module "babylonjs/Meshes/Compression/index" {
  68591. export * from "babylonjs/Meshes/Compression/dracoCompression";
  68592. }
  68593. declare module "babylonjs/Meshes/csg" {
  68594. import { Nullable } from "babylonjs/types";
  68595. import { Scene } from "babylonjs/scene";
  68596. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  68597. import { Mesh } from "babylonjs/Meshes/mesh";
  68598. import { Material } from "babylonjs/Materials/material";
  68599. /**
  68600. * Class for building Constructive Solid Geometry
  68601. */
  68602. export class CSG {
  68603. private polygons;
  68604. /**
  68605. * The world matrix
  68606. */
  68607. matrix: Matrix;
  68608. /**
  68609. * Stores the position
  68610. */
  68611. position: Vector3;
  68612. /**
  68613. * Stores the rotation
  68614. */
  68615. rotation: Vector3;
  68616. /**
  68617. * Stores the rotation quaternion
  68618. */
  68619. rotationQuaternion: Nullable<Quaternion>;
  68620. /**
  68621. * Stores the scaling vector
  68622. */
  68623. scaling: Vector3;
  68624. /**
  68625. * Convert the Mesh to CSG
  68626. * @param mesh The Mesh to convert to CSG
  68627. * @returns A new CSG from the Mesh
  68628. */
  68629. static FromMesh(mesh: Mesh): CSG;
  68630. /**
  68631. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  68632. * @param polygons Polygons used to construct a CSG solid
  68633. */
  68634. private static FromPolygons;
  68635. /**
  68636. * Clones, or makes a deep copy, of the CSG
  68637. * @returns A new CSG
  68638. */
  68639. clone(): CSG;
  68640. /**
  68641. * Unions this CSG with another CSG
  68642. * @param csg The CSG to union against this CSG
  68643. * @returns The unioned CSG
  68644. */
  68645. union(csg: CSG): CSG;
  68646. /**
  68647. * Unions this CSG with another CSG in place
  68648. * @param csg The CSG to union against this CSG
  68649. */
  68650. unionInPlace(csg: CSG): void;
  68651. /**
  68652. * Subtracts this CSG with another CSG
  68653. * @param csg The CSG to subtract against this CSG
  68654. * @returns A new CSG
  68655. */
  68656. subtract(csg: CSG): CSG;
  68657. /**
  68658. * Subtracts this CSG with another CSG in place
  68659. * @param csg The CSG to subtact against this CSG
  68660. */
  68661. subtractInPlace(csg: CSG): void;
  68662. /**
  68663. * Intersect this CSG with another CSG
  68664. * @param csg The CSG to intersect against this CSG
  68665. * @returns A new CSG
  68666. */
  68667. intersect(csg: CSG): CSG;
  68668. /**
  68669. * Intersects this CSG with another CSG in place
  68670. * @param csg The CSG to intersect against this CSG
  68671. */
  68672. intersectInPlace(csg: CSG): void;
  68673. /**
  68674. * Return a new CSG solid with solid and empty space switched. This solid is
  68675. * not modified.
  68676. * @returns A new CSG solid with solid and empty space switched
  68677. */
  68678. inverse(): CSG;
  68679. /**
  68680. * Inverses the CSG in place
  68681. */
  68682. inverseInPlace(): void;
  68683. /**
  68684. * This is used to keep meshes transformations so they can be restored
  68685. * when we build back a Babylon Mesh
  68686. * NB : All CSG operations are performed in world coordinates
  68687. * @param csg The CSG to copy the transform attributes from
  68688. * @returns This CSG
  68689. */
  68690. copyTransformAttributes(csg: CSG): CSG;
  68691. /**
  68692. * Build Raw mesh from CSG
  68693. * Coordinates here are in world space
  68694. * @param name The name of the mesh geometry
  68695. * @param scene The Scene
  68696. * @param keepSubMeshes Specifies if the submeshes should be kept
  68697. * @returns A new Mesh
  68698. */
  68699. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68700. /**
  68701. * Build Mesh from CSG taking material and transforms into account
  68702. * @param name The name of the Mesh
  68703. * @param material The material of the Mesh
  68704. * @param scene The Scene
  68705. * @param keepSubMeshes Specifies if submeshes should be kept
  68706. * @returns The new Mesh
  68707. */
  68708. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68709. }
  68710. }
  68711. declare module "babylonjs/Meshes/trailMesh" {
  68712. import { Mesh } from "babylonjs/Meshes/mesh";
  68713. import { Scene } from "babylonjs/scene";
  68714. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68715. /**
  68716. * Class used to create a trail following a mesh
  68717. */
  68718. export class TrailMesh extends Mesh {
  68719. private _generator;
  68720. private _autoStart;
  68721. private _running;
  68722. private _diameter;
  68723. private _length;
  68724. private _sectionPolygonPointsCount;
  68725. private _sectionVectors;
  68726. private _sectionNormalVectors;
  68727. private _beforeRenderObserver;
  68728. /**
  68729. * @constructor
  68730. * @param name The value used by scene.getMeshByName() to do a lookup.
  68731. * @param generator The mesh or transform node to generate a trail.
  68732. * @param scene The scene to add this mesh to.
  68733. * @param diameter Diameter of trailing mesh. Default is 1.
  68734. * @param length Length of trailing mesh. Default is 60.
  68735. * @param autoStart Automatically start trailing mesh. Default true.
  68736. */
  68737. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  68738. /**
  68739. * "TrailMesh"
  68740. * @returns "TrailMesh"
  68741. */
  68742. getClassName(): string;
  68743. private _createMesh;
  68744. /**
  68745. * Start trailing mesh.
  68746. */
  68747. start(): void;
  68748. /**
  68749. * Stop trailing mesh.
  68750. */
  68751. stop(): void;
  68752. /**
  68753. * Update trailing mesh geometry.
  68754. */
  68755. update(): void;
  68756. /**
  68757. * Returns a new TrailMesh object.
  68758. * @param name is a string, the name given to the new mesh
  68759. * @param newGenerator use new generator object for cloned trail mesh
  68760. * @returns a new mesh
  68761. */
  68762. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  68763. /**
  68764. * Serializes this trail mesh
  68765. * @param serializationObject object to write serialization to
  68766. */
  68767. serialize(serializationObject: any): void;
  68768. /**
  68769. * Parses a serialized trail mesh
  68770. * @param parsedMesh the serialized mesh
  68771. * @param scene the scene to create the trail mesh in
  68772. * @returns the created trail mesh
  68773. */
  68774. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  68775. }
  68776. }
  68777. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  68778. import { Nullable } from "babylonjs/types";
  68779. import { Scene } from "babylonjs/scene";
  68780. import { Vector4 } from "babylonjs/Maths/math.vector";
  68781. import { Color4 } from "babylonjs/Maths/math.color";
  68782. import { Mesh } from "babylonjs/Meshes/mesh";
  68783. /**
  68784. * Class containing static functions to help procedurally build meshes
  68785. */
  68786. export class TiledBoxBuilder {
  68787. /**
  68788. * Creates a box mesh
  68789. * 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)
  68790. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68791. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68792. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68794. * @param name defines the name of the mesh
  68795. * @param options defines the options used to create the mesh
  68796. * @param scene defines the hosting scene
  68797. * @returns the box mesh
  68798. */
  68799. static CreateTiledBox(name: string, options: {
  68800. pattern?: number;
  68801. width?: number;
  68802. height?: number;
  68803. depth?: number;
  68804. tileSize?: number;
  68805. tileWidth?: number;
  68806. tileHeight?: number;
  68807. alignHorizontal?: number;
  68808. alignVertical?: number;
  68809. faceUV?: Vector4[];
  68810. faceColors?: Color4[];
  68811. sideOrientation?: number;
  68812. updatable?: boolean;
  68813. }, scene?: Nullable<Scene>): Mesh;
  68814. }
  68815. }
  68816. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  68817. import { Vector4 } from "babylonjs/Maths/math.vector";
  68818. import { Mesh } from "babylonjs/Meshes/mesh";
  68819. /**
  68820. * Class containing static functions to help procedurally build meshes
  68821. */
  68822. export class TorusKnotBuilder {
  68823. /**
  68824. * Creates a torus knot mesh
  68825. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68826. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68827. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68828. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68829. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68830. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68832. * @param name defines the name of the mesh
  68833. * @param options defines the options used to create the mesh
  68834. * @param scene defines the hosting scene
  68835. * @returns the torus knot mesh
  68836. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68837. */
  68838. static CreateTorusKnot(name: string, options: {
  68839. radius?: number;
  68840. tube?: number;
  68841. radialSegments?: number;
  68842. tubularSegments?: number;
  68843. p?: number;
  68844. q?: number;
  68845. updatable?: boolean;
  68846. sideOrientation?: number;
  68847. frontUVs?: Vector4;
  68848. backUVs?: Vector4;
  68849. }, scene: any): Mesh;
  68850. }
  68851. }
  68852. declare module "babylonjs/Meshes/polygonMesh" {
  68853. import { Scene } from "babylonjs/scene";
  68854. import { Vector2 } from "babylonjs/Maths/math.vector";
  68855. import { Mesh } from "babylonjs/Meshes/mesh";
  68856. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68857. import { Path2 } from "babylonjs/Maths/math.path";
  68858. /**
  68859. * Polygon
  68860. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  68861. */
  68862. export class Polygon {
  68863. /**
  68864. * Creates a rectangle
  68865. * @param xmin bottom X coord
  68866. * @param ymin bottom Y coord
  68867. * @param xmax top X coord
  68868. * @param ymax top Y coord
  68869. * @returns points that make the resulting rectation
  68870. */
  68871. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  68872. /**
  68873. * Creates a circle
  68874. * @param radius radius of circle
  68875. * @param cx scale in x
  68876. * @param cy scale in y
  68877. * @param numberOfSides number of sides that make up the circle
  68878. * @returns points that make the resulting circle
  68879. */
  68880. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  68881. /**
  68882. * Creates a polygon from input string
  68883. * @param input Input polygon data
  68884. * @returns the parsed points
  68885. */
  68886. static Parse(input: string): Vector2[];
  68887. /**
  68888. * Starts building a polygon from x and y coordinates
  68889. * @param x x coordinate
  68890. * @param y y coordinate
  68891. * @returns the started path2
  68892. */
  68893. static StartingAt(x: number, y: number): Path2;
  68894. }
  68895. /**
  68896. * Builds a polygon
  68897. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  68898. */
  68899. export class PolygonMeshBuilder {
  68900. private _points;
  68901. private _outlinepoints;
  68902. private _holes;
  68903. private _name;
  68904. private _scene;
  68905. private _epoints;
  68906. private _eholes;
  68907. private _addToepoint;
  68908. /**
  68909. * Babylon reference to the earcut plugin.
  68910. */
  68911. bjsEarcut: any;
  68912. /**
  68913. * Creates a PolygonMeshBuilder
  68914. * @param name name of the builder
  68915. * @param contours Path of the polygon
  68916. * @param scene scene to add to when creating the mesh
  68917. * @param earcutInjection can be used to inject your own earcut reference
  68918. */
  68919. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  68920. /**
  68921. * Adds a whole within the polygon
  68922. * @param hole Array of points defining the hole
  68923. * @returns this
  68924. */
  68925. addHole(hole: Vector2[]): PolygonMeshBuilder;
  68926. /**
  68927. * Creates the polygon
  68928. * @param updatable If the mesh should be updatable
  68929. * @param depth The depth of the mesh created
  68930. * @returns the created mesh
  68931. */
  68932. build(updatable?: boolean, depth?: number): Mesh;
  68933. /**
  68934. * Creates the polygon
  68935. * @param depth The depth of the mesh created
  68936. * @returns the created VertexData
  68937. */
  68938. buildVertexData(depth?: number): VertexData;
  68939. /**
  68940. * Adds a side to the polygon
  68941. * @param positions points that make the polygon
  68942. * @param normals normals of the polygon
  68943. * @param uvs uvs of the polygon
  68944. * @param indices indices of the polygon
  68945. * @param bounds bounds of the polygon
  68946. * @param points points of the polygon
  68947. * @param depth depth of the polygon
  68948. * @param flip flip of the polygon
  68949. */
  68950. private addSide;
  68951. }
  68952. }
  68953. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  68954. import { Scene } from "babylonjs/scene";
  68955. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68956. import { Color4 } from "babylonjs/Maths/math.color";
  68957. import { Mesh } from "babylonjs/Meshes/mesh";
  68958. import { Nullable } from "babylonjs/types";
  68959. /**
  68960. * Class containing static functions to help procedurally build meshes
  68961. */
  68962. export class PolygonBuilder {
  68963. /**
  68964. * Creates a polygon mesh
  68965. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  68966. * * 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
  68967. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68969. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  68970. * * Remember you can only change the shape positions, not their number when updating a polygon
  68971. * @param name defines the name of the mesh
  68972. * @param options defines the options used to create the mesh
  68973. * @param scene defines the hosting scene
  68974. * @param earcutInjection can be used to inject your own earcut reference
  68975. * @returns the polygon mesh
  68976. */
  68977. static CreatePolygon(name: string, options: {
  68978. shape: Vector3[];
  68979. holes?: Vector3[][];
  68980. depth?: number;
  68981. faceUV?: Vector4[];
  68982. faceColors?: Color4[];
  68983. updatable?: boolean;
  68984. sideOrientation?: number;
  68985. frontUVs?: Vector4;
  68986. backUVs?: Vector4;
  68987. wrap?: boolean;
  68988. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68989. /**
  68990. * Creates an extruded polygon mesh, with depth in the Y direction.
  68991. * * 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)
  68992. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68993. * @param name defines the name of the mesh
  68994. * @param options defines the options used to create the mesh
  68995. * @param scene defines the hosting scene
  68996. * @param earcutInjection can be used to inject your own earcut reference
  68997. * @returns the polygon mesh
  68998. */
  68999. static ExtrudePolygon(name: string, options: {
  69000. shape: Vector3[];
  69001. holes?: Vector3[][];
  69002. depth?: number;
  69003. faceUV?: Vector4[];
  69004. faceColors?: Color4[];
  69005. updatable?: boolean;
  69006. sideOrientation?: number;
  69007. frontUVs?: Vector4;
  69008. backUVs?: Vector4;
  69009. wrap?: boolean;
  69010. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69011. }
  69012. }
  69013. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  69014. import { Scene } from "babylonjs/scene";
  69015. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69016. import { Mesh } from "babylonjs/Meshes/mesh";
  69017. import { Nullable } from "babylonjs/types";
  69018. /**
  69019. * Class containing static functions to help procedurally build meshes
  69020. */
  69021. export class LatheBuilder {
  69022. /**
  69023. * Creates lathe mesh.
  69024. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69025. * * 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
  69026. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69027. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69028. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69029. * * 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
  69030. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69031. * * 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
  69032. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69033. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69034. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69036. * @param name defines the name of the mesh
  69037. * @param options defines the options used to create the mesh
  69038. * @param scene defines the hosting scene
  69039. * @returns the lathe mesh
  69040. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69041. */
  69042. static CreateLathe(name: string, options: {
  69043. shape: Vector3[];
  69044. radius?: number;
  69045. tessellation?: number;
  69046. clip?: number;
  69047. arc?: number;
  69048. closed?: boolean;
  69049. updatable?: boolean;
  69050. sideOrientation?: number;
  69051. frontUVs?: Vector4;
  69052. backUVs?: Vector4;
  69053. cap?: number;
  69054. invertUV?: boolean;
  69055. }, scene?: Nullable<Scene>): Mesh;
  69056. }
  69057. }
  69058. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  69059. import { Nullable } from "babylonjs/types";
  69060. import { Scene } from "babylonjs/scene";
  69061. import { Vector4 } from "babylonjs/Maths/math.vector";
  69062. import { Mesh } from "babylonjs/Meshes/mesh";
  69063. /**
  69064. * Class containing static functions to help procedurally build meshes
  69065. */
  69066. export class TiledPlaneBuilder {
  69067. /**
  69068. * Creates a tiled plane mesh
  69069. * * The parameter `pattern` will, depending on value, do nothing or
  69070. * * * flip (reflect about central vertical) alternate tiles across and up
  69071. * * * flip every tile on alternate rows
  69072. * * * rotate (180 degs) alternate tiles across and up
  69073. * * * rotate every tile on alternate rows
  69074. * * * flip and rotate alternate tiles across and up
  69075. * * * flip and rotate every tile on alternate rows
  69076. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69077. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69078. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69079. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69080. * * 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)
  69081. * * 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)
  69082. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69083. * @param name defines the name of the mesh
  69084. * @param options defines the options used to create the mesh
  69085. * @param scene defines the hosting scene
  69086. * @returns the box mesh
  69087. */
  69088. static CreateTiledPlane(name: string, options: {
  69089. pattern?: number;
  69090. tileSize?: number;
  69091. tileWidth?: number;
  69092. tileHeight?: number;
  69093. size?: number;
  69094. width?: number;
  69095. height?: number;
  69096. alignHorizontal?: number;
  69097. alignVertical?: number;
  69098. sideOrientation?: number;
  69099. frontUVs?: Vector4;
  69100. backUVs?: Vector4;
  69101. updatable?: boolean;
  69102. }, scene?: Nullable<Scene>): Mesh;
  69103. }
  69104. }
  69105. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  69106. import { Nullable } from "babylonjs/types";
  69107. import { Scene } from "babylonjs/scene";
  69108. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69109. import { Mesh } from "babylonjs/Meshes/mesh";
  69110. /**
  69111. * Class containing static functions to help procedurally build meshes
  69112. */
  69113. export class TubeBuilder {
  69114. /**
  69115. * Creates a tube mesh.
  69116. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69117. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69118. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69119. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69120. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69121. * * 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)
  69122. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69123. * * 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
  69124. * * 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
  69125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69126. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69127. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69129. * @param name defines the name of the mesh
  69130. * @param options defines the options used to create the mesh
  69131. * @param scene defines the hosting scene
  69132. * @returns the tube mesh
  69133. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69134. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69135. */
  69136. static CreateTube(name: string, options: {
  69137. path: Vector3[];
  69138. radius?: number;
  69139. tessellation?: number;
  69140. radiusFunction?: {
  69141. (i: number, distance: number): number;
  69142. };
  69143. cap?: number;
  69144. arc?: number;
  69145. updatable?: boolean;
  69146. sideOrientation?: number;
  69147. frontUVs?: Vector4;
  69148. backUVs?: Vector4;
  69149. instance?: Mesh;
  69150. invertUV?: boolean;
  69151. }, scene?: Nullable<Scene>): Mesh;
  69152. }
  69153. }
  69154. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  69155. import { Scene } from "babylonjs/scene";
  69156. import { Vector4 } from "babylonjs/Maths/math.vector";
  69157. import { Mesh } from "babylonjs/Meshes/mesh";
  69158. import { Nullable } from "babylonjs/types";
  69159. /**
  69160. * Class containing static functions to help procedurally build meshes
  69161. */
  69162. export class IcoSphereBuilder {
  69163. /**
  69164. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69165. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69166. * * 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`)
  69167. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69168. * * 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
  69169. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69170. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69172. * @param name defines the name of the mesh
  69173. * @param options defines the options used to create the mesh
  69174. * @param scene defines the hosting scene
  69175. * @returns the icosahedron mesh
  69176. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69177. */
  69178. static CreateIcoSphere(name: string, options: {
  69179. radius?: number;
  69180. radiusX?: number;
  69181. radiusY?: number;
  69182. radiusZ?: number;
  69183. flat?: boolean;
  69184. subdivisions?: number;
  69185. sideOrientation?: number;
  69186. frontUVs?: Vector4;
  69187. backUVs?: Vector4;
  69188. updatable?: boolean;
  69189. }, scene?: Nullable<Scene>): Mesh;
  69190. }
  69191. }
  69192. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  69193. import { Vector3 } from "babylonjs/Maths/math.vector";
  69194. import { Mesh } from "babylonjs/Meshes/mesh";
  69195. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69196. /**
  69197. * Class containing static functions to help procedurally build meshes
  69198. */
  69199. export class DecalBuilder {
  69200. /**
  69201. * Creates a decal mesh.
  69202. * 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
  69203. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69204. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69205. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69206. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69207. * @param name defines the name of the mesh
  69208. * @param sourceMesh defines the mesh where the decal must be applied
  69209. * @param options defines the options used to create the mesh
  69210. * @param scene defines the hosting scene
  69211. * @returns the decal mesh
  69212. * @see https://doc.babylonjs.com/how_to/decals
  69213. */
  69214. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69215. position?: Vector3;
  69216. normal?: Vector3;
  69217. size?: Vector3;
  69218. angle?: number;
  69219. }): Mesh;
  69220. }
  69221. }
  69222. declare module "babylonjs/Meshes/meshBuilder" {
  69223. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  69224. import { Nullable } from "babylonjs/types";
  69225. import { Scene } from "babylonjs/scene";
  69226. import { Mesh } from "babylonjs/Meshes/mesh";
  69227. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  69228. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  69229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69230. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69231. import { Plane } from "babylonjs/Maths/math.plane";
  69232. /**
  69233. * Class containing static functions to help procedurally build meshes
  69234. */
  69235. export class MeshBuilder {
  69236. /**
  69237. * Creates a box mesh
  69238. * * The parameter `size` sets the size (float) of each box side (default 1)
  69239. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  69240. * * 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)
  69241. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69242. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69243. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69245. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69246. * @param name defines the name of the mesh
  69247. * @param options defines the options used to create the mesh
  69248. * @param scene defines the hosting scene
  69249. * @returns the box mesh
  69250. */
  69251. static CreateBox(name: string, options: {
  69252. size?: number;
  69253. width?: number;
  69254. height?: number;
  69255. depth?: number;
  69256. faceUV?: Vector4[];
  69257. faceColors?: Color4[];
  69258. sideOrientation?: number;
  69259. frontUVs?: Vector4;
  69260. backUVs?: Vector4;
  69261. wrap?: boolean;
  69262. topBaseAt?: number;
  69263. bottomBaseAt?: number;
  69264. updatable?: boolean;
  69265. }, scene?: Nullable<Scene>): Mesh;
  69266. /**
  69267. * Creates a tiled box mesh
  69268. * * faceTiles sets the pattern, tile size and number of tiles for a face
  69269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69270. * @param name defines the name of the mesh
  69271. * @param options defines the options used to create the mesh
  69272. * @param scene defines the hosting scene
  69273. * @returns the tiled box mesh
  69274. */
  69275. static CreateTiledBox(name: string, options: {
  69276. pattern?: number;
  69277. size?: number;
  69278. width?: number;
  69279. height?: number;
  69280. depth: number;
  69281. tileSize?: number;
  69282. tileWidth?: number;
  69283. tileHeight?: number;
  69284. faceUV?: Vector4[];
  69285. faceColors?: Color4[];
  69286. alignHorizontal?: number;
  69287. alignVertical?: number;
  69288. sideOrientation?: number;
  69289. updatable?: boolean;
  69290. }, scene?: Nullable<Scene>): Mesh;
  69291. /**
  69292. * Creates a sphere mesh
  69293. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  69294. * * 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`)
  69295. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  69296. * * 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
  69297. * * 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)
  69298. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69299. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69301. * @param name defines the name of the mesh
  69302. * @param options defines the options used to create the mesh
  69303. * @param scene defines the hosting scene
  69304. * @returns the sphere mesh
  69305. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  69306. */
  69307. static CreateSphere(name: string, options: {
  69308. segments?: number;
  69309. diameter?: number;
  69310. diameterX?: number;
  69311. diameterY?: number;
  69312. diameterZ?: number;
  69313. arc?: number;
  69314. slice?: number;
  69315. sideOrientation?: number;
  69316. frontUVs?: Vector4;
  69317. backUVs?: Vector4;
  69318. updatable?: boolean;
  69319. }, scene?: Nullable<Scene>): Mesh;
  69320. /**
  69321. * Creates a plane polygonal mesh. By default, this is a disc
  69322. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  69323. * * 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
  69324. * * 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
  69325. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69326. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69327. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69328. * @param name defines the name of the mesh
  69329. * @param options defines the options used to create the mesh
  69330. * @param scene defines the hosting scene
  69331. * @returns the plane polygonal mesh
  69332. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  69333. */
  69334. static CreateDisc(name: string, options: {
  69335. radius?: number;
  69336. tessellation?: number;
  69337. arc?: number;
  69338. updatable?: boolean;
  69339. sideOrientation?: number;
  69340. frontUVs?: Vector4;
  69341. backUVs?: Vector4;
  69342. }, scene?: Nullable<Scene>): Mesh;
  69343. /**
  69344. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69345. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69346. * * 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`)
  69347. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69348. * * 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
  69349. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69350. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69352. * @param name defines the name of the mesh
  69353. * @param options defines the options used to create the mesh
  69354. * @param scene defines the hosting scene
  69355. * @returns the icosahedron mesh
  69356. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69357. */
  69358. static CreateIcoSphere(name: string, options: {
  69359. radius?: number;
  69360. radiusX?: number;
  69361. radiusY?: number;
  69362. radiusZ?: number;
  69363. flat?: boolean;
  69364. subdivisions?: number;
  69365. sideOrientation?: number;
  69366. frontUVs?: Vector4;
  69367. backUVs?: Vector4;
  69368. updatable?: boolean;
  69369. }, scene?: Nullable<Scene>): Mesh;
  69370. /**
  69371. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69372. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  69373. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  69374. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  69375. * * 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
  69376. * * 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
  69377. * * 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
  69378. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69379. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69380. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69381. * * 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
  69382. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  69383. * * 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
  69384. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  69385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69386. * @param name defines the name of the mesh
  69387. * @param options defines the options used to create the mesh
  69388. * @param scene defines the hosting scene
  69389. * @returns the ribbon mesh
  69390. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  69391. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69392. */
  69393. static CreateRibbon(name: string, options: {
  69394. pathArray: Vector3[][];
  69395. closeArray?: boolean;
  69396. closePath?: boolean;
  69397. offset?: number;
  69398. updatable?: boolean;
  69399. sideOrientation?: number;
  69400. frontUVs?: Vector4;
  69401. backUVs?: Vector4;
  69402. instance?: Mesh;
  69403. invertUV?: boolean;
  69404. uvs?: Vector2[];
  69405. colors?: Color4[];
  69406. }, scene?: Nullable<Scene>): Mesh;
  69407. /**
  69408. * Creates a cylinder or a cone mesh
  69409. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  69410. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  69411. * * 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.
  69412. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  69413. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  69414. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  69415. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  69416. * * 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).
  69417. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  69418. * * 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).
  69419. * * 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
  69420. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  69421. * * 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
  69422. * * 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.
  69423. * * If `enclose` is false, a ring surface is one element.
  69424. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  69425. * * 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
  69426. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69427. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69429. * @param name defines the name of the mesh
  69430. * @param options defines the options used to create the mesh
  69431. * @param scene defines the hosting scene
  69432. * @returns the cylinder mesh
  69433. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  69434. */
  69435. static CreateCylinder(name: string, options: {
  69436. height?: number;
  69437. diameterTop?: number;
  69438. diameterBottom?: number;
  69439. diameter?: number;
  69440. tessellation?: number;
  69441. subdivisions?: number;
  69442. arc?: number;
  69443. faceColors?: Color4[];
  69444. faceUV?: Vector4[];
  69445. updatable?: boolean;
  69446. hasRings?: boolean;
  69447. enclose?: boolean;
  69448. cap?: number;
  69449. sideOrientation?: number;
  69450. frontUVs?: Vector4;
  69451. backUVs?: Vector4;
  69452. }, scene?: Nullable<Scene>): Mesh;
  69453. /**
  69454. * Creates a torus mesh
  69455. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  69456. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  69457. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  69458. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69459. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69461. * @param name defines the name of the mesh
  69462. * @param options defines the options used to create the mesh
  69463. * @param scene defines the hosting scene
  69464. * @returns the torus mesh
  69465. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  69466. */
  69467. static CreateTorus(name: string, options: {
  69468. diameter?: number;
  69469. thickness?: number;
  69470. tessellation?: number;
  69471. updatable?: boolean;
  69472. sideOrientation?: number;
  69473. frontUVs?: Vector4;
  69474. backUVs?: Vector4;
  69475. }, scene?: Nullable<Scene>): Mesh;
  69476. /**
  69477. * Creates a torus knot mesh
  69478. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69479. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69480. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69481. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69482. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69483. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69485. * @param name defines the name of the mesh
  69486. * @param options defines the options used to create the mesh
  69487. * @param scene defines the hosting scene
  69488. * @returns the torus knot mesh
  69489. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69490. */
  69491. static CreateTorusKnot(name: string, options: {
  69492. radius?: number;
  69493. tube?: number;
  69494. radialSegments?: number;
  69495. tubularSegments?: number;
  69496. p?: number;
  69497. q?: number;
  69498. updatable?: boolean;
  69499. sideOrientation?: number;
  69500. frontUVs?: Vector4;
  69501. backUVs?: Vector4;
  69502. }, scene?: Nullable<Scene>): Mesh;
  69503. /**
  69504. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  69505. * * 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
  69506. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  69507. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  69508. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  69509. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  69510. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  69511. * * 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
  69512. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  69513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69514. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  69515. * @param name defines the name of the new line system
  69516. * @param options defines the options used to create the line system
  69517. * @param scene defines the hosting scene
  69518. * @returns a new line system mesh
  69519. */
  69520. static CreateLineSystem(name: string, options: {
  69521. lines: Vector3[][];
  69522. updatable?: boolean;
  69523. instance?: Nullable<LinesMesh>;
  69524. colors?: Nullable<Color4[][]>;
  69525. useVertexAlpha?: boolean;
  69526. }, scene: Nullable<Scene>): LinesMesh;
  69527. /**
  69528. * Creates a line mesh
  69529. * 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
  69530. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69531. * * The parameter `points` is an array successive Vector3
  69532. * * 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
  69533. * * The optional parameter `colors` is an array of successive Color4, one per line point
  69534. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  69535. * * When updating an instance, remember that only point positions can change, not the number of points
  69536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69537. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  69538. * @param name defines the name of the new line system
  69539. * @param options defines the options used to create the line system
  69540. * @param scene defines the hosting scene
  69541. * @returns a new line mesh
  69542. */
  69543. static CreateLines(name: string, options: {
  69544. points: Vector3[];
  69545. updatable?: boolean;
  69546. instance?: Nullable<LinesMesh>;
  69547. colors?: Color4[];
  69548. useVertexAlpha?: boolean;
  69549. }, scene?: Nullable<Scene>): LinesMesh;
  69550. /**
  69551. * Creates a dashed line mesh
  69552. * * 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
  69553. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69554. * * The parameter `points` is an array successive Vector3
  69555. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  69556. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  69557. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  69558. * * 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
  69559. * * When updating an instance, remember that only point positions can change, not the number of points
  69560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69561. * @param name defines the name of the mesh
  69562. * @param options defines the options used to create the mesh
  69563. * @param scene defines the hosting scene
  69564. * @returns the dashed line mesh
  69565. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  69566. */
  69567. static CreateDashedLines(name: string, options: {
  69568. points: Vector3[];
  69569. dashSize?: number;
  69570. gapSize?: number;
  69571. dashNb?: number;
  69572. updatable?: boolean;
  69573. instance?: LinesMesh;
  69574. }, scene?: Nullable<Scene>): LinesMesh;
  69575. /**
  69576. * 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.
  69577. * * 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.
  69578. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69579. * * 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.
  69580. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  69581. * * 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
  69582. * * 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
  69583. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  69584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69585. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69586. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  69587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69588. * @param name defines the name of the mesh
  69589. * @param options defines the options used to create the mesh
  69590. * @param scene defines the hosting scene
  69591. * @returns the extruded shape mesh
  69592. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69593. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69594. */
  69595. static ExtrudeShape(name: string, options: {
  69596. shape: Vector3[];
  69597. path: Vector3[];
  69598. scale?: number;
  69599. rotation?: number;
  69600. cap?: number;
  69601. updatable?: boolean;
  69602. sideOrientation?: number;
  69603. frontUVs?: Vector4;
  69604. backUVs?: Vector4;
  69605. instance?: Mesh;
  69606. invertUV?: boolean;
  69607. }, scene?: Nullable<Scene>): Mesh;
  69608. /**
  69609. * Creates an custom extruded shape mesh.
  69610. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  69611. * * 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.
  69612. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69613. * * 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
  69614. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  69615. * * 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
  69616. * * It must returns a float value that will be the scale value applied to the shape on each path point
  69617. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  69618. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  69619. * * 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
  69620. * * 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
  69621. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  69622. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69623. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69624. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69626. * @param name defines the name of the mesh
  69627. * @param options defines the options used to create the mesh
  69628. * @param scene defines the hosting scene
  69629. * @returns the custom extruded shape mesh
  69630. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  69631. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69632. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69633. */
  69634. static ExtrudeShapeCustom(name: string, options: {
  69635. shape: Vector3[];
  69636. path: Vector3[];
  69637. scaleFunction?: any;
  69638. rotationFunction?: any;
  69639. ribbonCloseArray?: boolean;
  69640. ribbonClosePath?: boolean;
  69641. cap?: number;
  69642. updatable?: boolean;
  69643. sideOrientation?: number;
  69644. frontUVs?: Vector4;
  69645. backUVs?: Vector4;
  69646. instance?: Mesh;
  69647. invertUV?: boolean;
  69648. }, scene?: Nullable<Scene>): Mesh;
  69649. /**
  69650. * Creates lathe mesh.
  69651. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69652. * * 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
  69653. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69654. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69655. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69656. * * 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
  69657. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69658. * * 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
  69659. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69660. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69661. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69663. * @param name defines the name of the mesh
  69664. * @param options defines the options used to create the mesh
  69665. * @param scene defines the hosting scene
  69666. * @returns the lathe mesh
  69667. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69668. */
  69669. static CreateLathe(name: string, options: {
  69670. shape: Vector3[];
  69671. radius?: number;
  69672. tessellation?: number;
  69673. clip?: number;
  69674. arc?: number;
  69675. closed?: boolean;
  69676. updatable?: boolean;
  69677. sideOrientation?: number;
  69678. frontUVs?: Vector4;
  69679. backUVs?: Vector4;
  69680. cap?: number;
  69681. invertUV?: boolean;
  69682. }, scene?: Nullable<Scene>): Mesh;
  69683. /**
  69684. * Creates a tiled plane mesh
  69685. * * You can set a limited pattern arrangement with the tiles
  69686. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69687. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69689. * @param name defines the name of the mesh
  69690. * @param options defines the options used to create the mesh
  69691. * @param scene defines the hosting scene
  69692. * @returns the plane mesh
  69693. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69694. */
  69695. static CreateTiledPlane(name: string, options: {
  69696. pattern?: number;
  69697. tileSize?: number;
  69698. tileWidth?: number;
  69699. tileHeight?: number;
  69700. size?: number;
  69701. width?: number;
  69702. height?: number;
  69703. alignHorizontal?: number;
  69704. alignVertical?: number;
  69705. sideOrientation?: number;
  69706. frontUVs?: Vector4;
  69707. backUVs?: Vector4;
  69708. updatable?: boolean;
  69709. }, scene?: Nullable<Scene>): Mesh;
  69710. /**
  69711. * Creates a plane mesh
  69712. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  69713. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  69714. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  69715. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69716. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69717. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69718. * @param name defines the name of the mesh
  69719. * @param options defines the options used to create the mesh
  69720. * @param scene defines the hosting scene
  69721. * @returns the plane mesh
  69722. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69723. */
  69724. static CreatePlane(name: string, options: {
  69725. size?: number;
  69726. width?: number;
  69727. height?: number;
  69728. sideOrientation?: number;
  69729. frontUVs?: Vector4;
  69730. backUVs?: Vector4;
  69731. updatable?: boolean;
  69732. sourcePlane?: Plane;
  69733. }, scene?: Nullable<Scene>): Mesh;
  69734. /**
  69735. * Creates a ground mesh
  69736. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  69737. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  69738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69739. * @param name defines the name of the mesh
  69740. * @param options defines the options used to create the mesh
  69741. * @param scene defines the hosting scene
  69742. * @returns the ground mesh
  69743. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  69744. */
  69745. static CreateGround(name: string, options: {
  69746. width?: number;
  69747. height?: number;
  69748. subdivisions?: number;
  69749. subdivisionsX?: number;
  69750. subdivisionsY?: number;
  69751. updatable?: boolean;
  69752. }, scene?: Nullable<Scene>): Mesh;
  69753. /**
  69754. * Creates a tiled ground mesh
  69755. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  69756. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  69757. * * 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
  69758. * * 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
  69759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69760. * @param name defines the name of the mesh
  69761. * @param options defines the options used to create the mesh
  69762. * @param scene defines the hosting scene
  69763. * @returns the tiled ground mesh
  69764. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  69765. */
  69766. static CreateTiledGround(name: string, options: {
  69767. xmin: number;
  69768. zmin: number;
  69769. xmax: number;
  69770. zmax: number;
  69771. subdivisions?: {
  69772. w: number;
  69773. h: number;
  69774. };
  69775. precision?: {
  69776. w: number;
  69777. h: number;
  69778. };
  69779. updatable?: boolean;
  69780. }, scene?: Nullable<Scene>): Mesh;
  69781. /**
  69782. * Creates a ground mesh from a height map
  69783. * * The parameter `url` sets the URL of the height map image resource.
  69784. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  69785. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  69786. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  69787. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  69788. * * 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.
  69789. * * 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).
  69790. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  69791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69792. * @param name defines the name of the mesh
  69793. * @param url defines the url to the height map
  69794. * @param options defines the options used to create the mesh
  69795. * @param scene defines the hosting scene
  69796. * @returns the ground mesh
  69797. * @see https://doc.babylonjs.com/babylon101/height_map
  69798. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  69799. */
  69800. static CreateGroundFromHeightMap(name: string, url: string, options: {
  69801. width?: number;
  69802. height?: number;
  69803. subdivisions?: number;
  69804. minHeight?: number;
  69805. maxHeight?: number;
  69806. colorFilter?: Color3;
  69807. alphaFilter?: number;
  69808. updatable?: boolean;
  69809. onReady?: (mesh: GroundMesh) => void;
  69810. }, scene?: Nullable<Scene>): GroundMesh;
  69811. /**
  69812. * Creates a polygon mesh
  69813. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69814. * * 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
  69815. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69817. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  69818. * * Remember you can only change the shape positions, not their number when updating a polygon
  69819. * @param name defines the name of the mesh
  69820. * @param options defines the options used to create the mesh
  69821. * @param scene defines the hosting scene
  69822. * @param earcutInjection can be used to inject your own earcut reference
  69823. * @returns the polygon mesh
  69824. */
  69825. static CreatePolygon(name: string, options: {
  69826. shape: Vector3[];
  69827. holes?: Vector3[][];
  69828. depth?: number;
  69829. faceUV?: Vector4[];
  69830. faceColors?: Color4[];
  69831. updatable?: boolean;
  69832. sideOrientation?: number;
  69833. frontUVs?: Vector4;
  69834. backUVs?: Vector4;
  69835. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69836. /**
  69837. * Creates an extruded polygon mesh, with depth in the Y direction.
  69838. * * 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)
  69839. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69840. * @param name defines the name of the mesh
  69841. * @param options defines the options used to create the mesh
  69842. * @param scene defines the hosting scene
  69843. * @param earcutInjection can be used to inject your own earcut reference
  69844. * @returns the polygon mesh
  69845. */
  69846. static ExtrudePolygon(name: string, options: {
  69847. shape: Vector3[];
  69848. holes?: Vector3[][];
  69849. depth?: number;
  69850. faceUV?: Vector4[];
  69851. faceColors?: Color4[];
  69852. updatable?: boolean;
  69853. sideOrientation?: number;
  69854. frontUVs?: Vector4;
  69855. backUVs?: Vector4;
  69856. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69857. /**
  69858. * Creates a tube mesh.
  69859. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69860. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69861. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69862. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69863. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69864. * * 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)
  69865. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69866. * * 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
  69867. * * 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
  69868. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69869. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69870. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69872. * @param name defines the name of the mesh
  69873. * @param options defines the options used to create the mesh
  69874. * @param scene defines the hosting scene
  69875. * @returns the tube mesh
  69876. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69877. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69878. */
  69879. static CreateTube(name: string, options: {
  69880. path: Vector3[];
  69881. radius?: number;
  69882. tessellation?: number;
  69883. radiusFunction?: {
  69884. (i: number, distance: number): number;
  69885. };
  69886. cap?: number;
  69887. arc?: number;
  69888. updatable?: boolean;
  69889. sideOrientation?: number;
  69890. frontUVs?: Vector4;
  69891. backUVs?: Vector4;
  69892. instance?: Mesh;
  69893. invertUV?: boolean;
  69894. }, scene?: Nullable<Scene>): Mesh;
  69895. /**
  69896. * Creates a polyhedron mesh
  69897. * * 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
  69898. * * The parameter `size` (positive float, default 1) sets the polygon size
  69899. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  69900. * * 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`
  69901. * * 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
  69902. * * 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)`)
  69903. * * 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
  69904. * * 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
  69905. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69906. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69908. * @param name defines the name of the mesh
  69909. * @param options defines the options used to create the mesh
  69910. * @param scene defines the hosting scene
  69911. * @returns the polyhedron mesh
  69912. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  69913. */
  69914. static CreatePolyhedron(name: string, options: {
  69915. type?: number;
  69916. size?: number;
  69917. sizeX?: number;
  69918. sizeY?: number;
  69919. sizeZ?: number;
  69920. custom?: any;
  69921. faceUV?: Vector4[];
  69922. faceColors?: Color4[];
  69923. flat?: boolean;
  69924. updatable?: boolean;
  69925. sideOrientation?: number;
  69926. frontUVs?: Vector4;
  69927. backUVs?: Vector4;
  69928. }, scene?: Nullable<Scene>): Mesh;
  69929. /**
  69930. * Creates a decal mesh.
  69931. * 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
  69932. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69933. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69934. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69935. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69936. * @param name defines the name of the mesh
  69937. * @param sourceMesh defines the mesh where the decal must be applied
  69938. * @param options defines the options used to create the mesh
  69939. * @param scene defines the hosting scene
  69940. * @returns the decal mesh
  69941. * @see https://doc.babylonjs.com/how_to/decals
  69942. */
  69943. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69944. position?: Vector3;
  69945. normal?: Vector3;
  69946. size?: Vector3;
  69947. angle?: number;
  69948. }): Mesh;
  69949. }
  69950. }
  69951. declare module "babylonjs/Meshes/meshSimplification" {
  69952. import { Mesh } from "babylonjs/Meshes/mesh";
  69953. /**
  69954. * A simplifier interface for future simplification implementations
  69955. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69956. */
  69957. export interface ISimplifier {
  69958. /**
  69959. * Simplification of a given mesh according to the given settings.
  69960. * Since this requires computation, it is assumed that the function runs async.
  69961. * @param settings The settings of the simplification, including quality and distance
  69962. * @param successCallback A callback that will be called after the mesh was simplified.
  69963. * @param errorCallback in case of an error, this callback will be called. optional.
  69964. */
  69965. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  69966. }
  69967. /**
  69968. * Expected simplification settings.
  69969. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  69970. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69971. */
  69972. export interface ISimplificationSettings {
  69973. /**
  69974. * Gets or sets the expected quality
  69975. */
  69976. quality: number;
  69977. /**
  69978. * Gets or sets the distance when this optimized version should be used
  69979. */
  69980. distance: number;
  69981. /**
  69982. * Gets an already optimized mesh
  69983. */
  69984. optimizeMesh?: boolean;
  69985. }
  69986. /**
  69987. * Class used to specify simplification options
  69988. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69989. */
  69990. export class SimplificationSettings implements ISimplificationSettings {
  69991. /** expected quality */
  69992. quality: number;
  69993. /** distance when this optimized version should be used */
  69994. distance: number;
  69995. /** already optimized mesh */
  69996. optimizeMesh?: boolean | undefined;
  69997. /**
  69998. * Creates a SimplificationSettings
  69999. * @param quality expected quality
  70000. * @param distance distance when this optimized version should be used
  70001. * @param optimizeMesh already optimized mesh
  70002. */
  70003. constructor(
  70004. /** expected quality */
  70005. quality: number,
  70006. /** distance when this optimized version should be used */
  70007. distance: number,
  70008. /** already optimized mesh */
  70009. optimizeMesh?: boolean | undefined);
  70010. }
  70011. /**
  70012. * Interface used to define a simplification task
  70013. */
  70014. export interface ISimplificationTask {
  70015. /**
  70016. * Array of settings
  70017. */
  70018. settings: Array<ISimplificationSettings>;
  70019. /**
  70020. * Simplification type
  70021. */
  70022. simplificationType: SimplificationType;
  70023. /**
  70024. * Mesh to simplify
  70025. */
  70026. mesh: Mesh;
  70027. /**
  70028. * Callback called on success
  70029. */
  70030. successCallback?: () => void;
  70031. /**
  70032. * Defines if parallel processing can be used
  70033. */
  70034. parallelProcessing: boolean;
  70035. }
  70036. /**
  70037. * Queue used to order the simplification tasks
  70038. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70039. */
  70040. export class SimplificationQueue {
  70041. private _simplificationArray;
  70042. /**
  70043. * Gets a boolean indicating that the process is still running
  70044. */
  70045. running: boolean;
  70046. /**
  70047. * Creates a new queue
  70048. */
  70049. constructor();
  70050. /**
  70051. * Adds a new simplification task
  70052. * @param task defines a task to add
  70053. */
  70054. addTask(task: ISimplificationTask): void;
  70055. /**
  70056. * Execute next task
  70057. */
  70058. executeNext(): void;
  70059. /**
  70060. * Execute a simplification task
  70061. * @param task defines the task to run
  70062. */
  70063. runSimplification(task: ISimplificationTask): void;
  70064. private getSimplifier;
  70065. }
  70066. /**
  70067. * The implemented types of simplification
  70068. * At the moment only Quadratic Error Decimation is implemented
  70069. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70070. */
  70071. export enum SimplificationType {
  70072. /** Quadratic error decimation */
  70073. QUADRATIC = 0
  70074. }
  70075. /**
  70076. * An implementation of the Quadratic Error simplification algorithm.
  70077. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70078. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70079. * @author RaananW
  70080. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70081. */
  70082. export class QuadraticErrorSimplification implements ISimplifier {
  70083. private _mesh;
  70084. private triangles;
  70085. private vertices;
  70086. private references;
  70087. private _reconstructedMesh;
  70088. /** Gets or sets the number pf sync interations */
  70089. syncIterations: number;
  70090. /** Gets or sets the aggressiveness of the simplifier */
  70091. aggressiveness: number;
  70092. /** Gets or sets the number of allowed iterations for decimation */
  70093. decimationIterations: number;
  70094. /** Gets or sets the espilon to use for bounding box computation */
  70095. boundingBoxEpsilon: number;
  70096. /**
  70097. * Creates a new QuadraticErrorSimplification
  70098. * @param _mesh defines the target mesh
  70099. */
  70100. constructor(_mesh: Mesh);
  70101. /**
  70102. * Simplification of a given mesh according to the given settings.
  70103. * Since this requires computation, it is assumed that the function runs async.
  70104. * @param settings The settings of the simplification, including quality and distance
  70105. * @param successCallback A callback that will be called after the mesh was simplified.
  70106. */
  70107. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70108. private runDecimation;
  70109. private initWithMesh;
  70110. private init;
  70111. private reconstructMesh;
  70112. private initDecimatedMesh;
  70113. private isFlipped;
  70114. private updateTriangles;
  70115. private identifyBorder;
  70116. private updateMesh;
  70117. private vertexError;
  70118. private calculateError;
  70119. }
  70120. }
  70121. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  70122. import { Scene } from "babylonjs/scene";
  70123. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  70124. import { ISceneComponent } from "babylonjs/sceneComponent";
  70125. module "babylonjs/scene" {
  70126. interface Scene {
  70127. /** @hidden (Backing field) */
  70128. _simplificationQueue: SimplificationQueue;
  70129. /**
  70130. * Gets or sets the simplification queue attached to the scene
  70131. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70132. */
  70133. simplificationQueue: SimplificationQueue;
  70134. }
  70135. }
  70136. module "babylonjs/Meshes/mesh" {
  70137. interface Mesh {
  70138. /**
  70139. * Simplify the mesh according to the given array of settings.
  70140. * Function will return immediately and will simplify async
  70141. * @param settings a collection of simplification settings
  70142. * @param parallelProcessing should all levels calculate parallel or one after the other
  70143. * @param simplificationType the type of simplification to run
  70144. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70145. * @returns the current mesh
  70146. */
  70147. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70148. }
  70149. }
  70150. /**
  70151. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70152. * created in a scene
  70153. */
  70154. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70155. /**
  70156. * The component name helpfull to identify the component in the list of scene components.
  70157. */
  70158. readonly name: string;
  70159. /**
  70160. * The scene the component belongs to.
  70161. */
  70162. scene: Scene;
  70163. /**
  70164. * Creates a new instance of the component for the given scene
  70165. * @param scene Defines the scene to register the component in
  70166. */
  70167. constructor(scene: Scene);
  70168. /**
  70169. * Registers the component in a given scene
  70170. */
  70171. register(): void;
  70172. /**
  70173. * Rebuilds the elements related to this component in case of
  70174. * context lost for instance.
  70175. */
  70176. rebuild(): void;
  70177. /**
  70178. * Disposes the component and the associated ressources
  70179. */
  70180. dispose(): void;
  70181. private _beforeCameraUpdate;
  70182. }
  70183. }
  70184. declare module "babylonjs/Meshes/Builders/index" {
  70185. export * from "babylonjs/Meshes/Builders/boxBuilder";
  70186. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  70187. export * from "babylonjs/Meshes/Builders/discBuilder";
  70188. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  70189. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  70190. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  70191. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  70192. export * from "babylonjs/Meshes/Builders/torusBuilder";
  70193. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  70194. export * from "babylonjs/Meshes/Builders/linesBuilder";
  70195. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  70196. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  70197. export * from "babylonjs/Meshes/Builders/latheBuilder";
  70198. export * from "babylonjs/Meshes/Builders/planeBuilder";
  70199. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  70200. export * from "babylonjs/Meshes/Builders/groundBuilder";
  70201. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  70202. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  70203. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70204. export * from "babylonjs/Meshes/Builders/decalBuilder";
  70205. }
  70206. declare module "babylonjs/Meshes/thinInstanceMesh" {
  70207. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  70208. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  70209. import { Matrix } from "babylonjs/Maths/math.vector";
  70210. module "babylonjs/Meshes/mesh" {
  70211. interface Mesh {
  70212. /**
  70213. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  70214. */
  70215. thinInstanceEnablePicking: boolean;
  70216. /**
  70217. * Creates a new thin instance
  70218. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  70219. * @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
  70220. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  70221. */
  70222. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70223. /**
  70224. * Adds the transformation (matrix) of the current mesh as a thin instance
  70225. * @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
  70226. * @returns the thin instance index number
  70227. */
  70228. thinInstanceAddSelf(refresh: boolean): number;
  70229. /**
  70230. * Registers a custom attribute to be used with thin instances
  70231. * @param kind name of the attribute
  70232. * @param stride size in floats of the attribute
  70233. */
  70234. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70235. /**
  70236. * Sets the matrix of a thin instance
  70237. * @param index index of the thin instance
  70238. * @param matrix matrix to set
  70239. * @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
  70240. */
  70241. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  70242. /**
  70243. * Sets the value of a custom attribute for a thin instance
  70244. * @param kind name of the attribute
  70245. * @param index index of the thin instance
  70246. * @param value value to set
  70247. * @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
  70248. */
  70249. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  70250. /**
  70251. * 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.
  70252. */
  70253. thinInstanceCount: number;
  70254. /**
  70255. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  70256. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  70257. * @param buffer buffer to set
  70258. * @param stride size in floats of each value of the buffer
  70259. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  70260. */
  70261. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  70262. /**
  70263. * Gets the list of world matrices
  70264. * @return an array containing all the world matrices from the thin instances
  70265. */
  70266. thinInstanceGetWorldMatrices(): Matrix[];
  70267. /**
  70268. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  70269. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70270. */
  70271. thinInstanceBufferUpdated(kind: string): void;
  70272. /**
  70273. * Applies a partial update to a buffer directly on the GPU
  70274. * 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
  70275. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70276. * @param data the data to set in the GPU buffer
  70277. * @param offset the offset in the GPU buffer where to update the data
  70278. */
  70279. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  70280. /**
  70281. * Refreshes the bounding info, taking into account all the thin instances defined
  70282. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  70283. */
  70284. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  70285. /** @hidden */
  70286. _thinInstanceInitializeUserStorage(): void;
  70287. /** @hidden */
  70288. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  70289. /** @hidden */
  70290. _userThinInstanceBuffersStorage: {
  70291. data: {
  70292. [key: string]: Float32Array;
  70293. };
  70294. sizes: {
  70295. [key: string]: number;
  70296. };
  70297. vertexBuffers: {
  70298. [key: string]: Nullable<VertexBuffer>;
  70299. };
  70300. strides: {
  70301. [key: string]: number;
  70302. };
  70303. };
  70304. }
  70305. }
  70306. }
  70307. declare module "babylonjs/Meshes/index" {
  70308. export * from "babylonjs/Meshes/abstractMesh";
  70309. export * from "babylonjs/Meshes/buffer";
  70310. export * from "babylonjs/Meshes/Compression/index";
  70311. export * from "babylonjs/Meshes/csg";
  70312. export * from "babylonjs/Meshes/geometry";
  70313. export * from "babylonjs/Meshes/groundMesh";
  70314. export * from "babylonjs/Meshes/trailMesh";
  70315. export * from "babylonjs/Meshes/instancedMesh";
  70316. export * from "babylonjs/Meshes/linesMesh";
  70317. export * from "babylonjs/Meshes/mesh";
  70318. export * from "babylonjs/Meshes/mesh.vertexData";
  70319. export * from "babylonjs/Meshes/meshBuilder";
  70320. export * from "babylonjs/Meshes/meshSimplification";
  70321. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  70322. export * from "babylonjs/Meshes/polygonMesh";
  70323. export * from "babylonjs/Meshes/subMesh";
  70324. export * from "babylonjs/Meshes/meshLODLevel";
  70325. export * from "babylonjs/Meshes/transformNode";
  70326. export * from "babylonjs/Meshes/Builders/index";
  70327. export * from "babylonjs/Meshes/dataBuffer";
  70328. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  70329. import "babylonjs/Meshes/thinInstanceMesh";
  70330. export * from "babylonjs/Meshes/thinInstanceMesh";
  70331. }
  70332. declare module "babylonjs/Morph/index" {
  70333. export * from "babylonjs/Morph/morphTarget";
  70334. export * from "babylonjs/Morph/morphTargetManager";
  70335. }
  70336. declare module "babylonjs/Navigation/INavigationEngine" {
  70337. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70338. import { Vector3 } from "babylonjs/Maths/math";
  70339. import { Mesh } from "babylonjs/Meshes/mesh";
  70340. import { Scene } from "babylonjs/scene";
  70341. /**
  70342. * Navigation plugin interface to add navigation constrained by a navigation mesh
  70343. */
  70344. export interface INavigationEnginePlugin {
  70345. /**
  70346. * plugin name
  70347. */
  70348. name: string;
  70349. /**
  70350. * Creates a navigation mesh
  70351. * @param meshes array of all the geometry used to compute the navigatio mesh
  70352. * @param parameters bunch of parameters used to filter geometry
  70353. */
  70354. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70355. /**
  70356. * Create a navigation mesh debug mesh
  70357. * @param scene is where the mesh will be added
  70358. * @returns debug display mesh
  70359. */
  70360. createDebugNavMesh(scene: Scene): Mesh;
  70361. /**
  70362. * Get a navigation mesh constrained position, closest to the parameter position
  70363. * @param position world position
  70364. * @returns the closest point to position constrained by the navigation mesh
  70365. */
  70366. getClosestPoint(position: Vector3): Vector3;
  70367. /**
  70368. * Get a navigation mesh constrained position, closest to the parameter position
  70369. * @param position world position
  70370. * @param result output the closest point to position constrained by the navigation mesh
  70371. */
  70372. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70373. /**
  70374. * Get a navigation mesh constrained position, within a particular radius
  70375. * @param position world position
  70376. * @param maxRadius the maximum distance to the constrained world position
  70377. * @returns the closest point to position constrained by the navigation mesh
  70378. */
  70379. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70380. /**
  70381. * Get a navigation mesh constrained position, within a particular radius
  70382. * @param position world position
  70383. * @param maxRadius the maximum distance to the constrained world position
  70384. * @param result output the closest point to position constrained by the navigation mesh
  70385. */
  70386. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70387. /**
  70388. * Compute the final position from a segment made of destination-position
  70389. * @param position world position
  70390. * @param destination world position
  70391. * @returns the resulting point along the navmesh
  70392. */
  70393. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70394. /**
  70395. * Compute the final position from a segment made of destination-position
  70396. * @param position world position
  70397. * @param destination world position
  70398. * @param result output the resulting point along the navmesh
  70399. */
  70400. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70401. /**
  70402. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70403. * @param start world position
  70404. * @param end world position
  70405. * @returns array containing world position composing the path
  70406. */
  70407. computePath(start: Vector3, end: Vector3): Vector3[];
  70408. /**
  70409. * If this plugin is supported
  70410. * @returns true if plugin is supported
  70411. */
  70412. isSupported(): boolean;
  70413. /**
  70414. * Create a new Crowd so you can add agents
  70415. * @param maxAgents the maximum agent count in the crowd
  70416. * @param maxAgentRadius the maximum radius an agent can have
  70417. * @param scene to attach the crowd to
  70418. * @returns the crowd you can add agents to
  70419. */
  70420. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70421. /**
  70422. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70423. * The queries will try to find a solution within those bounds
  70424. * default is (1,1,1)
  70425. * @param extent x,y,z value that define the extent around the queries point of reference
  70426. */
  70427. setDefaultQueryExtent(extent: Vector3): void;
  70428. /**
  70429. * Get the Bounding box extent specified by setDefaultQueryExtent
  70430. * @returns the box extent values
  70431. */
  70432. getDefaultQueryExtent(): Vector3;
  70433. /**
  70434. * build the navmesh from a previously saved state using getNavmeshData
  70435. * @param data the Uint8Array returned by getNavmeshData
  70436. */
  70437. buildFromNavmeshData(data: Uint8Array): void;
  70438. /**
  70439. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70440. * @returns data the Uint8Array that can be saved and reused
  70441. */
  70442. getNavmeshData(): Uint8Array;
  70443. /**
  70444. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70445. * @param result output the box extent values
  70446. */
  70447. getDefaultQueryExtentToRef(result: Vector3): void;
  70448. /**
  70449. * Release all resources
  70450. */
  70451. dispose(): void;
  70452. }
  70453. /**
  70454. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  70455. */
  70456. export interface ICrowd {
  70457. /**
  70458. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70459. * You can attach anything to that node. The node position is updated in the scene update tick.
  70460. * @param pos world position that will be constrained by the navigation mesh
  70461. * @param parameters agent parameters
  70462. * @param transform hooked to the agent that will be update by the scene
  70463. * @returns agent index
  70464. */
  70465. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70466. /**
  70467. * Returns the agent position in world space
  70468. * @param index agent index returned by addAgent
  70469. * @returns world space position
  70470. */
  70471. getAgentPosition(index: number): Vector3;
  70472. /**
  70473. * Gets the agent position result in world space
  70474. * @param index agent index returned by addAgent
  70475. * @param result output world space position
  70476. */
  70477. getAgentPositionToRef(index: number, result: Vector3): void;
  70478. /**
  70479. * Gets the agent velocity in world space
  70480. * @param index agent index returned by addAgent
  70481. * @returns world space velocity
  70482. */
  70483. getAgentVelocity(index: number): Vector3;
  70484. /**
  70485. * Gets the agent velocity result in world space
  70486. * @param index agent index returned by addAgent
  70487. * @param result output world space velocity
  70488. */
  70489. getAgentVelocityToRef(index: number, result: Vector3): void;
  70490. /**
  70491. * remove a particular agent previously created
  70492. * @param index agent index returned by addAgent
  70493. */
  70494. removeAgent(index: number): void;
  70495. /**
  70496. * get the list of all agents attached to this crowd
  70497. * @returns list of agent indices
  70498. */
  70499. getAgents(): number[];
  70500. /**
  70501. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70502. * @param deltaTime in seconds
  70503. */
  70504. update(deltaTime: number): void;
  70505. /**
  70506. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70507. * @param index agent index returned by addAgent
  70508. * @param destination targeted world position
  70509. */
  70510. agentGoto(index: number, destination: Vector3): void;
  70511. /**
  70512. * Teleport the agent to a new position
  70513. * @param index agent index returned by addAgent
  70514. * @param destination targeted world position
  70515. */
  70516. agentTeleport(index: number, destination: Vector3): void;
  70517. /**
  70518. * Update agent parameters
  70519. * @param index agent index returned by addAgent
  70520. * @param parameters agent parameters
  70521. */
  70522. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70523. /**
  70524. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70525. * The queries will try to find a solution within those bounds
  70526. * default is (1,1,1)
  70527. * @param extent x,y,z value that define the extent around the queries point of reference
  70528. */
  70529. setDefaultQueryExtent(extent: Vector3): void;
  70530. /**
  70531. * Get the Bounding box extent specified by setDefaultQueryExtent
  70532. * @returns the box extent values
  70533. */
  70534. getDefaultQueryExtent(): Vector3;
  70535. /**
  70536. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70537. * @param result output the box extent values
  70538. */
  70539. getDefaultQueryExtentToRef(result: Vector3): void;
  70540. /**
  70541. * Release all resources
  70542. */
  70543. dispose(): void;
  70544. }
  70545. /**
  70546. * Configures an agent
  70547. */
  70548. export interface IAgentParameters {
  70549. /**
  70550. * Agent radius. [Limit: >= 0]
  70551. */
  70552. radius: number;
  70553. /**
  70554. * Agent height. [Limit: > 0]
  70555. */
  70556. height: number;
  70557. /**
  70558. * Maximum allowed acceleration. [Limit: >= 0]
  70559. */
  70560. maxAcceleration: number;
  70561. /**
  70562. * Maximum allowed speed. [Limit: >= 0]
  70563. */
  70564. maxSpeed: number;
  70565. /**
  70566. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  70567. */
  70568. collisionQueryRange: number;
  70569. /**
  70570. * The path visibility optimization range. [Limit: > 0]
  70571. */
  70572. pathOptimizationRange: number;
  70573. /**
  70574. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  70575. */
  70576. separationWeight: number;
  70577. }
  70578. /**
  70579. * Configures the navigation mesh creation
  70580. */
  70581. export interface INavMeshParameters {
  70582. /**
  70583. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  70584. */
  70585. cs: number;
  70586. /**
  70587. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  70588. */
  70589. ch: number;
  70590. /**
  70591. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  70592. */
  70593. walkableSlopeAngle: number;
  70594. /**
  70595. * Minimum floor to 'ceiling' height that will still allow the floor area to
  70596. * be considered walkable. [Limit: >= 3] [Units: vx]
  70597. */
  70598. walkableHeight: number;
  70599. /**
  70600. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  70601. */
  70602. walkableClimb: number;
  70603. /**
  70604. * The distance to erode/shrink the walkable area of the heightfield away from
  70605. * obstructions. [Limit: >=0] [Units: vx]
  70606. */
  70607. walkableRadius: number;
  70608. /**
  70609. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  70610. */
  70611. maxEdgeLen: number;
  70612. /**
  70613. * The maximum distance a simplfied contour's border edges should deviate
  70614. * the original raw contour. [Limit: >=0] [Units: vx]
  70615. */
  70616. maxSimplificationError: number;
  70617. /**
  70618. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  70619. */
  70620. minRegionArea: number;
  70621. /**
  70622. * Any regions with a span count smaller than this value will, if possible,
  70623. * be merged with larger regions. [Limit: >=0] [Units: vx]
  70624. */
  70625. mergeRegionArea: number;
  70626. /**
  70627. * The maximum number of vertices allowed for polygons generated during the
  70628. * contour to polygon conversion process. [Limit: >= 3]
  70629. */
  70630. maxVertsPerPoly: number;
  70631. /**
  70632. * Sets the sampling distance to use when generating the detail mesh.
  70633. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  70634. */
  70635. detailSampleDist: number;
  70636. /**
  70637. * The maximum distance the detail mesh surface should deviate from heightfield
  70638. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  70639. */
  70640. detailSampleMaxError: number;
  70641. }
  70642. }
  70643. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  70644. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  70645. import { Mesh } from "babylonjs/Meshes/mesh";
  70646. import { Scene } from "babylonjs/scene";
  70647. import { Vector3 } from "babylonjs/Maths/math";
  70648. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70649. /**
  70650. * RecastJS navigation plugin
  70651. */
  70652. export class RecastJSPlugin implements INavigationEnginePlugin {
  70653. /**
  70654. * Reference to the Recast library
  70655. */
  70656. bjsRECAST: any;
  70657. /**
  70658. * plugin name
  70659. */
  70660. name: string;
  70661. /**
  70662. * the first navmesh created. We might extend this to support multiple navmeshes
  70663. */
  70664. navMesh: any;
  70665. /**
  70666. * Initializes the recastJS plugin
  70667. * @param recastInjection can be used to inject your own recast reference
  70668. */
  70669. constructor(recastInjection?: any);
  70670. /**
  70671. * Creates a navigation mesh
  70672. * @param meshes array of all the geometry used to compute the navigatio mesh
  70673. * @param parameters bunch of parameters used to filter geometry
  70674. */
  70675. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70676. /**
  70677. * Create a navigation mesh debug mesh
  70678. * @param scene is where the mesh will be added
  70679. * @returns debug display mesh
  70680. */
  70681. createDebugNavMesh(scene: Scene): Mesh;
  70682. /**
  70683. * Get a navigation mesh constrained position, closest to the parameter position
  70684. * @param position world position
  70685. * @returns the closest point to position constrained by the navigation mesh
  70686. */
  70687. getClosestPoint(position: Vector3): Vector3;
  70688. /**
  70689. * Get a navigation mesh constrained position, closest to the parameter position
  70690. * @param position world position
  70691. * @param result output the closest point to position constrained by the navigation mesh
  70692. */
  70693. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70694. /**
  70695. * Get a navigation mesh constrained position, within a particular radius
  70696. * @param position world position
  70697. * @param maxRadius the maximum distance to the constrained world position
  70698. * @returns the closest point to position constrained by the navigation mesh
  70699. */
  70700. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70701. /**
  70702. * Get a navigation mesh constrained position, within a particular radius
  70703. * @param position world position
  70704. * @param maxRadius the maximum distance to the constrained world position
  70705. * @param result output the closest point to position constrained by the navigation mesh
  70706. */
  70707. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70708. /**
  70709. * Compute the final position from a segment made of destination-position
  70710. * @param position world position
  70711. * @param destination world position
  70712. * @returns the resulting point along the navmesh
  70713. */
  70714. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70715. /**
  70716. * Compute the final position from a segment made of destination-position
  70717. * @param position world position
  70718. * @param destination world position
  70719. * @param result output the resulting point along the navmesh
  70720. */
  70721. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70722. /**
  70723. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70724. * @param start world position
  70725. * @param end world position
  70726. * @returns array containing world position composing the path
  70727. */
  70728. computePath(start: Vector3, end: Vector3): Vector3[];
  70729. /**
  70730. * Create a new Crowd so you can add agents
  70731. * @param maxAgents the maximum agent count in the crowd
  70732. * @param maxAgentRadius the maximum radius an agent can have
  70733. * @param scene to attach the crowd to
  70734. * @returns the crowd you can add agents to
  70735. */
  70736. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70737. /**
  70738. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70739. * The queries will try to find a solution within those bounds
  70740. * default is (1,1,1)
  70741. * @param extent x,y,z value that define the extent around the queries point of reference
  70742. */
  70743. setDefaultQueryExtent(extent: Vector3): void;
  70744. /**
  70745. * Get the Bounding box extent specified by setDefaultQueryExtent
  70746. * @returns the box extent values
  70747. */
  70748. getDefaultQueryExtent(): Vector3;
  70749. /**
  70750. * build the navmesh from a previously saved state using getNavmeshData
  70751. * @param data the Uint8Array returned by getNavmeshData
  70752. */
  70753. buildFromNavmeshData(data: Uint8Array): void;
  70754. /**
  70755. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70756. * @returns data the Uint8Array that can be saved and reused
  70757. */
  70758. getNavmeshData(): Uint8Array;
  70759. /**
  70760. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70761. * @param result output the box extent values
  70762. */
  70763. getDefaultQueryExtentToRef(result: Vector3): void;
  70764. /**
  70765. * Disposes
  70766. */
  70767. dispose(): void;
  70768. /**
  70769. * If this plugin is supported
  70770. * @returns true if plugin is supported
  70771. */
  70772. isSupported(): boolean;
  70773. }
  70774. /**
  70775. * Recast detour crowd implementation
  70776. */
  70777. export class RecastJSCrowd implements ICrowd {
  70778. /**
  70779. * Recast/detour plugin
  70780. */
  70781. bjsRECASTPlugin: RecastJSPlugin;
  70782. /**
  70783. * Link to the detour crowd
  70784. */
  70785. recastCrowd: any;
  70786. /**
  70787. * One transform per agent
  70788. */
  70789. transforms: TransformNode[];
  70790. /**
  70791. * All agents created
  70792. */
  70793. agents: number[];
  70794. /**
  70795. * Link to the scene is kept to unregister the crowd from the scene
  70796. */
  70797. private _scene;
  70798. /**
  70799. * Observer for crowd updates
  70800. */
  70801. private _onBeforeAnimationsObserver;
  70802. /**
  70803. * Constructor
  70804. * @param plugin recastJS plugin
  70805. * @param maxAgents the maximum agent count in the crowd
  70806. * @param maxAgentRadius the maximum radius an agent can have
  70807. * @param scene to attach the crowd to
  70808. * @returns the crowd you can add agents to
  70809. */
  70810. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  70811. /**
  70812. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70813. * You can attach anything to that node. The node position is updated in the scene update tick.
  70814. * @param pos world position that will be constrained by the navigation mesh
  70815. * @param parameters agent parameters
  70816. * @param transform hooked to the agent that will be update by the scene
  70817. * @returns agent index
  70818. */
  70819. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70820. /**
  70821. * Returns the agent position in world space
  70822. * @param index agent index returned by addAgent
  70823. * @returns world space position
  70824. */
  70825. getAgentPosition(index: number): Vector3;
  70826. /**
  70827. * Returns the agent position result in world space
  70828. * @param index agent index returned by addAgent
  70829. * @param result output world space position
  70830. */
  70831. getAgentPositionToRef(index: number, result: Vector3): void;
  70832. /**
  70833. * Returns the agent velocity in world space
  70834. * @param index agent index returned by addAgent
  70835. * @returns world space velocity
  70836. */
  70837. getAgentVelocity(index: number): Vector3;
  70838. /**
  70839. * Returns the agent velocity result in world space
  70840. * @param index agent index returned by addAgent
  70841. * @param result output world space velocity
  70842. */
  70843. getAgentVelocityToRef(index: number, result: Vector3): void;
  70844. /**
  70845. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70846. * @param index agent index returned by addAgent
  70847. * @param destination targeted world position
  70848. */
  70849. agentGoto(index: number, destination: Vector3): void;
  70850. /**
  70851. * Teleport the agent to a new position
  70852. * @param index agent index returned by addAgent
  70853. * @param destination targeted world position
  70854. */
  70855. agentTeleport(index: number, destination: Vector3): void;
  70856. /**
  70857. * Update agent parameters
  70858. * @param index agent index returned by addAgent
  70859. * @param parameters agent parameters
  70860. */
  70861. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70862. /**
  70863. * remove a particular agent previously created
  70864. * @param index agent index returned by addAgent
  70865. */
  70866. removeAgent(index: number): void;
  70867. /**
  70868. * get the list of all agents attached to this crowd
  70869. * @returns list of agent indices
  70870. */
  70871. getAgents(): number[];
  70872. /**
  70873. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70874. * @param deltaTime in seconds
  70875. */
  70876. update(deltaTime: number): void;
  70877. /**
  70878. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70879. * The queries will try to find a solution within those bounds
  70880. * default is (1,1,1)
  70881. * @param extent x,y,z value that define the extent around the queries point of reference
  70882. */
  70883. setDefaultQueryExtent(extent: Vector3): void;
  70884. /**
  70885. * Get the Bounding box extent specified by setDefaultQueryExtent
  70886. * @returns the box extent values
  70887. */
  70888. getDefaultQueryExtent(): Vector3;
  70889. /**
  70890. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70891. * @param result output the box extent values
  70892. */
  70893. getDefaultQueryExtentToRef(result: Vector3): void;
  70894. /**
  70895. * Release all resources
  70896. */
  70897. dispose(): void;
  70898. }
  70899. }
  70900. declare module "babylonjs/Navigation/Plugins/index" {
  70901. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  70902. }
  70903. declare module "babylonjs/Navigation/index" {
  70904. export * from "babylonjs/Navigation/INavigationEngine";
  70905. export * from "babylonjs/Navigation/Plugins/index";
  70906. }
  70907. declare module "babylonjs/Offline/database" {
  70908. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  70909. /**
  70910. * Class used to enable access to IndexedDB
  70911. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70912. */
  70913. export class Database implements IOfflineProvider {
  70914. private _callbackManifestChecked;
  70915. private _currentSceneUrl;
  70916. private _db;
  70917. private _enableSceneOffline;
  70918. private _enableTexturesOffline;
  70919. private _manifestVersionFound;
  70920. private _mustUpdateRessources;
  70921. private _hasReachedQuota;
  70922. private _isSupported;
  70923. private _idbFactory;
  70924. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  70925. private static IsUASupportingBlobStorage;
  70926. /**
  70927. * Gets a boolean indicating if Database storate is enabled (off by default)
  70928. */
  70929. static IDBStorageEnabled: boolean;
  70930. /**
  70931. * Gets a boolean indicating if scene must be saved in the database
  70932. */
  70933. get enableSceneOffline(): boolean;
  70934. /**
  70935. * Gets a boolean indicating if textures must be saved in the database
  70936. */
  70937. get enableTexturesOffline(): boolean;
  70938. /**
  70939. * Creates a new Database
  70940. * @param urlToScene defines the url to load the scene
  70941. * @param callbackManifestChecked defines the callback to use when manifest is checked
  70942. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  70943. */
  70944. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  70945. private static _ParseURL;
  70946. private static _ReturnFullUrlLocation;
  70947. private _checkManifestFile;
  70948. /**
  70949. * Open the database and make it available
  70950. * @param successCallback defines the callback to call on success
  70951. * @param errorCallback defines the callback to call on error
  70952. */
  70953. open(successCallback: () => void, errorCallback: () => void): void;
  70954. /**
  70955. * Loads an image from the database
  70956. * @param url defines the url to load from
  70957. * @param image defines the target DOM image
  70958. */
  70959. loadImage(url: string, image: HTMLImageElement): void;
  70960. private _loadImageFromDBAsync;
  70961. private _saveImageIntoDBAsync;
  70962. private _checkVersionFromDB;
  70963. private _loadVersionFromDBAsync;
  70964. private _saveVersionIntoDBAsync;
  70965. /**
  70966. * Loads a file from database
  70967. * @param url defines the URL to load from
  70968. * @param sceneLoaded defines a callback to call on success
  70969. * @param progressCallBack defines a callback to call when progress changed
  70970. * @param errorCallback defines a callback to call on error
  70971. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70972. */
  70973. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70974. private _loadFileAsync;
  70975. private _saveFileAsync;
  70976. /**
  70977. * Validates if xhr data is correct
  70978. * @param xhr defines the request to validate
  70979. * @param dataType defines the expected data type
  70980. * @returns true if data is correct
  70981. */
  70982. private static _ValidateXHRData;
  70983. }
  70984. }
  70985. declare module "babylonjs/Offline/index" {
  70986. export * from "babylonjs/Offline/database";
  70987. export * from "babylonjs/Offline/IOfflineProvider";
  70988. }
  70989. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  70990. /** @hidden */
  70991. export var gpuUpdateParticlesPixelShader: {
  70992. name: string;
  70993. shader: string;
  70994. };
  70995. }
  70996. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  70997. /** @hidden */
  70998. export var gpuUpdateParticlesVertexShader: {
  70999. name: string;
  71000. shader: string;
  71001. };
  71002. }
  71003. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  71004. /** @hidden */
  71005. export var clipPlaneFragmentDeclaration2: {
  71006. name: string;
  71007. shader: string;
  71008. };
  71009. }
  71010. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  71011. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  71012. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  71013. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71014. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  71015. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  71016. /** @hidden */
  71017. export var gpuRenderParticlesPixelShader: {
  71018. name: string;
  71019. shader: string;
  71020. };
  71021. }
  71022. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  71023. /** @hidden */
  71024. export var clipPlaneVertexDeclaration2: {
  71025. name: string;
  71026. shader: string;
  71027. };
  71028. }
  71029. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  71030. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  71031. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  71032. /** @hidden */
  71033. export var gpuRenderParticlesVertexShader: {
  71034. name: string;
  71035. shader: string;
  71036. };
  71037. }
  71038. declare module "babylonjs/Particles/gpuParticleSystem" {
  71039. import { Nullable } from "babylonjs/types";
  71040. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  71041. import { Observable } from "babylonjs/Misc/observable";
  71042. import { Matrix } from "babylonjs/Maths/math.vector";
  71043. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  71044. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71045. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  71046. import { IDisposable } from "babylonjs/scene";
  71047. import { Effect } from "babylonjs/Materials/effect";
  71048. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71049. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71050. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  71051. import { Scene } from "babylonjs/scene";
  71052. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  71053. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  71054. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  71055. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  71056. /**
  71057. * This represents a GPU particle system in Babylon
  71058. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71059. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71060. */
  71061. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71062. /**
  71063. * The layer mask we are rendering the particles through.
  71064. */
  71065. layerMask: number;
  71066. private _capacity;
  71067. private _activeCount;
  71068. private _currentActiveCount;
  71069. private _accumulatedCount;
  71070. private _renderEffect;
  71071. private _updateEffect;
  71072. private _buffer0;
  71073. private _buffer1;
  71074. private _spriteBuffer;
  71075. private _updateVAO;
  71076. private _renderVAO;
  71077. private _targetIndex;
  71078. private _sourceBuffer;
  71079. private _targetBuffer;
  71080. private _currentRenderId;
  71081. private _started;
  71082. private _stopped;
  71083. private _timeDelta;
  71084. private _randomTexture;
  71085. private _randomTexture2;
  71086. private _attributesStrideSize;
  71087. private _updateEffectOptions;
  71088. private _randomTextureSize;
  71089. private _actualFrame;
  71090. private _customEffect;
  71091. private readonly _rawTextureWidth;
  71092. /**
  71093. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71094. */
  71095. static get IsSupported(): boolean;
  71096. /**
  71097. * An event triggered when the system is disposed.
  71098. */
  71099. onDisposeObservable: Observable<IParticleSystem>;
  71100. /**
  71101. * Gets the maximum number of particles active at the same time.
  71102. * @returns The max number of active particles.
  71103. */
  71104. getCapacity(): number;
  71105. /**
  71106. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71107. * to override the particles.
  71108. */
  71109. forceDepthWrite: boolean;
  71110. /**
  71111. * Gets or set the number of active particles
  71112. */
  71113. get activeParticleCount(): number;
  71114. set activeParticleCount(value: number);
  71115. private _preWarmDone;
  71116. /**
  71117. * Specifies if the particles are updated in emitter local space or world space.
  71118. */
  71119. isLocal: boolean;
  71120. /** Gets or sets a matrix to use to compute projection */
  71121. defaultProjectionMatrix: Matrix;
  71122. /**
  71123. * Is this system ready to be used/rendered
  71124. * @return true if the system is ready
  71125. */
  71126. isReady(): boolean;
  71127. /**
  71128. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71129. * @returns True if it has been started, otherwise false.
  71130. */
  71131. isStarted(): boolean;
  71132. /**
  71133. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71134. * @returns True if it has been stopped, otherwise false.
  71135. */
  71136. isStopped(): boolean;
  71137. /**
  71138. * Gets a boolean indicating that the system is stopping
  71139. * @returns true if the system is currently stopping
  71140. */
  71141. isStopping(): boolean;
  71142. /**
  71143. * Gets the number of particles active at the same time.
  71144. * @returns The number of active particles.
  71145. */
  71146. getActiveCount(): number;
  71147. /**
  71148. * Starts the particle system and begins to emit
  71149. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71150. */
  71151. start(delay?: number): void;
  71152. /**
  71153. * Stops the particle system.
  71154. */
  71155. stop(): void;
  71156. /**
  71157. * Remove all active particles
  71158. */
  71159. reset(): void;
  71160. /**
  71161. * Returns the string "GPUParticleSystem"
  71162. * @returns a string containing the class name
  71163. */
  71164. getClassName(): string;
  71165. /**
  71166. * Gets the custom effect used to render the particles
  71167. * @param blendMode Blend mode for which the effect should be retrieved
  71168. * @returns The effect
  71169. */
  71170. getCustomEffect(blendMode?: number): Nullable<Effect>;
  71171. /**
  71172. * Sets the custom effect used to render the particles
  71173. * @param effect The effect to set
  71174. * @param blendMode Blend mode for which the effect should be set
  71175. */
  71176. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71177. /** @hidden */
  71178. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71179. /**
  71180. * Observable that will be called just before the particles are drawn
  71181. */
  71182. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71183. /**
  71184. * Gets the name of the particle vertex shader
  71185. */
  71186. get vertexShaderName(): string;
  71187. private _colorGradientsTexture;
  71188. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  71189. /**
  71190. * Adds a new color gradient
  71191. * @param gradient defines the gradient to use (between 0 and 1)
  71192. * @param color1 defines the color to affect to the specified gradient
  71193. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71194. * @returns the current particle system
  71195. */
  71196. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  71197. private _refreshColorGradient;
  71198. /** Force the system to rebuild all gradients that need to be resync */
  71199. forceRefreshGradients(): void;
  71200. /**
  71201. * Remove a specific color gradient
  71202. * @param gradient defines the gradient to remove
  71203. * @returns the current particle system
  71204. */
  71205. removeColorGradient(gradient: number): GPUParticleSystem;
  71206. private _angularSpeedGradientsTexture;
  71207. private _sizeGradientsTexture;
  71208. private _velocityGradientsTexture;
  71209. private _limitVelocityGradientsTexture;
  71210. private _dragGradientsTexture;
  71211. private _addFactorGradient;
  71212. /**
  71213. * Adds a new size gradient
  71214. * @param gradient defines the gradient to use (between 0 and 1)
  71215. * @param factor defines the size factor to affect to the specified gradient
  71216. * @returns the current particle system
  71217. */
  71218. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  71219. /**
  71220. * Remove a specific size gradient
  71221. * @param gradient defines the gradient to remove
  71222. * @returns the current particle system
  71223. */
  71224. removeSizeGradient(gradient: number): GPUParticleSystem;
  71225. private _refreshFactorGradient;
  71226. /**
  71227. * Adds a new angular speed gradient
  71228. * @param gradient defines the gradient to use (between 0 and 1)
  71229. * @param factor defines the angular speed to affect to the specified gradient
  71230. * @returns the current particle system
  71231. */
  71232. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  71233. /**
  71234. * Remove a specific angular speed gradient
  71235. * @param gradient defines the gradient to remove
  71236. * @returns the current particle system
  71237. */
  71238. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  71239. /**
  71240. * Adds a new velocity gradient
  71241. * @param gradient defines the gradient to use (between 0 and 1)
  71242. * @param factor defines the velocity to affect to the specified gradient
  71243. * @returns the current particle system
  71244. */
  71245. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71246. /**
  71247. * Remove a specific velocity gradient
  71248. * @param gradient defines the gradient to remove
  71249. * @returns the current particle system
  71250. */
  71251. removeVelocityGradient(gradient: number): GPUParticleSystem;
  71252. /**
  71253. * Adds a new limit velocity gradient
  71254. * @param gradient defines the gradient to use (between 0 and 1)
  71255. * @param factor defines the limit velocity value to affect to the specified gradient
  71256. * @returns the current particle system
  71257. */
  71258. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71259. /**
  71260. * Remove a specific limit velocity gradient
  71261. * @param gradient defines the gradient to remove
  71262. * @returns the current particle system
  71263. */
  71264. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  71265. /**
  71266. * Adds a new drag gradient
  71267. * @param gradient defines the gradient to use (between 0 and 1)
  71268. * @param factor defines the drag value to affect to the specified gradient
  71269. * @returns the current particle system
  71270. */
  71271. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  71272. /**
  71273. * Remove a specific drag gradient
  71274. * @param gradient defines the gradient to remove
  71275. * @returns the current particle system
  71276. */
  71277. removeDragGradient(gradient: number): GPUParticleSystem;
  71278. /**
  71279. * Not supported by GPUParticleSystem
  71280. * @param gradient defines the gradient to use (between 0 and 1)
  71281. * @param factor defines the emit rate value to affect to the specified gradient
  71282. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71283. * @returns the current particle system
  71284. */
  71285. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71286. /**
  71287. * Not supported by GPUParticleSystem
  71288. * @param gradient defines the gradient to remove
  71289. * @returns the current particle system
  71290. */
  71291. removeEmitRateGradient(gradient: number): IParticleSystem;
  71292. /**
  71293. * Not supported by GPUParticleSystem
  71294. * @param gradient defines the gradient to use (between 0 and 1)
  71295. * @param factor defines the start size value to affect to the specified gradient
  71296. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71297. * @returns the current particle system
  71298. */
  71299. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71300. /**
  71301. * Not supported by GPUParticleSystem
  71302. * @param gradient defines the gradient to remove
  71303. * @returns the current particle system
  71304. */
  71305. removeStartSizeGradient(gradient: number): IParticleSystem;
  71306. /**
  71307. * Not supported by GPUParticleSystem
  71308. * @param gradient defines the gradient to use (between 0 and 1)
  71309. * @param min defines the color remap minimal range
  71310. * @param max defines the color remap maximal range
  71311. * @returns the current particle system
  71312. */
  71313. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71314. /**
  71315. * Not supported by GPUParticleSystem
  71316. * @param gradient defines the gradient to remove
  71317. * @returns the current particle system
  71318. */
  71319. removeColorRemapGradient(): IParticleSystem;
  71320. /**
  71321. * Not supported by GPUParticleSystem
  71322. * @param gradient defines the gradient to use (between 0 and 1)
  71323. * @param min defines the alpha remap minimal range
  71324. * @param max defines the alpha remap maximal range
  71325. * @returns the current particle system
  71326. */
  71327. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71328. /**
  71329. * Not supported by GPUParticleSystem
  71330. * @param gradient defines the gradient to remove
  71331. * @returns the current particle system
  71332. */
  71333. removeAlphaRemapGradient(): IParticleSystem;
  71334. /**
  71335. * Not supported by GPUParticleSystem
  71336. * @param gradient defines the gradient to use (between 0 and 1)
  71337. * @param color defines the color to affect to the specified gradient
  71338. * @returns the current particle system
  71339. */
  71340. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  71341. /**
  71342. * Not supported by GPUParticleSystem
  71343. * @param gradient defines the gradient to remove
  71344. * @returns the current particle system
  71345. */
  71346. removeRampGradient(): IParticleSystem;
  71347. /**
  71348. * Not supported by GPUParticleSystem
  71349. * @returns the list of ramp gradients
  71350. */
  71351. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71352. /**
  71353. * Not supported by GPUParticleSystem
  71354. * Gets or sets a boolean indicating that ramp gradients must be used
  71355. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71356. */
  71357. get useRampGradients(): boolean;
  71358. set useRampGradients(value: boolean);
  71359. /**
  71360. * Not supported by GPUParticleSystem
  71361. * @param gradient defines the gradient to use (between 0 and 1)
  71362. * @param factor defines the life time factor to affect to the specified gradient
  71363. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71364. * @returns the current particle system
  71365. */
  71366. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71367. /**
  71368. * Not supported by GPUParticleSystem
  71369. * @param gradient defines the gradient to remove
  71370. * @returns the current particle system
  71371. */
  71372. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71373. /**
  71374. * Instantiates a GPU particle system.
  71375. * 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.
  71376. * @param name The name of the particle system
  71377. * @param options The options used to create the system
  71378. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  71379. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71380. * @param customEffect a custom effect used to change the way particles are rendered by default
  71381. */
  71382. constructor(name: string, options: Partial<{
  71383. capacity: number;
  71384. randomTextureSize: number;
  71385. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  71386. protected _reset(): void;
  71387. private _createUpdateVAO;
  71388. private _createRenderVAO;
  71389. private _initialize;
  71390. /** @hidden */
  71391. _recreateUpdateEffect(): void;
  71392. private _getEffect;
  71393. /**
  71394. * Fill the defines array according to the current settings of the particle system
  71395. * @param defines Array to be updated
  71396. * @param blendMode blend mode to take into account when updating the array
  71397. */
  71398. fillDefines(defines: Array<string>, blendMode?: number): void;
  71399. /**
  71400. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  71401. * @param uniforms Uniforms array to fill
  71402. * @param attributes Attributes array to fill
  71403. * @param samplers Samplers array to fill
  71404. */
  71405. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  71406. /** @hidden */
  71407. _recreateRenderEffect(): Effect;
  71408. /**
  71409. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  71410. * @param preWarm defines if we are in the pre-warmimg phase
  71411. */
  71412. animate(preWarm?: boolean): void;
  71413. private _createFactorGradientTexture;
  71414. private _createSizeGradientTexture;
  71415. private _createAngularSpeedGradientTexture;
  71416. private _createVelocityGradientTexture;
  71417. private _createLimitVelocityGradientTexture;
  71418. private _createDragGradientTexture;
  71419. private _createColorGradientTexture;
  71420. /**
  71421. * Renders the particle system in its current state
  71422. * @param preWarm defines if the system should only update the particles but not render them
  71423. * @returns the current number of particles
  71424. */
  71425. render(preWarm?: boolean): number;
  71426. /**
  71427. * Rebuilds the particle system
  71428. */
  71429. rebuild(): void;
  71430. private _releaseBuffers;
  71431. private _releaseVAOs;
  71432. /**
  71433. * Disposes the particle system and free the associated resources
  71434. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71435. */
  71436. dispose(disposeTexture?: boolean): void;
  71437. /**
  71438. * Clones the particle system.
  71439. * @param name The name of the cloned object
  71440. * @param newEmitter The new emitter to use
  71441. * @returns the cloned particle system
  71442. */
  71443. clone(name: string, newEmitter: any): GPUParticleSystem;
  71444. /**
  71445. * Serializes the particle system to a JSON object
  71446. * @param serializeTexture defines if the texture must be serialized as well
  71447. * @returns the JSON object
  71448. */
  71449. serialize(serializeTexture?: boolean): any;
  71450. /**
  71451. * Parses a JSON object to create a GPU particle system.
  71452. * @param parsedParticleSystem The JSON object to parse
  71453. * @param sceneOrEngine The scene or the engine to create the particle system in
  71454. * @param rootUrl The root url to use to load external dependencies like texture
  71455. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  71456. * @returns the parsed GPU particle system
  71457. */
  71458. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  71459. }
  71460. }
  71461. declare module "babylonjs/Particles/particleSystemSet" {
  71462. import { Nullable } from "babylonjs/types";
  71463. import { Color3 } from "babylonjs/Maths/math.color";
  71464. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71466. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71467. import { Scene, IDisposable } from "babylonjs/scene";
  71468. /**
  71469. * Represents a set of particle systems working together to create a specific effect
  71470. */
  71471. export class ParticleSystemSet implements IDisposable {
  71472. /**
  71473. * Gets or sets base Assets URL
  71474. */
  71475. static BaseAssetsUrl: string;
  71476. private _emitterCreationOptions;
  71477. private _emitterNode;
  71478. /**
  71479. * Gets the particle system list
  71480. */
  71481. systems: IParticleSystem[];
  71482. /**
  71483. * Gets the emitter node used with this set
  71484. */
  71485. get emitterNode(): Nullable<TransformNode>;
  71486. /**
  71487. * Creates a new emitter mesh as a sphere
  71488. * @param options defines the options used to create the sphere
  71489. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  71490. * @param scene defines the hosting scene
  71491. */
  71492. setEmitterAsSphere(options: {
  71493. diameter: number;
  71494. segments: number;
  71495. color: Color3;
  71496. }, renderingGroupId: number, scene: Scene): void;
  71497. /**
  71498. * Starts all particle systems of the set
  71499. * @param emitter defines an optional mesh to use as emitter for the particle systems
  71500. */
  71501. start(emitter?: AbstractMesh): void;
  71502. /**
  71503. * Release all associated resources
  71504. */
  71505. dispose(): void;
  71506. /**
  71507. * Serialize the set into a JSON compatible object
  71508. * @param serializeTexture defines if the texture must be serialized as well
  71509. * @returns a JSON compatible representation of the set
  71510. */
  71511. serialize(serializeTexture?: boolean): any;
  71512. /**
  71513. * Parse a new ParticleSystemSet from a serialized source
  71514. * @param data defines a JSON compatible representation of the set
  71515. * @param scene defines the hosting scene
  71516. * @param gpu defines if we want GPU particles or CPU particles
  71517. * @returns a new ParticleSystemSet
  71518. */
  71519. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  71520. }
  71521. }
  71522. declare module "babylonjs/Particles/particleHelper" {
  71523. import { Nullable } from "babylonjs/types";
  71524. import { Scene } from "babylonjs/scene";
  71525. import { Vector3 } from "babylonjs/Maths/math.vector";
  71526. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71527. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71528. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  71529. /**
  71530. * This class is made for on one-liner static method to help creating particle system set.
  71531. */
  71532. export class ParticleHelper {
  71533. /**
  71534. * Gets or sets base Assets URL
  71535. */
  71536. static BaseAssetsUrl: string;
  71537. /** Define the Url to load snippets */
  71538. static SnippetUrl: string;
  71539. /**
  71540. * Create a default particle system that you can tweak
  71541. * @param emitter defines the emitter to use
  71542. * @param capacity defines the system capacity (default is 500 particles)
  71543. * @param scene defines the hosting scene
  71544. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  71545. * @returns the new Particle system
  71546. */
  71547. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  71548. /**
  71549. * This is the main static method (one-liner) of this helper to create different particle systems
  71550. * @param type This string represents the type to the particle system to create
  71551. * @param scene The scene where the particle system should live
  71552. * @param gpu If the system will use gpu
  71553. * @returns the ParticleSystemSet created
  71554. */
  71555. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  71556. /**
  71557. * Static function used to export a particle system to a ParticleSystemSet variable.
  71558. * Please note that the emitter shape is not exported
  71559. * @param systems defines the particle systems to export
  71560. * @returns the created particle system set
  71561. */
  71562. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  71563. /**
  71564. * Creates a particle system from a snippet saved in a remote file
  71565. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  71566. * @param url defines the url to load from
  71567. * @param scene defines the hosting scene
  71568. * @param gpu If the system will use gpu
  71569. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71570. * @returns a promise that will resolve to the new particle system
  71571. */
  71572. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71573. /**
  71574. * Creates a particle system from a snippet saved by the particle system editor
  71575. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  71576. * @param scene defines the hosting scene
  71577. * @param gpu If the system will use gpu
  71578. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71579. * @returns a promise that will resolve to the new particle system
  71580. */
  71581. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71582. }
  71583. }
  71584. declare module "babylonjs/Particles/particleSystemComponent" {
  71585. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71586. import { Effect } from "babylonjs/Materials/effect";
  71587. import "babylonjs/Shaders/particles.vertex";
  71588. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  71589. module "babylonjs/Engines/engine" {
  71590. interface Engine {
  71591. /**
  71592. * Create an effect to use with particle systems.
  71593. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  71594. * the particle system for which you want to create a custom effect in the last parameter
  71595. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  71596. * @param uniformsNames defines a list of attribute names
  71597. * @param samplers defines an array of string used to represent textures
  71598. * @param defines defines the string containing the defines to use to compile the shaders
  71599. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  71600. * @param onCompiled defines a function to call when the effect creation is successful
  71601. * @param onError defines a function to call when the effect creation has failed
  71602. * @param particleSystem the particle system you want to create the effect for
  71603. * @returns the new Effect
  71604. */
  71605. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  71606. }
  71607. }
  71608. module "babylonjs/Meshes/mesh" {
  71609. interface Mesh {
  71610. /**
  71611. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  71612. * @returns an array of IParticleSystem
  71613. */
  71614. getEmittedParticleSystems(): IParticleSystem[];
  71615. /**
  71616. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  71617. * @returns an array of IParticleSystem
  71618. */
  71619. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  71620. }
  71621. }
  71622. }
  71623. declare module "babylonjs/Particles/pointsCloudSystem" {
  71624. import { Color4 } from "babylonjs/Maths/math";
  71625. import { Mesh } from "babylonjs/Meshes/mesh";
  71626. import { Scene, IDisposable } from "babylonjs/scene";
  71627. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  71628. /** Defines the 4 color options */
  71629. export enum PointColor {
  71630. /** color value */
  71631. Color = 2,
  71632. /** uv value */
  71633. UV = 1,
  71634. /** random value */
  71635. Random = 0,
  71636. /** stated value */
  71637. Stated = 3
  71638. }
  71639. /**
  71640. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  71641. * 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.
  71642. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  71643. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  71644. *
  71645. * Full documentation here : TO BE ENTERED
  71646. */
  71647. export class PointsCloudSystem implements IDisposable {
  71648. /**
  71649. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  71650. * Example : var p = SPS.particles[i];
  71651. */
  71652. particles: CloudPoint[];
  71653. /**
  71654. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  71655. */
  71656. nbParticles: number;
  71657. /**
  71658. * This a counter for your own usage. It's not set by any SPS functions.
  71659. */
  71660. counter: number;
  71661. /**
  71662. * The PCS name. This name is also given to the underlying mesh.
  71663. */
  71664. name: string;
  71665. /**
  71666. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  71667. */
  71668. mesh: Mesh;
  71669. /**
  71670. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  71671. * Please read :
  71672. */
  71673. vars: any;
  71674. /**
  71675. * @hidden
  71676. */
  71677. _size: number;
  71678. private _scene;
  71679. private _promises;
  71680. private _positions;
  71681. private _indices;
  71682. private _normals;
  71683. private _colors;
  71684. private _uvs;
  71685. private _indices32;
  71686. private _positions32;
  71687. private _colors32;
  71688. private _uvs32;
  71689. private _updatable;
  71690. private _isVisibilityBoxLocked;
  71691. private _alwaysVisible;
  71692. private _groups;
  71693. private _groupCounter;
  71694. private _computeParticleColor;
  71695. private _computeParticleTexture;
  71696. private _computeParticleRotation;
  71697. private _computeBoundingBox;
  71698. private _isReady;
  71699. /**
  71700. * Creates a PCS (Points Cloud System) object
  71701. * @param name (String) is the PCS name, this will be the underlying mesh name
  71702. * @param pointSize (number) is the size for each point
  71703. * @param scene (Scene) is the scene in which the PCS is added
  71704. * @param options defines the options of the PCS e.g.
  71705. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  71706. */
  71707. constructor(name: string, pointSize: number, scene: Scene, options?: {
  71708. updatable?: boolean;
  71709. });
  71710. /**
  71711. * Builds the PCS underlying mesh. Returns a standard Mesh.
  71712. * If no points were added to the PCS, the returned mesh is just a single point.
  71713. * @returns a promise for the created mesh
  71714. */
  71715. buildMeshAsync(): Promise<Mesh>;
  71716. /**
  71717. * @hidden
  71718. */
  71719. private _buildMesh;
  71720. private _addParticle;
  71721. private _randomUnitVector;
  71722. private _getColorIndicesForCoord;
  71723. private _setPointsColorOrUV;
  71724. private _colorFromTexture;
  71725. private _calculateDensity;
  71726. /**
  71727. * Adds points to the PCS in random positions within a unit sphere
  71728. * @param nb (positive integer) the number of particles to be created from this model
  71729. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  71730. * @returns the number of groups in the system
  71731. */
  71732. addPoints(nb: number, pointFunction?: any): number;
  71733. /**
  71734. * Adds points to the PCS from the surface of the model shape
  71735. * @param mesh is any Mesh object that will be used as a surface model for the points
  71736. * @param nb (positive integer) the number of particles to be created from this model
  71737. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71738. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71739. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71740. * @returns the number of groups in the system
  71741. */
  71742. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71743. /**
  71744. * Adds points to the PCS inside the model shape
  71745. * @param mesh is any Mesh object that will be used as a surface model for the points
  71746. * @param nb (positive integer) the number of particles to be created from this model
  71747. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71748. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71749. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71750. * @returns the number of groups in the system
  71751. */
  71752. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71753. /**
  71754. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  71755. * This method calls `updateParticle()` for each particle of the SPS.
  71756. * For an animated SPS, it is usually called within the render loop.
  71757. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  71758. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  71759. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  71760. * @returns the PCS.
  71761. */
  71762. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  71763. /**
  71764. * Disposes the PCS.
  71765. */
  71766. dispose(): void;
  71767. /**
  71768. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  71769. * doc :
  71770. * @returns the PCS.
  71771. */
  71772. refreshVisibleSize(): PointsCloudSystem;
  71773. /**
  71774. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  71775. * @param size the size (float) of the visibility box
  71776. * note : this doesn't lock the PCS mesh bounding box.
  71777. * doc :
  71778. */
  71779. setVisibilityBox(size: number): void;
  71780. /**
  71781. * Gets whether the PCS is always visible or not
  71782. * doc :
  71783. */
  71784. get isAlwaysVisible(): boolean;
  71785. /**
  71786. * Sets the PCS as always visible or not
  71787. * doc :
  71788. */
  71789. set isAlwaysVisible(val: boolean);
  71790. /**
  71791. * Tells to `setParticles()` to compute the particle rotations or not
  71792. * Default value : false. The PCS is faster when it's set to false
  71793. * Note : particle rotations are only applied to parent particles
  71794. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  71795. */
  71796. set computeParticleRotation(val: boolean);
  71797. /**
  71798. * Tells to `setParticles()` to compute the particle colors or not.
  71799. * Default value : true. The PCS is faster when it's set to false.
  71800. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71801. */
  71802. set computeParticleColor(val: boolean);
  71803. set computeParticleTexture(val: boolean);
  71804. /**
  71805. * Gets if `setParticles()` computes the particle colors or not.
  71806. * Default value : false. The PCS is faster when it's set to false.
  71807. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71808. */
  71809. get computeParticleColor(): boolean;
  71810. /**
  71811. * Gets if `setParticles()` computes the particle textures or not.
  71812. * Default value : false. The PCS is faster when it's set to false.
  71813. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  71814. */
  71815. get computeParticleTexture(): boolean;
  71816. /**
  71817. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  71818. */
  71819. set computeBoundingBox(val: boolean);
  71820. /**
  71821. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  71822. */
  71823. get computeBoundingBox(): boolean;
  71824. /**
  71825. * This function does nothing. It may be overwritten to set all the particle first values.
  71826. * The PCS doesn't call this function, you may have to call it by your own.
  71827. * doc :
  71828. */
  71829. initParticles(): void;
  71830. /**
  71831. * This function does nothing. It may be overwritten to recycle a particle
  71832. * The PCS doesn't call this function, you can to call it
  71833. * doc :
  71834. * @param particle The particle to recycle
  71835. * @returns the recycled particle
  71836. */
  71837. recycleParticle(particle: CloudPoint): CloudPoint;
  71838. /**
  71839. * Updates a particle : this function should be overwritten by the user.
  71840. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  71841. * doc :
  71842. * @example : just set a particle position or velocity and recycle conditions
  71843. * @param particle The particle to update
  71844. * @returns the updated particle
  71845. */
  71846. updateParticle(particle: CloudPoint): CloudPoint;
  71847. /**
  71848. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  71849. * This does nothing and may be overwritten by the user.
  71850. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71851. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71852. * @param update the boolean update value actually passed to setParticles()
  71853. */
  71854. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71855. /**
  71856. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  71857. * This will be passed three parameters.
  71858. * This does nothing and may be overwritten by the user.
  71859. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71860. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71861. * @param update the boolean update value actually passed to setParticles()
  71862. */
  71863. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71864. }
  71865. }
  71866. declare module "babylonjs/Particles/cloudPoint" {
  71867. import { Nullable } from "babylonjs/types";
  71868. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  71869. import { Mesh } from "babylonjs/Meshes/mesh";
  71870. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  71871. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  71872. /**
  71873. * Represents one particle of a points cloud system.
  71874. */
  71875. export class CloudPoint {
  71876. /**
  71877. * particle global index
  71878. */
  71879. idx: number;
  71880. /**
  71881. * The color of the particle
  71882. */
  71883. color: Nullable<Color4>;
  71884. /**
  71885. * The world space position of the particle.
  71886. */
  71887. position: Vector3;
  71888. /**
  71889. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  71890. */
  71891. rotation: Vector3;
  71892. /**
  71893. * The world space rotation quaternion of the particle.
  71894. */
  71895. rotationQuaternion: Nullable<Quaternion>;
  71896. /**
  71897. * The uv of the particle.
  71898. */
  71899. uv: Nullable<Vector2>;
  71900. /**
  71901. * The current speed of the particle.
  71902. */
  71903. velocity: Vector3;
  71904. /**
  71905. * The pivot point in the particle local space.
  71906. */
  71907. pivot: Vector3;
  71908. /**
  71909. * Must the particle be translated from its pivot point in its local space ?
  71910. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  71911. * Default : false
  71912. */
  71913. translateFromPivot: boolean;
  71914. /**
  71915. * Index of this particle in the global "positions" array (Internal use)
  71916. * @hidden
  71917. */
  71918. _pos: number;
  71919. /**
  71920. * @hidden Index of this particle in the global "indices" array (Internal use)
  71921. */
  71922. _ind: number;
  71923. /**
  71924. * Group this particle belongs to
  71925. */
  71926. _group: PointsGroup;
  71927. /**
  71928. * Group id of this particle
  71929. */
  71930. groupId: number;
  71931. /**
  71932. * Index of the particle in its group id (Internal use)
  71933. */
  71934. idxInGroup: number;
  71935. /**
  71936. * @hidden Particle BoundingInfo object (Internal use)
  71937. */
  71938. _boundingInfo: BoundingInfo;
  71939. /**
  71940. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  71941. */
  71942. _pcs: PointsCloudSystem;
  71943. /**
  71944. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  71945. */
  71946. _stillInvisible: boolean;
  71947. /**
  71948. * @hidden Last computed particle rotation matrix
  71949. */
  71950. _rotationMatrix: number[];
  71951. /**
  71952. * Parent particle Id, if any.
  71953. * Default null.
  71954. */
  71955. parentId: Nullable<number>;
  71956. /**
  71957. * @hidden Internal global position in the PCS.
  71958. */
  71959. _globalPosition: Vector3;
  71960. /**
  71961. * Creates a Point Cloud object.
  71962. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  71963. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  71964. * @param group (PointsGroup) is the group the particle belongs to
  71965. * @param groupId (integer) is the group identifier in the PCS.
  71966. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  71967. * @param pcs defines the PCS it is associated to
  71968. */
  71969. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  71970. /**
  71971. * get point size
  71972. */
  71973. get size(): Vector3;
  71974. /**
  71975. * Set point size
  71976. */
  71977. set size(scale: Vector3);
  71978. /**
  71979. * Legacy support, changed quaternion to rotationQuaternion
  71980. */
  71981. get quaternion(): Nullable<Quaternion>;
  71982. /**
  71983. * Legacy support, changed quaternion to rotationQuaternion
  71984. */
  71985. set quaternion(q: Nullable<Quaternion>);
  71986. /**
  71987. * Returns a boolean. True if the particle intersects a mesh, else false
  71988. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  71989. * @param target is the object (point or mesh) what the intersection is computed against
  71990. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  71991. * @returns true if it intersects
  71992. */
  71993. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  71994. /**
  71995. * get the rotation matrix of the particle
  71996. * @hidden
  71997. */
  71998. getRotationMatrix(m: Matrix): void;
  71999. }
  72000. /**
  72001. * Represents a group of points in a points cloud system
  72002. * * PCS internal tool, don't use it manually.
  72003. */
  72004. export class PointsGroup {
  72005. /**
  72006. * The group id
  72007. * @hidden
  72008. */
  72009. groupID: number;
  72010. /**
  72011. * image data for group (internal use)
  72012. * @hidden
  72013. */
  72014. _groupImageData: Nullable<ArrayBufferView>;
  72015. /**
  72016. * Image Width (internal use)
  72017. * @hidden
  72018. */
  72019. _groupImgWidth: number;
  72020. /**
  72021. * Image Height (internal use)
  72022. * @hidden
  72023. */
  72024. _groupImgHeight: number;
  72025. /**
  72026. * Custom position function (internal use)
  72027. * @hidden
  72028. */
  72029. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72030. /**
  72031. * density per facet for surface points
  72032. * @hidden
  72033. */
  72034. _groupDensity: number[];
  72035. /**
  72036. * Only when points are colored by texture carries pointer to texture list array
  72037. * @hidden
  72038. */
  72039. _textureNb: number;
  72040. /**
  72041. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72042. * PCS internal tool, don't use it manually.
  72043. * @hidden
  72044. */
  72045. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72046. }
  72047. }
  72048. declare module "babylonjs/Particles/index" {
  72049. export * from "babylonjs/Particles/baseParticleSystem";
  72050. export * from "babylonjs/Particles/EmitterTypes/index";
  72051. export * from "babylonjs/Particles/gpuParticleSystem";
  72052. export * from "babylonjs/Particles/IParticleSystem";
  72053. export * from "babylonjs/Particles/particle";
  72054. export * from "babylonjs/Particles/particleHelper";
  72055. export * from "babylonjs/Particles/particleSystem";
  72056. import "babylonjs/Particles/particleSystemComponent";
  72057. export * from "babylonjs/Particles/particleSystemComponent";
  72058. export * from "babylonjs/Particles/particleSystemSet";
  72059. export * from "babylonjs/Particles/solidParticle";
  72060. export * from "babylonjs/Particles/solidParticleSystem";
  72061. export * from "babylonjs/Particles/cloudPoint";
  72062. export * from "babylonjs/Particles/pointsCloudSystem";
  72063. export * from "babylonjs/Particles/subEmitter";
  72064. }
  72065. declare module "babylonjs/Physics/physicsEngineComponent" {
  72066. import { Nullable } from "babylonjs/types";
  72067. import { Observable, Observer } from "babylonjs/Misc/observable";
  72068. import { Vector3 } from "babylonjs/Maths/math.vector";
  72069. import { Mesh } from "babylonjs/Meshes/mesh";
  72070. import { ISceneComponent } from "babylonjs/sceneComponent";
  72071. import { Scene } from "babylonjs/scene";
  72072. import { Node } from "babylonjs/node";
  72073. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  72074. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72075. module "babylonjs/scene" {
  72076. interface Scene {
  72077. /** @hidden (Backing field) */
  72078. _physicsEngine: Nullable<IPhysicsEngine>;
  72079. /** @hidden */
  72080. _physicsTimeAccumulator: number;
  72081. /**
  72082. * Gets the current physics engine
  72083. * @returns a IPhysicsEngine or null if none attached
  72084. */
  72085. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72086. /**
  72087. * Enables physics to the current scene
  72088. * @param gravity defines the scene's gravity for the physics engine
  72089. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72090. * @return a boolean indicating if the physics engine was initialized
  72091. */
  72092. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72093. /**
  72094. * Disables and disposes the physics engine associated with the scene
  72095. */
  72096. disablePhysicsEngine(): void;
  72097. /**
  72098. * Gets a boolean indicating if there is an active physics engine
  72099. * @returns a boolean indicating if there is an active physics engine
  72100. */
  72101. isPhysicsEnabled(): boolean;
  72102. /**
  72103. * Deletes a physics compound impostor
  72104. * @param compound defines the compound to delete
  72105. */
  72106. deleteCompoundImpostor(compound: any): void;
  72107. /**
  72108. * An event triggered when physic simulation is about to be run
  72109. */
  72110. onBeforePhysicsObservable: Observable<Scene>;
  72111. /**
  72112. * An event triggered when physic simulation has been done
  72113. */
  72114. onAfterPhysicsObservable: Observable<Scene>;
  72115. }
  72116. }
  72117. module "babylonjs/Meshes/abstractMesh" {
  72118. interface AbstractMesh {
  72119. /** @hidden */
  72120. _physicsImpostor: Nullable<PhysicsImpostor>;
  72121. /**
  72122. * Gets or sets impostor used for physic simulation
  72123. * @see https://doc.babylonjs.com/features/physics_engine
  72124. */
  72125. physicsImpostor: Nullable<PhysicsImpostor>;
  72126. /**
  72127. * Gets the current physics impostor
  72128. * @see https://doc.babylonjs.com/features/physics_engine
  72129. * @returns a physics impostor or null
  72130. */
  72131. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72132. /** Apply a physic impulse to the mesh
  72133. * @param force defines the force to apply
  72134. * @param contactPoint defines where to apply the force
  72135. * @returns the current mesh
  72136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72137. */
  72138. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72139. /**
  72140. * Creates a physic joint between two meshes
  72141. * @param otherMesh defines the other mesh to use
  72142. * @param pivot1 defines the pivot to use on this mesh
  72143. * @param pivot2 defines the pivot to use on the other mesh
  72144. * @param options defines additional options (can be plugin dependent)
  72145. * @returns the current mesh
  72146. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72147. */
  72148. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72149. /** @hidden */
  72150. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72151. }
  72152. }
  72153. /**
  72154. * Defines the physics engine scene component responsible to manage a physics engine
  72155. */
  72156. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72157. /**
  72158. * The component name helpful to identify the component in the list of scene components.
  72159. */
  72160. readonly name: string;
  72161. /**
  72162. * The scene the component belongs to.
  72163. */
  72164. scene: Scene;
  72165. /**
  72166. * Creates a new instance of the component for the given scene
  72167. * @param scene Defines the scene to register the component in
  72168. */
  72169. constructor(scene: Scene);
  72170. /**
  72171. * Registers the component in a given scene
  72172. */
  72173. register(): void;
  72174. /**
  72175. * Rebuilds the elements related to this component in case of
  72176. * context lost for instance.
  72177. */
  72178. rebuild(): void;
  72179. /**
  72180. * Disposes the component and the associated ressources
  72181. */
  72182. dispose(): void;
  72183. }
  72184. }
  72185. declare module "babylonjs/Physics/physicsHelper" {
  72186. import { Nullable } from "babylonjs/types";
  72187. import { Vector3 } from "babylonjs/Maths/math.vector";
  72188. import { Mesh } from "babylonjs/Meshes/mesh";
  72189. import { Scene } from "babylonjs/scene";
  72190. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72191. /**
  72192. * A helper for physics simulations
  72193. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72194. */
  72195. export class PhysicsHelper {
  72196. private _scene;
  72197. private _physicsEngine;
  72198. /**
  72199. * Initializes the Physics helper
  72200. * @param scene Babylon.js scene
  72201. */
  72202. constructor(scene: Scene);
  72203. /**
  72204. * Applies a radial explosion impulse
  72205. * @param origin the origin of the explosion
  72206. * @param radiusOrEventOptions the radius or the options of radial explosion
  72207. * @param strength the explosion strength
  72208. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72209. * @returns A physics radial explosion event, or null
  72210. */
  72211. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72212. /**
  72213. * Applies a radial explosion force
  72214. * @param origin the origin of the explosion
  72215. * @param radiusOrEventOptions the radius or the options of radial explosion
  72216. * @param strength the explosion strength
  72217. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72218. * @returns A physics radial explosion event, or null
  72219. */
  72220. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72221. /**
  72222. * Creates a gravitational field
  72223. * @param origin the origin of the explosion
  72224. * @param radiusOrEventOptions the radius or the options of radial explosion
  72225. * @param strength the explosion strength
  72226. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72227. * @returns A physics gravitational field event, or null
  72228. */
  72229. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72230. /**
  72231. * Creates a physics updraft event
  72232. * @param origin the origin of the updraft
  72233. * @param radiusOrEventOptions the radius or the options of the updraft
  72234. * @param strength the strength of the updraft
  72235. * @param height the height of the updraft
  72236. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  72237. * @returns A physics updraft event, or null
  72238. */
  72239. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  72240. /**
  72241. * Creates a physics vortex event
  72242. * @param origin the of the vortex
  72243. * @param radiusOrEventOptions the radius or the options of the vortex
  72244. * @param strength the strength of the vortex
  72245. * @param height the height of the vortex
  72246. * @returns a Physics vortex event, or null
  72247. * A physics vortex event or null
  72248. */
  72249. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  72250. }
  72251. /**
  72252. * Represents a physics radial explosion event
  72253. */
  72254. class PhysicsRadialExplosionEvent {
  72255. private _scene;
  72256. private _options;
  72257. private _sphere;
  72258. private _dataFetched;
  72259. /**
  72260. * Initializes a radial explosioin event
  72261. * @param _scene BabylonJS scene
  72262. * @param _options The options for the vortex event
  72263. */
  72264. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  72265. /**
  72266. * Returns the data related to the radial explosion event (sphere).
  72267. * @returns The radial explosion event data
  72268. */
  72269. getData(): PhysicsRadialExplosionEventData;
  72270. /**
  72271. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  72272. * @param impostor A physics imposter
  72273. * @param origin the origin of the explosion
  72274. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  72275. */
  72276. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  72277. /**
  72278. * Triggers affecterd impostors callbacks
  72279. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  72280. */
  72281. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  72282. /**
  72283. * Disposes the sphere.
  72284. * @param force Specifies if the sphere should be disposed by force
  72285. */
  72286. dispose(force?: boolean): void;
  72287. /*** Helpers ***/
  72288. private _prepareSphere;
  72289. private _intersectsWithSphere;
  72290. }
  72291. /**
  72292. * Represents a gravitational field event
  72293. */
  72294. class PhysicsGravitationalFieldEvent {
  72295. private _physicsHelper;
  72296. private _scene;
  72297. private _origin;
  72298. private _options;
  72299. private _tickCallback;
  72300. private _sphere;
  72301. private _dataFetched;
  72302. /**
  72303. * Initializes the physics gravitational field event
  72304. * @param _physicsHelper A physics helper
  72305. * @param _scene BabylonJS scene
  72306. * @param _origin The origin position of the gravitational field event
  72307. * @param _options The options for the vortex event
  72308. */
  72309. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  72310. /**
  72311. * Returns the data related to the gravitational field event (sphere).
  72312. * @returns A gravitational field event
  72313. */
  72314. getData(): PhysicsGravitationalFieldEventData;
  72315. /**
  72316. * Enables the gravitational field.
  72317. */
  72318. enable(): void;
  72319. /**
  72320. * Disables the gravitational field.
  72321. */
  72322. disable(): void;
  72323. /**
  72324. * Disposes the sphere.
  72325. * @param force The force to dispose from the gravitational field event
  72326. */
  72327. dispose(force?: boolean): void;
  72328. private _tick;
  72329. }
  72330. /**
  72331. * Represents a physics updraft event
  72332. */
  72333. class PhysicsUpdraftEvent {
  72334. private _scene;
  72335. private _origin;
  72336. private _options;
  72337. private _physicsEngine;
  72338. private _originTop;
  72339. private _originDirection;
  72340. private _tickCallback;
  72341. private _cylinder;
  72342. private _cylinderPosition;
  72343. private _dataFetched;
  72344. /**
  72345. * Initializes the physics updraft event
  72346. * @param _scene BabylonJS scene
  72347. * @param _origin The origin position of the updraft
  72348. * @param _options The options for the updraft event
  72349. */
  72350. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  72351. /**
  72352. * Returns the data related to the updraft event (cylinder).
  72353. * @returns A physics updraft event
  72354. */
  72355. getData(): PhysicsUpdraftEventData;
  72356. /**
  72357. * Enables the updraft.
  72358. */
  72359. enable(): void;
  72360. /**
  72361. * Disables the updraft.
  72362. */
  72363. disable(): void;
  72364. /**
  72365. * Disposes the cylinder.
  72366. * @param force Specifies if the updraft should be disposed by force
  72367. */
  72368. dispose(force?: boolean): void;
  72369. private getImpostorHitData;
  72370. private _tick;
  72371. /*** Helpers ***/
  72372. private _prepareCylinder;
  72373. private _intersectsWithCylinder;
  72374. }
  72375. /**
  72376. * Represents a physics vortex event
  72377. */
  72378. class PhysicsVortexEvent {
  72379. private _scene;
  72380. private _origin;
  72381. private _options;
  72382. private _physicsEngine;
  72383. private _originTop;
  72384. private _tickCallback;
  72385. private _cylinder;
  72386. private _cylinderPosition;
  72387. private _dataFetched;
  72388. /**
  72389. * Initializes the physics vortex event
  72390. * @param _scene The BabylonJS scene
  72391. * @param _origin The origin position of the vortex
  72392. * @param _options The options for the vortex event
  72393. */
  72394. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  72395. /**
  72396. * Returns the data related to the vortex event (cylinder).
  72397. * @returns The physics vortex event data
  72398. */
  72399. getData(): PhysicsVortexEventData;
  72400. /**
  72401. * Enables the vortex.
  72402. */
  72403. enable(): void;
  72404. /**
  72405. * Disables the cortex.
  72406. */
  72407. disable(): void;
  72408. /**
  72409. * Disposes the sphere.
  72410. * @param force
  72411. */
  72412. dispose(force?: boolean): void;
  72413. private getImpostorHitData;
  72414. private _tick;
  72415. /*** Helpers ***/
  72416. private _prepareCylinder;
  72417. private _intersectsWithCylinder;
  72418. }
  72419. /**
  72420. * Options fot the radial explosion event
  72421. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72422. */
  72423. export class PhysicsRadialExplosionEventOptions {
  72424. /**
  72425. * The radius of the sphere for the radial explosion.
  72426. */
  72427. radius: number;
  72428. /**
  72429. * The strenth of the explosion.
  72430. */
  72431. strength: number;
  72432. /**
  72433. * The strenght of the force in correspondence to the distance of the affected object
  72434. */
  72435. falloff: PhysicsRadialImpulseFalloff;
  72436. /**
  72437. * Sphere options for the radial explosion.
  72438. */
  72439. sphere: {
  72440. segments: number;
  72441. diameter: number;
  72442. };
  72443. /**
  72444. * Sphere options for the radial explosion.
  72445. */
  72446. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  72447. }
  72448. /**
  72449. * Options fot the updraft event
  72450. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72451. */
  72452. export class PhysicsUpdraftEventOptions {
  72453. /**
  72454. * The radius of the cylinder for the vortex
  72455. */
  72456. radius: number;
  72457. /**
  72458. * The strenth of the updraft.
  72459. */
  72460. strength: number;
  72461. /**
  72462. * The height of the cylinder for the updraft.
  72463. */
  72464. height: number;
  72465. /**
  72466. * The mode for the the updraft.
  72467. */
  72468. updraftMode: PhysicsUpdraftMode;
  72469. }
  72470. /**
  72471. * Options fot the vortex event
  72472. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72473. */
  72474. export class PhysicsVortexEventOptions {
  72475. /**
  72476. * The radius of the cylinder for the vortex
  72477. */
  72478. radius: number;
  72479. /**
  72480. * The strenth of the vortex.
  72481. */
  72482. strength: number;
  72483. /**
  72484. * The height of the cylinder for the vortex.
  72485. */
  72486. height: number;
  72487. /**
  72488. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  72489. */
  72490. centripetalForceThreshold: number;
  72491. /**
  72492. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  72493. */
  72494. centripetalForceMultiplier: number;
  72495. /**
  72496. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  72497. */
  72498. centrifugalForceMultiplier: number;
  72499. /**
  72500. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  72501. */
  72502. updraftForceMultiplier: number;
  72503. }
  72504. /**
  72505. * The strenght of the force in correspondence to the distance of the affected object
  72506. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72507. */
  72508. export enum PhysicsRadialImpulseFalloff {
  72509. /** Defines that impulse is constant in strength across it's whole radius */
  72510. Constant = 0,
  72511. /** Defines that impulse gets weaker if it's further from the origin */
  72512. Linear = 1
  72513. }
  72514. /**
  72515. * The strength of the force in correspondence to the distance of the affected object
  72516. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72517. */
  72518. export enum PhysicsUpdraftMode {
  72519. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  72520. Center = 0,
  72521. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  72522. Perpendicular = 1
  72523. }
  72524. /**
  72525. * Interface for a physics hit data
  72526. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72527. */
  72528. export interface PhysicsHitData {
  72529. /**
  72530. * The force applied at the contact point
  72531. */
  72532. force: Vector3;
  72533. /**
  72534. * The contact point
  72535. */
  72536. contactPoint: Vector3;
  72537. /**
  72538. * The distance from the origin to the contact point
  72539. */
  72540. distanceFromOrigin: number;
  72541. }
  72542. /**
  72543. * Interface for radial explosion event data
  72544. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72545. */
  72546. export interface PhysicsRadialExplosionEventData {
  72547. /**
  72548. * A sphere used for the radial explosion event
  72549. */
  72550. sphere: Mesh;
  72551. }
  72552. /**
  72553. * Interface for gravitational field event data
  72554. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72555. */
  72556. export interface PhysicsGravitationalFieldEventData {
  72557. /**
  72558. * A sphere mesh used for the gravitational field event
  72559. */
  72560. sphere: Mesh;
  72561. }
  72562. /**
  72563. * Interface for updraft event data
  72564. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72565. */
  72566. export interface PhysicsUpdraftEventData {
  72567. /**
  72568. * A cylinder used for the updraft event
  72569. */
  72570. cylinder: Mesh;
  72571. }
  72572. /**
  72573. * Interface for vortex event data
  72574. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72575. */
  72576. export interface PhysicsVortexEventData {
  72577. /**
  72578. * A cylinder used for the vortex event
  72579. */
  72580. cylinder: Mesh;
  72581. }
  72582. /**
  72583. * Interface for an affected physics impostor
  72584. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72585. */
  72586. export interface PhysicsAffectedImpostorWithData {
  72587. /**
  72588. * The impostor affected by the effect
  72589. */
  72590. impostor: PhysicsImpostor;
  72591. /**
  72592. * The data about the hit/horce from the explosion
  72593. */
  72594. hitData: PhysicsHitData;
  72595. }
  72596. }
  72597. declare module "babylonjs/Physics/Plugins/index" {
  72598. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  72599. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  72600. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  72601. }
  72602. declare module "babylonjs/Physics/index" {
  72603. export * from "babylonjs/Physics/IPhysicsEngine";
  72604. export * from "babylonjs/Physics/physicsEngine";
  72605. export * from "babylonjs/Physics/physicsEngineComponent";
  72606. export * from "babylonjs/Physics/physicsHelper";
  72607. export * from "babylonjs/Physics/physicsImpostor";
  72608. export * from "babylonjs/Physics/physicsJoint";
  72609. export * from "babylonjs/Physics/Plugins/index";
  72610. }
  72611. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  72612. /** @hidden */
  72613. export var blackAndWhitePixelShader: {
  72614. name: string;
  72615. shader: string;
  72616. };
  72617. }
  72618. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  72619. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72620. import { Camera } from "babylonjs/Cameras/camera";
  72621. import { Engine } from "babylonjs/Engines/engine";
  72622. import "babylonjs/Shaders/blackAndWhite.fragment";
  72623. import { Nullable } from "babylonjs/types";
  72624. import { Scene } from "babylonjs/scene";
  72625. /**
  72626. * Post process used to render in black and white
  72627. */
  72628. export class BlackAndWhitePostProcess extends PostProcess {
  72629. /**
  72630. * Linear about to convert he result to black and white (default: 1)
  72631. */
  72632. degree: number;
  72633. /**
  72634. * Gets a string identifying the name of the class
  72635. * @returns "BlackAndWhitePostProcess" string
  72636. */
  72637. getClassName(): string;
  72638. /**
  72639. * Creates a black and white post process
  72640. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  72641. * @param name The name of the effect.
  72642. * @param options The required width/height ratio to downsize to before computing the render pass.
  72643. * @param camera The camera to apply the render pass to.
  72644. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72645. * @param engine The engine which the post process will be applied. (default: current engine)
  72646. * @param reusable If the post process can be reused on the same frame. (default: false)
  72647. */
  72648. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72649. /** @hidden */
  72650. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  72651. }
  72652. }
  72653. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  72654. import { Nullable } from "babylonjs/types";
  72655. import { Camera } from "babylonjs/Cameras/camera";
  72656. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72657. import { Engine } from "babylonjs/Engines/engine";
  72658. /**
  72659. * This represents a set of one or more post processes in Babylon.
  72660. * A post process can be used to apply a shader to a texture after it is rendered.
  72661. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72662. */
  72663. export class PostProcessRenderEffect {
  72664. private _postProcesses;
  72665. private _getPostProcesses;
  72666. private _singleInstance;
  72667. private _cameras;
  72668. private _indicesForCamera;
  72669. /**
  72670. * Name of the effect
  72671. * @hidden
  72672. */
  72673. _name: string;
  72674. /**
  72675. * Instantiates a post process render effect.
  72676. * A post process can be used to apply a shader to a texture after it is rendered.
  72677. * @param engine The engine the effect is tied to
  72678. * @param name The name of the effect
  72679. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  72680. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  72681. */
  72682. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  72683. /**
  72684. * Checks if all the post processes in the effect are supported.
  72685. */
  72686. get isSupported(): boolean;
  72687. /**
  72688. * Updates the current state of the effect
  72689. * @hidden
  72690. */
  72691. _update(): void;
  72692. /**
  72693. * Attaches the effect on cameras
  72694. * @param cameras The camera to attach to.
  72695. * @hidden
  72696. */
  72697. _attachCameras(cameras: Camera): void;
  72698. /**
  72699. * Attaches the effect on cameras
  72700. * @param cameras The camera to attach to.
  72701. * @hidden
  72702. */
  72703. _attachCameras(cameras: Camera[]): void;
  72704. /**
  72705. * Detaches the effect on cameras
  72706. * @param cameras The camera to detatch from.
  72707. * @hidden
  72708. */
  72709. _detachCameras(cameras: Camera): void;
  72710. /**
  72711. * Detatches the effect on cameras
  72712. * @param cameras The camera to detatch from.
  72713. * @hidden
  72714. */
  72715. _detachCameras(cameras: Camera[]): void;
  72716. /**
  72717. * Enables the effect on given cameras
  72718. * @param cameras The camera to enable.
  72719. * @hidden
  72720. */
  72721. _enable(cameras: Camera): void;
  72722. /**
  72723. * Enables the effect on given cameras
  72724. * @param cameras The camera to enable.
  72725. * @hidden
  72726. */
  72727. _enable(cameras: Nullable<Camera[]>): void;
  72728. /**
  72729. * Disables the effect on the given cameras
  72730. * @param cameras The camera to disable.
  72731. * @hidden
  72732. */
  72733. _disable(cameras: Camera): void;
  72734. /**
  72735. * Disables the effect on the given cameras
  72736. * @param cameras The camera to disable.
  72737. * @hidden
  72738. */
  72739. _disable(cameras: Nullable<Camera[]>): void;
  72740. /**
  72741. * Gets a list of the post processes contained in the effect.
  72742. * @param camera The camera to get the post processes on.
  72743. * @returns The list of the post processes in the effect.
  72744. */
  72745. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  72746. }
  72747. }
  72748. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  72749. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72750. /** @hidden */
  72751. export var extractHighlightsPixelShader: {
  72752. name: string;
  72753. shader: string;
  72754. };
  72755. }
  72756. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  72757. import { Nullable } from "babylonjs/types";
  72758. import { Camera } from "babylonjs/Cameras/camera";
  72759. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72760. import { Engine } from "babylonjs/Engines/engine";
  72761. import "babylonjs/Shaders/extractHighlights.fragment";
  72762. /**
  72763. * 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.
  72764. */
  72765. export class ExtractHighlightsPostProcess extends PostProcess {
  72766. /**
  72767. * The luminance threshold, pixels below this value will be set to black.
  72768. */
  72769. threshold: number;
  72770. /** @hidden */
  72771. _exposure: number;
  72772. /**
  72773. * Post process which has the input texture to be used when performing highlight extraction
  72774. * @hidden
  72775. */
  72776. _inputPostProcess: Nullable<PostProcess>;
  72777. /**
  72778. * Gets a string identifying the name of the class
  72779. * @returns "ExtractHighlightsPostProcess" string
  72780. */
  72781. getClassName(): string;
  72782. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72783. }
  72784. }
  72785. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  72786. /** @hidden */
  72787. export var bloomMergePixelShader: {
  72788. name: string;
  72789. shader: string;
  72790. };
  72791. }
  72792. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  72793. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72794. import { Nullable } from "babylonjs/types";
  72795. import { Engine } from "babylonjs/Engines/engine";
  72796. import { Camera } from "babylonjs/Cameras/camera";
  72797. import "babylonjs/Shaders/bloomMerge.fragment";
  72798. /**
  72799. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72800. */
  72801. export class BloomMergePostProcess extends PostProcess {
  72802. /** Weight of the bloom to be added to the original input. */
  72803. weight: number;
  72804. /**
  72805. * Gets a string identifying the name of the class
  72806. * @returns "BloomMergePostProcess" string
  72807. */
  72808. getClassName(): string;
  72809. /**
  72810. * Creates a new instance of @see BloomMergePostProcess
  72811. * @param name The name of the effect.
  72812. * @param originalFromInput Post process which's input will be used for the merge.
  72813. * @param blurred Blurred highlights post process which's output will be used.
  72814. * @param weight Weight of the bloom to be added to the original input.
  72815. * @param options The required width/height ratio to downsize to before computing the render pass.
  72816. * @param camera The camera to apply the render pass to.
  72817. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72818. * @param engine The engine which the post process will be applied. (default: current engine)
  72819. * @param reusable If the post process can be reused on the same frame. (default: false)
  72820. * @param textureType Type of textures used when performing the post process. (default: 0)
  72821. * @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)
  72822. */
  72823. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  72824. /** Weight of the bloom to be added to the original input. */
  72825. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72826. }
  72827. }
  72828. declare module "babylonjs/PostProcesses/bloomEffect" {
  72829. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72830. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72831. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  72832. import { Camera } from "babylonjs/Cameras/camera";
  72833. import { Scene } from "babylonjs/scene";
  72834. /**
  72835. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  72836. */
  72837. export class BloomEffect extends PostProcessRenderEffect {
  72838. private bloomScale;
  72839. /**
  72840. * @hidden Internal
  72841. */
  72842. _effects: Array<PostProcess>;
  72843. /**
  72844. * @hidden Internal
  72845. */
  72846. _downscale: ExtractHighlightsPostProcess;
  72847. private _blurX;
  72848. private _blurY;
  72849. private _merge;
  72850. /**
  72851. * The luminance threshold to find bright areas of the image to bloom.
  72852. */
  72853. get threshold(): number;
  72854. set threshold(value: number);
  72855. /**
  72856. * The strength of the bloom.
  72857. */
  72858. get weight(): number;
  72859. set weight(value: number);
  72860. /**
  72861. * Specifies the size of the bloom blur kernel, relative to the final output size
  72862. */
  72863. get kernel(): number;
  72864. set kernel(value: number);
  72865. /**
  72866. * Creates a new instance of @see BloomEffect
  72867. * @param scene The scene the effect belongs to.
  72868. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  72869. * @param bloomKernel The size of the kernel to be used when applying the blur.
  72870. * @param bloomWeight The the strength of bloom.
  72871. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72872. * @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)
  72873. */
  72874. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  72875. /**
  72876. * Disposes each of the internal effects for a given camera.
  72877. * @param camera The camera to dispose the effect on.
  72878. */
  72879. disposeEffects(camera: Camera): void;
  72880. /**
  72881. * @hidden Internal
  72882. */
  72883. _updateEffects(): void;
  72884. /**
  72885. * Internal
  72886. * @returns if all the contained post processes are ready.
  72887. * @hidden
  72888. */
  72889. _isReady(): boolean;
  72890. }
  72891. }
  72892. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  72893. /** @hidden */
  72894. export var chromaticAberrationPixelShader: {
  72895. name: string;
  72896. shader: string;
  72897. };
  72898. }
  72899. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  72900. import { Vector2 } from "babylonjs/Maths/math.vector";
  72901. import { Nullable } from "babylonjs/types";
  72902. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72903. import { Camera } from "babylonjs/Cameras/camera";
  72904. import { Engine } from "babylonjs/Engines/engine";
  72905. import "babylonjs/Shaders/chromaticAberration.fragment";
  72906. import { Scene } from "babylonjs/scene";
  72907. /**
  72908. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  72909. */
  72910. export class ChromaticAberrationPostProcess extends PostProcess {
  72911. /**
  72912. * The amount of seperation of rgb channels (default: 30)
  72913. */
  72914. aberrationAmount: number;
  72915. /**
  72916. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  72917. */
  72918. radialIntensity: number;
  72919. /**
  72920. * 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))
  72921. */
  72922. direction: Vector2;
  72923. /**
  72924. * 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))
  72925. */
  72926. centerPosition: Vector2;
  72927. /** The width of the screen to apply the effect on */
  72928. screenWidth: number;
  72929. /** The height of the screen to apply the effect on */
  72930. screenHeight: number;
  72931. /**
  72932. * Gets a string identifying the name of the class
  72933. * @returns "ChromaticAberrationPostProcess" string
  72934. */
  72935. getClassName(): string;
  72936. /**
  72937. * Creates a new instance ChromaticAberrationPostProcess
  72938. * @param name The name of the effect.
  72939. * @param screenWidth The width of the screen to apply the effect on.
  72940. * @param screenHeight The height of the screen to apply the effect on.
  72941. * @param options The required width/height ratio to downsize to before computing the render pass.
  72942. * @param camera The camera to apply the render pass to.
  72943. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72944. * @param engine The engine which the post process will be applied. (default: current engine)
  72945. * @param reusable If the post process can be reused on the same frame. (default: false)
  72946. * @param textureType Type of textures used when performing the post process. (default: 0)
  72947. * @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)
  72948. */
  72949. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72950. /** @hidden */
  72951. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  72952. }
  72953. }
  72954. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  72955. /** @hidden */
  72956. export var circleOfConfusionPixelShader: {
  72957. name: string;
  72958. shader: string;
  72959. };
  72960. }
  72961. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  72962. import { Nullable } from "babylonjs/types";
  72963. import { Engine } from "babylonjs/Engines/engine";
  72964. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72965. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72966. import { Camera } from "babylonjs/Cameras/camera";
  72967. import "babylonjs/Shaders/circleOfConfusion.fragment";
  72968. /**
  72969. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  72970. */
  72971. export class CircleOfConfusionPostProcess extends PostProcess {
  72972. /**
  72973. * 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.
  72974. */
  72975. lensSize: number;
  72976. /**
  72977. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  72978. */
  72979. fStop: number;
  72980. /**
  72981. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  72982. */
  72983. focusDistance: number;
  72984. /**
  72985. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  72986. */
  72987. focalLength: number;
  72988. /**
  72989. * Gets a string identifying the name of the class
  72990. * @returns "CircleOfConfusionPostProcess" string
  72991. */
  72992. getClassName(): string;
  72993. private _depthTexture;
  72994. /**
  72995. * Creates a new instance CircleOfConfusionPostProcess
  72996. * @param name The name of the effect.
  72997. * @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.
  72998. * @param options The required width/height ratio to downsize to before computing the render pass.
  72999. * @param camera The camera to apply the render pass to.
  73000. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73001. * @param engine The engine which the post process will be applied. (default: current engine)
  73002. * @param reusable If the post process can be reused on the same frame. (default: false)
  73003. * @param textureType Type of textures used when performing the post process. (default: 0)
  73004. * @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)
  73005. */
  73006. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73007. /**
  73008. * 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.
  73009. */
  73010. set depthTexture(value: RenderTargetTexture);
  73011. }
  73012. }
  73013. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  73014. /** @hidden */
  73015. export var colorCorrectionPixelShader: {
  73016. name: string;
  73017. shader: string;
  73018. };
  73019. }
  73020. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  73021. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73022. import { Engine } from "babylonjs/Engines/engine";
  73023. import { Camera } from "babylonjs/Cameras/camera";
  73024. import "babylonjs/Shaders/colorCorrection.fragment";
  73025. import { Nullable } from "babylonjs/types";
  73026. import { Scene } from "babylonjs/scene";
  73027. /**
  73028. *
  73029. * This post-process allows the modification of rendered colors by using
  73030. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73031. *
  73032. * The object needs to be provided an url to a texture containing the color
  73033. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73034. * Use an image editing software to tweak the LUT to match your needs.
  73035. *
  73036. * For an example of a color LUT, see here:
  73037. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73038. * For explanations on color grading, see here:
  73039. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73040. *
  73041. */
  73042. export class ColorCorrectionPostProcess extends PostProcess {
  73043. private _colorTableTexture;
  73044. /**
  73045. * Gets the color table url used to create the LUT texture
  73046. */
  73047. colorTableUrl: string;
  73048. /**
  73049. * Gets a string identifying the name of the class
  73050. * @returns "ColorCorrectionPostProcess" string
  73051. */
  73052. getClassName(): string;
  73053. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73054. /** @hidden */
  73055. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73056. }
  73057. }
  73058. declare module "babylonjs/Shaders/convolution.fragment" {
  73059. /** @hidden */
  73060. export var convolutionPixelShader: {
  73061. name: string;
  73062. shader: string;
  73063. };
  73064. }
  73065. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  73066. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73067. import { Nullable } from "babylonjs/types";
  73068. import { Camera } from "babylonjs/Cameras/camera";
  73069. import { Engine } from "babylonjs/Engines/engine";
  73070. import "babylonjs/Shaders/convolution.fragment";
  73071. import { Scene } from "babylonjs/scene";
  73072. /**
  73073. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73074. * input texture to perform effects such as edge detection or sharpening
  73075. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73076. */
  73077. export class ConvolutionPostProcess extends PostProcess {
  73078. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73079. kernel: number[];
  73080. /**
  73081. * Gets a string identifying the name of the class
  73082. * @returns "ConvolutionPostProcess" string
  73083. */
  73084. getClassName(): string;
  73085. /**
  73086. * Creates a new instance ConvolutionPostProcess
  73087. * @param name The name of the effect.
  73088. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73089. * @param options The required width/height ratio to downsize to before computing the render pass.
  73090. * @param camera The camera to apply the render pass to.
  73091. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73092. * @param engine The engine which the post process will be applied. (default: current engine)
  73093. * @param reusable If the post process can be reused on the same frame. (default: false)
  73094. * @param textureType Type of textures used when performing the post process. (default: 0)
  73095. */
  73096. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73097. /** @hidden */
  73098. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73099. /**
  73100. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73101. */
  73102. static EdgeDetect0Kernel: number[];
  73103. /**
  73104. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73105. */
  73106. static EdgeDetect1Kernel: number[];
  73107. /**
  73108. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73109. */
  73110. static EdgeDetect2Kernel: number[];
  73111. /**
  73112. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73113. */
  73114. static SharpenKernel: number[];
  73115. /**
  73116. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73117. */
  73118. static EmbossKernel: number[];
  73119. /**
  73120. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73121. */
  73122. static GaussianKernel: number[];
  73123. }
  73124. }
  73125. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  73126. import { Nullable } from "babylonjs/types";
  73127. import { Vector2 } from "babylonjs/Maths/math.vector";
  73128. import { Camera } from "babylonjs/Cameras/camera";
  73129. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73130. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73131. import { Engine } from "babylonjs/Engines/engine";
  73132. import { Scene } from "babylonjs/scene";
  73133. /**
  73134. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73135. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73136. * based on samples that have a large difference in distance than the center pixel.
  73137. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73138. */
  73139. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73140. /**
  73141. * The direction the blur should be applied
  73142. */
  73143. direction: Vector2;
  73144. /**
  73145. * Gets a string identifying the name of the class
  73146. * @returns "DepthOfFieldBlurPostProcess" string
  73147. */
  73148. getClassName(): string;
  73149. /**
  73150. * Creates a new instance CircleOfConfusionPostProcess
  73151. * @param name The name of the effect.
  73152. * @param scene The scene the effect belongs to.
  73153. * @param direction The direction the blur should be applied.
  73154. * @param kernel The size of the kernel used to blur.
  73155. * @param options The required width/height ratio to downsize to before computing the render pass.
  73156. * @param camera The camera to apply the render pass to.
  73157. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73158. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73159. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73160. * @param engine The engine which the post process will be applied. (default: current engine)
  73161. * @param reusable If the post process can be reused on the same frame. (default: false)
  73162. * @param textureType Type of textures used when performing the post process. (default: 0)
  73163. * @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)
  73164. */
  73165. 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);
  73166. }
  73167. }
  73168. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  73169. /** @hidden */
  73170. export var depthOfFieldMergePixelShader: {
  73171. name: string;
  73172. shader: string;
  73173. };
  73174. }
  73175. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  73176. import { Nullable } from "babylonjs/types";
  73177. import { Camera } from "babylonjs/Cameras/camera";
  73178. import { Effect } from "babylonjs/Materials/effect";
  73179. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73180. import { Engine } from "babylonjs/Engines/engine";
  73181. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  73182. /**
  73183. * Options to be set when merging outputs from the default pipeline.
  73184. */
  73185. export class DepthOfFieldMergePostProcessOptions {
  73186. /**
  73187. * The original image to merge on top of
  73188. */
  73189. originalFromInput: PostProcess;
  73190. /**
  73191. * Parameters to perform the merge of the depth of field effect
  73192. */
  73193. depthOfField?: {
  73194. circleOfConfusion: PostProcess;
  73195. blurSteps: Array<PostProcess>;
  73196. };
  73197. /**
  73198. * Parameters to perform the merge of bloom effect
  73199. */
  73200. bloom?: {
  73201. blurred: PostProcess;
  73202. weight: number;
  73203. };
  73204. }
  73205. /**
  73206. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73207. */
  73208. export class DepthOfFieldMergePostProcess extends PostProcess {
  73209. private blurSteps;
  73210. /**
  73211. * Gets a string identifying the name of the class
  73212. * @returns "DepthOfFieldMergePostProcess" string
  73213. */
  73214. getClassName(): string;
  73215. /**
  73216. * Creates a new instance of DepthOfFieldMergePostProcess
  73217. * @param name The name of the effect.
  73218. * @param originalFromInput Post process which's input will be used for the merge.
  73219. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73220. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73221. * @param options The required width/height ratio to downsize to before computing the render pass.
  73222. * @param camera The camera to apply the render pass to.
  73223. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73224. * @param engine The engine which the post process will be applied. (default: current engine)
  73225. * @param reusable If the post process can be reused on the same frame. (default: false)
  73226. * @param textureType Type of textures used when performing the post process. (default: 0)
  73227. * @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)
  73228. */
  73229. 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);
  73230. /**
  73231. * Updates the effect with the current post process compile time values and recompiles the shader.
  73232. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73233. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73234. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73235. * @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
  73236. * @param onCompiled Called when the shader has been compiled.
  73237. * @param onError Called if there is an error when compiling a shader.
  73238. */
  73239. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73240. }
  73241. }
  73242. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  73243. import { Nullable } from "babylonjs/types";
  73244. import { Camera } from "babylonjs/Cameras/camera";
  73245. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73246. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73247. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73248. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  73249. import { Scene } from "babylonjs/scene";
  73250. /**
  73251. * Specifies the level of max blur that should be applied when using the depth of field effect
  73252. */
  73253. export enum DepthOfFieldEffectBlurLevel {
  73254. /**
  73255. * Subtle blur
  73256. */
  73257. Low = 0,
  73258. /**
  73259. * Medium blur
  73260. */
  73261. Medium = 1,
  73262. /**
  73263. * Large blur
  73264. */
  73265. High = 2
  73266. }
  73267. /**
  73268. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73269. */
  73270. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73271. private _circleOfConfusion;
  73272. /**
  73273. * @hidden Internal, blurs from high to low
  73274. */
  73275. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73276. private _depthOfFieldBlurY;
  73277. private _dofMerge;
  73278. /**
  73279. * @hidden Internal post processes in depth of field effect
  73280. */
  73281. _effects: Array<PostProcess>;
  73282. /**
  73283. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73284. */
  73285. set focalLength(value: number);
  73286. get focalLength(): number;
  73287. /**
  73288. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73289. */
  73290. set fStop(value: number);
  73291. get fStop(): number;
  73292. /**
  73293. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73294. */
  73295. set focusDistance(value: number);
  73296. get focusDistance(): number;
  73297. /**
  73298. * 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.
  73299. */
  73300. set lensSize(value: number);
  73301. get lensSize(): number;
  73302. /**
  73303. * Creates a new instance DepthOfFieldEffect
  73304. * @param scene The scene the effect belongs to.
  73305. * @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.
  73306. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73307. * @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)
  73308. */
  73309. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  73310. /**
  73311. * Get the current class name of the current effet
  73312. * @returns "DepthOfFieldEffect"
  73313. */
  73314. getClassName(): string;
  73315. /**
  73316. * 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.
  73317. */
  73318. set depthTexture(value: RenderTargetTexture);
  73319. /**
  73320. * Disposes each of the internal effects for a given camera.
  73321. * @param camera The camera to dispose the effect on.
  73322. */
  73323. disposeEffects(camera: Camera): void;
  73324. /**
  73325. * @hidden Internal
  73326. */
  73327. _updateEffects(): void;
  73328. /**
  73329. * Internal
  73330. * @returns if all the contained post processes are ready.
  73331. * @hidden
  73332. */
  73333. _isReady(): boolean;
  73334. }
  73335. }
  73336. declare module "babylonjs/Shaders/displayPass.fragment" {
  73337. /** @hidden */
  73338. export var displayPassPixelShader: {
  73339. name: string;
  73340. shader: string;
  73341. };
  73342. }
  73343. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  73344. import { Nullable } from "babylonjs/types";
  73345. import { Camera } from "babylonjs/Cameras/camera";
  73346. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73347. import { Engine } from "babylonjs/Engines/engine";
  73348. import "babylonjs/Shaders/displayPass.fragment";
  73349. import { Scene } from "babylonjs/scene";
  73350. /**
  73351. * DisplayPassPostProcess which produces an output the same as it's input
  73352. */
  73353. export class DisplayPassPostProcess extends PostProcess {
  73354. /**
  73355. * Gets a string identifying the name of the class
  73356. * @returns "DisplayPassPostProcess" string
  73357. */
  73358. getClassName(): string;
  73359. /**
  73360. * Creates the DisplayPassPostProcess
  73361. * @param name The name of the effect.
  73362. * @param options The required width/height ratio to downsize to before computing the render pass.
  73363. * @param camera The camera to apply the render pass to.
  73364. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73365. * @param engine The engine which the post process will be applied. (default: current engine)
  73366. * @param reusable If the post process can be reused on the same frame. (default: false)
  73367. */
  73368. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73369. /** @hidden */
  73370. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  73371. }
  73372. }
  73373. declare module "babylonjs/Shaders/filter.fragment" {
  73374. /** @hidden */
  73375. export var filterPixelShader: {
  73376. name: string;
  73377. shader: string;
  73378. };
  73379. }
  73380. declare module "babylonjs/PostProcesses/filterPostProcess" {
  73381. import { Nullable } from "babylonjs/types";
  73382. import { Matrix } from "babylonjs/Maths/math.vector";
  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/filter.fragment";
  73387. import { Scene } from "babylonjs/scene";
  73388. /**
  73389. * Applies a kernel filter to the image
  73390. */
  73391. export class FilterPostProcess extends PostProcess {
  73392. /** The matrix to be applied to the image */
  73393. kernelMatrix: Matrix;
  73394. /**
  73395. * Gets a string identifying the name of the class
  73396. * @returns "FilterPostProcess" string
  73397. */
  73398. getClassName(): string;
  73399. /**
  73400. *
  73401. * @param name The name of the effect.
  73402. * @param kernelMatrix The matrix to be applied to the image
  73403. * @param options The required width/height ratio to downsize to before computing the render pass.
  73404. * @param camera The camera to apply the render pass to.
  73405. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73406. * @param engine The engine which the post process will be applied. (default: current engine)
  73407. * @param reusable If the post process can be reused on the same frame. (default: false)
  73408. */
  73409. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73410. /** @hidden */
  73411. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  73412. }
  73413. }
  73414. declare module "babylonjs/Shaders/fxaa.fragment" {
  73415. /** @hidden */
  73416. export var fxaaPixelShader: {
  73417. name: string;
  73418. shader: string;
  73419. };
  73420. }
  73421. declare module "babylonjs/Shaders/fxaa.vertex" {
  73422. /** @hidden */
  73423. export var fxaaVertexShader: {
  73424. name: string;
  73425. shader: string;
  73426. };
  73427. }
  73428. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  73429. import { Nullable } from "babylonjs/types";
  73430. import { Camera } from "babylonjs/Cameras/camera";
  73431. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73432. import { Engine } from "babylonjs/Engines/engine";
  73433. import "babylonjs/Shaders/fxaa.fragment";
  73434. import "babylonjs/Shaders/fxaa.vertex";
  73435. import { Scene } from "babylonjs/scene";
  73436. /**
  73437. * Fxaa post process
  73438. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  73439. */
  73440. export class FxaaPostProcess extends PostProcess {
  73441. /**
  73442. * Gets a string identifying the name of the class
  73443. * @returns "FxaaPostProcess" string
  73444. */
  73445. getClassName(): string;
  73446. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73447. private _getDefines;
  73448. /** @hidden */
  73449. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  73450. }
  73451. }
  73452. declare module "babylonjs/Shaders/grain.fragment" {
  73453. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73454. /** @hidden */
  73455. export var grainPixelShader: {
  73456. name: string;
  73457. shader: string;
  73458. };
  73459. }
  73460. declare module "babylonjs/PostProcesses/grainPostProcess" {
  73461. import { Nullable } from "babylonjs/types";
  73462. import { Camera } from "babylonjs/Cameras/camera";
  73463. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73464. import { Engine } from "babylonjs/Engines/engine";
  73465. import "babylonjs/Shaders/grain.fragment";
  73466. import { Scene } from "babylonjs/scene";
  73467. /**
  73468. * The GrainPostProcess adds noise to the image at mid luminance levels
  73469. */
  73470. export class GrainPostProcess extends PostProcess {
  73471. /**
  73472. * The intensity of the grain added (default: 30)
  73473. */
  73474. intensity: number;
  73475. /**
  73476. * If the grain should be randomized on every frame
  73477. */
  73478. animated: boolean;
  73479. /**
  73480. * Gets a string identifying the name of the class
  73481. * @returns "GrainPostProcess" string
  73482. */
  73483. getClassName(): string;
  73484. /**
  73485. * Creates a new instance of @see GrainPostProcess
  73486. * @param name The name of the effect.
  73487. * @param options The required width/height ratio to downsize to before computing the render pass.
  73488. * @param camera The camera to apply the render pass to.
  73489. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73490. * @param engine The engine which the post process will be applied. (default: current engine)
  73491. * @param reusable If the post process can be reused on the same frame. (default: false)
  73492. * @param textureType Type of textures used when performing the post process. (default: 0)
  73493. * @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)
  73494. */
  73495. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73496. /** @hidden */
  73497. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  73498. }
  73499. }
  73500. declare module "babylonjs/Shaders/highlights.fragment" {
  73501. /** @hidden */
  73502. export var highlightsPixelShader: {
  73503. name: string;
  73504. shader: string;
  73505. };
  73506. }
  73507. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  73508. import { Nullable } from "babylonjs/types";
  73509. import { Camera } from "babylonjs/Cameras/camera";
  73510. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73511. import { Engine } from "babylonjs/Engines/engine";
  73512. import "babylonjs/Shaders/highlights.fragment";
  73513. /**
  73514. * Extracts highlights from the image
  73515. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73516. */
  73517. export class HighlightsPostProcess extends PostProcess {
  73518. /**
  73519. * Gets a string identifying the name of the class
  73520. * @returns "HighlightsPostProcess" string
  73521. */
  73522. getClassName(): string;
  73523. /**
  73524. * Extracts highlights from the image
  73525. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73526. * @param name The name of the effect.
  73527. * @param options The required width/height ratio to downsize to before computing the render pass.
  73528. * @param camera The camera to apply the render pass to.
  73529. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73530. * @param engine The engine which the post process will be applied. (default: current engine)
  73531. * @param reusable If the post process can be reused on the same frame. (default: false)
  73532. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  73533. */
  73534. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73535. }
  73536. }
  73537. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  73538. /** @hidden */
  73539. export var mrtFragmentDeclaration: {
  73540. name: string;
  73541. shader: string;
  73542. };
  73543. }
  73544. declare module "babylonjs/Shaders/geometry.fragment" {
  73545. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  73546. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  73547. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  73548. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  73549. /** @hidden */
  73550. export var geometryPixelShader: {
  73551. name: string;
  73552. shader: string;
  73553. };
  73554. }
  73555. declare module "babylonjs/Shaders/geometry.vertex" {
  73556. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73557. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73558. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73559. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73560. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73561. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73562. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73563. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  73564. /** @hidden */
  73565. export var geometryVertexShader: {
  73566. name: string;
  73567. shader: string;
  73568. };
  73569. }
  73570. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  73571. import { Matrix } from "babylonjs/Maths/math.vector";
  73572. import { SubMesh } from "babylonjs/Meshes/subMesh";
  73573. import { Mesh } from "babylonjs/Meshes/mesh";
  73574. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  73575. import { Effect } from "babylonjs/Materials/effect";
  73576. import { Scene } from "babylonjs/scene";
  73577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73578. import "babylonjs/Shaders/geometry.fragment";
  73579. import "babylonjs/Shaders/geometry.vertex";
  73580. /** @hidden */
  73581. interface ISavedTransformationMatrix {
  73582. world: Matrix;
  73583. viewProjection: Matrix;
  73584. }
  73585. /**
  73586. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  73587. */
  73588. export class GeometryBufferRenderer {
  73589. /**
  73590. * Constant used to retrieve the position texture index in the G-Buffer textures array
  73591. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  73592. */
  73593. static readonly POSITION_TEXTURE_TYPE: number;
  73594. /**
  73595. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  73596. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  73597. */
  73598. static readonly VELOCITY_TEXTURE_TYPE: number;
  73599. /**
  73600. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  73601. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  73602. */
  73603. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  73604. /**
  73605. * Dictionary used to store the previous transformation matrices of each rendered mesh
  73606. * in order to compute objects velocities when enableVelocity is set to "true"
  73607. * @hidden
  73608. */
  73609. _previousTransformationMatrices: {
  73610. [index: number]: ISavedTransformationMatrix;
  73611. };
  73612. /**
  73613. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  73614. * in order to compute objects velocities when enableVelocity is set to "true"
  73615. * @hidden
  73616. */
  73617. _previousBonesTransformationMatrices: {
  73618. [index: number]: Float32Array;
  73619. };
  73620. /**
  73621. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  73622. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  73623. */
  73624. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  73625. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  73626. renderTransparentMeshes: boolean;
  73627. private _scene;
  73628. private _resizeObserver;
  73629. private _multiRenderTarget;
  73630. private _ratio;
  73631. private _enablePosition;
  73632. private _enableVelocity;
  73633. private _enableReflectivity;
  73634. private _positionIndex;
  73635. private _velocityIndex;
  73636. private _reflectivityIndex;
  73637. protected _effect: Effect;
  73638. protected _cachedDefines: string;
  73639. /**
  73640. * Set the render list (meshes to be rendered) used in the G buffer.
  73641. */
  73642. set renderList(meshes: Mesh[]);
  73643. /**
  73644. * Gets wether or not G buffer are supported by the running hardware.
  73645. * This requires draw buffer supports
  73646. */
  73647. get isSupported(): boolean;
  73648. /**
  73649. * Returns the index of the given texture type in the G-Buffer textures array
  73650. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  73651. * @returns the index of the given texture type in the G-Buffer textures array
  73652. */
  73653. getTextureIndex(textureType: number): number;
  73654. /**
  73655. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  73656. */
  73657. get enablePosition(): boolean;
  73658. /**
  73659. * Sets whether or not objects positions are enabled for the G buffer.
  73660. */
  73661. set enablePosition(enable: boolean);
  73662. /**
  73663. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  73664. */
  73665. get enableVelocity(): boolean;
  73666. /**
  73667. * Sets wether or not objects velocities are enabled for the G buffer.
  73668. */
  73669. set enableVelocity(enable: boolean);
  73670. /**
  73671. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  73672. */
  73673. get enableReflectivity(): boolean;
  73674. /**
  73675. * Sets wether or not objects roughness are enabled for the G buffer.
  73676. */
  73677. set enableReflectivity(enable: boolean);
  73678. /**
  73679. * Gets the scene associated with the buffer.
  73680. */
  73681. get scene(): Scene;
  73682. /**
  73683. * Gets the ratio used by the buffer during its creation.
  73684. * How big is the buffer related to the main canvas.
  73685. */
  73686. get ratio(): number;
  73687. /** @hidden */
  73688. static _SceneComponentInitialization: (scene: Scene) => void;
  73689. /**
  73690. * Creates a new G Buffer for the scene
  73691. * @param scene The scene the buffer belongs to
  73692. * @param ratio How big is the buffer related to the main canvas.
  73693. */
  73694. constructor(scene: Scene, ratio?: number);
  73695. /**
  73696. * Checks wether everything is ready to render a submesh to the G buffer.
  73697. * @param subMesh the submesh to check readiness for
  73698. * @param useInstances is the mesh drawn using instance or not
  73699. * @returns true if ready otherwise false
  73700. */
  73701. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73702. /**
  73703. * Gets the current underlying G Buffer.
  73704. * @returns the buffer
  73705. */
  73706. getGBuffer(): MultiRenderTarget;
  73707. /**
  73708. * Gets the number of samples used to render the buffer (anti aliasing).
  73709. */
  73710. get samples(): number;
  73711. /**
  73712. * Sets the number of samples used to render the buffer (anti aliasing).
  73713. */
  73714. set samples(value: number);
  73715. /**
  73716. * Disposes the renderer and frees up associated resources.
  73717. */
  73718. dispose(): void;
  73719. protected _createRenderTargets(): void;
  73720. private _copyBonesTransformationMatrices;
  73721. }
  73722. }
  73723. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  73724. import { Nullable } from "babylonjs/types";
  73725. import { Scene } from "babylonjs/scene";
  73726. import { ISceneComponent } from "babylonjs/sceneComponent";
  73727. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  73728. module "babylonjs/scene" {
  73729. interface Scene {
  73730. /** @hidden (Backing field) */
  73731. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73732. /**
  73733. * Gets or Sets the current geometry buffer associated to the scene.
  73734. */
  73735. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73736. /**
  73737. * Enables a GeometryBufferRender and associates it with the scene
  73738. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  73739. * @returns the GeometryBufferRenderer
  73740. */
  73741. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  73742. /**
  73743. * Disables the GeometryBufferRender associated with the scene
  73744. */
  73745. disableGeometryBufferRenderer(): void;
  73746. }
  73747. }
  73748. /**
  73749. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73750. * in several rendering techniques.
  73751. */
  73752. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  73753. /**
  73754. * The component name helpful to identify the component in the list of scene components.
  73755. */
  73756. readonly name: string;
  73757. /**
  73758. * The scene the component belongs to.
  73759. */
  73760. scene: Scene;
  73761. /**
  73762. * Creates a new instance of the component for the given scene
  73763. * @param scene Defines the scene to register the component in
  73764. */
  73765. constructor(scene: Scene);
  73766. /**
  73767. * Registers the component in a given scene
  73768. */
  73769. register(): void;
  73770. /**
  73771. * Rebuilds the elements related to this component in case of
  73772. * context lost for instance.
  73773. */
  73774. rebuild(): void;
  73775. /**
  73776. * Disposes the component and the associated ressources
  73777. */
  73778. dispose(): void;
  73779. private _gatherRenderTargets;
  73780. }
  73781. }
  73782. declare module "babylonjs/Shaders/motionBlur.fragment" {
  73783. /** @hidden */
  73784. export var motionBlurPixelShader: {
  73785. name: string;
  73786. shader: string;
  73787. };
  73788. }
  73789. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  73790. import { Nullable } from "babylonjs/types";
  73791. import { Camera } from "babylonjs/Cameras/camera";
  73792. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73794. import "babylonjs/Animations/animatable";
  73795. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  73796. import "babylonjs/Shaders/motionBlur.fragment";
  73797. import { Engine } from "babylonjs/Engines/engine";
  73798. import { Scene } from "babylonjs/scene";
  73799. /**
  73800. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  73801. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  73802. * As an example, all you have to do is to create the post-process:
  73803. * var mb = new BABYLON.MotionBlurPostProcess(
  73804. * 'mb', // The name of the effect.
  73805. * scene, // The scene containing the objects to blur according to their velocity.
  73806. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  73807. * camera // The camera to apply the render pass to.
  73808. * );
  73809. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  73810. */
  73811. export class MotionBlurPostProcess extends PostProcess {
  73812. /**
  73813. * Defines how much the image is blurred by the movement. Default value is equal to 1
  73814. */
  73815. motionStrength: number;
  73816. /**
  73817. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  73818. */
  73819. get motionBlurSamples(): number;
  73820. /**
  73821. * Sets the number of iterations to be used for motion blur quality
  73822. */
  73823. set motionBlurSamples(samples: number);
  73824. private _motionBlurSamples;
  73825. private _geometryBufferRenderer;
  73826. /**
  73827. * Gets a string identifying the name of the class
  73828. * @returns "MotionBlurPostProcess" string
  73829. */
  73830. getClassName(): string;
  73831. /**
  73832. * Creates a new instance MotionBlurPostProcess
  73833. * @param name The name of the effect.
  73834. * @param scene The scene containing the objects to blur according to their velocity.
  73835. * @param options The required width/height ratio to downsize to before computing the render pass.
  73836. * @param camera The camera to apply the render pass to.
  73837. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73838. * @param engine The engine which the post process will be applied. (default: current engine)
  73839. * @param reusable If the post process can be reused on the same frame. (default: false)
  73840. * @param textureType Type of textures used when performing the post process. (default: 0)
  73841. * @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)
  73842. */
  73843. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73844. /**
  73845. * Excludes the given skinned mesh from computing bones velocities.
  73846. * 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.
  73847. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  73848. */
  73849. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73850. /**
  73851. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  73852. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  73853. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  73854. */
  73855. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73856. /**
  73857. * Disposes the post process.
  73858. * @param camera The camera to dispose the post process on.
  73859. */
  73860. dispose(camera?: Camera): void;
  73861. /** @hidden */
  73862. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  73863. }
  73864. }
  73865. declare module "babylonjs/Shaders/refraction.fragment" {
  73866. /** @hidden */
  73867. export var refractionPixelShader: {
  73868. name: string;
  73869. shader: string;
  73870. };
  73871. }
  73872. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  73873. import { Color3 } from "babylonjs/Maths/math.color";
  73874. import { Camera } from "babylonjs/Cameras/camera";
  73875. import { Texture } from "babylonjs/Materials/Textures/texture";
  73876. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73877. import { Engine } from "babylonjs/Engines/engine";
  73878. import "babylonjs/Shaders/refraction.fragment";
  73879. import { Scene } from "babylonjs/scene";
  73880. /**
  73881. * Post process which applies a refractin texture
  73882. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73883. */
  73884. export class RefractionPostProcess extends PostProcess {
  73885. private _refTexture;
  73886. private _ownRefractionTexture;
  73887. /** the base color of the refraction (used to taint the rendering) */
  73888. color: Color3;
  73889. /** simulated refraction depth */
  73890. depth: number;
  73891. /** the coefficient of the base color (0 to remove base color tainting) */
  73892. colorLevel: number;
  73893. /** Gets the url used to load the refraction texture */
  73894. refractionTextureUrl: string;
  73895. /**
  73896. * Gets or sets the refraction texture
  73897. * Please note that you are responsible for disposing the texture if you set it manually
  73898. */
  73899. get refractionTexture(): Texture;
  73900. set refractionTexture(value: Texture);
  73901. /**
  73902. * Gets a string identifying the name of the class
  73903. * @returns "RefractionPostProcess" string
  73904. */
  73905. getClassName(): string;
  73906. /**
  73907. * Initializes the RefractionPostProcess
  73908. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73909. * @param name The name of the effect.
  73910. * @param refractionTextureUrl Url of the refraction texture to use
  73911. * @param color the base color of the refraction (used to taint the rendering)
  73912. * @param depth simulated refraction depth
  73913. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  73914. * @param camera The camera to apply the render pass to.
  73915. * @param options The required width/height ratio to downsize to before computing the render pass.
  73916. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73917. * @param engine The engine which the post process will be applied. (default: current engine)
  73918. * @param reusable If the post process can be reused on the same frame. (default: false)
  73919. */
  73920. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73921. /**
  73922. * Disposes of the post process
  73923. * @param camera Camera to dispose post process on
  73924. */
  73925. dispose(camera: Camera): void;
  73926. /** @hidden */
  73927. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  73928. }
  73929. }
  73930. declare module "babylonjs/Shaders/sharpen.fragment" {
  73931. /** @hidden */
  73932. export var sharpenPixelShader: {
  73933. name: string;
  73934. shader: string;
  73935. };
  73936. }
  73937. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  73938. import { Nullable } from "babylonjs/types";
  73939. import { Camera } from "babylonjs/Cameras/camera";
  73940. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73941. import "babylonjs/Shaders/sharpen.fragment";
  73942. import { Engine } from "babylonjs/Engines/engine";
  73943. import { Scene } from "babylonjs/scene";
  73944. /**
  73945. * The SharpenPostProcess applies a sharpen kernel to every pixel
  73946. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73947. */
  73948. export class SharpenPostProcess extends PostProcess {
  73949. /**
  73950. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  73951. */
  73952. colorAmount: number;
  73953. /**
  73954. * How much sharpness should be applied (default: 0.3)
  73955. */
  73956. edgeAmount: number;
  73957. /**
  73958. * Gets a string identifying the name of the class
  73959. * @returns "SharpenPostProcess" string
  73960. */
  73961. getClassName(): string;
  73962. /**
  73963. * Creates a new instance ConvolutionPostProcess
  73964. * @param name The name of the effect.
  73965. * @param options The required width/height ratio to downsize to before computing the render pass.
  73966. * @param camera The camera to apply the render pass to.
  73967. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73968. * @param engine The engine which the post process will be applied. (default: current engine)
  73969. * @param reusable If the post process can be reused on the same frame. (default: false)
  73970. * @param textureType Type of textures used when performing the post process. (default: 0)
  73971. * @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)
  73972. */
  73973. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73974. /** @hidden */
  73975. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  73976. }
  73977. }
  73978. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  73979. import { Nullable } from "babylonjs/types";
  73980. import { Camera } from "babylonjs/Cameras/camera";
  73981. import { Engine } from "babylonjs/Engines/engine";
  73982. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73983. import { IInspectable } from "babylonjs/Misc/iInspectable";
  73984. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  73985. /**
  73986. * PostProcessRenderPipeline
  73987. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73988. */
  73989. export class PostProcessRenderPipeline {
  73990. private engine;
  73991. private _renderEffects;
  73992. private _renderEffectsForIsolatedPass;
  73993. /**
  73994. * List of inspectable custom properties (used by the Inspector)
  73995. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73996. */
  73997. inspectableCustomProperties: IInspectable[];
  73998. /**
  73999. * @hidden
  74000. */
  74001. protected _cameras: Camera[];
  74002. /** @hidden */
  74003. _name: string;
  74004. /**
  74005. * Gets pipeline name
  74006. */
  74007. get name(): string;
  74008. /** Gets the list of attached cameras */
  74009. get cameras(): Camera[];
  74010. /**
  74011. * Initializes a PostProcessRenderPipeline
  74012. * @param engine engine to add the pipeline to
  74013. * @param name name of the pipeline
  74014. */
  74015. constructor(engine: Engine, name: string);
  74016. /**
  74017. * Gets the class name
  74018. * @returns "PostProcessRenderPipeline"
  74019. */
  74020. getClassName(): string;
  74021. /**
  74022. * If all the render effects in the pipeline are supported
  74023. */
  74024. get isSupported(): boolean;
  74025. /**
  74026. * Adds an effect to the pipeline
  74027. * @param renderEffect the effect to add
  74028. */
  74029. addEffect(renderEffect: PostProcessRenderEffect): void;
  74030. /** @hidden */
  74031. _rebuild(): void;
  74032. /** @hidden */
  74033. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74034. /** @hidden */
  74035. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74036. /** @hidden */
  74037. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74038. /** @hidden */
  74039. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74040. /** @hidden */
  74041. _attachCameras(cameras: Camera, unique: boolean): void;
  74042. /** @hidden */
  74043. _attachCameras(cameras: Camera[], unique: boolean): void;
  74044. /** @hidden */
  74045. _detachCameras(cameras: Camera): void;
  74046. /** @hidden */
  74047. _detachCameras(cameras: Nullable<Camera[]>): void;
  74048. /** @hidden */
  74049. _update(): void;
  74050. /** @hidden */
  74051. _reset(): void;
  74052. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74053. /**
  74054. * Sets the required values to the prepass renderer.
  74055. * @param prePassRenderer defines the prepass renderer to setup.
  74056. * @returns true if the pre pass is needed.
  74057. */
  74058. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74059. /**
  74060. * Disposes of the pipeline
  74061. */
  74062. dispose(): void;
  74063. }
  74064. }
  74065. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  74066. import { Camera } from "babylonjs/Cameras/camera";
  74067. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74068. /**
  74069. * PostProcessRenderPipelineManager class
  74070. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74071. */
  74072. export class PostProcessRenderPipelineManager {
  74073. private _renderPipelines;
  74074. /**
  74075. * Initializes a PostProcessRenderPipelineManager
  74076. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74077. */
  74078. constructor();
  74079. /**
  74080. * Gets the list of supported render pipelines
  74081. */
  74082. get supportedPipelines(): PostProcessRenderPipeline[];
  74083. /**
  74084. * Adds a pipeline to the manager
  74085. * @param renderPipeline The pipeline to add
  74086. */
  74087. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74088. /**
  74089. * Attaches a camera to the pipeline
  74090. * @param renderPipelineName The name of the pipeline to attach to
  74091. * @param cameras the camera to attach
  74092. * @param unique if the camera can be attached multiple times to the pipeline
  74093. */
  74094. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74095. /**
  74096. * Detaches a camera from the pipeline
  74097. * @param renderPipelineName The name of the pipeline to detach from
  74098. * @param cameras the camera to detach
  74099. */
  74100. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74101. /**
  74102. * Enables an effect by name on a pipeline
  74103. * @param renderPipelineName the name of the pipeline to enable the effect in
  74104. * @param renderEffectName the name of the effect to enable
  74105. * @param cameras the cameras that the effect should be enabled on
  74106. */
  74107. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74108. /**
  74109. * Disables an effect by name on a pipeline
  74110. * @param renderPipelineName the name of the pipeline to disable the effect in
  74111. * @param renderEffectName the name of the effect to disable
  74112. * @param cameras the cameras that the effect should be disabled on
  74113. */
  74114. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74115. /**
  74116. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74117. */
  74118. update(): void;
  74119. /** @hidden */
  74120. _rebuild(): void;
  74121. /**
  74122. * Disposes of the manager and pipelines
  74123. */
  74124. dispose(): void;
  74125. }
  74126. }
  74127. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  74128. import { ISceneComponent } from "babylonjs/sceneComponent";
  74129. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74130. import { Scene } from "babylonjs/scene";
  74131. module "babylonjs/scene" {
  74132. interface Scene {
  74133. /** @hidden (Backing field) */
  74134. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74135. /**
  74136. * Gets the postprocess render pipeline manager
  74137. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74138. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74139. */
  74140. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74141. }
  74142. }
  74143. /**
  74144. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74145. */
  74146. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74147. /**
  74148. * The component name helpfull to identify the component in the list of scene components.
  74149. */
  74150. readonly name: string;
  74151. /**
  74152. * The scene the component belongs to.
  74153. */
  74154. scene: Scene;
  74155. /**
  74156. * Creates a new instance of the component for the given scene
  74157. * @param scene Defines the scene to register the component in
  74158. */
  74159. constructor(scene: Scene);
  74160. /**
  74161. * Registers the component in a given scene
  74162. */
  74163. register(): void;
  74164. /**
  74165. * Rebuilds the elements related to this component in case of
  74166. * context lost for instance.
  74167. */
  74168. rebuild(): void;
  74169. /**
  74170. * Disposes the component and the associated ressources
  74171. */
  74172. dispose(): void;
  74173. private _gatherRenderTargets;
  74174. }
  74175. }
  74176. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  74177. import { Nullable } from "babylonjs/types";
  74178. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74179. import { Camera } from "babylonjs/Cameras/camera";
  74180. import { IDisposable } from "babylonjs/scene";
  74181. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  74182. import { Scene } from "babylonjs/scene";
  74183. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  74184. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74185. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74186. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  74187. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74188. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74189. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  74190. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74191. import { Animation } from "babylonjs/Animations/animation";
  74192. /**
  74193. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74194. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74195. */
  74196. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74197. private _scene;
  74198. private _camerasToBeAttached;
  74199. /**
  74200. * ID of the sharpen post process,
  74201. */
  74202. private readonly SharpenPostProcessId;
  74203. /**
  74204. * @ignore
  74205. * ID of the image processing post process;
  74206. */
  74207. readonly ImageProcessingPostProcessId: string;
  74208. /**
  74209. * @ignore
  74210. * ID of the Fast Approximate Anti-Aliasing post process;
  74211. */
  74212. readonly FxaaPostProcessId: string;
  74213. /**
  74214. * ID of the chromatic aberration post process,
  74215. */
  74216. private readonly ChromaticAberrationPostProcessId;
  74217. /**
  74218. * ID of the grain post process
  74219. */
  74220. private readonly GrainPostProcessId;
  74221. /**
  74222. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74223. */
  74224. sharpen: SharpenPostProcess;
  74225. private _sharpenEffect;
  74226. private bloom;
  74227. /**
  74228. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74229. */
  74230. depthOfField: DepthOfFieldEffect;
  74231. /**
  74232. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74233. */
  74234. fxaa: FxaaPostProcess;
  74235. /**
  74236. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74237. */
  74238. imageProcessing: ImageProcessingPostProcess;
  74239. /**
  74240. * Chromatic aberration post process which will shift rgb colors in the image
  74241. */
  74242. chromaticAberration: ChromaticAberrationPostProcess;
  74243. private _chromaticAberrationEffect;
  74244. /**
  74245. * Grain post process which add noise to the image
  74246. */
  74247. grain: GrainPostProcess;
  74248. private _grainEffect;
  74249. /**
  74250. * Glow post process which adds a glow to emissive areas of the image
  74251. */
  74252. private _glowLayer;
  74253. /**
  74254. * Animations which can be used to tweak settings over a period of time
  74255. */
  74256. animations: Animation[];
  74257. private _imageProcessingConfigurationObserver;
  74258. private _sharpenEnabled;
  74259. private _bloomEnabled;
  74260. private _depthOfFieldEnabled;
  74261. private _depthOfFieldBlurLevel;
  74262. private _fxaaEnabled;
  74263. private _imageProcessingEnabled;
  74264. private _defaultPipelineTextureType;
  74265. private _bloomScale;
  74266. private _chromaticAberrationEnabled;
  74267. private _grainEnabled;
  74268. private _buildAllowed;
  74269. /**
  74270. * Gets active scene
  74271. */
  74272. get scene(): Scene;
  74273. /**
  74274. * Enable or disable the sharpen process from the pipeline
  74275. */
  74276. set sharpenEnabled(enabled: boolean);
  74277. get sharpenEnabled(): boolean;
  74278. private _resizeObserver;
  74279. private _hardwareScaleLevel;
  74280. private _bloomKernel;
  74281. /**
  74282. * Specifies the size of the bloom blur kernel, relative to the final output size
  74283. */
  74284. get bloomKernel(): number;
  74285. set bloomKernel(value: number);
  74286. /**
  74287. * Specifies the weight of the bloom in the final rendering
  74288. */
  74289. private _bloomWeight;
  74290. /**
  74291. * Specifies the luma threshold for the area that will be blurred by the bloom
  74292. */
  74293. private _bloomThreshold;
  74294. private _hdr;
  74295. /**
  74296. * The strength of the bloom.
  74297. */
  74298. set bloomWeight(value: number);
  74299. get bloomWeight(): number;
  74300. /**
  74301. * The strength of the bloom.
  74302. */
  74303. set bloomThreshold(value: number);
  74304. get bloomThreshold(): number;
  74305. /**
  74306. * The scale of the bloom, lower value will provide better performance.
  74307. */
  74308. set bloomScale(value: number);
  74309. get bloomScale(): number;
  74310. /**
  74311. * Enable or disable the bloom from the pipeline
  74312. */
  74313. set bloomEnabled(enabled: boolean);
  74314. get bloomEnabled(): boolean;
  74315. private _rebuildBloom;
  74316. /**
  74317. * If the depth of field is enabled.
  74318. */
  74319. get depthOfFieldEnabled(): boolean;
  74320. set depthOfFieldEnabled(enabled: boolean);
  74321. /**
  74322. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74323. */
  74324. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74325. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74326. /**
  74327. * If the anti aliasing is enabled.
  74328. */
  74329. set fxaaEnabled(enabled: boolean);
  74330. get fxaaEnabled(): boolean;
  74331. private _samples;
  74332. /**
  74333. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74334. */
  74335. set samples(sampleCount: number);
  74336. get samples(): number;
  74337. /**
  74338. * If image processing is enabled.
  74339. */
  74340. set imageProcessingEnabled(enabled: boolean);
  74341. get imageProcessingEnabled(): boolean;
  74342. /**
  74343. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74344. */
  74345. set glowLayerEnabled(enabled: boolean);
  74346. get glowLayerEnabled(): boolean;
  74347. /**
  74348. * Gets the glow layer (or null if not defined)
  74349. */
  74350. get glowLayer(): Nullable<GlowLayer>;
  74351. /**
  74352. * Enable or disable the chromaticAberration process from the pipeline
  74353. */
  74354. set chromaticAberrationEnabled(enabled: boolean);
  74355. get chromaticAberrationEnabled(): boolean;
  74356. /**
  74357. * Enable or disable the grain process from the pipeline
  74358. */
  74359. set grainEnabled(enabled: boolean);
  74360. get grainEnabled(): boolean;
  74361. /**
  74362. * @constructor
  74363. * @param name - The rendering pipeline name (default: "")
  74364. * @param hdr - If high dynamic range textures should be used (default: true)
  74365. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74366. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74367. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74368. */
  74369. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74370. /**
  74371. * Get the class name
  74372. * @returns "DefaultRenderingPipeline"
  74373. */
  74374. getClassName(): string;
  74375. /**
  74376. * Force the compilation of the entire pipeline.
  74377. */
  74378. prepare(): void;
  74379. private _hasCleared;
  74380. private _prevPostProcess;
  74381. private _prevPrevPostProcess;
  74382. private _setAutoClearAndTextureSharing;
  74383. private _depthOfFieldSceneObserver;
  74384. private _buildPipeline;
  74385. private _disposePostProcesses;
  74386. /**
  74387. * Adds a camera to the pipeline
  74388. * @param camera the camera to be added
  74389. */
  74390. addCamera(camera: Camera): void;
  74391. /**
  74392. * Removes a camera from the pipeline
  74393. * @param camera the camera to remove
  74394. */
  74395. removeCamera(camera: Camera): void;
  74396. /**
  74397. * Dispose of the pipeline and stop all post processes
  74398. */
  74399. dispose(): void;
  74400. /**
  74401. * Serialize the rendering pipeline (Used when exporting)
  74402. * @returns the serialized object
  74403. */
  74404. serialize(): any;
  74405. /**
  74406. * Parse the serialized pipeline
  74407. * @param source Source pipeline.
  74408. * @param scene The scene to load the pipeline to.
  74409. * @param rootUrl The URL of the serialized pipeline.
  74410. * @returns An instantiated pipeline from the serialized object.
  74411. */
  74412. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74413. }
  74414. }
  74415. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  74416. /** @hidden */
  74417. export var lensHighlightsPixelShader: {
  74418. name: string;
  74419. shader: string;
  74420. };
  74421. }
  74422. declare module "babylonjs/Shaders/depthOfField.fragment" {
  74423. /** @hidden */
  74424. export var depthOfFieldPixelShader: {
  74425. name: string;
  74426. shader: string;
  74427. };
  74428. }
  74429. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  74430. import { Camera } from "babylonjs/Cameras/camera";
  74431. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74432. import { Scene } from "babylonjs/scene";
  74433. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74434. import "babylonjs/Shaders/chromaticAberration.fragment";
  74435. import "babylonjs/Shaders/lensHighlights.fragment";
  74436. import "babylonjs/Shaders/depthOfField.fragment";
  74437. /**
  74438. * BABYLON.JS Chromatic Aberration GLSL Shader
  74439. * Author: Olivier Guyot
  74440. * Separates very slightly R, G and B colors on the edges of the screen
  74441. * Inspired by Francois Tarlier & Martins Upitis
  74442. */
  74443. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74444. /**
  74445. * @ignore
  74446. * The chromatic aberration PostProcess id in the pipeline
  74447. */
  74448. LensChromaticAberrationEffect: string;
  74449. /**
  74450. * @ignore
  74451. * The highlights enhancing PostProcess id in the pipeline
  74452. */
  74453. HighlightsEnhancingEffect: string;
  74454. /**
  74455. * @ignore
  74456. * The depth-of-field PostProcess id in the pipeline
  74457. */
  74458. LensDepthOfFieldEffect: string;
  74459. private _scene;
  74460. private _depthTexture;
  74461. private _grainTexture;
  74462. private _chromaticAberrationPostProcess;
  74463. private _highlightsPostProcess;
  74464. private _depthOfFieldPostProcess;
  74465. private _edgeBlur;
  74466. private _grainAmount;
  74467. private _chromaticAberration;
  74468. private _distortion;
  74469. private _highlightsGain;
  74470. private _highlightsThreshold;
  74471. private _dofDistance;
  74472. private _dofAperture;
  74473. private _dofDarken;
  74474. private _dofPentagon;
  74475. private _blurNoise;
  74476. /**
  74477. * @constructor
  74478. *
  74479. * Effect parameters are as follow:
  74480. * {
  74481. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74482. * edge_blur: number; // from 0 to x (1 for realism)
  74483. * distortion: number; // from 0 to x (1 for realism)
  74484. * grain_amount: number; // from 0 to 1
  74485. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74486. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74487. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74488. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74489. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74490. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74491. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74492. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74493. * }
  74494. * Note: if an effect parameter is unset, effect is disabled
  74495. *
  74496. * @param name The rendering pipeline name
  74497. * @param parameters - An object containing all parameters (see above)
  74498. * @param scene The scene linked to this pipeline
  74499. * @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)
  74500. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74501. */
  74502. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74503. /**
  74504. * Get the class name
  74505. * @returns "LensRenderingPipeline"
  74506. */
  74507. getClassName(): string;
  74508. /**
  74509. * Gets associated scene
  74510. */
  74511. get scene(): Scene;
  74512. /**
  74513. * Gets or sets the edge blur
  74514. */
  74515. get edgeBlur(): number;
  74516. set edgeBlur(value: number);
  74517. /**
  74518. * Gets or sets the grain amount
  74519. */
  74520. get grainAmount(): number;
  74521. set grainAmount(value: number);
  74522. /**
  74523. * Gets or sets the chromatic aberration amount
  74524. */
  74525. get chromaticAberration(): number;
  74526. set chromaticAberration(value: number);
  74527. /**
  74528. * Gets or sets the depth of field aperture
  74529. */
  74530. get dofAperture(): number;
  74531. set dofAperture(value: number);
  74532. /**
  74533. * Gets or sets the edge distortion
  74534. */
  74535. get edgeDistortion(): number;
  74536. set edgeDistortion(value: number);
  74537. /**
  74538. * Gets or sets the depth of field distortion
  74539. */
  74540. get dofDistortion(): number;
  74541. set dofDistortion(value: number);
  74542. /**
  74543. * Gets or sets the darken out of focus amount
  74544. */
  74545. get darkenOutOfFocus(): number;
  74546. set darkenOutOfFocus(value: number);
  74547. /**
  74548. * Gets or sets a boolean indicating if blur noise is enabled
  74549. */
  74550. get blurNoise(): boolean;
  74551. set blurNoise(value: boolean);
  74552. /**
  74553. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  74554. */
  74555. get pentagonBokeh(): boolean;
  74556. set pentagonBokeh(value: boolean);
  74557. /**
  74558. * Gets or sets the highlight grain amount
  74559. */
  74560. get highlightsGain(): number;
  74561. set highlightsGain(value: number);
  74562. /**
  74563. * Gets or sets the highlight threshold
  74564. */
  74565. get highlightsThreshold(): number;
  74566. set highlightsThreshold(value: number);
  74567. /**
  74568. * Sets the amount of blur at the edges
  74569. * @param amount blur amount
  74570. */
  74571. setEdgeBlur(amount: number): void;
  74572. /**
  74573. * Sets edge blur to 0
  74574. */
  74575. disableEdgeBlur(): void;
  74576. /**
  74577. * Sets the amout of grain
  74578. * @param amount Amount of grain
  74579. */
  74580. setGrainAmount(amount: number): void;
  74581. /**
  74582. * Set grain amount to 0
  74583. */
  74584. disableGrain(): void;
  74585. /**
  74586. * Sets the chromatic aberration amount
  74587. * @param amount amount of chromatic aberration
  74588. */
  74589. setChromaticAberration(amount: number): void;
  74590. /**
  74591. * Sets chromatic aberration amount to 0
  74592. */
  74593. disableChromaticAberration(): void;
  74594. /**
  74595. * Sets the EdgeDistortion amount
  74596. * @param amount amount of EdgeDistortion
  74597. */
  74598. setEdgeDistortion(amount: number): void;
  74599. /**
  74600. * Sets edge distortion to 0
  74601. */
  74602. disableEdgeDistortion(): void;
  74603. /**
  74604. * Sets the FocusDistance amount
  74605. * @param amount amount of FocusDistance
  74606. */
  74607. setFocusDistance(amount: number): void;
  74608. /**
  74609. * Disables depth of field
  74610. */
  74611. disableDepthOfField(): void;
  74612. /**
  74613. * Sets the Aperture amount
  74614. * @param amount amount of Aperture
  74615. */
  74616. setAperture(amount: number): void;
  74617. /**
  74618. * Sets the DarkenOutOfFocus amount
  74619. * @param amount amount of DarkenOutOfFocus
  74620. */
  74621. setDarkenOutOfFocus(amount: number): void;
  74622. private _pentagonBokehIsEnabled;
  74623. /**
  74624. * Creates a pentagon bokeh effect
  74625. */
  74626. enablePentagonBokeh(): void;
  74627. /**
  74628. * Disables the pentagon bokeh effect
  74629. */
  74630. disablePentagonBokeh(): void;
  74631. /**
  74632. * Enables noise blur
  74633. */
  74634. enableNoiseBlur(): void;
  74635. /**
  74636. * Disables noise blur
  74637. */
  74638. disableNoiseBlur(): void;
  74639. /**
  74640. * Sets the HighlightsGain amount
  74641. * @param amount amount of HighlightsGain
  74642. */
  74643. setHighlightsGain(amount: number): void;
  74644. /**
  74645. * Sets the HighlightsThreshold amount
  74646. * @param amount amount of HighlightsThreshold
  74647. */
  74648. setHighlightsThreshold(amount: number): void;
  74649. /**
  74650. * Disables highlights
  74651. */
  74652. disableHighlights(): void;
  74653. /**
  74654. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  74655. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  74656. */
  74657. dispose(disableDepthRender?: boolean): void;
  74658. private _createChromaticAberrationPostProcess;
  74659. private _createHighlightsPostProcess;
  74660. private _createDepthOfFieldPostProcess;
  74661. private _createGrainTexture;
  74662. }
  74663. }
  74664. declare module "babylonjs/Shaders/ssao2.fragment" {
  74665. /** @hidden */
  74666. export var ssao2PixelShader: {
  74667. name: string;
  74668. shader: string;
  74669. };
  74670. }
  74671. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  74672. /** @hidden */
  74673. export var ssaoCombinePixelShader: {
  74674. name: string;
  74675. shader: string;
  74676. };
  74677. }
  74678. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  74679. import { Camera } from "babylonjs/Cameras/camera";
  74680. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74681. import { Scene } from "babylonjs/scene";
  74682. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74683. import "babylonjs/Shaders/ssao2.fragment";
  74684. import "babylonjs/Shaders/ssaoCombine.fragment";
  74685. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74686. /**
  74687. * Render pipeline to produce ssao effect
  74688. */
  74689. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  74690. /**
  74691. * @ignore
  74692. * The PassPostProcess id in the pipeline that contains the original scene color
  74693. */
  74694. SSAOOriginalSceneColorEffect: string;
  74695. /**
  74696. * @ignore
  74697. * The SSAO PostProcess id in the pipeline
  74698. */
  74699. SSAORenderEffect: string;
  74700. /**
  74701. * @ignore
  74702. * The horizontal blur PostProcess id in the pipeline
  74703. */
  74704. SSAOBlurHRenderEffect: string;
  74705. /**
  74706. * @ignore
  74707. * The vertical blur PostProcess id in the pipeline
  74708. */
  74709. SSAOBlurVRenderEffect: string;
  74710. /**
  74711. * @ignore
  74712. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74713. */
  74714. SSAOCombineRenderEffect: string;
  74715. /**
  74716. * The output strength of the SSAO post-process. Default value is 1.0.
  74717. */
  74718. totalStrength: number;
  74719. /**
  74720. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  74721. */
  74722. maxZ: number;
  74723. /**
  74724. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  74725. */
  74726. minZAspect: number;
  74727. private _samples;
  74728. /**
  74729. * Number of samples used for the SSAO calculations. Default value is 8
  74730. */
  74731. set samples(n: number);
  74732. get samples(): number;
  74733. private _textureSamples;
  74734. /**
  74735. * Number of samples to use for antialiasing
  74736. */
  74737. set textureSamples(n: number);
  74738. get textureSamples(): number;
  74739. /**
  74740. * Force rendering the geometry through geometry buffer
  74741. */
  74742. private _forceGeometryBuffer;
  74743. /**
  74744. * Ratio object used for SSAO ratio and blur ratio
  74745. */
  74746. private _ratio;
  74747. /**
  74748. * Dynamically generated sphere sampler.
  74749. */
  74750. private _sampleSphere;
  74751. /**
  74752. * Blur filter offsets
  74753. */
  74754. private _samplerOffsets;
  74755. private _expensiveBlur;
  74756. /**
  74757. * If bilateral blur should be used
  74758. */
  74759. set expensiveBlur(b: boolean);
  74760. get expensiveBlur(): boolean;
  74761. /**
  74762. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  74763. */
  74764. radius: number;
  74765. /**
  74766. * The base color of the SSAO post-process
  74767. * The final result is "base + ssao" between [0, 1]
  74768. */
  74769. base: number;
  74770. /**
  74771. * Support test.
  74772. */
  74773. static get IsSupported(): boolean;
  74774. private _scene;
  74775. private _randomTexture;
  74776. private _originalColorPostProcess;
  74777. private _ssaoPostProcess;
  74778. private _blurHPostProcess;
  74779. private _blurVPostProcess;
  74780. private _ssaoCombinePostProcess;
  74781. private _prePassRenderer;
  74782. /**
  74783. * Gets active scene
  74784. */
  74785. get scene(): Scene;
  74786. /**
  74787. * @constructor
  74788. * @param name The rendering pipeline name
  74789. * @param scene The scene linked to this pipeline
  74790. * @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 }
  74791. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74792. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  74793. */
  74794. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  74795. /**
  74796. * Get the class name
  74797. * @returns "SSAO2RenderingPipeline"
  74798. */
  74799. getClassName(): string;
  74800. /**
  74801. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74802. */
  74803. dispose(disableGeometryBufferRenderer?: boolean): void;
  74804. private _createBlurPostProcess;
  74805. /** @hidden */
  74806. _rebuild(): void;
  74807. private _bits;
  74808. private _radicalInverse_VdC;
  74809. private _hammersley;
  74810. private _hemisphereSample_uniform;
  74811. private _generateHemisphere;
  74812. private _getDefinesForSSAO;
  74813. private _createSSAOPostProcess;
  74814. private _createSSAOCombinePostProcess;
  74815. private _createRandomTexture;
  74816. /**
  74817. * Serialize the rendering pipeline (Used when exporting)
  74818. * @returns the serialized object
  74819. */
  74820. serialize(): any;
  74821. /**
  74822. * Parse the serialized pipeline
  74823. * @param source Source pipeline.
  74824. * @param scene The scene to load the pipeline to.
  74825. * @param rootUrl The URL of the serialized pipeline.
  74826. * @returns An instantiated pipeline from the serialized object.
  74827. */
  74828. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  74829. /**
  74830. * Sets the required values to the prepass renderer.
  74831. * @param prePassRenderer defines the prepass renderer to setup
  74832. * @returns true if the pre pass is needed.
  74833. */
  74834. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74835. }
  74836. }
  74837. declare module "babylonjs/Shaders/ssao.fragment" {
  74838. /** @hidden */
  74839. export var ssaoPixelShader: {
  74840. name: string;
  74841. shader: string;
  74842. };
  74843. }
  74844. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  74845. import { Camera } from "babylonjs/Cameras/camera";
  74846. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74847. import { Scene } from "babylonjs/scene";
  74848. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74849. import "babylonjs/Shaders/ssao.fragment";
  74850. import "babylonjs/Shaders/ssaoCombine.fragment";
  74851. /**
  74852. * Render pipeline to produce ssao effect
  74853. */
  74854. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  74855. /**
  74856. * @ignore
  74857. * The PassPostProcess id in the pipeline that contains the original scene color
  74858. */
  74859. SSAOOriginalSceneColorEffect: string;
  74860. /**
  74861. * @ignore
  74862. * The SSAO PostProcess id in the pipeline
  74863. */
  74864. SSAORenderEffect: string;
  74865. /**
  74866. * @ignore
  74867. * The horizontal blur PostProcess id in the pipeline
  74868. */
  74869. SSAOBlurHRenderEffect: string;
  74870. /**
  74871. * @ignore
  74872. * The vertical blur PostProcess id in the pipeline
  74873. */
  74874. SSAOBlurVRenderEffect: string;
  74875. /**
  74876. * @ignore
  74877. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74878. */
  74879. SSAOCombineRenderEffect: string;
  74880. /**
  74881. * The output strength of the SSAO post-process. Default value is 1.0.
  74882. */
  74883. totalStrength: number;
  74884. /**
  74885. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  74886. */
  74887. radius: number;
  74888. /**
  74889. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  74890. * Must not be equal to fallOff and superior to fallOff.
  74891. * Default value is 0.0075
  74892. */
  74893. area: number;
  74894. /**
  74895. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  74896. * Must not be equal to area and inferior to area.
  74897. * Default value is 0.000001
  74898. */
  74899. fallOff: number;
  74900. /**
  74901. * The base color of the SSAO post-process
  74902. * The final result is "base + ssao" between [0, 1]
  74903. */
  74904. base: number;
  74905. private _scene;
  74906. private _depthTexture;
  74907. private _randomTexture;
  74908. private _originalColorPostProcess;
  74909. private _ssaoPostProcess;
  74910. private _blurHPostProcess;
  74911. private _blurVPostProcess;
  74912. private _ssaoCombinePostProcess;
  74913. private _firstUpdate;
  74914. /**
  74915. * Gets active scene
  74916. */
  74917. get scene(): Scene;
  74918. /**
  74919. * @constructor
  74920. * @param name - The rendering pipeline name
  74921. * @param scene - The scene linked to this pipeline
  74922. * @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 }
  74923. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  74924. */
  74925. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  74926. /**
  74927. * Get the class name
  74928. * @returns "SSAORenderingPipeline"
  74929. */
  74930. getClassName(): string;
  74931. /**
  74932. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74933. */
  74934. dispose(disableDepthRender?: boolean): void;
  74935. private _createBlurPostProcess;
  74936. /** @hidden */
  74937. _rebuild(): void;
  74938. private _createSSAOPostProcess;
  74939. private _createSSAOCombinePostProcess;
  74940. private _createRandomTexture;
  74941. }
  74942. }
  74943. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  74944. /** @hidden */
  74945. export var screenSpaceReflectionPixelShader: {
  74946. name: string;
  74947. shader: string;
  74948. };
  74949. }
  74950. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  74951. import { Nullable } from "babylonjs/types";
  74952. import { Camera } from "babylonjs/Cameras/camera";
  74953. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74954. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  74955. import { Engine } from "babylonjs/Engines/engine";
  74956. import { Scene } from "babylonjs/scene";
  74957. /**
  74958. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  74959. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  74960. */
  74961. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  74962. /**
  74963. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  74964. */
  74965. threshold: number;
  74966. /**
  74967. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  74968. */
  74969. strength: number;
  74970. /**
  74971. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  74972. */
  74973. reflectionSpecularFalloffExponent: number;
  74974. /**
  74975. * 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]
  74976. */
  74977. step: number;
  74978. /**
  74979. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  74980. */
  74981. roughnessFactor: number;
  74982. private _geometryBufferRenderer;
  74983. private _enableSmoothReflections;
  74984. private _reflectionSamples;
  74985. private _smoothSteps;
  74986. /**
  74987. * Gets a string identifying the name of the class
  74988. * @returns "ScreenSpaceReflectionPostProcess" string
  74989. */
  74990. getClassName(): string;
  74991. /**
  74992. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  74993. * @param name The name of the effect.
  74994. * @param scene The scene containing the objects to calculate reflections.
  74995. * @param options The required width/height ratio to downsize to before computing the render pass.
  74996. * @param camera The camera to apply the render pass to.
  74997. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74998. * @param engine The engine which the post process will be applied. (default: current engine)
  74999. * @param reusable If the post process can be reused on the same frame. (default: false)
  75000. * @param textureType Type of textures used when performing the post process. (default: 0)
  75001. * @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)
  75002. */
  75003. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75004. /**
  75005. * Gets wether or not smoothing reflections is enabled.
  75006. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75007. */
  75008. get enableSmoothReflections(): boolean;
  75009. /**
  75010. * Sets wether or not smoothing reflections is enabled.
  75011. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75012. */
  75013. set enableSmoothReflections(enabled: boolean);
  75014. /**
  75015. * Gets the number of samples taken while computing reflections. More samples count is high,
  75016. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75017. */
  75018. get reflectionSamples(): number;
  75019. /**
  75020. * Sets the number of samples taken while computing reflections. More samples count is high,
  75021. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75022. */
  75023. set reflectionSamples(samples: number);
  75024. /**
  75025. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75026. * more the post-process will require GPU power and can generate a drop in FPS.
  75027. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75028. */
  75029. get smoothSteps(): number;
  75030. set smoothSteps(steps: number);
  75031. private _updateEffectDefines;
  75032. /** @hidden */
  75033. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75034. }
  75035. }
  75036. declare module "babylonjs/Shaders/standard.fragment" {
  75037. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  75038. /** @hidden */
  75039. export var standardPixelShader: {
  75040. name: string;
  75041. shader: string;
  75042. };
  75043. }
  75044. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  75045. import { Nullable } from "babylonjs/types";
  75046. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75047. import { Camera } from "babylonjs/Cameras/camera";
  75048. import { Texture } from "babylonjs/Materials/Textures/texture";
  75049. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75050. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75051. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  75052. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75053. import { IDisposable } from "babylonjs/scene";
  75054. import { SpotLight } from "babylonjs/Lights/spotLight";
  75055. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  75056. import { Scene } from "babylonjs/scene";
  75057. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75058. import { Animation } from "babylonjs/Animations/animation";
  75059. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75060. import "babylonjs/Shaders/standard.fragment";
  75061. /**
  75062. * Standard rendering pipeline
  75063. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75064. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75065. */
  75066. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75067. /**
  75068. * Public members
  75069. */
  75070. /**
  75071. * Post-process which contains the original scene color before the pipeline applies all the effects
  75072. */
  75073. originalPostProcess: Nullable<PostProcess>;
  75074. /**
  75075. * Post-process used to down scale an image x4
  75076. */
  75077. downSampleX4PostProcess: Nullable<PostProcess>;
  75078. /**
  75079. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75080. */
  75081. brightPassPostProcess: Nullable<PostProcess>;
  75082. /**
  75083. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75084. */
  75085. blurHPostProcesses: PostProcess[];
  75086. /**
  75087. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75088. */
  75089. blurVPostProcesses: PostProcess[];
  75090. /**
  75091. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75092. */
  75093. textureAdderPostProcess: Nullable<PostProcess>;
  75094. /**
  75095. * Post-process used to create volumetric lighting effect
  75096. */
  75097. volumetricLightPostProcess: Nullable<PostProcess>;
  75098. /**
  75099. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75100. */
  75101. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75102. /**
  75103. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75104. */
  75105. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75106. /**
  75107. * Post-process used to merge the volumetric light effect and the real scene color
  75108. */
  75109. volumetricLightMergePostProces: Nullable<PostProcess>;
  75110. /**
  75111. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75112. */
  75113. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75114. /**
  75115. * Base post-process used to calculate the average luminance of the final image for HDR
  75116. */
  75117. luminancePostProcess: Nullable<PostProcess>;
  75118. /**
  75119. * Post-processes used to create down sample post-processes in order to get
  75120. * the average luminance of the final image for HDR
  75121. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75122. */
  75123. luminanceDownSamplePostProcesses: PostProcess[];
  75124. /**
  75125. * Post-process used to create a HDR effect (light adaptation)
  75126. */
  75127. hdrPostProcess: Nullable<PostProcess>;
  75128. /**
  75129. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75130. */
  75131. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75132. /**
  75133. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75134. */
  75135. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75136. /**
  75137. * Post-process used to merge the final HDR post-process and the real scene color
  75138. */
  75139. hdrFinalPostProcess: Nullable<PostProcess>;
  75140. /**
  75141. * Post-process used to create a lens flare effect
  75142. */
  75143. lensFlarePostProcess: Nullable<PostProcess>;
  75144. /**
  75145. * Post-process that merges the result of the lens flare post-process and the real scene color
  75146. */
  75147. lensFlareComposePostProcess: Nullable<PostProcess>;
  75148. /**
  75149. * Post-process used to create a motion blur effect
  75150. */
  75151. motionBlurPostProcess: Nullable<PostProcess>;
  75152. /**
  75153. * Post-process used to create a depth of field effect
  75154. */
  75155. depthOfFieldPostProcess: Nullable<PostProcess>;
  75156. /**
  75157. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75158. */
  75159. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75160. /**
  75161. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75162. */
  75163. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75164. /**
  75165. * Represents the brightness threshold in order to configure the illuminated surfaces
  75166. */
  75167. brightThreshold: number;
  75168. /**
  75169. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75170. */
  75171. blurWidth: number;
  75172. /**
  75173. * Sets if the blur for highlighted surfaces must be only horizontal
  75174. */
  75175. horizontalBlur: boolean;
  75176. /**
  75177. * Gets the overall exposure used by the pipeline
  75178. */
  75179. get exposure(): number;
  75180. /**
  75181. * Sets the overall exposure used by the pipeline
  75182. */
  75183. set exposure(value: number);
  75184. /**
  75185. * Texture used typically to simulate "dirty" on camera lens
  75186. */
  75187. lensTexture: Nullable<Texture>;
  75188. /**
  75189. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75190. */
  75191. volumetricLightCoefficient: number;
  75192. /**
  75193. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75194. */
  75195. volumetricLightPower: number;
  75196. /**
  75197. * Used the set the blur intensity to smooth the volumetric lights
  75198. */
  75199. volumetricLightBlurScale: number;
  75200. /**
  75201. * Light (spot or directional) used to generate the volumetric lights rays
  75202. * The source light must have a shadow generate so the pipeline can get its
  75203. * depth map
  75204. */
  75205. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75206. /**
  75207. * For eye adaptation, represents the minimum luminance the eye can see
  75208. */
  75209. hdrMinimumLuminance: number;
  75210. /**
  75211. * For eye adaptation, represents the decrease luminance speed
  75212. */
  75213. hdrDecreaseRate: number;
  75214. /**
  75215. * For eye adaptation, represents the increase luminance speed
  75216. */
  75217. hdrIncreaseRate: number;
  75218. /**
  75219. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75220. */
  75221. get hdrAutoExposure(): boolean;
  75222. /**
  75223. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75224. */
  75225. set hdrAutoExposure(value: boolean);
  75226. /**
  75227. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75228. */
  75229. lensColorTexture: Nullable<Texture>;
  75230. /**
  75231. * The overall strengh for the lens flare effect
  75232. */
  75233. lensFlareStrength: number;
  75234. /**
  75235. * Dispersion coefficient for lens flare ghosts
  75236. */
  75237. lensFlareGhostDispersal: number;
  75238. /**
  75239. * Main lens flare halo width
  75240. */
  75241. lensFlareHaloWidth: number;
  75242. /**
  75243. * Based on the lens distortion effect, defines how much the lens flare result
  75244. * is distorted
  75245. */
  75246. lensFlareDistortionStrength: number;
  75247. /**
  75248. * Configures the blur intensity used for for lens flare (halo)
  75249. */
  75250. lensFlareBlurWidth: number;
  75251. /**
  75252. * Lens star texture must be used to simulate rays on the flares and is available
  75253. * in the documentation
  75254. */
  75255. lensStarTexture: Nullable<Texture>;
  75256. /**
  75257. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75258. * flare effect by taking account of the dirt texture
  75259. */
  75260. lensFlareDirtTexture: Nullable<Texture>;
  75261. /**
  75262. * Represents the focal length for the depth of field effect
  75263. */
  75264. depthOfFieldDistance: number;
  75265. /**
  75266. * Represents the blur intensity for the blurred part of the depth of field effect
  75267. */
  75268. depthOfFieldBlurWidth: number;
  75269. /**
  75270. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75271. */
  75272. get motionStrength(): number;
  75273. /**
  75274. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75275. */
  75276. set motionStrength(strength: number);
  75277. /**
  75278. * Gets wether or not the motion blur post-process is object based or screen based.
  75279. */
  75280. get objectBasedMotionBlur(): boolean;
  75281. /**
  75282. * Sets wether or not the motion blur post-process should be object based or screen based
  75283. */
  75284. set objectBasedMotionBlur(value: boolean);
  75285. /**
  75286. * List of animations for the pipeline (IAnimatable implementation)
  75287. */
  75288. animations: Animation[];
  75289. /**
  75290. * Private members
  75291. */
  75292. private _scene;
  75293. private _currentDepthOfFieldSource;
  75294. private _basePostProcess;
  75295. private _fixedExposure;
  75296. private _currentExposure;
  75297. private _hdrAutoExposure;
  75298. private _hdrCurrentLuminance;
  75299. private _motionStrength;
  75300. private _isObjectBasedMotionBlur;
  75301. private _floatTextureType;
  75302. private _camerasToBeAttached;
  75303. private _ratio;
  75304. private _bloomEnabled;
  75305. private _depthOfFieldEnabled;
  75306. private _vlsEnabled;
  75307. private _lensFlareEnabled;
  75308. private _hdrEnabled;
  75309. private _motionBlurEnabled;
  75310. private _fxaaEnabled;
  75311. private _screenSpaceReflectionsEnabled;
  75312. private _motionBlurSamples;
  75313. private _volumetricLightStepsCount;
  75314. private _samples;
  75315. /**
  75316. * @ignore
  75317. * Specifies if the bloom pipeline is enabled
  75318. */
  75319. get BloomEnabled(): boolean;
  75320. set BloomEnabled(enabled: boolean);
  75321. /**
  75322. * @ignore
  75323. * Specifies if the depth of field pipeline is enabed
  75324. */
  75325. get DepthOfFieldEnabled(): boolean;
  75326. set DepthOfFieldEnabled(enabled: boolean);
  75327. /**
  75328. * @ignore
  75329. * Specifies if the lens flare pipeline is enabed
  75330. */
  75331. get LensFlareEnabled(): boolean;
  75332. set LensFlareEnabled(enabled: boolean);
  75333. /**
  75334. * @ignore
  75335. * Specifies if the HDR pipeline is enabled
  75336. */
  75337. get HDREnabled(): boolean;
  75338. set HDREnabled(enabled: boolean);
  75339. /**
  75340. * @ignore
  75341. * Specifies if the volumetric lights scattering effect is enabled
  75342. */
  75343. get VLSEnabled(): boolean;
  75344. set VLSEnabled(enabled: boolean);
  75345. /**
  75346. * @ignore
  75347. * Specifies if the motion blur effect is enabled
  75348. */
  75349. get MotionBlurEnabled(): boolean;
  75350. set MotionBlurEnabled(enabled: boolean);
  75351. /**
  75352. * Specifies if anti-aliasing is enabled
  75353. */
  75354. get fxaaEnabled(): boolean;
  75355. set fxaaEnabled(enabled: boolean);
  75356. /**
  75357. * Specifies if screen space reflections are enabled.
  75358. */
  75359. get screenSpaceReflectionsEnabled(): boolean;
  75360. set screenSpaceReflectionsEnabled(enabled: boolean);
  75361. /**
  75362. * Specifies the number of steps used to calculate the volumetric lights
  75363. * Typically in interval [50, 200]
  75364. */
  75365. get volumetricLightStepsCount(): number;
  75366. set volumetricLightStepsCount(count: number);
  75367. /**
  75368. * Specifies the number of samples used for the motion blur effect
  75369. * Typically in interval [16, 64]
  75370. */
  75371. get motionBlurSamples(): number;
  75372. set motionBlurSamples(samples: number);
  75373. /**
  75374. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75375. */
  75376. get samples(): number;
  75377. set samples(sampleCount: number);
  75378. /**
  75379. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75380. * @constructor
  75381. * @param name The rendering pipeline name
  75382. * @param scene The scene linked to this pipeline
  75383. * @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)
  75384. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75385. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75386. */
  75387. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75388. private _buildPipeline;
  75389. private _createDownSampleX4PostProcess;
  75390. private _createBrightPassPostProcess;
  75391. private _createBlurPostProcesses;
  75392. private _createTextureAdderPostProcess;
  75393. private _createVolumetricLightPostProcess;
  75394. private _createLuminancePostProcesses;
  75395. private _createHdrPostProcess;
  75396. private _createLensFlarePostProcess;
  75397. private _createDepthOfFieldPostProcess;
  75398. private _createMotionBlurPostProcess;
  75399. private _getDepthTexture;
  75400. private _disposePostProcesses;
  75401. /**
  75402. * Dispose of the pipeline and stop all post processes
  75403. */
  75404. dispose(): void;
  75405. /**
  75406. * Serialize the rendering pipeline (Used when exporting)
  75407. * @returns the serialized object
  75408. */
  75409. serialize(): any;
  75410. /**
  75411. * Parse the serialized pipeline
  75412. * @param source Source pipeline.
  75413. * @param scene The scene to load the pipeline to.
  75414. * @param rootUrl The URL of the serialized pipeline.
  75415. * @returns An instantiated pipeline from the serialized object.
  75416. */
  75417. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75418. /**
  75419. * Luminance steps
  75420. */
  75421. static LuminanceSteps: number;
  75422. }
  75423. }
  75424. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  75425. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  75426. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  75427. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  75428. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  75429. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  75430. }
  75431. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  75432. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  75433. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75434. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75435. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75436. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75437. }
  75438. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  75439. /** @hidden */
  75440. export var stereoscopicInterlacePixelShader: {
  75441. name: string;
  75442. shader: string;
  75443. };
  75444. }
  75445. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  75446. import { Camera } from "babylonjs/Cameras/camera";
  75447. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75448. import { Engine } from "babylonjs/Engines/engine";
  75449. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  75450. /**
  75451. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  75452. */
  75453. export class StereoscopicInterlacePostProcessI extends PostProcess {
  75454. private _stepSize;
  75455. private _passedProcess;
  75456. /**
  75457. * Gets a string identifying the name of the class
  75458. * @returns "StereoscopicInterlacePostProcessI" string
  75459. */
  75460. getClassName(): string;
  75461. /**
  75462. * Initializes a StereoscopicInterlacePostProcessI
  75463. * @param name The name of the effect.
  75464. * @param rigCameras The rig cameras to be appled to the post process
  75465. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  75466. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  75467. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75468. * @param engine The engine which the post process will be applied. (default: current engine)
  75469. * @param reusable If the post process can be reused on the same frame. (default: false)
  75470. */
  75471. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75472. }
  75473. /**
  75474. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  75475. */
  75476. export class StereoscopicInterlacePostProcess extends PostProcess {
  75477. private _stepSize;
  75478. private _passedProcess;
  75479. /**
  75480. * Gets a string identifying the name of the class
  75481. * @returns "StereoscopicInterlacePostProcess" string
  75482. */
  75483. getClassName(): string;
  75484. /**
  75485. * Initializes a StereoscopicInterlacePostProcess
  75486. * @param name The name of the effect.
  75487. * @param rigCameras The rig cameras to be appled to the post process
  75488. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  75489. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75490. * @param engine The engine which the post process will be applied. (default: current engine)
  75491. * @param reusable If the post process can be reused on the same frame. (default: false)
  75492. */
  75493. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75494. }
  75495. }
  75496. declare module "babylonjs/Shaders/tonemap.fragment" {
  75497. /** @hidden */
  75498. export var tonemapPixelShader: {
  75499. name: string;
  75500. shader: string;
  75501. };
  75502. }
  75503. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  75504. import { Camera } from "babylonjs/Cameras/camera";
  75505. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75506. import "babylonjs/Shaders/tonemap.fragment";
  75507. import { Engine } from "babylonjs/Engines/engine";
  75508. /** Defines operator used for tonemapping */
  75509. export enum TonemappingOperator {
  75510. /** Hable */
  75511. Hable = 0,
  75512. /** Reinhard */
  75513. Reinhard = 1,
  75514. /** HejiDawson */
  75515. HejiDawson = 2,
  75516. /** Photographic */
  75517. Photographic = 3
  75518. }
  75519. /**
  75520. * Defines a post process to apply tone mapping
  75521. */
  75522. export class TonemapPostProcess extends PostProcess {
  75523. private _operator;
  75524. /** Defines the required exposure adjustement */
  75525. exposureAdjustment: number;
  75526. /**
  75527. * Gets a string identifying the name of the class
  75528. * @returns "TonemapPostProcess" string
  75529. */
  75530. getClassName(): string;
  75531. /**
  75532. * Creates a new TonemapPostProcess
  75533. * @param name defines the name of the postprocess
  75534. * @param _operator defines the operator to use
  75535. * @param exposureAdjustment defines the required exposure adjustement
  75536. * @param camera defines the camera to use (can be null)
  75537. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  75538. * @param engine defines the hosting engine (can be ignore if camera is set)
  75539. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75540. */
  75541. constructor(name: string, _operator: TonemappingOperator,
  75542. /** Defines the required exposure adjustement */
  75543. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  75544. }
  75545. }
  75546. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  75547. /** @hidden */
  75548. export var volumetricLightScatteringPixelShader: {
  75549. name: string;
  75550. shader: string;
  75551. };
  75552. }
  75553. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  75554. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75555. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75556. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75557. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75558. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75559. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75560. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75561. /** @hidden */
  75562. export var volumetricLightScatteringPassVertexShader: {
  75563. name: string;
  75564. shader: string;
  75565. };
  75566. }
  75567. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  75568. /** @hidden */
  75569. export var volumetricLightScatteringPassPixelShader: {
  75570. name: string;
  75571. shader: string;
  75572. };
  75573. }
  75574. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  75575. import { Vector3 } from "babylonjs/Maths/math.vector";
  75576. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75577. import { Mesh } from "babylonjs/Meshes/mesh";
  75578. import { Camera } from "babylonjs/Cameras/camera";
  75579. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  75580. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75581. import { Scene } from "babylonjs/scene";
  75582. import "babylonjs/Meshes/Builders/planeBuilder";
  75583. import "babylonjs/Shaders/depth.vertex";
  75584. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  75585. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  75586. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  75587. import { Engine } from "babylonjs/Engines/engine";
  75588. /**
  75589. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  75590. */
  75591. export class VolumetricLightScatteringPostProcess extends PostProcess {
  75592. private _volumetricLightScatteringPass;
  75593. private _volumetricLightScatteringRTT;
  75594. private _viewPort;
  75595. private _screenCoordinates;
  75596. private _cachedDefines;
  75597. /**
  75598. * If not undefined, the mesh position is computed from the attached node position
  75599. */
  75600. attachedNode: {
  75601. position: Vector3;
  75602. };
  75603. /**
  75604. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  75605. */
  75606. customMeshPosition: Vector3;
  75607. /**
  75608. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  75609. */
  75610. useCustomMeshPosition: boolean;
  75611. /**
  75612. * If the post-process should inverse the light scattering direction
  75613. */
  75614. invert: boolean;
  75615. /**
  75616. * The internal mesh used by the post-process
  75617. */
  75618. mesh: Mesh;
  75619. /**
  75620. * @hidden
  75621. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  75622. */
  75623. get useDiffuseColor(): boolean;
  75624. set useDiffuseColor(useDiffuseColor: boolean);
  75625. /**
  75626. * Array containing the excluded meshes not rendered in the internal pass
  75627. */
  75628. excludedMeshes: AbstractMesh[];
  75629. /**
  75630. * Controls the overall intensity of the post-process
  75631. */
  75632. exposure: number;
  75633. /**
  75634. * Dissipates each sample's contribution in range [0, 1]
  75635. */
  75636. decay: number;
  75637. /**
  75638. * Controls the overall intensity of each sample
  75639. */
  75640. weight: number;
  75641. /**
  75642. * Controls the density of each sample
  75643. */
  75644. density: number;
  75645. /**
  75646. * @constructor
  75647. * @param name The post-process name
  75648. * @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)
  75649. * @param camera The camera that the post-process will be attached to
  75650. * @param mesh The mesh used to create the light scattering
  75651. * @param samples The post-process quality, default 100
  75652. * @param samplingModeThe post-process filtering mode
  75653. * @param engine The babylon engine
  75654. * @param reusable If the post-process is reusable
  75655. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  75656. */
  75657. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  75658. /**
  75659. * Returns the string "VolumetricLightScatteringPostProcess"
  75660. * @returns "VolumetricLightScatteringPostProcess"
  75661. */
  75662. getClassName(): string;
  75663. private _isReady;
  75664. /**
  75665. * Sets the new light position for light scattering effect
  75666. * @param position The new custom light position
  75667. */
  75668. setCustomMeshPosition(position: Vector3): void;
  75669. /**
  75670. * Returns the light position for light scattering effect
  75671. * @return Vector3 The custom light position
  75672. */
  75673. getCustomMeshPosition(): Vector3;
  75674. /**
  75675. * Disposes the internal assets and detaches the post-process from the camera
  75676. */
  75677. dispose(camera: Camera): void;
  75678. /**
  75679. * Returns the render target texture used by the post-process
  75680. * @return the render target texture used by the post-process
  75681. */
  75682. getPass(): RenderTargetTexture;
  75683. private _meshExcluded;
  75684. private _createPass;
  75685. private _updateMeshScreenCoordinates;
  75686. /**
  75687. * Creates a default mesh for the Volumeric Light Scattering post-process
  75688. * @param name The mesh name
  75689. * @param scene The scene where to create the mesh
  75690. * @return the default mesh
  75691. */
  75692. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  75693. }
  75694. }
  75695. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  75696. /** @hidden */
  75697. export var screenSpaceCurvaturePixelShader: {
  75698. name: string;
  75699. shader: string;
  75700. };
  75701. }
  75702. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  75703. import { Nullable } from "babylonjs/types";
  75704. import { Camera } from "babylonjs/Cameras/camera";
  75705. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75706. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75707. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  75708. import { Engine } from "babylonjs/Engines/engine";
  75709. import { Scene } from "babylonjs/scene";
  75710. /**
  75711. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  75712. */
  75713. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  75714. /**
  75715. * Defines how much ridge the curvature effect displays.
  75716. */
  75717. ridge: number;
  75718. /**
  75719. * Defines how much valley the curvature effect displays.
  75720. */
  75721. valley: number;
  75722. private _geometryBufferRenderer;
  75723. /**
  75724. * Gets a string identifying the name of the class
  75725. * @returns "ScreenSpaceCurvaturePostProcess" string
  75726. */
  75727. getClassName(): string;
  75728. /**
  75729. * Creates a new instance ScreenSpaceCurvaturePostProcess
  75730. * @param name The name of the effect.
  75731. * @param scene The scene containing the objects to blur according to their velocity.
  75732. * @param options The required width/height ratio to downsize to before computing the render pass.
  75733. * @param camera The camera to apply the render pass to.
  75734. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75735. * @param engine The engine which the post process will be applied. (default: current engine)
  75736. * @param reusable If the post process can be reused on the same frame. (default: false)
  75737. * @param textureType Type of textures used when performing the post process. (default: 0)
  75738. * @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)
  75739. */
  75740. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75741. /**
  75742. * Support test.
  75743. */
  75744. static get IsSupported(): boolean;
  75745. /** @hidden */
  75746. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  75747. }
  75748. }
  75749. declare module "babylonjs/PostProcesses/index" {
  75750. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  75751. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  75752. export * from "babylonjs/PostProcesses/bloomEffect";
  75753. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  75754. export * from "babylonjs/PostProcesses/blurPostProcess";
  75755. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75756. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  75757. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  75758. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  75759. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  75760. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  75761. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  75762. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  75763. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  75764. export * from "babylonjs/PostProcesses/filterPostProcess";
  75765. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  75766. export * from "babylonjs/PostProcesses/grainPostProcess";
  75767. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  75768. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75769. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  75770. export * from "babylonjs/PostProcesses/passPostProcess";
  75771. export * from "babylonjs/PostProcesses/postProcess";
  75772. export * from "babylonjs/PostProcesses/postProcessManager";
  75773. export * from "babylonjs/PostProcesses/refractionPostProcess";
  75774. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  75775. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  75776. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  75777. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  75778. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  75779. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  75780. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  75781. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75782. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  75783. }
  75784. declare module "babylonjs/Probes/index" {
  75785. export * from "babylonjs/Probes/reflectionProbe";
  75786. }
  75787. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  75788. import { Scene } from "babylonjs/scene";
  75789. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75790. import { SmartArray } from "babylonjs/Misc/smartArray";
  75791. import { ISceneComponent } from "babylonjs/sceneComponent";
  75792. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  75793. import "babylonjs/Meshes/Builders/boxBuilder";
  75794. import "babylonjs/Shaders/color.fragment";
  75795. import "babylonjs/Shaders/color.vertex";
  75796. import { Color3 } from "babylonjs/Maths/math.color";
  75797. import { Observable } from "babylonjs/Misc/observable";
  75798. module "babylonjs/scene" {
  75799. interface Scene {
  75800. /** @hidden (Backing field) */
  75801. _boundingBoxRenderer: BoundingBoxRenderer;
  75802. /** @hidden (Backing field) */
  75803. _forceShowBoundingBoxes: boolean;
  75804. /**
  75805. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  75806. */
  75807. forceShowBoundingBoxes: boolean;
  75808. /**
  75809. * Gets the bounding box renderer associated with the scene
  75810. * @returns a BoundingBoxRenderer
  75811. */
  75812. getBoundingBoxRenderer(): BoundingBoxRenderer;
  75813. }
  75814. }
  75815. module "babylonjs/Meshes/abstractMesh" {
  75816. interface AbstractMesh {
  75817. /** @hidden (Backing field) */
  75818. _showBoundingBox: boolean;
  75819. /**
  75820. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  75821. */
  75822. showBoundingBox: boolean;
  75823. }
  75824. }
  75825. /**
  75826. * Component responsible of rendering the bounding box of the meshes in a scene.
  75827. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  75828. */
  75829. export class BoundingBoxRenderer implements ISceneComponent {
  75830. /**
  75831. * The component name helpfull to identify the component in the list of scene components.
  75832. */
  75833. readonly name: string;
  75834. /**
  75835. * The scene the component belongs to.
  75836. */
  75837. scene: Scene;
  75838. /**
  75839. * Color of the bounding box lines placed in front of an object
  75840. */
  75841. frontColor: Color3;
  75842. /**
  75843. * Color of the bounding box lines placed behind an object
  75844. */
  75845. backColor: Color3;
  75846. /**
  75847. * Defines if the renderer should show the back lines or not
  75848. */
  75849. showBackLines: boolean;
  75850. /**
  75851. * Observable raised before rendering a bounding box
  75852. */
  75853. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  75854. /**
  75855. * Observable raised after rendering a bounding box
  75856. */
  75857. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  75858. /**
  75859. * @hidden
  75860. */
  75861. renderList: SmartArray<BoundingBox>;
  75862. private _colorShader;
  75863. private _vertexBuffers;
  75864. private _indexBuffer;
  75865. private _fillIndexBuffer;
  75866. private _fillIndexData;
  75867. /**
  75868. * Instantiates a new bounding box renderer in a scene.
  75869. * @param scene the scene the renderer renders in
  75870. */
  75871. constructor(scene: Scene);
  75872. /**
  75873. * Registers the component in a given scene
  75874. */
  75875. register(): void;
  75876. private _evaluateSubMesh;
  75877. private _activeMesh;
  75878. private _prepareRessources;
  75879. private _createIndexBuffer;
  75880. /**
  75881. * Rebuilds the elements related to this component in case of
  75882. * context lost for instance.
  75883. */
  75884. rebuild(): void;
  75885. /**
  75886. * @hidden
  75887. */
  75888. reset(): void;
  75889. /**
  75890. * Render the bounding boxes of a specific rendering group
  75891. * @param renderingGroupId defines the rendering group to render
  75892. */
  75893. render(renderingGroupId: number): void;
  75894. /**
  75895. * In case of occlusion queries, we can render the occlusion bounding box through this method
  75896. * @param mesh Define the mesh to render the occlusion bounding box for
  75897. */
  75898. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  75899. /**
  75900. * Dispose and release the resources attached to this renderer.
  75901. */
  75902. dispose(): void;
  75903. }
  75904. }
  75905. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  75906. import { Nullable } from "babylonjs/types";
  75907. import { Scene } from "babylonjs/scene";
  75908. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  75909. import { Camera } from "babylonjs/Cameras/camera";
  75910. import { ISceneComponent } from "babylonjs/sceneComponent";
  75911. module "babylonjs/scene" {
  75912. interface Scene {
  75913. /** @hidden (Backing field) */
  75914. _depthRenderer: {
  75915. [id: string]: DepthRenderer;
  75916. };
  75917. /**
  75918. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  75919. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  75920. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  75921. * @returns the created depth renderer
  75922. */
  75923. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  75924. /**
  75925. * Disables a depth renderer for a given camera
  75926. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  75927. */
  75928. disableDepthRenderer(camera?: Nullable<Camera>): void;
  75929. }
  75930. }
  75931. /**
  75932. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  75933. * in several rendering techniques.
  75934. */
  75935. export class DepthRendererSceneComponent implements ISceneComponent {
  75936. /**
  75937. * The component name helpfull to identify the component in the list of scene components.
  75938. */
  75939. readonly name: string;
  75940. /**
  75941. * The scene the component belongs to.
  75942. */
  75943. scene: Scene;
  75944. /**
  75945. * Creates a new instance of the component for the given scene
  75946. * @param scene Defines the scene to register the component in
  75947. */
  75948. constructor(scene: Scene);
  75949. /**
  75950. * Registers the component in a given scene
  75951. */
  75952. register(): void;
  75953. /**
  75954. * Rebuilds the elements related to this component in case of
  75955. * context lost for instance.
  75956. */
  75957. rebuild(): void;
  75958. /**
  75959. * Disposes the component and the associated ressources
  75960. */
  75961. dispose(): void;
  75962. private _gatherRenderTargets;
  75963. private _gatherActiveCameraRenderTargets;
  75964. }
  75965. }
  75966. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  75967. import { Nullable } from "babylonjs/types";
  75968. import { Scene } from "babylonjs/scene";
  75969. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  75970. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  75971. import { AbstractScene } from "babylonjs/abstractScene";
  75972. module "babylonjs/abstractScene" {
  75973. interface AbstractScene {
  75974. /** @hidden (Backing field) */
  75975. _prePassRenderer: Nullable<PrePassRenderer>;
  75976. /**
  75977. * Gets or Sets the current prepass renderer associated to the scene.
  75978. */
  75979. prePassRenderer: Nullable<PrePassRenderer>;
  75980. /**
  75981. * Enables the prepass and associates it with the scene
  75982. * @returns the PrePassRenderer
  75983. */
  75984. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  75985. /**
  75986. * Disables the prepass associated with the scene
  75987. */
  75988. disablePrePassRenderer(): void;
  75989. }
  75990. }
  75991. /**
  75992. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  75993. * in several rendering techniques.
  75994. */
  75995. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  75996. /**
  75997. * The component name helpful to identify the component in the list of scene components.
  75998. */
  75999. readonly name: string;
  76000. /**
  76001. * The scene the component belongs to.
  76002. */
  76003. scene: Scene;
  76004. /**
  76005. * Creates a new instance of the component for the given scene
  76006. * @param scene Defines the scene to register the component in
  76007. */
  76008. constructor(scene: Scene);
  76009. /**
  76010. * Registers the component in a given scene
  76011. */
  76012. register(): void;
  76013. private _beforeCameraDraw;
  76014. private _afterCameraDraw;
  76015. private _beforeClearStage;
  76016. /**
  76017. * Serializes the component data to the specified json object
  76018. * @param serializationObject The object to serialize to
  76019. */
  76020. serialize(serializationObject: any): void;
  76021. /**
  76022. * Adds all the elements from the container to the scene
  76023. * @param container the container holding the elements
  76024. */
  76025. addFromContainer(container: AbstractScene): void;
  76026. /**
  76027. * Removes all the elements in the container from the scene
  76028. * @param container contains the elements to remove
  76029. * @param dispose if the removed element should be disposed (default: false)
  76030. */
  76031. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76032. /**
  76033. * Rebuilds the elements related to this component in case of
  76034. * context lost for instance.
  76035. */
  76036. rebuild(): void;
  76037. /**
  76038. * Disposes the component and the associated ressources
  76039. */
  76040. dispose(): void;
  76041. }
  76042. }
  76043. declare module "babylonjs/Shaders/outline.fragment" {
  76044. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76045. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  76046. /** @hidden */
  76047. export var outlinePixelShader: {
  76048. name: string;
  76049. shader: string;
  76050. };
  76051. }
  76052. declare module "babylonjs/Shaders/outline.vertex" {
  76053. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76054. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76055. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76056. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76057. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76058. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76059. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76060. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76061. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  76062. /** @hidden */
  76063. export var outlineVertexShader: {
  76064. name: string;
  76065. shader: string;
  76066. };
  76067. }
  76068. declare module "babylonjs/Rendering/outlineRenderer" {
  76069. import { SubMesh } from "babylonjs/Meshes/subMesh";
  76070. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  76071. import { Scene } from "babylonjs/scene";
  76072. import { ISceneComponent } from "babylonjs/sceneComponent";
  76073. import "babylonjs/Shaders/outline.fragment";
  76074. import "babylonjs/Shaders/outline.vertex";
  76075. module "babylonjs/scene" {
  76076. interface Scene {
  76077. /** @hidden */
  76078. _outlineRenderer: OutlineRenderer;
  76079. /**
  76080. * Gets the outline renderer associated with the scene
  76081. * @returns a OutlineRenderer
  76082. */
  76083. getOutlineRenderer(): OutlineRenderer;
  76084. }
  76085. }
  76086. module "babylonjs/Meshes/abstractMesh" {
  76087. interface AbstractMesh {
  76088. /** @hidden (Backing field) */
  76089. _renderOutline: boolean;
  76090. /**
  76091. * Gets or sets a boolean indicating if the outline must be rendered as well
  76092. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76093. */
  76094. renderOutline: boolean;
  76095. /** @hidden (Backing field) */
  76096. _renderOverlay: boolean;
  76097. /**
  76098. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76099. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76100. */
  76101. renderOverlay: boolean;
  76102. }
  76103. }
  76104. /**
  76105. * This class is responsible to draw bothe outline/overlay of meshes.
  76106. * It should not be used directly but through the available method on mesh.
  76107. */
  76108. export class OutlineRenderer implements ISceneComponent {
  76109. /**
  76110. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76111. */
  76112. private static _StencilReference;
  76113. /**
  76114. * The name of the component. Each component must have a unique name.
  76115. */
  76116. name: string;
  76117. /**
  76118. * The scene the component belongs to.
  76119. */
  76120. scene: Scene;
  76121. /**
  76122. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76123. */
  76124. zOffset: number;
  76125. private _engine;
  76126. private _effect;
  76127. private _cachedDefines;
  76128. private _savedDepthWrite;
  76129. /**
  76130. * Instantiates a new outline renderer. (There could be only one per scene).
  76131. * @param scene Defines the scene it belongs to
  76132. */
  76133. constructor(scene: Scene);
  76134. /**
  76135. * Register the component to one instance of a scene.
  76136. */
  76137. register(): void;
  76138. /**
  76139. * Rebuilds the elements related to this component in case of
  76140. * context lost for instance.
  76141. */
  76142. rebuild(): void;
  76143. /**
  76144. * Disposes the component and the associated ressources.
  76145. */
  76146. dispose(): void;
  76147. /**
  76148. * Renders the outline in the canvas.
  76149. * @param subMesh Defines the sumesh to render
  76150. * @param batch Defines the batch of meshes in case of instances
  76151. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76152. */
  76153. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76154. /**
  76155. * Returns whether or not the outline renderer is ready for a given submesh.
  76156. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76157. * @param subMesh Defines the submesh to check readyness for
  76158. * @param useInstances Defines wheter wee are trying to render instances or not
  76159. * @returns true if ready otherwise false
  76160. */
  76161. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76162. private _beforeRenderingMesh;
  76163. private _afterRenderingMesh;
  76164. }
  76165. }
  76166. declare module "babylonjs/Rendering/index" {
  76167. export * from "babylonjs/Rendering/boundingBoxRenderer";
  76168. export * from "babylonjs/Rendering/depthRenderer";
  76169. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  76170. export * from "babylonjs/Rendering/edgesRenderer";
  76171. export * from "babylonjs/Rendering/geometryBufferRenderer";
  76172. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76173. export * from "babylonjs/Rendering/prePassRenderer";
  76174. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  76175. export * from "babylonjs/Rendering/outlineRenderer";
  76176. export * from "babylonjs/Rendering/renderingGroup";
  76177. export * from "babylonjs/Rendering/renderingManager";
  76178. export * from "babylonjs/Rendering/utilityLayerRenderer";
  76179. }
  76180. declare module "babylonjs/Sprites/ISprites" {
  76181. /**
  76182. * Defines the basic options interface of a Sprite Frame Source Size.
  76183. */
  76184. export interface ISpriteJSONSpriteSourceSize {
  76185. /**
  76186. * number of the original width of the Frame
  76187. */
  76188. w: number;
  76189. /**
  76190. * number of the original height of the Frame
  76191. */
  76192. h: number;
  76193. }
  76194. /**
  76195. * Defines the basic options interface of a Sprite Frame Data.
  76196. */
  76197. export interface ISpriteJSONSpriteFrameData {
  76198. /**
  76199. * number of the x offset of the Frame
  76200. */
  76201. x: number;
  76202. /**
  76203. * number of the y offset of the Frame
  76204. */
  76205. y: number;
  76206. /**
  76207. * number of the width of the Frame
  76208. */
  76209. w: number;
  76210. /**
  76211. * number of the height of the Frame
  76212. */
  76213. h: number;
  76214. }
  76215. /**
  76216. * Defines the basic options interface of a JSON Sprite.
  76217. */
  76218. export interface ISpriteJSONSprite {
  76219. /**
  76220. * string name of the Frame
  76221. */
  76222. filename: string;
  76223. /**
  76224. * ISpriteJSONSpriteFrame basic object of the frame data
  76225. */
  76226. frame: ISpriteJSONSpriteFrameData;
  76227. /**
  76228. * boolean to flag is the frame was rotated.
  76229. */
  76230. rotated: boolean;
  76231. /**
  76232. * boolean to flag is the frame was trimmed.
  76233. */
  76234. trimmed: boolean;
  76235. /**
  76236. * ISpriteJSONSpriteFrame basic object of the source data
  76237. */
  76238. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76239. /**
  76240. * ISpriteJSONSpriteFrame basic object of the source data
  76241. */
  76242. sourceSize: ISpriteJSONSpriteSourceSize;
  76243. }
  76244. /**
  76245. * Defines the basic options interface of a JSON atlas.
  76246. */
  76247. export interface ISpriteJSONAtlas {
  76248. /**
  76249. * Array of objects that contain the frame data.
  76250. */
  76251. frames: Array<ISpriteJSONSprite>;
  76252. /**
  76253. * object basic object containing the sprite meta data.
  76254. */
  76255. meta?: object;
  76256. }
  76257. }
  76258. declare module "babylonjs/Shaders/spriteMap.fragment" {
  76259. /** @hidden */
  76260. export var spriteMapPixelShader: {
  76261. name: string;
  76262. shader: string;
  76263. };
  76264. }
  76265. declare module "babylonjs/Shaders/spriteMap.vertex" {
  76266. /** @hidden */
  76267. export var spriteMapVertexShader: {
  76268. name: string;
  76269. shader: string;
  76270. };
  76271. }
  76272. declare module "babylonjs/Sprites/spriteMap" {
  76273. import { IDisposable, Scene } from "babylonjs/scene";
  76274. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  76275. import { Texture } from "babylonjs/Materials/Textures/texture";
  76276. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  76277. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  76278. import "babylonjs/Meshes/Builders/planeBuilder";
  76279. import "babylonjs/Shaders/spriteMap.fragment";
  76280. import "babylonjs/Shaders/spriteMap.vertex";
  76281. /**
  76282. * Defines the basic options interface of a SpriteMap
  76283. */
  76284. export interface ISpriteMapOptions {
  76285. /**
  76286. * Vector2 of the number of cells in the grid.
  76287. */
  76288. stageSize?: Vector2;
  76289. /**
  76290. * Vector2 of the size of the output plane in World Units.
  76291. */
  76292. outputSize?: Vector2;
  76293. /**
  76294. * Vector3 of the position of the output plane in World Units.
  76295. */
  76296. outputPosition?: Vector3;
  76297. /**
  76298. * Vector3 of the rotation of the output plane.
  76299. */
  76300. outputRotation?: Vector3;
  76301. /**
  76302. * number of layers that the system will reserve in resources.
  76303. */
  76304. layerCount?: number;
  76305. /**
  76306. * number of max animation frames a single cell will reserve in resources.
  76307. */
  76308. maxAnimationFrames?: number;
  76309. /**
  76310. * number cell index of the base tile when the system compiles.
  76311. */
  76312. baseTile?: number;
  76313. /**
  76314. * boolean flip the sprite after its been repositioned by the framing data.
  76315. */
  76316. flipU?: boolean;
  76317. /**
  76318. * Vector3 scalar of the global RGB values of the SpriteMap.
  76319. */
  76320. colorMultiply?: Vector3;
  76321. }
  76322. /**
  76323. * Defines the IDisposable interface in order to be cleanable from resources.
  76324. */
  76325. export interface ISpriteMap extends IDisposable {
  76326. /**
  76327. * String name of the SpriteMap.
  76328. */
  76329. name: string;
  76330. /**
  76331. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  76332. */
  76333. atlasJSON: ISpriteJSONAtlas;
  76334. /**
  76335. * Texture of the SpriteMap.
  76336. */
  76337. spriteSheet: Texture;
  76338. /**
  76339. * The parameters to initialize the SpriteMap with.
  76340. */
  76341. options: ISpriteMapOptions;
  76342. }
  76343. /**
  76344. * Class used to manage a grid restricted sprite deployment on an Output plane.
  76345. */
  76346. export class SpriteMap implements ISpriteMap {
  76347. /** The Name of the spriteMap */
  76348. name: string;
  76349. /** The JSON file with the frame and meta data */
  76350. atlasJSON: ISpriteJSONAtlas;
  76351. /** The systems Sprite Sheet Texture */
  76352. spriteSheet: Texture;
  76353. /** Arguments passed with the Constructor */
  76354. options: ISpriteMapOptions;
  76355. /** Public Sprite Storage array, parsed from atlasJSON */
  76356. sprites: Array<ISpriteJSONSprite>;
  76357. /** Returns the Number of Sprites in the System */
  76358. get spriteCount(): number;
  76359. /** Returns the Position of Output Plane*/
  76360. get position(): Vector3;
  76361. /** Returns the Position of Output Plane*/
  76362. set position(v: Vector3);
  76363. /** Returns the Rotation of Output Plane*/
  76364. get rotation(): Vector3;
  76365. /** Returns the Rotation of Output Plane*/
  76366. set rotation(v: Vector3);
  76367. /** Sets the AnimationMap*/
  76368. get animationMap(): RawTexture;
  76369. /** Sets the AnimationMap*/
  76370. set animationMap(v: RawTexture);
  76371. /** Scene that the SpriteMap was created in */
  76372. private _scene;
  76373. /** Texture Buffer of Float32 that holds tile frame data*/
  76374. private _frameMap;
  76375. /** Texture Buffers of Float32 that holds tileMap data*/
  76376. private _tileMaps;
  76377. /** Texture Buffer of Float32 that holds Animation Data*/
  76378. private _animationMap;
  76379. /** Custom ShaderMaterial Central to the System*/
  76380. private _material;
  76381. /** Custom ShaderMaterial Central to the System*/
  76382. private _output;
  76383. /** Systems Time Ticker*/
  76384. private _time;
  76385. /**
  76386. * Creates a new SpriteMap
  76387. * @param name defines the SpriteMaps Name
  76388. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  76389. * @param spriteSheet is the Texture that the Sprites are on.
  76390. * @param options a basic deployment configuration
  76391. * @param scene The Scene that the map is deployed on
  76392. */
  76393. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  76394. /**
  76395. * Returns tileID location
  76396. * @returns Vector2 the cell position ID
  76397. */
  76398. getTileID(): Vector2;
  76399. /**
  76400. * Gets the UV location of the mouse over the SpriteMap.
  76401. * @returns Vector2 the UV position of the mouse interaction
  76402. */
  76403. getMousePosition(): Vector2;
  76404. /**
  76405. * Creates the "frame" texture Buffer
  76406. * -------------------------------------
  76407. * Structure of frames
  76408. * "filename": "Falling-Water-2.png",
  76409. * "frame": {"x":69,"y":103,"w":24,"h":32},
  76410. * "rotated": true,
  76411. * "trimmed": true,
  76412. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  76413. * "sourceSize": {"w":32,"h":32}
  76414. * @returns RawTexture of the frameMap
  76415. */
  76416. private _createFrameBuffer;
  76417. /**
  76418. * Creates the tileMap texture Buffer
  76419. * @param buffer normally and array of numbers, or a false to generate from scratch
  76420. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  76421. * @returns RawTexture of the tileMap
  76422. */
  76423. private _createTileBuffer;
  76424. /**
  76425. * Modifies the data of the tileMaps
  76426. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  76427. * @param pos is the iVector2 Coordinates of the Tile
  76428. * @param tile The SpriteIndex of the new Tile
  76429. */
  76430. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  76431. /**
  76432. * Creates the animationMap texture Buffer
  76433. * @param buffer normally and array of numbers, or a false to generate from scratch
  76434. * @returns RawTexture of the animationMap
  76435. */
  76436. private _createTileAnimationBuffer;
  76437. /**
  76438. * Modifies the data of the animationMap
  76439. * @param cellID is the Index of the Sprite
  76440. * @param _frame is the target Animation frame
  76441. * @param toCell is the Target Index of the next frame of the animation
  76442. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  76443. * @param speed is a global scalar of the time variable on the map.
  76444. */
  76445. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  76446. /**
  76447. * Exports the .tilemaps file
  76448. */
  76449. saveTileMaps(): void;
  76450. /**
  76451. * Imports the .tilemaps file
  76452. * @param url of the .tilemaps file
  76453. */
  76454. loadTileMaps(url: string): void;
  76455. /**
  76456. * Release associated resources
  76457. */
  76458. dispose(): void;
  76459. }
  76460. }
  76461. declare module "babylonjs/Sprites/spritePackedManager" {
  76462. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  76463. import { Scene } from "babylonjs/scene";
  76464. /**
  76465. * Class used to manage multiple sprites of different sizes on the same spritesheet
  76466. * @see https://doc.babylonjs.com/babylon101/sprites
  76467. */
  76468. export class SpritePackedManager extends SpriteManager {
  76469. /** defines the packed manager's name */
  76470. name: string;
  76471. /**
  76472. * Creates a new sprite manager from a packed sprite sheet
  76473. * @param name defines the manager's name
  76474. * @param imgUrl defines the sprite sheet url
  76475. * @param capacity defines the maximum allowed number of sprites
  76476. * @param scene defines the hosting scene
  76477. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  76478. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76479. * @param samplingMode defines the smapling mode to use with spritesheet
  76480. * @param fromPacked set to true; do not alter
  76481. */
  76482. constructor(
  76483. /** defines the packed manager's name */
  76484. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  76485. }
  76486. }
  76487. declare module "babylonjs/Sprites/index" {
  76488. export * from "babylonjs/Sprites/sprite";
  76489. export * from "babylonjs/Sprites/ISprites";
  76490. export * from "babylonjs/Sprites/spriteManager";
  76491. export * from "babylonjs/Sprites/spriteMap";
  76492. export * from "babylonjs/Sprites/spritePackedManager";
  76493. export * from "babylonjs/Sprites/spriteSceneComponent";
  76494. }
  76495. declare module "babylonjs/States/index" {
  76496. export * from "babylonjs/States/alphaCullingState";
  76497. export * from "babylonjs/States/depthCullingState";
  76498. export * from "babylonjs/States/stencilState";
  76499. }
  76500. declare module "babylonjs/Misc/assetsManager" {
  76501. import { Scene } from "babylonjs/scene";
  76502. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76503. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  76504. import { Skeleton } from "babylonjs/Bones/skeleton";
  76505. import { Observable } from "babylonjs/Misc/observable";
  76506. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  76507. import { Texture } from "babylonjs/Materials/Textures/texture";
  76508. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  76509. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  76510. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  76511. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  76512. import { AssetContainer } from "babylonjs/assetContainer";
  76513. /**
  76514. * Defines the list of states available for a task inside a AssetsManager
  76515. */
  76516. export enum AssetTaskState {
  76517. /**
  76518. * Initialization
  76519. */
  76520. INIT = 0,
  76521. /**
  76522. * Running
  76523. */
  76524. RUNNING = 1,
  76525. /**
  76526. * Done
  76527. */
  76528. DONE = 2,
  76529. /**
  76530. * Error
  76531. */
  76532. ERROR = 3
  76533. }
  76534. /**
  76535. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  76536. */
  76537. export abstract class AbstractAssetTask {
  76538. /**
  76539. * Task name
  76540. */ name: string;
  76541. /**
  76542. * Callback called when the task is successful
  76543. */
  76544. onSuccess: (task: any) => void;
  76545. /**
  76546. * Callback called when the task is not successful
  76547. */
  76548. onError: (task: any, message?: string, exception?: any) => void;
  76549. /**
  76550. * Creates a new AssetsManager
  76551. * @param name defines the name of the task
  76552. */
  76553. constructor(
  76554. /**
  76555. * Task name
  76556. */ name: string);
  76557. private _isCompleted;
  76558. private _taskState;
  76559. private _errorObject;
  76560. /**
  76561. * Get if the task is completed
  76562. */
  76563. get isCompleted(): boolean;
  76564. /**
  76565. * Gets the current state of the task
  76566. */
  76567. get taskState(): AssetTaskState;
  76568. /**
  76569. * Gets the current error object (if task is in error)
  76570. */
  76571. get errorObject(): {
  76572. message?: string;
  76573. exception?: any;
  76574. };
  76575. /**
  76576. * Internal only
  76577. * @hidden
  76578. */
  76579. _setErrorObject(message?: string, exception?: any): void;
  76580. /**
  76581. * Execute the current task
  76582. * @param scene defines the scene where you want your assets to be loaded
  76583. * @param onSuccess is a callback called when the task is successfully executed
  76584. * @param onError is a callback called if an error occurs
  76585. */
  76586. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76587. /**
  76588. * Execute the current task
  76589. * @param scene defines the scene where you want your assets to be loaded
  76590. * @param onSuccess is a callback called when the task is successfully executed
  76591. * @param onError is a callback called if an error occurs
  76592. */
  76593. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76594. /**
  76595. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  76596. * This can be used with failed tasks that have the reason for failure fixed.
  76597. */
  76598. reset(): void;
  76599. private onErrorCallback;
  76600. private onDoneCallback;
  76601. }
  76602. /**
  76603. * Define the interface used by progress events raised during assets loading
  76604. */
  76605. export interface IAssetsProgressEvent {
  76606. /**
  76607. * Defines the number of remaining tasks to process
  76608. */
  76609. remainingCount: number;
  76610. /**
  76611. * Defines the total number of tasks
  76612. */
  76613. totalCount: number;
  76614. /**
  76615. * Defines the task that was just processed
  76616. */
  76617. task: AbstractAssetTask;
  76618. }
  76619. /**
  76620. * Class used to share progress information about assets loading
  76621. */
  76622. export class AssetsProgressEvent implements IAssetsProgressEvent {
  76623. /**
  76624. * Defines the number of remaining tasks to process
  76625. */
  76626. remainingCount: number;
  76627. /**
  76628. * Defines the total number of tasks
  76629. */
  76630. totalCount: number;
  76631. /**
  76632. * Defines the task that was just processed
  76633. */
  76634. task: AbstractAssetTask;
  76635. /**
  76636. * Creates a AssetsProgressEvent
  76637. * @param remainingCount defines the number of remaining tasks to process
  76638. * @param totalCount defines the total number of tasks
  76639. * @param task defines the task that was just processed
  76640. */
  76641. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  76642. }
  76643. /**
  76644. * Define a task used by AssetsManager to load assets into a container
  76645. */
  76646. export class ContainerAssetTask extends AbstractAssetTask {
  76647. /**
  76648. * Defines the name of the task
  76649. */
  76650. name: string;
  76651. /**
  76652. * Defines the list of mesh's names you want to load
  76653. */
  76654. meshesNames: any;
  76655. /**
  76656. * Defines the root url to use as a base to load your meshes and associated resources
  76657. */
  76658. rootUrl: string;
  76659. /**
  76660. * Defines the filename or File of the scene to load from
  76661. */
  76662. sceneFilename: string | File;
  76663. /**
  76664. * Get the loaded asset container
  76665. */
  76666. loadedContainer: AssetContainer;
  76667. /**
  76668. * Gets the list of loaded meshes
  76669. */
  76670. loadedMeshes: Array<AbstractMesh>;
  76671. /**
  76672. * Gets the list of loaded particle systems
  76673. */
  76674. loadedParticleSystems: Array<IParticleSystem>;
  76675. /**
  76676. * Gets the list of loaded skeletons
  76677. */
  76678. loadedSkeletons: Array<Skeleton>;
  76679. /**
  76680. * Gets the list of loaded animation groups
  76681. */
  76682. loadedAnimationGroups: Array<AnimationGroup>;
  76683. /**
  76684. * Callback called when the task is successful
  76685. */
  76686. onSuccess: (task: ContainerAssetTask) => void;
  76687. /**
  76688. * Callback called when the task is successful
  76689. */
  76690. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  76691. /**
  76692. * Creates a new ContainerAssetTask
  76693. * @param name defines the name of the task
  76694. * @param meshesNames defines the list of mesh's names you want to load
  76695. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76696. * @param sceneFilename defines the filename or File of the scene to load from
  76697. */
  76698. constructor(
  76699. /**
  76700. * Defines the name of the task
  76701. */
  76702. name: string,
  76703. /**
  76704. * Defines the list of mesh's names you want to load
  76705. */
  76706. meshesNames: any,
  76707. /**
  76708. * Defines the root url to use as a base to load your meshes and associated resources
  76709. */
  76710. rootUrl: string,
  76711. /**
  76712. * Defines the filename or File of the scene to load from
  76713. */
  76714. sceneFilename: string | File);
  76715. /**
  76716. * Execute the current task
  76717. * @param scene defines the scene where you want your assets to be loaded
  76718. * @param onSuccess is a callback called when the task is successfully executed
  76719. * @param onError is a callback called if an error occurs
  76720. */
  76721. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76722. }
  76723. /**
  76724. * Define a task used by AssetsManager to load meshes
  76725. */
  76726. export class MeshAssetTask extends AbstractAssetTask {
  76727. /**
  76728. * Defines the name of the task
  76729. */
  76730. name: string;
  76731. /**
  76732. * Defines the list of mesh's names you want to load
  76733. */
  76734. meshesNames: any;
  76735. /**
  76736. * Defines the root url to use as a base to load your meshes and associated resources
  76737. */
  76738. rootUrl: string;
  76739. /**
  76740. * Defines the filename or File of the scene to load from
  76741. */
  76742. sceneFilename: string | File;
  76743. /**
  76744. * Gets the list of loaded meshes
  76745. */
  76746. loadedMeshes: Array<AbstractMesh>;
  76747. /**
  76748. * Gets the list of loaded particle systems
  76749. */
  76750. loadedParticleSystems: Array<IParticleSystem>;
  76751. /**
  76752. * Gets the list of loaded skeletons
  76753. */
  76754. loadedSkeletons: Array<Skeleton>;
  76755. /**
  76756. * Gets the list of loaded animation groups
  76757. */
  76758. loadedAnimationGroups: Array<AnimationGroup>;
  76759. /**
  76760. * Callback called when the task is successful
  76761. */
  76762. onSuccess: (task: MeshAssetTask) => void;
  76763. /**
  76764. * Callback called when the task is successful
  76765. */
  76766. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  76767. /**
  76768. * Creates a new MeshAssetTask
  76769. * @param name defines the name of the task
  76770. * @param meshesNames defines the list of mesh's names you want to load
  76771. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76772. * @param sceneFilename defines the filename or File of the scene to load from
  76773. */
  76774. constructor(
  76775. /**
  76776. * Defines the name of the task
  76777. */
  76778. name: string,
  76779. /**
  76780. * Defines the list of mesh's names you want to load
  76781. */
  76782. meshesNames: any,
  76783. /**
  76784. * Defines the root url to use as a base to load your meshes and associated resources
  76785. */
  76786. rootUrl: string,
  76787. /**
  76788. * Defines the filename or File of the scene to load from
  76789. */
  76790. sceneFilename: string | File);
  76791. /**
  76792. * Execute the current task
  76793. * @param scene defines the scene where you want your assets to be loaded
  76794. * @param onSuccess is a callback called when the task is successfully executed
  76795. * @param onError is a callback called if an error occurs
  76796. */
  76797. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76798. }
  76799. /**
  76800. * Define a task used by AssetsManager to load text content
  76801. */
  76802. export class TextFileAssetTask extends AbstractAssetTask {
  76803. /**
  76804. * Defines the name of the task
  76805. */
  76806. name: string;
  76807. /**
  76808. * Defines the location of the file to load
  76809. */
  76810. url: string;
  76811. /**
  76812. * Gets the loaded text string
  76813. */
  76814. text: string;
  76815. /**
  76816. * Callback called when the task is successful
  76817. */
  76818. onSuccess: (task: TextFileAssetTask) => void;
  76819. /**
  76820. * Callback called when the task is successful
  76821. */
  76822. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  76823. /**
  76824. * Creates a new TextFileAssetTask object
  76825. * @param name defines the name of the task
  76826. * @param url defines the location of the file to load
  76827. */
  76828. constructor(
  76829. /**
  76830. * Defines the name of the task
  76831. */
  76832. name: string,
  76833. /**
  76834. * Defines the location of the file to load
  76835. */
  76836. url: string);
  76837. /**
  76838. * Execute the current task
  76839. * @param scene defines the scene where you want your assets to be loaded
  76840. * @param onSuccess is a callback called when the task is successfully executed
  76841. * @param onError is a callback called if an error occurs
  76842. */
  76843. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76844. }
  76845. /**
  76846. * Define a task used by AssetsManager to load binary data
  76847. */
  76848. export class BinaryFileAssetTask extends AbstractAssetTask {
  76849. /**
  76850. * Defines the name of the task
  76851. */
  76852. name: string;
  76853. /**
  76854. * Defines the location of the file to load
  76855. */
  76856. url: string;
  76857. /**
  76858. * Gets the lodaded data (as an array buffer)
  76859. */
  76860. data: ArrayBuffer;
  76861. /**
  76862. * Callback called when the task is successful
  76863. */
  76864. onSuccess: (task: BinaryFileAssetTask) => void;
  76865. /**
  76866. * Callback called when the task is successful
  76867. */
  76868. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  76869. /**
  76870. * Creates a new BinaryFileAssetTask object
  76871. * @param name defines the name of the new task
  76872. * @param url defines the location of the file to load
  76873. */
  76874. constructor(
  76875. /**
  76876. * Defines the name of the task
  76877. */
  76878. name: string,
  76879. /**
  76880. * Defines the location of the file to load
  76881. */
  76882. url: string);
  76883. /**
  76884. * Execute the current task
  76885. * @param scene defines the scene where you want your assets to be loaded
  76886. * @param onSuccess is a callback called when the task is successfully executed
  76887. * @param onError is a callback called if an error occurs
  76888. */
  76889. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76890. }
  76891. /**
  76892. * Define a task used by AssetsManager to load images
  76893. */
  76894. export class ImageAssetTask extends AbstractAssetTask {
  76895. /**
  76896. * Defines the name of the task
  76897. */
  76898. name: string;
  76899. /**
  76900. * Defines the location of the image to load
  76901. */
  76902. url: string;
  76903. /**
  76904. * Gets the loaded images
  76905. */
  76906. image: HTMLImageElement;
  76907. /**
  76908. * Callback called when the task is successful
  76909. */
  76910. onSuccess: (task: ImageAssetTask) => void;
  76911. /**
  76912. * Callback called when the task is successful
  76913. */
  76914. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  76915. /**
  76916. * Creates a new ImageAssetTask
  76917. * @param name defines the name of the task
  76918. * @param url defines the location of the image to load
  76919. */
  76920. constructor(
  76921. /**
  76922. * Defines the name of the task
  76923. */
  76924. name: string,
  76925. /**
  76926. * Defines the location of the image to load
  76927. */
  76928. url: string);
  76929. /**
  76930. * Execute the current task
  76931. * @param scene defines the scene where you want your assets to be loaded
  76932. * @param onSuccess is a callback called when the task is successfully executed
  76933. * @param onError is a callback called if an error occurs
  76934. */
  76935. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76936. }
  76937. /**
  76938. * Defines the interface used by texture loading tasks
  76939. */
  76940. export interface ITextureAssetTask<TEX extends BaseTexture> {
  76941. /**
  76942. * Gets the loaded texture
  76943. */
  76944. texture: TEX;
  76945. }
  76946. /**
  76947. * Define a task used by AssetsManager to load 2D textures
  76948. */
  76949. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  76950. /**
  76951. * Defines the name of the task
  76952. */
  76953. name: string;
  76954. /**
  76955. * Defines the location of the file to load
  76956. */
  76957. url: string;
  76958. /**
  76959. * Defines if mipmap should not be generated (default is false)
  76960. */
  76961. noMipmap?: boolean | undefined;
  76962. /**
  76963. * Defines if texture must be inverted on Y axis (default is true)
  76964. */
  76965. invertY: boolean;
  76966. /**
  76967. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76968. */
  76969. samplingMode: number;
  76970. /**
  76971. * Gets the loaded texture
  76972. */
  76973. texture: Texture;
  76974. /**
  76975. * Callback called when the task is successful
  76976. */
  76977. onSuccess: (task: TextureAssetTask) => void;
  76978. /**
  76979. * Callback called when the task is successful
  76980. */
  76981. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  76982. /**
  76983. * Creates a new TextureAssetTask object
  76984. * @param name defines the name of the task
  76985. * @param url defines the location of the file to load
  76986. * @param noMipmap defines if mipmap should not be generated (default is false)
  76987. * @param invertY defines if texture must be inverted on Y axis (default is true)
  76988. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  76989. */
  76990. constructor(
  76991. /**
  76992. * Defines the name of the task
  76993. */
  76994. name: string,
  76995. /**
  76996. * Defines the location of the file to load
  76997. */
  76998. url: string,
  76999. /**
  77000. * Defines if mipmap should not be generated (default is false)
  77001. */
  77002. noMipmap?: boolean | undefined,
  77003. /**
  77004. * Defines if texture must be inverted on Y axis (default is true)
  77005. */
  77006. invertY?: boolean,
  77007. /**
  77008. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77009. */
  77010. samplingMode?: number);
  77011. /**
  77012. * Execute the current task
  77013. * @param scene defines the scene where you want your assets to be loaded
  77014. * @param onSuccess is a callback called when the task is successfully executed
  77015. * @param onError is a callback called if an error occurs
  77016. */
  77017. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77018. }
  77019. /**
  77020. * Define a task used by AssetsManager to load cube textures
  77021. */
  77022. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77023. /**
  77024. * Defines the name of the task
  77025. */
  77026. name: string;
  77027. /**
  77028. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77029. */
  77030. url: string;
  77031. /**
  77032. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77033. */
  77034. extensions?: string[] | undefined;
  77035. /**
  77036. * Defines if mipmaps should not be generated (default is false)
  77037. */
  77038. noMipmap?: boolean | undefined;
  77039. /**
  77040. * Defines the explicit list of files (undefined by default)
  77041. */
  77042. files?: string[] | undefined;
  77043. /**
  77044. * Gets the loaded texture
  77045. */
  77046. texture: CubeTexture;
  77047. /**
  77048. * Callback called when the task is successful
  77049. */
  77050. onSuccess: (task: CubeTextureAssetTask) => void;
  77051. /**
  77052. * Callback called when the task is successful
  77053. */
  77054. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77055. /**
  77056. * Creates a new CubeTextureAssetTask
  77057. * @param name defines the name of the task
  77058. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77059. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77060. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77061. * @param files defines the explicit list of files (undefined by default)
  77062. */
  77063. constructor(
  77064. /**
  77065. * Defines the name of the task
  77066. */
  77067. name: string,
  77068. /**
  77069. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77070. */
  77071. url: string,
  77072. /**
  77073. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77074. */
  77075. extensions?: string[] | undefined,
  77076. /**
  77077. * Defines if mipmaps should not be generated (default is false)
  77078. */
  77079. noMipmap?: boolean | undefined,
  77080. /**
  77081. * Defines the explicit list of files (undefined by default)
  77082. */
  77083. files?: string[] | undefined);
  77084. /**
  77085. * Execute the current task
  77086. * @param scene defines the scene where you want your assets to be loaded
  77087. * @param onSuccess is a callback called when the task is successfully executed
  77088. * @param onError is a callback called if an error occurs
  77089. */
  77090. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77091. }
  77092. /**
  77093. * Define a task used by AssetsManager to load HDR cube textures
  77094. */
  77095. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77096. /**
  77097. * Defines the name of the task
  77098. */
  77099. name: string;
  77100. /**
  77101. * Defines the location of the file to load
  77102. */
  77103. url: string;
  77104. /**
  77105. * Defines the desired size (the more it increases the longer the generation will be)
  77106. */
  77107. size: number;
  77108. /**
  77109. * Defines if mipmaps should not be generated (default is false)
  77110. */
  77111. noMipmap: boolean;
  77112. /**
  77113. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77114. */
  77115. generateHarmonics: boolean;
  77116. /**
  77117. * 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)
  77118. */
  77119. gammaSpace: boolean;
  77120. /**
  77121. * Internal Use Only
  77122. */
  77123. reserved: boolean;
  77124. /**
  77125. * Gets the loaded texture
  77126. */
  77127. texture: HDRCubeTexture;
  77128. /**
  77129. * Callback called when the task is successful
  77130. */
  77131. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77132. /**
  77133. * Callback called when the task is successful
  77134. */
  77135. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77136. /**
  77137. * Creates a new HDRCubeTextureAssetTask object
  77138. * @param name defines the name of the task
  77139. * @param url defines the location of the file to load
  77140. * @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.
  77141. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77142. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77143. * @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)
  77144. * @param reserved Internal use only
  77145. */
  77146. constructor(
  77147. /**
  77148. * Defines the name of the task
  77149. */
  77150. name: string,
  77151. /**
  77152. * Defines the location of the file to load
  77153. */
  77154. url: string,
  77155. /**
  77156. * Defines the desired size (the more it increases the longer the generation will be)
  77157. */
  77158. size: number,
  77159. /**
  77160. * Defines if mipmaps should not be generated (default is false)
  77161. */
  77162. noMipmap?: boolean,
  77163. /**
  77164. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77165. */
  77166. generateHarmonics?: boolean,
  77167. /**
  77168. * 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)
  77169. */
  77170. gammaSpace?: boolean,
  77171. /**
  77172. * Internal Use Only
  77173. */
  77174. reserved?: boolean);
  77175. /**
  77176. * Execute the current task
  77177. * @param scene defines the scene where you want your assets to be loaded
  77178. * @param onSuccess is a callback called when the task is successfully executed
  77179. * @param onError is a callback called if an error occurs
  77180. */
  77181. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77182. }
  77183. /**
  77184. * Define a task used by AssetsManager to load Equirectangular cube textures
  77185. */
  77186. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77187. /**
  77188. * Defines the name of the task
  77189. */
  77190. name: string;
  77191. /**
  77192. * Defines the location of the file to load
  77193. */
  77194. url: string;
  77195. /**
  77196. * Defines the desired size (the more it increases the longer the generation will be)
  77197. */
  77198. size: number;
  77199. /**
  77200. * Defines if mipmaps should not be generated (default is false)
  77201. */
  77202. noMipmap: boolean;
  77203. /**
  77204. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77205. * but the standard material would require them in Gamma space) (default is true)
  77206. */
  77207. gammaSpace: boolean;
  77208. /**
  77209. * Gets the loaded texture
  77210. */
  77211. texture: EquiRectangularCubeTexture;
  77212. /**
  77213. * Callback called when the task is successful
  77214. */
  77215. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77216. /**
  77217. * Callback called when the task is successful
  77218. */
  77219. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77220. /**
  77221. * Creates a new EquiRectangularCubeTextureAssetTask object
  77222. * @param name defines the name of the task
  77223. * @param url defines the location of the file to load
  77224. * @param size defines the desired size (the more it increases the longer the generation will be)
  77225. * If the size is omitted this implies you are using a preprocessed cubemap.
  77226. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77227. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77228. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77229. * (default is true)
  77230. */
  77231. constructor(
  77232. /**
  77233. * Defines the name of the task
  77234. */
  77235. name: string,
  77236. /**
  77237. * Defines the location of the file to load
  77238. */
  77239. url: string,
  77240. /**
  77241. * Defines the desired size (the more it increases the longer the generation will be)
  77242. */
  77243. size: number,
  77244. /**
  77245. * Defines if mipmaps should not be generated (default is false)
  77246. */
  77247. noMipmap?: boolean,
  77248. /**
  77249. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77250. * but the standard material would require them in Gamma space) (default is true)
  77251. */
  77252. gammaSpace?: boolean);
  77253. /**
  77254. * Execute the current task
  77255. * @param scene defines the scene where you want your assets to be loaded
  77256. * @param onSuccess is a callback called when the task is successfully executed
  77257. * @param onError is a callback called if an error occurs
  77258. */
  77259. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77260. }
  77261. /**
  77262. * This class can be used to easily import assets into a scene
  77263. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77264. */
  77265. export class AssetsManager {
  77266. private _scene;
  77267. private _isLoading;
  77268. protected _tasks: AbstractAssetTask[];
  77269. protected _waitingTasksCount: number;
  77270. protected _totalTasksCount: number;
  77271. /**
  77272. * Callback called when all tasks are processed
  77273. */
  77274. onFinish: (tasks: AbstractAssetTask[]) => void;
  77275. /**
  77276. * Callback called when a task is successful
  77277. */
  77278. onTaskSuccess: (task: AbstractAssetTask) => void;
  77279. /**
  77280. * Callback called when a task had an error
  77281. */
  77282. onTaskError: (task: AbstractAssetTask) => void;
  77283. /**
  77284. * Callback called when a task is done (whatever the result is)
  77285. */
  77286. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77287. /**
  77288. * Observable called when all tasks are processed
  77289. */
  77290. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  77291. /**
  77292. * Observable called when a task had an error
  77293. */
  77294. onTaskErrorObservable: Observable<AbstractAssetTask>;
  77295. /**
  77296. * Observable called when all tasks were executed
  77297. */
  77298. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  77299. /**
  77300. * Observable called when a task is done (whatever the result is)
  77301. */
  77302. onProgressObservable: Observable<IAssetsProgressEvent>;
  77303. /**
  77304. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  77305. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  77306. */
  77307. useDefaultLoadingScreen: boolean;
  77308. /**
  77309. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  77310. * when all assets have been downloaded.
  77311. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  77312. */
  77313. autoHideLoadingUI: boolean;
  77314. /**
  77315. * Creates a new AssetsManager
  77316. * @param scene defines the scene to work on
  77317. */
  77318. constructor(scene: Scene);
  77319. /**
  77320. * Add a ContainerAssetTask to the list of active tasks
  77321. * @param taskName defines the name of the new task
  77322. * @param meshesNames defines the name of meshes to load
  77323. * @param rootUrl defines the root url to use to locate files
  77324. * @param sceneFilename defines the filename of the scene file
  77325. * @returns a new ContainerAssetTask object
  77326. */
  77327. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  77328. /**
  77329. * Add a MeshAssetTask to the list of active tasks
  77330. * @param taskName defines the name of the new task
  77331. * @param meshesNames defines the name of meshes to load
  77332. * @param rootUrl defines the root url to use to locate files
  77333. * @param sceneFilename defines the filename of the scene file
  77334. * @returns a new MeshAssetTask object
  77335. */
  77336. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  77337. /**
  77338. * Add a TextFileAssetTask to the list of active tasks
  77339. * @param taskName defines the name of the new task
  77340. * @param url defines the url of the file to load
  77341. * @returns a new TextFileAssetTask object
  77342. */
  77343. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  77344. /**
  77345. * Add a BinaryFileAssetTask to the list of active tasks
  77346. * @param taskName defines the name of the new task
  77347. * @param url defines the url of the file to load
  77348. * @returns a new BinaryFileAssetTask object
  77349. */
  77350. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  77351. /**
  77352. * Add a ImageAssetTask to the list of active tasks
  77353. * @param taskName defines the name of the new task
  77354. * @param url defines the url of the file to load
  77355. * @returns a new ImageAssetTask object
  77356. */
  77357. addImageTask(taskName: string, url: string): ImageAssetTask;
  77358. /**
  77359. * Add a TextureAssetTask to the list of active tasks
  77360. * @param taskName defines the name of the new task
  77361. * @param url defines the url of the file to load
  77362. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77363. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  77364. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  77365. * @returns a new TextureAssetTask object
  77366. */
  77367. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  77368. /**
  77369. * Add a CubeTextureAssetTask to the list of active tasks
  77370. * @param taskName defines the name of the new task
  77371. * @param url defines the url of the file to load
  77372. * @param extensions defines the extension to use to load the cube map (can be null)
  77373. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77374. * @param files defines the list of files to load (can be null)
  77375. * @returns a new CubeTextureAssetTask object
  77376. */
  77377. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  77378. /**
  77379. *
  77380. * Add a HDRCubeTextureAssetTask to the list of active tasks
  77381. * @param taskName defines the name of the new task
  77382. * @param url defines the url of the file to load
  77383. * @param size defines the size you want for the cubemap (can be null)
  77384. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77385. * @param generateHarmonics defines if you want to automatically generate (true by default)
  77386. * @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)
  77387. * @param reserved Internal use only
  77388. * @returns a new HDRCubeTextureAssetTask object
  77389. */
  77390. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  77391. /**
  77392. *
  77393. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  77394. * @param taskName defines the name of the new task
  77395. * @param url defines the url of the file to load
  77396. * @param size defines the size you want for the cubemap (can be null)
  77397. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77398. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  77399. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  77400. * @returns a new EquiRectangularCubeTextureAssetTask object
  77401. */
  77402. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  77403. /**
  77404. * Remove a task from the assets manager.
  77405. * @param task the task to remove
  77406. */
  77407. removeTask(task: AbstractAssetTask): void;
  77408. private _decreaseWaitingTasksCount;
  77409. private _runTask;
  77410. /**
  77411. * Reset the AssetsManager and remove all tasks
  77412. * @return the current instance of the AssetsManager
  77413. */
  77414. reset(): AssetsManager;
  77415. /**
  77416. * Start the loading process
  77417. * @return the current instance of the AssetsManager
  77418. */
  77419. load(): AssetsManager;
  77420. /**
  77421. * Start the loading process as an async operation
  77422. * @return a promise returning the list of failed tasks
  77423. */
  77424. loadAsync(): Promise<void>;
  77425. }
  77426. }
  77427. declare module "babylonjs/Misc/deferred" {
  77428. /**
  77429. * Wrapper class for promise with external resolve and reject.
  77430. */
  77431. export class Deferred<T> {
  77432. /**
  77433. * The promise associated with this deferred object.
  77434. */
  77435. readonly promise: Promise<T>;
  77436. private _resolve;
  77437. private _reject;
  77438. /**
  77439. * The resolve method of the promise associated with this deferred object.
  77440. */
  77441. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  77442. /**
  77443. * The reject method of the promise associated with this deferred object.
  77444. */
  77445. get reject(): (reason?: any) => void;
  77446. /**
  77447. * Constructor for this deferred object.
  77448. */
  77449. constructor();
  77450. }
  77451. }
  77452. declare module "babylonjs/Misc/meshExploder" {
  77453. import { Mesh } from "babylonjs/Meshes/mesh";
  77454. /**
  77455. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  77456. */
  77457. export class MeshExploder {
  77458. private _centerMesh;
  77459. private _meshes;
  77460. private _meshesOrigins;
  77461. private _toCenterVectors;
  77462. private _scaledDirection;
  77463. private _newPosition;
  77464. private _centerPosition;
  77465. /**
  77466. * Explodes meshes from a center mesh.
  77467. * @param meshes The meshes to explode.
  77468. * @param centerMesh The mesh to be center of explosion.
  77469. */
  77470. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  77471. private _setCenterMesh;
  77472. /**
  77473. * Get class name
  77474. * @returns "MeshExploder"
  77475. */
  77476. getClassName(): string;
  77477. /**
  77478. * "Exploded meshes"
  77479. * @returns Array of meshes with the centerMesh at index 0.
  77480. */
  77481. getMeshes(): Array<Mesh>;
  77482. /**
  77483. * Explodes meshes giving a specific direction
  77484. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  77485. */
  77486. explode(direction?: number): void;
  77487. }
  77488. }
  77489. declare module "babylonjs/Misc/filesInput" {
  77490. import { Engine } from "babylonjs/Engines/engine";
  77491. import { Scene } from "babylonjs/scene";
  77492. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  77493. import { Nullable } from "babylonjs/types";
  77494. /**
  77495. * Class used to help managing file picking and drag'n'drop
  77496. */
  77497. export class FilesInput {
  77498. /**
  77499. * List of files ready to be loaded
  77500. */
  77501. static get FilesToLoad(): {
  77502. [key: string]: File;
  77503. };
  77504. /**
  77505. * Callback called when a file is processed
  77506. */
  77507. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  77508. private _engine;
  77509. private _currentScene;
  77510. private _sceneLoadedCallback;
  77511. private _progressCallback;
  77512. private _additionalRenderLoopLogicCallback;
  77513. private _textureLoadingCallback;
  77514. private _startingProcessingFilesCallback;
  77515. private _onReloadCallback;
  77516. private _errorCallback;
  77517. private _elementToMonitor;
  77518. private _sceneFileToLoad;
  77519. private _filesToLoad;
  77520. /**
  77521. * Creates a new FilesInput
  77522. * @param engine defines the rendering engine
  77523. * @param scene defines the hosting scene
  77524. * @param sceneLoadedCallback callback called when scene is loaded
  77525. * @param progressCallback callback called to track progress
  77526. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  77527. * @param textureLoadingCallback callback called when a texture is loading
  77528. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  77529. * @param onReloadCallback callback called when a reload is requested
  77530. * @param errorCallback callback call if an error occurs
  77531. */
  77532. 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>);
  77533. private _dragEnterHandler;
  77534. private _dragOverHandler;
  77535. private _dropHandler;
  77536. /**
  77537. * Calls this function to listen to drag'n'drop events on a specific DOM element
  77538. * @param elementToMonitor defines the DOM element to track
  77539. */
  77540. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  77541. /** Gets the current list of files to load */
  77542. get filesToLoad(): File[];
  77543. /**
  77544. * Release all associated resources
  77545. */
  77546. dispose(): void;
  77547. private renderFunction;
  77548. private drag;
  77549. private drop;
  77550. private _traverseFolder;
  77551. private _processFiles;
  77552. /**
  77553. * Load files from a drop event
  77554. * @param event defines the drop event to use as source
  77555. */
  77556. loadFiles(event: any): void;
  77557. private _processReload;
  77558. /**
  77559. * Reload the current scene from the loaded files
  77560. */
  77561. reload(): void;
  77562. }
  77563. }
  77564. declare module "babylonjs/Misc/HighDynamicRange/index" {
  77565. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  77566. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  77567. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  77568. }
  77569. declare module "babylonjs/Misc/sceneOptimizer" {
  77570. import { Scene, IDisposable } from "babylonjs/scene";
  77571. import { Observable } from "babylonjs/Misc/observable";
  77572. /**
  77573. * Defines the root class used to create scene optimization to use with SceneOptimizer
  77574. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77575. */
  77576. export class SceneOptimization {
  77577. /**
  77578. * Defines the priority of this optimization (0 by default which means first in the list)
  77579. */
  77580. priority: number;
  77581. /**
  77582. * Gets a string describing the action executed by the current optimization
  77583. * @returns description string
  77584. */
  77585. getDescription(): string;
  77586. /**
  77587. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77588. * @param scene defines the current scene where to apply this optimization
  77589. * @param optimizer defines the current optimizer
  77590. * @returns true if everything that can be done was applied
  77591. */
  77592. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77593. /**
  77594. * Creates the SceneOptimization object
  77595. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77596. * @param desc defines the description associated with the optimization
  77597. */
  77598. constructor(
  77599. /**
  77600. * Defines the priority of this optimization (0 by default which means first in the list)
  77601. */
  77602. priority?: number);
  77603. }
  77604. /**
  77605. * Defines an optimization used to reduce the size of render target textures
  77606. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77607. */
  77608. export class TextureOptimization extends SceneOptimization {
  77609. /**
  77610. * Defines the priority of this optimization (0 by default which means first in the list)
  77611. */
  77612. priority: number;
  77613. /**
  77614. * 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
  77615. */
  77616. maximumSize: number;
  77617. /**
  77618. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77619. */
  77620. step: number;
  77621. /**
  77622. * Gets a string describing the action executed by the current optimization
  77623. * @returns description string
  77624. */
  77625. getDescription(): string;
  77626. /**
  77627. * Creates the TextureOptimization object
  77628. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77629. * @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
  77630. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77631. */
  77632. constructor(
  77633. /**
  77634. * Defines the priority of this optimization (0 by default which means first in the list)
  77635. */
  77636. priority?: number,
  77637. /**
  77638. * 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
  77639. */
  77640. maximumSize?: number,
  77641. /**
  77642. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77643. */
  77644. step?: number);
  77645. /**
  77646. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77647. * @param scene defines the current scene where to apply this optimization
  77648. * @param optimizer defines the current optimizer
  77649. * @returns true if everything that can be done was applied
  77650. */
  77651. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77652. }
  77653. /**
  77654. * Defines an optimization used to increase or decrease the rendering resolution
  77655. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77656. */
  77657. export class HardwareScalingOptimization extends SceneOptimization {
  77658. /**
  77659. * Defines the priority of this optimization (0 by default which means first in the list)
  77660. */
  77661. priority: number;
  77662. /**
  77663. * Defines the maximum scale to use (2 by default)
  77664. */
  77665. maximumScale: number;
  77666. /**
  77667. * Defines the step to use between two passes (0.5 by default)
  77668. */
  77669. step: number;
  77670. private _currentScale;
  77671. private _directionOffset;
  77672. /**
  77673. * Gets a string describing the action executed by the current optimization
  77674. * @return description string
  77675. */
  77676. getDescription(): string;
  77677. /**
  77678. * Creates the HardwareScalingOptimization object
  77679. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77680. * @param maximumScale defines the maximum scale to use (2 by default)
  77681. * @param step defines the step to use between two passes (0.5 by default)
  77682. */
  77683. constructor(
  77684. /**
  77685. * Defines the priority of this optimization (0 by default which means first in the list)
  77686. */
  77687. priority?: number,
  77688. /**
  77689. * Defines the maximum scale to use (2 by default)
  77690. */
  77691. maximumScale?: number,
  77692. /**
  77693. * Defines the step to use between two passes (0.5 by default)
  77694. */
  77695. step?: number);
  77696. /**
  77697. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77698. * @param scene defines the current scene where to apply this optimization
  77699. * @param optimizer defines the current optimizer
  77700. * @returns true if everything that can be done was applied
  77701. */
  77702. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77703. }
  77704. /**
  77705. * Defines an optimization used to remove shadows
  77706. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77707. */
  77708. export class ShadowsOptimization extends SceneOptimization {
  77709. /**
  77710. * Gets a string describing the action executed by the current optimization
  77711. * @return description string
  77712. */
  77713. getDescription(): string;
  77714. /**
  77715. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77716. * @param scene defines the current scene where to apply this optimization
  77717. * @param optimizer defines the current optimizer
  77718. * @returns true if everything that can be done was applied
  77719. */
  77720. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77721. }
  77722. /**
  77723. * Defines an optimization used to turn post-processes off
  77724. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77725. */
  77726. export class PostProcessesOptimization extends SceneOptimization {
  77727. /**
  77728. * Gets a string describing the action executed by the current optimization
  77729. * @return description string
  77730. */
  77731. getDescription(): string;
  77732. /**
  77733. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77734. * @param scene defines the current scene where to apply this optimization
  77735. * @param optimizer defines the current optimizer
  77736. * @returns true if everything that can be done was applied
  77737. */
  77738. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77739. }
  77740. /**
  77741. * Defines an optimization used to turn lens flares off
  77742. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77743. */
  77744. export class LensFlaresOptimization extends SceneOptimization {
  77745. /**
  77746. * Gets a string describing the action executed by the current optimization
  77747. * @return description string
  77748. */
  77749. getDescription(): string;
  77750. /**
  77751. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77752. * @param scene defines the current scene where to apply this optimization
  77753. * @param optimizer defines the current optimizer
  77754. * @returns true if everything that can be done was applied
  77755. */
  77756. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77757. }
  77758. /**
  77759. * Defines an optimization based on user defined callback.
  77760. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77761. */
  77762. export class CustomOptimization extends SceneOptimization {
  77763. /**
  77764. * Callback called to apply the custom optimization.
  77765. */
  77766. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  77767. /**
  77768. * Callback called to get custom description
  77769. */
  77770. onGetDescription: () => string;
  77771. /**
  77772. * Gets a string describing the action executed by the current optimization
  77773. * @returns description string
  77774. */
  77775. getDescription(): string;
  77776. /**
  77777. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77778. * @param scene defines the current scene where to apply this optimization
  77779. * @param optimizer defines the current optimizer
  77780. * @returns true if everything that can be done was applied
  77781. */
  77782. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77783. }
  77784. /**
  77785. * Defines an optimization used to turn particles off
  77786. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77787. */
  77788. export class ParticlesOptimization extends SceneOptimization {
  77789. /**
  77790. * Gets a string describing the action executed by the current optimization
  77791. * @return description string
  77792. */
  77793. getDescription(): string;
  77794. /**
  77795. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77796. * @param scene defines the current scene where to apply this optimization
  77797. * @param optimizer defines the current optimizer
  77798. * @returns true if everything that can be done was applied
  77799. */
  77800. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77801. }
  77802. /**
  77803. * Defines an optimization used to turn render targets off
  77804. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77805. */
  77806. export class RenderTargetsOptimization extends SceneOptimization {
  77807. /**
  77808. * Gets a string describing the action executed by the current optimization
  77809. * @return description string
  77810. */
  77811. getDescription(): string;
  77812. /**
  77813. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77814. * @param scene defines the current scene where to apply this optimization
  77815. * @param optimizer defines the current optimizer
  77816. * @returns true if everything that can be done was applied
  77817. */
  77818. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77819. }
  77820. /**
  77821. * Defines an optimization used to merge meshes with compatible materials
  77822. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77823. */
  77824. export class MergeMeshesOptimization extends SceneOptimization {
  77825. private static _UpdateSelectionTree;
  77826. /**
  77827. * Gets or sets a boolean which defines if optimization octree has to be updated
  77828. */
  77829. static get UpdateSelectionTree(): boolean;
  77830. /**
  77831. * Gets or sets a boolean which defines if optimization octree has to be updated
  77832. */
  77833. static set UpdateSelectionTree(value: boolean);
  77834. /**
  77835. * Gets a string describing the action executed by the current optimization
  77836. * @return description string
  77837. */
  77838. getDescription(): string;
  77839. private _canBeMerged;
  77840. /**
  77841. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77842. * @param scene defines the current scene where to apply this optimization
  77843. * @param optimizer defines the current optimizer
  77844. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  77845. * @returns true if everything that can be done was applied
  77846. */
  77847. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  77848. }
  77849. /**
  77850. * Defines a list of options used by SceneOptimizer
  77851. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77852. */
  77853. export class SceneOptimizerOptions {
  77854. /**
  77855. * Defines the target frame rate to reach (60 by default)
  77856. */
  77857. targetFrameRate: number;
  77858. /**
  77859. * Defines the interval between two checkes (2000ms by default)
  77860. */
  77861. trackerDuration: number;
  77862. /**
  77863. * Gets the list of optimizations to apply
  77864. */
  77865. optimizations: SceneOptimization[];
  77866. /**
  77867. * Creates a new list of options used by SceneOptimizer
  77868. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  77869. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  77870. */
  77871. constructor(
  77872. /**
  77873. * Defines the target frame rate to reach (60 by default)
  77874. */
  77875. targetFrameRate?: number,
  77876. /**
  77877. * Defines the interval between two checkes (2000ms by default)
  77878. */
  77879. trackerDuration?: number);
  77880. /**
  77881. * Add a new optimization
  77882. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  77883. * @returns the current SceneOptimizerOptions
  77884. */
  77885. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  77886. /**
  77887. * Add a new custom optimization
  77888. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  77889. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  77890. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77891. * @returns the current SceneOptimizerOptions
  77892. */
  77893. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  77894. /**
  77895. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  77896. * @param targetFrameRate defines the target frame rate (60 by default)
  77897. * @returns a SceneOptimizerOptions object
  77898. */
  77899. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77900. /**
  77901. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  77902. * @param targetFrameRate defines the target frame rate (60 by default)
  77903. * @returns a SceneOptimizerOptions object
  77904. */
  77905. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77906. /**
  77907. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  77908. * @param targetFrameRate defines the target frame rate (60 by default)
  77909. * @returns a SceneOptimizerOptions object
  77910. */
  77911. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  77912. }
  77913. /**
  77914. * Class used to run optimizations in order to reach a target frame rate
  77915. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77916. */
  77917. export class SceneOptimizer implements IDisposable {
  77918. private _isRunning;
  77919. private _options;
  77920. private _scene;
  77921. private _currentPriorityLevel;
  77922. private _targetFrameRate;
  77923. private _trackerDuration;
  77924. private _currentFrameRate;
  77925. private _sceneDisposeObserver;
  77926. private _improvementMode;
  77927. /**
  77928. * Defines an observable called when the optimizer reaches the target frame rate
  77929. */
  77930. onSuccessObservable: Observable<SceneOptimizer>;
  77931. /**
  77932. * Defines an observable called when the optimizer enables an optimization
  77933. */
  77934. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  77935. /**
  77936. * Defines an observable called when the optimizer is not able to reach the target frame rate
  77937. */
  77938. onFailureObservable: Observable<SceneOptimizer>;
  77939. /**
  77940. * Gets a boolean indicating if the optimizer is in improvement mode
  77941. */
  77942. get isInImprovementMode(): boolean;
  77943. /**
  77944. * Gets the current priority level (0 at start)
  77945. */
  77946. get currentPriorityLevel(): number;
  77947. /**
  77948. * Gets the current frame rate checked by the SceneOptimizer
  77949. */
  77950. get currentFrameRate(): number;
  77951. /**
  77952. * Gets or sets the current target frame rate (60 by default)
  77953. */
  77954. get targetFrameRate(): number;
  77955. /**
  77956. * Gets or sets the current target frame rate (60 by default)
  77957. */
  77958. set targetFrameRate(value: number);
  77959. /**
  77960. * Gets or sets the current interval between two checks (every 2000ms by default)
  77961. */
  77962. get trackerDuration(): number;
  77963. /**
  77964. * Gets or sets the current interval between two checks (every 2000ms by default)
  77965. */
  77966. set trackerDuration(value: number);
  77967. /**
  77968. * Gets the list of active optimizations
  77969. */
  77970. get optimizations(): SceneOptimization[];
  77971. /**
  77972. * Creates a new SceneOptimizer
  77973. * @param scene defines the scene to work on
  77974. * @param options defines the options to use with the SceneOptimizer
  77975. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  77976. * @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)
  77977. */
  77978. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  77979. /**
  77980. * Stops the current optimizer
  77981. */
  77982. stop(): void;
  77983. /**
  77984. * Reset the optimizer to initial step (current priority level = 0)
  77985. */
  77986. reset(): void;
  77987. /**
  77988. * Start the optimizer. By default it will try to reach a specific framerate
  77989. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  77990. */
  77991. start(): void;
  77992. private _checkCurrentState;
  77993. /**
  77994. * Release all resources
  77995. */
  77996. dispose(): void;
  77997. /**
  77998. * Helper function to create a SceneOptimizer with one single line of code
  77999. * @param scene defines the scene to work on
  78000. * @param options defines the options to use with the SceneOptimizer
  78001. * @param onSuccess defines a callback to call on success
  78002. * @param onFailure defines a callback to call on failure
  78003. * @returns the new SceneOptimizer object
  78004. */
  78005. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78006. }
  78007. }
  78008. declare module "babylonjs/Misc/sceneSerializer" {
  78009. import { Scene } from "babylonjs/scene";
  78010. /**
  78011. * Class used to serialize a scene into a string
  78012. */
  78013. export class SceneSerializer {
  78014. /**
  78015. * Clear cache used by a previous serialization
  78016. */
  78017. static ClearCache(): void;
  78018. /**
  78019. * Serialize a scene into a JSON compatible object
  78020. * @param scene defines the scene to serialize
  78021. * @returns a JSON compatible object
  78022. */
  78023. static Serialize(scene: Scene): any;
  78024. /**
  78025. * Serialize a mesh into a JSON compatible object
  78026. * @param toSerialize defines the mesh to serialize
  78027. * @param withParents defines if parents must be serialized as well
  78028. * @param withChildren defines if children must be serialized as well
  78029. * @returns a JSON compatible object
  78030. */
  78031. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78032. }
  78033. }
  78034. declare module "babylonjs/Misc/textureTools" {
  78035. import { Texture } from "babylonjs/Materials/Textures/texture";
  78036. /**
  78037. * Class used to host texture specific utilities
  78038. */
  78039. export class TextureTools {
  78040. /**
  78041. * Uses the GPU to create a copy texture rescaled at a given size
  78042. * @param texture Texture to copy from
  78043. * @param width defines the desired width
  78044. * @param height defines the desired height
  78045. * @param useBilinearMode defines if bilinear mode has to be used
  78046. * @return the generated texture
  78047. */
  78048. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  78049. }
  78050. }
  78051. declare module "babylonjs/Misc/videoRecorder" {
  78052. import { Nullable } from "babylonjs/types";
  78053. import { Engine } from "babylonjs/Engines/engine";
  78054. /**
  78055. * This represents the different options available for the video capture.
  78056. */
  78057. export interface VideoRecorderOptions {
  78058. /** Defines the mime type of the video. */
  78059. mimeType: string;
  78060. /** Defines the FPS the video should be recorded at. */
  78061. fps: number;
  78062. /** Defines the chunk size for the recording data. */
  78063. recordChunckSize: number;
  78064. /** The audio tracks to attach to the recording. */
  78065. audioTracks?: MediaStreamTrack[];
  78066. }
  78067. /**
  78068. * This can help with recording videos from BabylonJS.
  78069. * This is based on the available WebRTC functionalities of the browser.
  78070. *
  78071. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78072. */
  78073. export class VideoRecorder {
  78074. private static readonly _defaultOptions;
  78075. /**
  78076. * Returns whether or not the VideoRecorder is available in your browser.
  78077. * @param engine Defines the Babylon Engine.
  78078. * @returns true if supported otherwise false.
  78079. */
  78080. static IsSupported(engine: Engine): boolean;
  78081. private readonly _options;
  78082. private _canvas;
  78083. private _mediaRecorder;
  78084. private _recordedChunks;
  78085. private _fileName;
  78086. private _resolve;
  78087. private _reject;
  78088. /**
  78089. * True when a recording is already in progress.
  78090. */
  78091. get isRecording(): boolean;
  78092. /**
  78093. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78094. * @param engine Defines the BabylonJS Engine you wish to record.
  78095. * @param options Defines options that can be used to customize the capture.
  78096. */
  78097. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78098. /**
  78099. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78100. */
  78101. stopRecording(): void;
  78102. /**
  78103. * Starts recording the canvas for a max duration specified in parameters.
  78104. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78105. * If null no automatic download will start and you can rely on the promise to get the data back.
  78106. * @param maxDuration Defines the maximum recording time in seconds.
  78107. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78108. * @return A promise callback at the end of the recording with the video data in Blob.
  78109. */
  78110. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78111. /**
  78112. * Releases internal resources used during the recording.
  78113. */
  78114. dispose(): void;
  78115. private _handleDataAvailable;
  78116. private _handleError;
  78117. private _handleStop;
  78118. }
  78119. }
  78120. declare module "babylonjs/Misc/screenshotTools" {
  78121. import { Camera } from "babylonjs/Cameras/camera";
  78122. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  78123. import { Engine } from "babylonjs/Engines/engine";
  78124. /**
  78125. * Class containing a set of static utilities functions for screenshots
  78126. */
  78127. export class ScreenshotTools {
  78128. /**
  78129. * Captures a screenshot of the current rendering
  78130. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78131. * @param engine defines the rendering engine
  78132. * @param camera defines the source camera
  78133. * @param size This parameter can be set to a single number or to an object with the
  78134. * following (optional) properties: precision, width, height. If a single number is passed,
  78135. * it will be used for both width and height. If an object is passed, the screenshot size
  78136. * will be derived from the parameters. The precision property is a multiplier allowing
  78137. * rendering at a higher or lower resolution
  78138. * @param successCallback defines the callback receives a single parameter which contains the
  78139. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78140. * src parameter of an <img> to display it
  78141. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78142. * Check your browser for supported MIME types
  78143. */
  78144. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  78145. /**
  78146. * Captures a screenshot of the current rendering
  78147. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78148. * @param engine defines the rendering engine
  78149. * @param camera defines the source camera
  78150. * @param size This parameter can be set to a single number or to an object with the
  78151. * following (optional) properties: precision, width, height. If a single number is passed,
  78152. * it will be used for both width and height. If an object is passed, the screenshot size
  78153. * will be derived from the parameters. The precision property is a multiplier allowing
  78154. * rendering at a higher or lower resolution
  78155. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78156. * Check your browser for supported MIME types
  78157. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78158. * to the src parameter of an <img> to display it
  78159. */
  78160. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78161. /**
  78162. * Generates an image screenshot from the specified camera.
  78163. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78164. * @param engine The engine to use for rendering
  78165. * @param camera The camera to use for rendering
  78166. * @param size This parameter can be set to a single number or to an object with the
  78167. * following (optional) properties: precision, width, height. If a single number is passed,
  78168. * it will be used for both width and height. If an object is passed, the screenshot size
  78169. * will be derived from the parameters. The precision property is a multiplier allowing
  78170. * rendering at a higher or lower resolution
  78171. * @param successCallback The callback receives a single parameter which contains the
  78172. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78173. * src parameter of an <img> to display it
  78174. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78175. * Check your browser for supported MIME types
  78176. * @param samples Texture samples (default: 1)
  78177. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78178. * @param fileName A name for for the downloaded file.
  78179. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78180. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78181. */
  78182. 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;
  78183. /**
  78184. * Generates an image screenshot from the specified camera.
  78185. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78186. * @param engine The engine to use for rendering
  78187. * @param camera The camera to use for rendering
  78188. * @param size This parameter can be set to a single number or to an object with the
  78189. * following (optional) properties: precision, width, height. If a single number is passed,
  78190. * it will be used for both width and height. If an object is passed, the screenshot size
  78191. * will be derived from the parameters. The precision property is a multiplier allowing
  78192. * rendering at a higher or lower resolution
  78193. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78194. * Check your browser for supported MIME types
  78195. * @param samples Texture samples (default: 1)
  78196. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78197. * @param fileName A name for for the downloaded file.
  78198. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78199. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78200. * to the src parameter of an <img> to display it
  78201. */
  78202. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78203. /**
  78204. * Gets height and width for screenshot size
  78205. * @private
  78206. */
  78207. private static _getScreenshotSize;
  78208. }
  78209. }
  78210. declare module "babylonjs/Misc/dataReader" {
  78211. /**
  78212. * Interface for a data buffer
  78213. */
  78214. export interface IDataBuffer {
  78215. /**
  78216. * Reads bytes from the data buffer.
  78217. * @param byteOffset The byte offset to read
  78218. * @param byteLength The byte length to read
  78219. * @returns A promise that resolves when the bytes are read
  78220. */
  78221. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78222. /**
  78223. * The byte length of the buffer.
  78224. */
  78225. readonly byteLength: number;
  78226. }
  78227. /**
  78228. * Utility class for reading from a data buffer
  78229. */
  78230. export class DataReader {
  78231. /**
  78232. * The data buffer associated with this data reader.
  78233. */
  78234. readonly buffer: IDataBuffer;
  78235. /**
  78236. * The current byte offset from the beginning of the data buffer.
  78237. */
  78238. byteOffset: number;
  78239. private _dataView;
  78240. private _dataByteOffset;
  78241. /**
  78242. * Constructor
  78243. * @param buffer The buffer to read
  78244. */
  78245. constructor(buffer: IDataBuffer);
  78246. /**
  78247. * Loads the given byte length.
  78248. * @param byteLength The byte length to load
  78249. * @returns A promise that resolves when the load is complete
  78250. */
  78251. loadAsync(byteLength: number): Promise<void>;
  78252. /**
  78253. * Read a unsigned 32-bit integer from the currently loaded data range.
  78254. * @returns The 32-bit integer read
  78255. */
  78256. readUint32(): number;
  78257. /**
  78258. * Read a byte array from the currently loaded data range.
  78259. * @param byteLength The byte length to read
  78260. * @returns The byte array read
  78261. */
  78262. readUint8Array(byteLength: number): Uint8Array;
  78263. /**
  78264. * Read a string from the currently loaded data range.
  78265. * @param byteLength The byte length to read
  78266. * @returns The string read
  78267. */
  78268. readString(byteLength: number): string;
  78269. /**
  78270. * Skips the given byte length the currently loaded data range.
  78271. * @param byteLength The byte length to skip
  78272. */
  78273. skipBytes(byteLength: number): void;
  78274. }
  78275. }
  78276. declare module "babylonjs/Misc/dataStorage" {
  78277. /**
  78278. * Class for storing data to local storage if available or in-memory storage otherwise
  78279. */
  78280. export class DataStorage {
  78281. private static _Storage;
  78282. private static _GetStorage;
  78283. /**
  78284. * Reads a string from the data storage
  78285. * @param key The key to read
  78286. * @param defaultValue The value if the key doesn't exist
  78287. * @returns The string value
  78288. */
  78289. static ReadString(key: string, defaultValue: string): string;
  78290. /**
  78291. * Writes a string to the data storage
  78292. * @param key The key to write
  78293. * @param value The value to write
  78294. */
  78295. static WriteString(key: string, value: string): void;
  78296. /**
  78297. * Reads a boolean from the data storage
  78298. * @param key The key to read
  78299. * @param defaultValue The value if the key doesn't exist
  78300. * @returns The boolean value
  78301. */
  78302. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  78303. /**
  78304. * Writes a boolean to the data storage
  78305. * @param key The key to write
  78306. * @param value The value to write
  78307. */
  78308. static WriteBoolean(key: string, value: boolean): void;
  78309. /**
  78310. * Reads a number from the data storage
  78311. * @param key The key to read
  78312. * @param defaultValue The value if the key doesn't exist
  78313. * @returns The number value
  78314. */
  78315. static ReadNumber(key: string, defaultValue: number): number;
  78316. /**
  78317. * Writes a number to the data storage
  78318. * @param key The key to write
  78319. * @param value The value to write
  78320. */
  78321. static WriteNumber(key: string, value: number): void;
  78322. }
  78323. }
  78324. declare module "babylonjs/Misc/sceneRecorder" {
  78325. import { Scene } from "babylonjs/scene";
  78326. /**
  78327. * Class used to record delta files between 2 scene states
  78328. */
  78329. export class SceneRecorder {
  78330. private _trackedScene;
  78331. private _savedJSON;
  78332. /**
  78333. * Track a given scene. This means the current scene state will be considered the original state
  78334. * @param scene defines the scene to track
  78335. */
  78336. track(scene: Scene): void;
  78337. /**
  78338. * Get the delta between current state and original state
  78339. * @returns a string containing the delta
  78340. */
  78341. getDelta(): any;
  78342. private _compareArray;
  78343. private _compareObjects;
  78344. private _compareCollections;
  78345. private static GetShadowGeneratorById;
  78346. /**
  78347. * Apply a given delta to a given scene
  78348. * @param deltaJSON defines the JSON containing the delta
  78349. * @param scene defines the scene to apply the delta to
  78350. */
  78351. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  78352. private static _ApplyPropertiesToEntity;
  78353. private static _ApplyDeltaForEntity;
  78354. }
  78355. }
  78356. declare module "babylonjs/Misc/index" {
  78357. export * from "babylonjs/Misc/andOrNotEvaluator";
  78358. export * from "babylonjs/Misc/assetsManager";
  78359. export * from "babylonjs/Misc/basis";
  78360. export * from "babylonjs/Misc/dds";
  78361. export * from "babylonjs/Misc/decorators";
  78362. export * from "babylonjs/Misc/deferred";
  78363. export * from "babylonjs/Misc/environmentTextureTools";
  78364. export * from "babylonjs/Misc/meshExploder";
  78365. export * from "babylonjs/Misc/filesInput";
  78366. export * from "babylonjs/Misc/HighDynamicRange/index";
  78367. export * from "babylonjs/Misc/khronosTextureContainer";
  78368. export * from "babylonjs/Misc/observable";
  78369. export * from "babylonjs/Misc/performanceMonitor";
  78370. export * from "babylonjs/Misc/promise";
  78371. export * from "babylonjs/Misc/sceneOptimizer";
  78372. export * from "babylonjs/Misc/sceneSerializer";
  78373. export * from "babylonjs/Misc/smartArray";
  78374. export * from "babylonjs/Misc/stringDictionary";
  78375. export * from "babylonjs/Misc/tags";
  78376. export * from "babylonjs/Misc/textureTools";
  78377. export * from "babylonjs/Misc/tga";
  78378. export * from "babylonjs/Misc/tools";
  78379. export * from "babylonjs/Misc/videoRecorder";
  78380. export * from "babylonjs/Misc/virtualJoystick";
  78381. export * from "babylonjs/Misc/workerPool";
  78382. export * from "babylonjs/Misc/logger";
  78383. export * from "babylonjs/Misc/typeStore";
  78384. export * from "babylonjs/Misc/filesInputStore";
  78385. export * from "babylonjs/Misc/deepCopier";
  78386. export * from "babylonjs/Misc/pivotTools";
  78387. export * from "babylonjs/Misc/precisionDate";
  78388. export * from "babylonjs/Misc/screenshotTools";
  78389. export * from "babylonjs/Misc/typeStore";
  78390. export * from "babylonjs/Misc/webRequest";
  78391. export * from "babylonjs/Misc/iInspectable";
  78392. export * from "babylonjs/Misc/brdfTextureTools";
  78393. export * from "babylonjs/Misc/rgbdTextureTools";
  78394. export * from "babylonjs/Misc/gradients";
  78395. export * from "babylonjs/Misc/perfCounter";
  78396. export * from "babylonjs/Misc/fileRequest";
  78397. export * from "babylonjs/Misc/customAnimationFrameRequester";
  78398. export * from "babylonjs/Misc/retryStrategy";
  78399. export * from "babylonjs/Misc/interfaces/screenshotSize";
  78400. export * from "babylonjs/Misc/canvasGenerator";
  78401. export * from "babylonjs/Misc/fileTools";
  78402. export * from "babylonjs/Misc/stringTools";
  78403. export * from "babylonjs/Misc/dataReader";
  78404. export * from "babylonjs/Misc/minMaxReducer";
  78405. export * from "babylonjs/Misc/depthReducer";
  78406. export * from "babylonjs/Misc/dataStorage";
  78407. export * from "babylonjs/Misc/sceneRecorder";
  78408. export * from "babylonjs/Misc/khronosTextureContainer2";
  78409. }
  78410. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  78411. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  78412. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78413. import { Observable } from "babylonjs/Misc/observable";
  78414. import { Matrix } from "babylonjs/Maths/math.vector";
  78415. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78416. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78417. /**
  78418. * An interface for all Hit test features
  78419. */
  78420. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  78421. /**
  78422. * Triggered when new babylon (transformed) hit test results are available
  78423. */
  78424. onHitTestResultObservable: Observable<T[]>;
  78425. }
  78426. /**
  78427. * Options used for hit testing
  78428. */
  78429. export interface IWebXRLegacyHitTestOptions {
  78430. /**
  78431. * Only test when user interacted with the scene. Default - hit test every frame
  78432. */
  78433. testOnPointerDownOnly?: boolean;
  78434. /**
  78435. * The node to use to transform the local results to world coordinates
  78436. */
  78437. worldParentNode?: TransformNode;
  78438. }
  78439. /**
  78440. * Interface defining the babylon result of raycasting/hit-test
  78441. */
  78442. export interface IWebXRLegacyHitResult {
  78443. /**
  78444. * Transformation matrix that can be applied to a node that will put it in the hit point location
  78445. */
  78446. transformationMatrix: Matrix;
  78447. /**
  78448. * The native hit test result
  78449. */
  78450. xrHitResult: XRHitResult | XRHitTestResult;
  78451. }
  78452. /**
  78453. * The currently-working hit-test module.
  78454. * Hit test (or Ray-casting) is used to interact with the real world.
  78455. * For further information read here - https://github.com/immersive-web/hit-test
  78456. */
  78457. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  78458. /**
  78459. * options to use when constructing this feature
  78460. */
  78461. readonly options: IWebXRLegacyHitTestOptions;
  78462. private _direction;
  78463. private _mat;
  78464. private _onSelectEnabled;
  78465. private _origin;
  78466. /**
  78467. * The module's name
  78468. */
  78469. static readonly Name: string;
  78470. /**
  78471. * The (Babylon) version of this module.
  78472. * This is an integer representing the implementation version.
  78473. * This number does not correspond to the WebXR specs version
  78474. */
  78475. static readonly Version: number;
  78476. /**
  78477. * Populated with the last native XR Hit Results
  78478. */
  78479. lastNativeXRHitResults: XRHitResult[];
  78480. /**
  78481. * Triggered when new babylon (transformed) hit test results are available
  78482. */
  78483. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  78484. /**
  78485. * Creates a new instance of the (legacy version) hit test feature
  78486. * @param _xrSessionManager an instance of WebXRSessionManager
  78487. * @param options options to use when constructing this feature
  78488. */
  78489. constructor(_xrSessionManager: WebXRSessionManager,
  78490. /**
  78491. * options to use when constructing this feature
  78492. */
  78493. options?: IWebXRLegacyHitTestOptions);
  78494. /**
  78495. * execute a hit test with an XR Ray
  78496. *
  78497. * @param xrSession a native xrSession that will execute this hit test
  78498. * @param xrRay the ray (position and direction) to use for ray-casting
  78499. * @param referenceSpace native XR reference space to use for the hit-test
  78500. * @param filter filter function that will filter the results
  78501. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78502. */
  78503. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  78504. /**
  78505. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  78506. * @param event the (select) event to use to select with
  78507. * @param referenceSpace the reference space to use for this hit test
  78508. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78509. */
  78510. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  78511. /**
  78512. * attach this feature
  78513. * Will usually be called by the features manager
  78514. *
  78515. * @returns true if successful.
  78516. */
  78517. attach(): boolean;
  78518. /**
  78519. * detach this feature.
  78520. * Will usually be called by the features manager
  78521. *
  78522. * @returns true if successful.
  78523. */
  78524. detach(): boolean;
  78525. /**
  78526. * Dispose this feature and all of the resources attached
  78527. */
  78528. dispose(): void;
  78529. protected _onXRFrame(frame: XRFrame): void;
  78530. private _onHitTestResults;
  78531. private _onSelect;
  78532. }
  78533. }
  78534. declare module "babylonjs/XR/features/WebXRHitTest" {
  78535. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78536. import { Observable } from "babylonjs/Misc/observable";
  78537. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  78538. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78539. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  78540. /**
  78541. * Options used for hit testing (version 2)
  78542. */
  78543. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  78544. /**
  78545. * Do not create a permanent hit test. Will usually be used when only
  78546. * transient inputs are needed.
  78547. */
  78548. disablePermanentHitTest?: boolean;
  78549. /**
  78550. * Enable transient (for example touch-based) hit test inspections
  78551. */
  78552. enableTransientHitTest?: boolean;
  78553. /**
  78554. * Offset ray for the permanent hit test
  78555. */
  78556. offsetRay?: Vector3;
  78557. /**
  78558. * Offset ray for the transient hit test
  78559. */
  78560. transientOffsetRay?: Vector3;
  78561. /**
  78562. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  78563. */
  78564. useReferenceSpace?: boolean;
  78565. /**
  78566. * Override the default entity type(s) of the hit-test result
  78567. */
  78568. entityTypes?: XRHitTestTrackableType[];
  78569. }
  78570. /**
  78571. * Interface defining the babylon result of hit-test
  78572. */
  78573. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  78574. /**
  78575. * The input source that generated this hit test (if transient)
  78576. */
  78577. inputSource?: XRInputSource;
  78578. /**
  78579. * Is this a transient hit test
  78580. */
  78581. isTransient?: boolean;
  78582. /**
  78583. * Position of the hit test result
  78584. */
  78585. position: Vector3;
  78586. /**
  78587. * Rotation of the hit test result
  78588. */
  78589. rotationQuaternion: Quaternion;
  78590. /**
  78591. * The native hit test result
  78592. */
  78593. xrHitResult: XRHitTestResult;
  78594. }
  78595. /**
  78596. * The currently-working hit-test module.
  78597. * Hit test (or Ray-casting) is used to interact with the real world.
  78598. * For further information read here - https://github.com/immersive-web/hit-test
  78599. *
  78600. * Tested on chrome (mobile) 80.
  78601. */
  78602. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  78603. /**
  78604. * options to use when constructing this feature
  78605. */
  78606. readonly options: IWebXRHitTestOptions;
  78607. private _tmpMat;
  78608. private _tmpPos;
  78609. private _tmpQuat;
  78610. private _transientXrHitTestSource;
  78611. private _xrHitTestSource;
  78612. private initHitTestSource;
  78613. /**
  78614. * The module's name
  78615. */
  78616. static readonly Name: string;
  78617. /**
  78618. * The (Babylon) version of this module.
  78619. * This is an integer representing the implementation version.
  78620. * This number does not correspond to the WebXR specs version
  78621. */
  78622. static readonly Version: number;
  78623. /**
  78624. * When set to true, each hit test will have its own position/rotation objects
  78625. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  78626. * the developers will clone them or copy them as they see fit.
  78627. */
  78628. autoCloneTransformation: boolean;
  78629. /**
  78630. * Triggered when new babylon (transformed) hit test results are available
  78631. * Note - this will be called when results come back from the device. It can be an empty array!!
  78632. */
  78633. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  78634. /**
  78635. * Use this to temporarily pause hit test checks.
  78636. */
  78637. paused: boolean;
  78638. /**
  78639. * Creates a new instance of the hit test feature
  78640. * @param _xrSessionManager an instance of WebXRSessionManager
  78641. * @param options options to use when constructing this feature
  78642. */
  78643. constructor(_xrSessionManager: WebXRSessionManager,
  78644. /**
  78645. * options to use when constructing this feature
  78646. */
  78647. options?: IWebXRHitTestOptions);
  78648. /**
  78649. * attach this feature
  78650. * Will usually be called by the features manager
  78651. *
  78652. * @returns true if successful.
  78653. */
  78654. attach(): boolean;
  78655. /**
  78656. * detach this feature.
  78657. * Will usually be called by the features manager
  78658. *
  78659. * @returns true if successful.
  78660. */
  78661. detach(): boolean;
  78662. /**
  78663. * Dispose this feature and all of the resources attached
  78664. */
  78665. dispose(): void;
  78666. protected _onXRFrame(frame: XRFrame): void;
  78667. private _processWebXRHitTestResult;
  78668. }
  78669. }
  78670. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  78671. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78672. import { Observable } from "babylonjs/Misc/observable";
  78673. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  78674. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78675. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78676. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  78677. /**
  78678. * Configuration options of the anchor system
  78679. */
  78680. export interface IWebXRAnchorSystemOptions {
  78681. /**
  78682. * a node that will be used to convert local to world coordinates
  78683. */
  78684. worldParentNode?: TransformNode;
  78685. /**
  78686. * If set to true a reference of the created anchors will be kept until the next session starts
  78687. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  78688. */
  78689. doNotRemoveAnchorsOnSessionEnded?: boolean;
  78690. }
  78691. /**
  78692. * A babylon container for an XR Anchor
  78693. */
  78694. export interface IWebXRAnchor {
  78695. /**
  78696. * A babylon-assigned ID for this anchor
  78697. */
  78698. id: number;
  78699. /**
  78700. * Transformation matrix to apply to an object attached to this anchor
  78701. */
  78702. transformationMatrix: Matrix;
  78703. /**
  78704. * The native anchor object
  78705. */
  78706. xrAnchor: XRAnchor;
  78707. /**
  78708. * if defined, this object will be constantly updated by the anchor's position and rotation
  78709. */
  78710. attachedNode?: TransformNode;
  78711. }
  78712. /**
  78713. * An implementation of the anchor system for WebXR.
  78714. * For further information see https://github.com/immersive-web/anchors/
  78715. */
  78716. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  78717. private _options;
  78718. private _lastFrameDetected;
  78719. private _trackedAnchors;
  78720. private _referenceSpaceForFrameAnchors;
  78721. private _futureAnchors;
  78722. /**
  78723. * The module's name
  78724. */
  78725. static readonly Name: string;
  78726. /**
  78727. * The (Babylon) version of this module.
  78728. * This is an integer representing the implementation version.
  78729. * This number does not correspond to the WebXR specs version
  78730. */
  78731. static readonly Version: number;
  78732. /**
  78733. * Observers registered here will be executed when a new anchor was added to the session
  78734. */
  78735. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  78736. /**
  78737. * Observers registered here will be executed when an anchor was removed from the session
  78738. */
  78739. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  78740. /**
  78741. * Observers registered here will be executed when an existing anchor updates
  78742. * This can execute N times every frame
  78743. */
  78744. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  78745. /**
  78746. * Set the reference space to use for anchor creation, when not using a hit test.
  78747. * Will default to the session's reference space if not defined
  78748. */
  78749. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  78750. /**
  78751. * constructs a new anchor system
  78752. * @param _xrSessionManager an instance of WebXRSessionManager
  78753. * @param _options configuration object for this feature
  78754. */
  78755. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  78756. private _tmpVector;
  78757. private _tmpQuaternion;
  78758. private _populateTmpTransformation;
  78759. /**
  78760. * Create a new anchor point using a hit test result at a specific point in the scene
  78761. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78762. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78763. *
  78764. * @param hitTestResult The hit test result to use for this anchor creation
  78765. * @param position an optional position offset for this anchor
  78766. * @param rotationQuaternion an optional rotation offset for this anchor
  78767. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  78768. */
  78769. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  78770. /**
  78771. * Add a new anchor at a specific position and rotation
  78772. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  78773. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  78774. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78775. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78776. *
  78777. * @param position the position in which to add an anchor
  78778. * @param rotationQuaternion an optional rotation for the anchor transformation
  78779. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  78780. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  78781. */
  78782. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  78783. /**
  78784. * detach this feature.
  78785. * Will usually be called by the features manager
  78786. *
  78787. * @returns true if successful.
  78788. */
  78789. detach(): boolean;
  78790. /**
  78791. * Dispose this feature and all of the resources attached
  78792. */
  78793. dispose(): void;
  78794. protected _onXRFrame(frame: XRFrame): void;
  78795. /**
  78796. * avoiding using Array.find for global support.
  78797. * @param xrAnchor the plane to find in the array
  78798. */
  78799. private _findIndexInAnchorArray;
  78800. private _updateAnchorWithXRFrame;
  78801. private _createAnchorAtTransformation;
  78802. }
  78803. }
  78804. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  78805. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78806. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78807. import { Observable } from "babylonjs/Misc/observable";
  78808. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  78809. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78810. /**
  78811. * Options used in the plane detector module
  78812. */
  78813. export interface IWebXRPlaneDetectorOptions {
  78814. /**
  78815. * The node to use to transform the local results to world coordinates
  78816. */
  78817. worldParentNode?: TransformNode;
  78818. /**
  78819. * If set to true a reference of the created planes will be kept until the next session starts
  78820. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  78821. */
  78822. doNotRemovePlanesOnSessionEnded?: boolean;
  78823. }
  78824. /**
  78825. * A babylon interface for a WebXR plane.
  78826. * A Plane is actually a polygon, built from N points in space
  78827. *
  78828. * Supported in chrome 79, not supported in canary 81 ATM
  78829. */
  78830. export interface IWebXRPlane {
  78831. /**
  78832. * a babylon-assigned ID for this polygon
  78833. */
  78834. id: number;
  78835. /**
  78836. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  78837. */
  78838. polygonDefinition: Array<Vector3>;
  78839. /**
  78840. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  78841. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  78842. */
  78843. transformationMatrix: Matrix;
  78844. /**
  78845. * the native xr-plane object
  78846. */
  78847. xrPlane: XRPlane;
  78848. }
  78849. /**
  78850. * The plane detector is used to detect planes in the real world when in AR
  78851. * For more information see https://github.com/immersive-web/real-world-geometry/
  78852. */
  78853. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  78854. private _options;
  78855. private _detectedPlanes;
  78856. private _enabled;
  78857. private _lastFrameDetected;
  78858. /**
  78859. * The module's name
  78860. */
  78861. static readonly Name: string;
  78862. /**
  78863. * The (Babylon) version of this module.
  78864. * This is an integer representing the implementation version.
  78865. * This number does not correspond to the WebXR specs version
  78866. */
  78867. static readonly Version: number;
  78868. /**
  78869. * Observers registered here will be executed when a new plane was added to the session
  78870. */
  78871. onPlaneAddedObservable: Observable<IWebXRPlane>;
  78872. /**
  78873. * Observers registered here will be executed when a plane is no longer detected in the session
  78874. */
  78875. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  78876. /**
  78877. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  78878. * This can execute N times every frame
  78879. */
  78880. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  78881. /**
  78882. * construct a new Plane Detector
  78883. * @param _xrSessionManager an instance of xr Session manager
  78884. * @param _options configuration to use when constructing this feature
  78885. */
  78886. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  78887. /**
  78888. * detach this feature.
  78889. * Will usually be called by the features manager
  78890. *
  78891. * @returns true if successful.
  78892. */
  78893. detach(): boolean;
  78894. /**
  78895. * Dispose this feature and all of the resources attached
  78896. */
  78897. dispose(): void;
  78898. protected _onXRFrame(frame: XRFrame): void;
  78899. private _init;
  78900. private _updatePlaneWithXRPlane;
  78901. /**
  78902. * avoiding using Array.find for global support.
  78903. * @param xrPlane the plane to find in the array
  78904. */
  78905. private findIndexInPlaneArray;
  78906. }
  78907. }
  78908. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  78909. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78911. import { Observable } from "babylonjs/Misc/observable";
  78912. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78913. /**
  78914. * Options interface for the background remover plugin
  78915. */
  78916. export interface IWebXRBackgroundRemoverOptions {
  78917. /**
  78918. * Further background meshes to disable when entering AR
  78919. */
  78920. backgroundMeshes?: AbstractMesh[];
  78921. /**
  78922. * flags to configure the removal of the environment helper.
  78923. * If not set, the entire background will be removed. If set, flags should be set as well.
  78924. */
  78925. environmentHelperRemovalFlags?: {
  78926. /**
  78927. * Should the skybox be removed (default false)
  78928. */
  78929. skyBox?: boolean;
  78930. /**
  78931. * Should the ground be removed (default false)
  78932. */
  78933. ground?: boolean;
  78934. };
  78935. /**
  78936. * don't disable the environment helper
  78937. */
  78938. ignoreEnvironmentHelper?: boolean;
  78939. }
  78940. /**
  78941. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  78942. */
  78943. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  78944. /**
  78945. * read-only options to be used in this module
  78946. */
  78947. readonly options: IWebXRBackgroundRemoverOptions;
  78948. /**
  78949. * The module's name
  78950. */
  78951. static readonly Name: string;
  78952. /**
  78953. * The (Babylon) version of this module.
  78954. * This is an integer representing the implementation version.
  78955. * This number does not correspond to the WebXR specs version
  78956. */
  78957. static readonly Version: number;
  78958. /**
  78959. * registered observers will be triggered when the background state changes
  78960. */
  78961. onBackgroundStateChangedObservable: Observable<boolean>;
  78962. /**
  78963. * constructs a new background remover module
  78964. * @param _xrSessionManager the session manager for this module
  78965. * @param options read-only options to be used in this module
  78966. */
  78967. constructor(_xrSessionManager: WebXRSessionManager,
  78968. /**
  78969. * read-only options to be used in this module
  78970. */
  78971. options?: IWebXRBackgroundRemoverOptions);
  78972. /**
  78973. * attach this feature
  78974. * Will usually be called by the features manager
  78975. *
  78976. * @returns true if successful.
  78977. */
  78978. attach(): boolean;
  78979. /**
  78980. * detach this feature.
  78981. * Will usually be called by the features manager
  78982. *
  78983. * @returns true if successful.
  78984. */
  78985. detach(): boolean;
  78986. /**
  78987. * Dispose this feature and all of the resources attached
  78988. */
  78989. dispose(): void;
  78990. protected _onXRFrame(_xrFrame: XRFrame): void;
  78991. private _setBackgroundState;
  78992. }
  78993. }
  78994. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  78995. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78996. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  78997. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  78998. import { WebXRInput } from "babylonjs/XR/webXRInput";
  78999. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79000. import { Nullable } from "babylonjs/types";
  79001. /**
  79002. * Options for the controller physics feature
  79003. */
  79004. export class IWebXRControllerPhysicsOptions {
  79005. /**
  79006. * Should the headset get its own impostor
  79007. */
  79008. enableHeadsetImpostor?: boolean;
  79009. /**
  79010. * Optional parameters for the headset impostor
  79011. */
  79012. headsetImpostorParams?: {
  79013. /**
  79014. * The type of impostor to create. Default is sphere
  79015. */
  79016. impostorType: number;
  79017. /**
  79018. * the size of the impostor. Defaults to 10cm
  79019. */
  79020. impostorSize?: number | {
  79021. width: number;
  79022. height: number;
  79023. depth: number;
  79024. };
  79025. /**
  79026. * Friction definitions
  79027. */
  79028. friction?: number;
  79029. /**
  79030. * Restitution
  79031. */
  79032. restitution?: number;
  79033. };
  79034. /**
  79035. * The physics properties of the future impostors
  79036. */
  79037. physicsProperties?: {
  79038. /**
  79039. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79040. * Note that this requires a physics engine that supports mesh impostors!
  79041. */
  79042. useControllerMesh?: boolean;
  79043. /**
  79044. * The type of impostor to create. Default is sphere
  79045. */
  79046. impostorType?: number;
  79047. /**
  79048. * the size of the impostor. Defaults to 10cm
  79049. */
  79050. impostorSize?: number | {
  79051. width: number;
  79052. height: number;
  79053. depth: number;
  79054. };
  79055. /**
  79056. * Friction definitions
  79057. */
  79058. friction?: number;
  79059. /**
  79060. * Restitution
  79061. */
  79062. restitution?: number;
  79063. };
  79064. /**
  79065. * the xr input to use with this pointer selection
  79066. */
  79067. xrInput: WebXRInput;
  79068. }
  79069. /**
  79070. * Add physics impostor to your webxr controllers,
  79071. * including naive calculation of their linear and angular velocity
  79072. */
  79073. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79074. private readonly _options;
  79075. private _attachController;
  79076. private _controllers;
  79077. private _debugMode;
  79078. private _delta;
  79079. private _headsetImpostor?;
  79080. private _headsetMesh?;
  79081. private _lastTimestamp;
  79082. private _tmpQuaternion;
  79083. private _tmpVector;
  79084. /**
  79085. * The module's name
  79086. */
  79087. static readonly Name: string;
  79088. /**
  79089. * The (Babylon) version of this module.
  79090. * This is an integer representing the implementation version.
  79091. * This number does not correspond to the webxr specs version
  79092. */
  79093. static readonly Version: number;
  79094. /**
  79095. * Construct a new Controller Physics Feature
  79096. * @param _xrSessionManager the corresponding xr session manager
  79097. * @param _options options to create this feature with
  79098. */
  79099. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  79100. /**
  79101. * @hidden
  79102. * enable debugging - will show console outputs and the impostor mesh
  79103. */
  79104. _enablePhysicsDebug(): void;
  79105. /**
  79106. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  79107. * @param xrController the controller to add
  79108. */
  79109. addController(xrController: WebXRInputSource): void;
  79110. /**
  79111. * attach this feature
  79112. * Will usually be called by the features manager
  79113. *
  79114. * @returns true if successful.
  79115. */
  79116. attach(): boolean;
  79117. /**
  79118. * detach this feature.
  79119. * Will usually be called by the features manager
  79120. *
  79121. * @returns true if successful.
  79122. */
  79123. detach(): boolean;
  79124. /**
  79125. * Get the headset impostor, if enabled
  79126. * @returns the impostor
  79127. */
  79128. getHeadsetImpostor(): PhysicsImpostor | undefined;
  79129. /**
  79130. * Get the physics impostor of a specific controller.
  79131. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  79132. * @param controller the controller or the controller id of which to get the impostor
  79133. * @returns the impostor or null
  79134. */
  79135. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  79136. /**
  79137. * Update the physics properties provided in the constructor
  79138. * @param newProperties the new properties object
  79139. */
  79140. setPhysicsProperties(newProperties: {
  79141. impostorType?: number;
  79142. impostorSize?: number | {
  79143. width: number;
  79144. height: number;
  79145. depth: number;
  79146. };
  79147. friction?: number;
  79148. restitution?: number;
  79149. }): void;
  79150. protected _onXRFrame(_xrFrame: any): void;
  79151. private _detachController;
  79152. }
  79153. }
  79154. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  79155. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79156. import { Observable } from "babylonjs/Misc/observable";
  79157. import { Vector3 } from "babylonjs/Maths/math.vector";
  79158. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79159. /**
  79160. * A babylon interface for a "WebXR" feature point.
  79161. * Represents the position and confidence value of a given feature point.
  79162. */
  79163. export interface IWebXRFeaturePoint {
  79164. /**
  79165. * Represents the position of the feature point in world space.
  79166. */
  79167. position: Vector3;
  79168. /**
  79169. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  79170. */
  79171. confidenceValue: number;
  79172. }
  79173. /**
  79174. * The feature point system is used to detect feature points from real world geometry.
  79175. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  79176. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  79177. */
  79178. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  79179. private _enabled;
  79180. private _featurePointCloud;
  79181. /**
  79182. * The module's name
  79183. */
  79184. static readonly Name: string;
  79185. /**
  79186. * The (Babylon) version of this module.
  79187. * This is an integer representing the implementation version.
  79188. * This number does not correspond to the WebXR specs version
  79189. */
  79190. static readonly Version: number;
  79191. /**
  79192. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  79193. * Will notify the observers about which feature points have been added.
  79194. */
  79195. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  79196. /**
  79197. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  79198. * Will notify the observers about which feature points have been updated.
  79199. */
  79200. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  79201. /**
  79202. * The current feature point cloud maintained across frames.
  79203. */
  79204. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  79205. /**
  79206. * construct the feature point system
  79207. * @param _xrSessionManager an instance of xr Session manager
  79208. */
  79209. constructor(_xrSessionManager: WebXRSessionManager);
  79210. /**
  79211. * Detach this feature.
  79212. * Will usually be called by the features manager
  79213. *
  79214. * @returns true if successful.
  79215. */
  79216. detach(): boolean;
  79217. /**
  79218. * Dispose this feature and all of the resources attached
  79219. */
  79220. dispose(): void;
  79221. /**
  79222. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  79223. */
  79224. protected _onXRFrame(frame: XRFrame): void;
  79225. /**
  79226. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  79227. */
  79228. private _init;
  79229. }
  79230. }
  79231. declare module "babylonjs/XR/features/WebXRHandTracking" {
  79232. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79233. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79235. import { Mesh } from "babylonjs/Meshes/mesh";
  79236. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79237. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79238. import { Nullable } from "babylonjs/types";
  79239. import { IDisposable } from "babylonjs/scene";
  79240. import { Observable } from "babylonjs/Misc/observable";
  79241. /**
  79242. * Configuration interface for the hand tracking feature
  79243. */
  79244. export interface IWebXRHandTrackingOptions {
  79245. /**
  79246. * The xrInput that will be used as source for new hands
  79247. */
  79248. xrInput: WebXRInput;
  79249. /**
  79250. * Configuration object for the joint meshes
  79251. */
  79252. jointMeshes?: {
  79253. /**
  79254. * Should the meshes created be invisible (defaults to false)
  79255. */
  79256. invisible?: boolean;
  79257. /**
  79258. * A source mesh to be used to create instances. Defaults to a sphere.
  79259. * This mesh will be the source for all other (25) meshes.
  79260. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  79261. */
  79262. sourceMesh?: Mesh;
  79263. /**
  79264. * Should the source mesh stay visible. Defaults to false
  79265. */
  79266. keepOriginalVisible?: boolean;
  79267. /**
  79268. * Scale factor for all instances (defaults to 2)
  79269. */
  79270. scaleFactor?: number;
  79271. /**
  79272. * Should each instance have its own physics impostor
  79273. */
  79274. enablePhysics?: boolean;
  79275. /**
  79276. * If enabled, override default physics properties
  79277. */
  79278. physicsProps?: {
  79279. friction?: number;
  79280. restitution?: number;
  79281. impostorType?: number;
  79282. };
  79283. /**
  79284. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  79285. */
  79286. handMesh?: AbstractMesh;
  79287. };
  79288. }
  79289. /**
  79290. * Parts of the hands divided to writs and finger names
  79291. */
  79292. export const enum HandPart {
  79293. /**
  79294. * HandPart - Wrist
  79295. */
  79296. WRIST = "wrist",
  79297. /**
  79298. * HandPart - The THumb
  79299. */
  79300. THUMB = "thumb",
  79301. /**
  79302. * HandPart - Index finger
  79303. */
  79304. INDEX = "index",
  79305. /**
  79306. * HandPart - Middle finger
  79307. */
  79308. MIDDLE = "middle",
  79309. /**
  79310. * HandPart - Ring finger
  79311. */
  79312. RING = "ring",
  79313. /**
  79314. * HandPart - Little finger
  79315. */
  79316. LITTLE = "little"
  79317. }
  79318. /**
  79319. * Representing a single hand (with its corresponding native XRHand object)
  79320. */
  79321. export class WebXRHand implements IDisposable {
  79322. /** the controller to which the hand correlates */
  79323. readonly xrController: WebXRInputSource;
  79324. /** the meshes to be used to track the hand joints */
  79325. readonly trackedMeshes: AbstractMesh[];
  79326. /**
  79327. * Hand-parts definition (key is HandPart)
  79328. */
  79329. handPartsDefinition: {
  79330. [key: string]: number[];
  79331. };
  79332. /**
  79333. * Populate the HandPartsDefinition object.
  79334. * This is called as a side effect since certain browsers don't have XRHand defined.
  79335. */
  79336. private generateHandPartsDefinition;
  79337. /**
  79338. * Construct a new hand object
  79339. * @param xrController the controller to which the hand correlates
  79340. * @param trackedMeshes the meshes to be used to track the hand joints
  79341. */
  79342. constructor(
  79343. /** the controller to which the hand correlates */
  79344. xrController: WebXRInputSource,
  79345. /** the meshes to be used to track the hand joints */
  79346. trackedMeshes: AbstractMesh[]);
  79347. /**
  79348. * Update this hand from the latest xr frame
  79349. * @param xrFrame xrFrame to update from
  79350. * @param referenceSpace The current viewer reference space
  79351. * @param scaleFactor optional scale factor for the meshes
  79352. */
  79353. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  79354. /**
  79355. * Get meshes of part of the hand
  79356. * @param part the part of hand to get
  79357. * @returns An array of meshes that correlate to the hand part requested
  79358. */
  79359. getHandPartMeshes(part: HandPart): AbstractMesh[];
  79360. /**
  79361. * Dispose this Hand object
  79362. */
  79363. dispose(): void;
  79364. }
  79365. /**
  79366. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  79367. */
  79368. export class WebXRHandTracking extends WebXRAbstractFeature {
  79369. /**
  79370. * options to use when constructing this feature
  79371. */
  79372. readonly options: IWebXRHandTrackingOptions;
  79373. private static _idCounter;
  79374. /**
  79375. * The module's name
  79376. */
  79377. static readonly Name: string;
  79378. /**
  79379. * The (Babylon) version of this module.
  79380. * This is an integer representing the implementation version.
  79381. * This number does not correspond to the WebXR specs version
  79382. */
  79383. static readonly Version: number;
  79384. /**
  79385. * This observable will notify registered observers when a new hand object was added and initialized
  79386. */
  79387. onHandAddedObservable: Observable<WebXRHand>;
  79388. /**
  79389. * This observable will notify its observers right before the hand object is disposed
  79390. */
  79391. onHandRemovedObservable: Observable<WebXRHand>;
  79392. private _hands;
  79393. /**
  79394. * Creates a new instance of the hit test feature
  79395. * @param _xrSessionManager an instance of WebXRSessionManager
  79396. * @param options options to use when constructing this feature
  79397. */
  79398. constructor(_xrSessionManager: WebXRSessionManager,
  79399. /**
  79400. * options to use when constructing this feature
  79401. */
  79402. options: IWebXRHandTrackingOptions);
  79403. /**
  79404. * Check if the needed objects are defined.
  79405. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79406. */
  79407. isCompatible(): boolean;
  79408. /**
  79409. * attach this feature
  79410. * Will usually be called by the features manager
  79411. *
  79412. * @returns true if successful.
  79413. */
  79414. attach(): boolean;
  79415. /**
  79416. * detach this feature.
  79417. * Will usually be called by the features manager
  79418. *
  79419. * @returns true if successful.
  79420. */
  79421. detach(): boolean;
  79422. /**
  79423. * Dispose this feature and all of the resources attached
  79424. */
  79425. dispose(): void;
  79426. /**
  79427. * Get the hand object according to the controller id
  79428. * @param controllerId the controller id to which we want to get the hand
  79429. * @returns null if not found or the WebXRHand object if found
  79430. */
  79431. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  79432. /**
  79433. * Get a hand object according to the requested handedness
  79434. * @param handedness the handedness to request
  79435. * @returns null if not found or the WebXRHand object if found
  79436. */
  79437. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  79438. protected _onXRFrame(_xrFrame: XRFrame): void;
  79439. private _attachHand;
  79440. private _detachHand;
  79441. }
  79442. }
  79443. declare module "babylonjs/XR/features/index" {
  79444. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  79445. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  79446. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  79447. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  79448. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  79449. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  79450. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  79451. export * from "babylonjs/XR/features/WebXRHitTest";
  79452. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  79453. export * from "babylonjs/XR/features/WebXRHandTracking";
  79454. }
  79455. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  79456. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79457. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79458. import { Scene } from "babylonjs/scene";
  79459. /**
  79460. * The motion controller class for all microsoft mixed reality controllers
  79461. */
  79462. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  79463. protected readonly _mapping: {
  79464. defaultButton: {
  79465. valueNodeName: string;
  79466. unpressedNodeName: string;
  79467. pressedNodeName: string;
  79468. };
  79469. defaultAxis: {
  79470. valueNodeName: string;
  79471. minNodeName: string;
  79472. maxNodeName: string;
  79473. };
  79474. buttons: {
  79475. "xr-standard-trigger": {
  79476. rootNodeName: string;
  79477. componentProperty: string;
  79478. states: string[];
  79479. };
  79480. "xr-standard-squeeze": {
  79481. rootNodeName: string;
  79482. componentProperty: string;
  79483. states: string[];
  79484. };
  79485. "xr-standard-touchpad": {
  79486. rootNodeName: string;
  79487. labelAnchorNodeName: string;
  79488. touchPointNodeName: string;
  79489. };
  79490. "xr-standard-thumbstick": {
  79491. rootNodeName: string;
  79492. componentProperty: string;
  79493. states: string[];
  79494. };
  79495. };
  79496. axes: {
  79497. "xr-standard-touchpad": {
  79498. "x-axis": {
  79499. rootNodeName: string;
  79500. };
  79501. "y-axis": {
  79502. rootNodeName: string;
  79503. };
  79504. };
  79505. "xr-standard-thumbstick": {
  79506. "x-axis": {
  79507. rootNodeName: string;
  79508. };
  79509. "y-axis": {
  79510. rootNodeName: string;
  79511. };
  79512. };
  79513. };
  79514. };
  79515. /**
  79516. * The base url used to load the left and right controller models
  79517. */
  79518. static MODEL_BASE_URL: string;
  79519. /**
  79520. * The name of the left controller model file
  79521. */
  79522. static MODEL_LEFT_FILENAME: string;
  79523. /**
  79524. * The name of the right controller model file
  79525. */
  79526. static MODEL_RIGHT_FILENAME: string;
  79527. profileId: string;
  79528. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  79529. protected _getFilenameAndPath(): {
  79530. filename: string;
  79531. path: string;
  79532. };
  79533. protected _getModelLoadingConstraints(): boolean;
  79534. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79535. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79536. protected _updateModel(): void;
  79537. }
  79538. }
  79539. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  79540. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79541. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79542. import { Scene } from "babylonjs/scene";
  79543. /**
  79544. * The motion controller class for oculus touch (quest, rift).
  79545. * This class supports legacy mapping as well the standard xr mapping
  79546. */
  79547. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  79548. private _forceLegacyControllers;
  79549. private _modelRootNode;
  79550. /**
  79551. * The base url used to load the left and right controller models
  79552. */
  79553. static MODEL_BASE_URL: string;
  79554. /**
  79555. * The name of the left controller model file
  79556. */
  79557. static MODEL_LEFT_FILENAME: string;
  79558. /**
  79559. * The name of the right controller model file
  79560. */
  79561. static MODEL_RIGHT_FILENAME: string;
  79562. /**
  79563. * Base Url for the Quest controller model.
  79564. */
  79565. static QUEST_MODEL_BASE_URL: string;
  79566. profileId: string;
  79567. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  79568. protected _getFilenameAndPath(): {
  79569. filename: string;
  79570. path: string;
  79571. };
  79572. protected _getModelLoadingConstraints(): boolean;
  79573. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79574. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79575. protected _updateModel(): void;
  79576. /**
  79577. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  79578. * between the touch and touch 2.
  79579. */
  79580. private _isQuest;
  79581. }
  79582. }
  79583. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  79584. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79585. import { Scene } from "babylonjs/scene";
  79586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79587. /**
  79588. * The motion controller class for the standard HTC-Vive controllers
  79589. */
  79590. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  79591. private _modelRootNode;
  79592. /**
  79593. * The base url used to load the left and right controller models
  79594. */
  79595. static MODEL_BASE_URL: string;
  79596. /**
  79597. * File name for the controller model.
  79598. */
  79599. static MODEL_FILENAME: string;
  79600. profileId: string;
  79601. /**
  79602. * Create a new Vive motion controller object
  79603. * @param scene the scene to use to create this controller
  79604. * @param gamepadObject the corresponding gamepad object
  79605. * @param handedness the handedness of the controller
  79606. */
  79607. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  79608. protected _getFilenameAndPath(): {
  79609. filename: string;
  79610. path: string;
  79611. };
  79612. protected _getModelLoadingConstraints(): boolean;
  79613. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79614. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79615. protected _updateModel(): void;
  79616. }
  79617. }
  79618. declare module "babylonjs/XR/motionController/index" {
  79619. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79620. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  79621. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  79622. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  79623. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  79624. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  79625. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  79626. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  79627. }
  79628. declare module "babylonjs/XR/index" {
  79629. export * from "babylonjs/XR/webXRCamera";
  79630. export * from "babylonjs/XR/webXREnterExitUI";
  79631. export * from "babylonjs/XR/webXRExperienceHelper";
  79632. export * from "babylonjs/XR/webXRInput";
  79633. export * from "babylonjs/XR/webXRInputSource";
  79634. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  79635. export * from "babylonjs/XR/webXRTypes";
  79636. export * from "babylonjs/XR/webXRSessionManager";
  79637. export * from "babylonjs/XR/webXRDefaultExperience";
  79638. export * from "babylonjs/XR/webXRFeaturesManager";
  79639. export * from "babylonjs/XR/features/index";
  79640. export * from "babylonjs/XR/motionController/index";
  79641. }
  79642. declare module "babylonjs/index" {
  79643. export * from "babylonjs/abstractScene";
  79644. export * from "babylonjs/Actions/index";
  79645. export * from "babylonjs/Animations/index";
  79646. export * from "babylonjs/assetContainer";
  79647. export * from "babylonjs/Audio/index";
  79648. export * from "babylonjs/Behaviors/index";
  79649. export * from "babylonjs/Bones/index";
  79650. export * from "babylonjs/Cameras/index";
  79651. export * from "babylonjs/Collisions/index";
  79652. export * from "babylonjs/Culling/index";
  79653. export * from "babylonjs/Debug/index";
  79654. export * from "babylonjs/DeviceInput/index";
  79655. export * from "babylonjs/Engines/index";
  79656. export * from "babylonjs/Events/index";
  79657. export * from "babylonjs/Gamepads/index";
  79658. export * from "babylonjs/Gizmos/index";
  79659. export * from "babylonjs/Helpers/index";
  79660. export * from "babylonjs/Instrumentation/index";
  79661. export * from "babylonjs/Layers/index";
  79662. export * from "babylonjs/LensFlares/index";
  79663. export * from "babylonjs/Lights/index";
  79664. export * from "babylonjs/Loading/index";
  79665. export * from "babylonjs/Materials/index";
  79666. export * from "babylonjs/Maths/index";
  79667. export * from "babylonjs/Meshes/index";
  79668. export * from "babylonjs/Morph/index";
  79669. export * from "babylonjs/Navigation/index";
  79670. export * from "babylonjs/node";
  79671. export * from "babylonjs/Offline/index";
  79672. export * from "babylonjs/Particles/index";
  79673. export * from "babylonjs/Physics/index";
  79674. export * from "babylonjs/PostProcesses/index";
  79675. export * from "babylonjs/Probes/index";
  79676. export * from "babylonjs/Rendering/index";
  79677. export * from "babylonjs/scene";
  79678. export * from "babylonjs/sceneComponent";
  79679. export * from "babylonjs/Sprites/index";
  79680. export * from "babylonjs/States/index";
  79681. export * from "babylonjs/Misc/index";
  79682. export * from "babylonjs/XR/index";
  79683. export * from "babylonjs/types";
  79684. }
  79685. declare module "babylonjs/Animations/pathCursor" {
  79686. import { Vector3 } from "babylonjs/Maths/math.vector";
  79687. import { Path2 } from "babylonjs/Maths/math.path";
  79688. /**
  79689. * A cursor which tracks a point on a path
  79690. */
  79691. export class PathCursor {
  79692. private path;
  79693. /**
  79694. * Stores path cursor callbacks for when an onchange event is triggered
  79695. */
  79696. private _onchange;
  79697. /**
  79698. * The value of the path cursor
  79699. */
  79700. value: number;
  79701. /**
  79702. * The animation array of the path cursor
  79703. */
  79704. animations: Animation[];
  79705. /**
  79706. * Initializes the path cursor
  79707. * @param path The path to track
  79708. */
  79709. constructor(path: Path2);
  79710. /**
  79711. * Gets the cursor point on the path
  79712. * @returns A point on the path cursor at the cursor location
  79713. */
  79714. getPoint(): Vector3;
  79715. /**
  79716. * Moves the cursor ahead by the step amount
  79717. * @param step The amount to move the cursor forward
  79718. * @returns This path cursor
  79719. */
  79720. moveAhead(step?: number): PathCursor;
  79721. /**
  79722. * Moves the cursor behind by the step amount
  79723. * @param step The amount to move the cursor back
  79724. * @returns This path cursor
  79725. */
  79726. moveBack(step?: number): PathCursor;
  79727. /**
  79728. * Moves the cursor by the step amount
  79729. * If the step amount is greater than one, an exception is thrown
  79730. * @param step The amount to move the cursor
  79731. * @returns This path cursor
  79732. */
  79733. move(step: number): PathCursor;
  79734. /**
  79735. * Ensures that the value is limited between zero and one
  79736. * @returns This path cursor
  79737. */
  79738. private ensureLimits;
  79739. /**
  79740. * Runs onchange callbacks on change (used by the animation engine)
  79741. * @returns This path cursor
  79742. */
  79743. private raiseOnChange;
  79744. /**
  79745. * Executes a function on change
  79746. * @param f A path cursor onchange callback
  79747. * @returns This path cursor
  79748. */
  79749. onchange(f: (cursor: PathCursor) => void): PathCursor;
  79750. }
  79751. }
  79752. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  79753. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  79754. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  79755. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  79756. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  79757. }
  79758. declare module "babylonjs/Engines/Processors/Expressions/index" {
  79759. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  79760. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  79761. }
  79762. declare module "babylonjs/Engines/Processors/index" {
  79763. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  79764. export * from "babylonjs/Engines/Processors/Expressions/index";
  79765. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  79766. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  79767. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  79768. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  79769. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  79770. export * from "babylonjs/Engines/Processors/shaderProcessor";
  79771. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  79772. }
  79773. declare module "babylonjs/Legacy/legacy" {
  79774. import * as Babylon from "babylonjs/index";
  79775. export * from "babylonjs/index";
  79776. }
  79777. declare module "babylonjs/Shaders/blur.fragment" {
  79778. /** @hidden */
  79779. export var blurPixelShader: {
  79780. name: string;
  79781. shader: string;
  79782. };
  79783. }
  79784. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  79785. /** @hidden */
  79786. export var pointCloudVertexDeclaration: {
  79787. name: string;
  79788. shader: string;
  79789. };
  79790. }
  79791. declare module "babylonjs" {
  79792. export * from "babylonjs/Legacy/legacy";
  79793. }
  79794. declare module BABYLON {
  79795. /** Alias type for value that can be null */
  79796. export type Nullable<T> = T | null;
  79797. /**
  79798. * Alias type for number that are floats
  79799. * @ignorenaming
  79800. */
  79801. export type float = number;
  79802. /**
  79803. * Alias type for number that are doubles.
  79804. * @ignorenaming
  79805. */
  79806. export type double = number;
  79807. /**
  79808. * Alias type for number that are integer
  79809. * @ignorenaming
  79810. */
  79811. export type int = number;
  79812. /** Alias type for number array or Float32Array */
  79813. export type FloatArray = number[] | Float32Array;
  79814. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  79815. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  79816. /**
  79817. * Alias for types that can be used by a Buffer or VertexBuffer.
  79818. */
  79819. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  79820. /**
  79821. * Alias type for primitive types
  79822. * @ignorenaming
  79823. */
  79824. type Primitive = undefined | null | boolean | string | number | Function;
  79825. /**
  79826. * Type modifier to make all the properties of an object Readonly
  79827. */
  79828. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  79829. /**
  79830. * Type modifier to make all the properties of an object Readonly recursively
  79831. */
  79832. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  79833. /**
  79834. * Type modifier to make object properties readonly.
  79835. */
  79836. export type DeepImmutableObject<T> = {
  79837. readonly [K in keyof T]: DeepImmutable<T[K]>;
  79838. };
  79839. /** @hidden */
  79840. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  79841. }
  79842. }
  79843. declare module BABYLON {
  79844. /**
  79845. * A class serves as a medium between the observable and its observers
  79846. */
  79847. export class EventState {
  79848. /**
  79849. * Create a new EventState
  79850. * @param mask defines the mask associated with this state
  79851. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  79852. * @param target defines the original target of the state
  79853. * @param currentTarget defines the current target of the state
  79854. */
  79855. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  79856. /**
  79857. * Initialize the current event state
  79858. * @param mask defines the mask associated with this state
  79859. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  79860. * @param target defines the original target of the state
  79861. * @param currentTarget defines the current target of the state
  79862. * @returns the current event state
  79863. */
  79864. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  79865. /**
  79866. * An Observer can set this property to true to prevent subsequent observers of being notified
  79867. */
  79868. skipNextObservers: boolean;
  79869. /**
  79870. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79871. */
  79872. mask: number;
  79873. /**
  79874. * The object that originally notified the event
  79875. */
  79876. target?: any;
  79877. /**
  79878. * The current object in the bubbling phase
  79879. */
  79880. currentTarget?: any;
  79881. /**
  79882. * This will be populated with the return value of the last function that was executed.
  79883. * If it is the first function in the callback chain it will be the event data.
  79884. */
  79885. lastReturnValue?: any;
  79886. }
  79887. /**
  79888. * Represent an Observer registered to a given Observable object.
  79889. */
  79890. export class Observer<T> {
  79891. /**
  79892. * Defines the callback to call when the observer is notified
  79893. */
  79894. callback: (eventData: T, eventState: EventState) => void;
  79895. /**
  79896. * Defines the mask of the observer (used to filter notifications)
  79897. */
  79898. mask: number;
  79899. /**
  79900. * Defines the current scope used to restore the JS context
  79901. */
  79902. scope: any;
  79903. /** @hidden */
  79904. _willBeUnregistered: boolean;
  79905. /**
  79906. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  79907. */
  79908. unregisterOnNextCall: boolean;
  79909. /**
  79910. * Creates a new observer
  79911. * @param callback defines the callback to call when the observer is notified
  79912. * @param mask defines the mask of the observer (used to filter notifications)
  79913. * @param scope defines the current scope used to restore the JS context
  79914. */
  79915. constructor(
  79916. /**
  79917. * Defines the callback to call when the observer is notified
  79918. */
  79919. callback: (eventData: T, eventState: EventState) => void,
  79920. /**
  79921. * Defines the mask of the observer (used to filter notifications)
  79922. */
  79923. mask: number,
  79924. /**
  79925. * Defines the current scope used to restore the JS context
  79926. */
  79927. scope?: any);
  79928. }
  79929. /**
  79930. * Represent a list of observers registered to multiple Observables object.
  79931. */
  79932. export class MultiObserver<T> {
  79933. private _observers;
  79934. private _observables;
  79935. /**
  79936. * Release associated resources
  79937. */
  79938. dispose(): void;
  79939. /**
  79940. * Raise a callback when one of the observable will notify
  79941. * @param observables defines a list of observables to watch
  79942. * @param callback defines the callback to call on notification
  79943. * @param mask defines the mask used to filter notifications
  79944. * @param scope defines the current scope used to restore the JS context
  79945. * @returns the new MultiObserver
  79946. */
  79947. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  79948. }
  79949. /**
  79950. * The Observable class is a simple implementation of the Observable pattern.
  79951. *
  79952. * 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.
  79953. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  79954. * 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).
  79955. * 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.
  79956. */
  79957. export class Observable<T> {
  79958. private _observers;
  79959. private _eventState;
  79960. private _onObserverAdded;
  79961. /**
  79962. * Gets the list of observers
  79963. */
  79964. get observers(): Array<Observer<T>>;
  79965. /**
  79966. * Creates a new observable
  79967. * @param onObserverAdded defines a callback to call when a new observer is added
  79968. */
  79969. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  79970. /**
  79971. * Create a new Observer with the specified callback
  79972. * @param callback the callback that will be executed for that Observer
  79973. * @param mask the mask used to filter observers
  79974. * @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.
  79975. * @param scope optional scope for the callback to be called from
  79976. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  79977. * @returns the new observer created for the callback
  79978. */
  79979. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  79980. /**
  79981. * Create a new Observer with the specified callback and unregisters after the next notification
  79982. * @param callback the callback that will be executed for that Observer
  79983. * @returns the new observer created for the callback
  79984. */
  79985. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  79986. /**
  79987. * Remove an Observer from the Observable object
  79988. * @param observer the instance of the Observer to remove
  79989. * @returns false if it doesn't belong to this Observable
  79990. */
  79991. remove(observer: Nullable<Observer<T>>): boolean;
  79992. /**
  79993. * Remove a callback from the Observable object
  79994. * @param callback the callback to remove
  79995. * @param scope optional scope. If used only the callbacks with this scope will be removed
  79996. * @returns false if it doesn't belong to this Observable
  79997. */
  79998. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  79999. private _deferUnregister;
  80000. private _remove;
  80001. /**
  80002. * Moves the observable to the top of the observer list making it get called first when notified
  80003. * @param observer the observer to move
  80004. */
  80005. makeObserverTopPriority(observer: Observer<T>): void;
  80006. /**
  80007. * Moves the observable to the bottom of the observer list making it get called last when notified
  80008. * @param observer the observer to move
  80009. */
  80010. makeObserverBottomPriority(observer: Observer<T>): void;
  80011. /**
  80012. * Notify all Observers by calling their respective callback with the given data
  80013. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  80014. * @param eventData defines the data to send to all observers
  80015. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  80016. * @param target defines the original target of the state
  80017. * @param currentTarget defines the current target of the state
  80018. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  80019. */
  80020. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  80021. /**
  80022. * Calling this will execute each callback, expecting it to be a promise or return a value.
  80023. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  80024. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  80025. * and it is crucial that all callbacks will be executed.
  80026. * The order of the callbacks is kept, callbacks are not executed parallel.
  80027. *
  80028. * @param eventData The data to be sent to each callback
  80029. * @param mask is used to filter observers defaults to -1
  80030. * @param target defines the callback target (see EventState)
  80031. * @param currentTarget defines he current object in the bubbling phase
  80032. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  80033. */
  80034. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  80035. /**
  80036. * Notify a specific observer
  80037. * @param observer defines the observer to notify
  80038. * @param eventData defines the data to be sent to each callback
  80039. * @param mask is used to filter observers defaults to -1
  80040. */
  80041. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  80042. /**
  80043. * Gets a boolean indicating if the observable has at least one observer
  80044. * @returns true is the Observable has at least one Observer registered
  80045. */
  80046. hasObservers(): boolean;
  80047. /**
  80048. * Clear the list of observers
  80049. */
  80050. clear(): void;
  80051. /**
  80052. * Clone the current observable
  80053. * @returns a new observable
  80054. */
  80055. clone(): Observable<T>;
  80056. /**
  80057. * Does this observable handles observer registered with a given mask
  80058. * @param mask defines the mask to be tested
  80059. * @return whether or not one observer registered with the given mask is handeled
  80060. **/
  80061. hasSpecificMask(mask?: number): boolean;
  80062. }
  80063. }
  80064. declare module BABYLON {
  80065. /**
  80066. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  80067. * Babylon.js
  80068. */
  80069. export class DomManagement {
  80070. /**
  80071. * Checks if the window object exists
  80072. * @returns true if the window object exists
  80073. */
  80074. static IsWindowObjectExist(): boolean;
  80075. /**
  80076. * Checks if the navigator object exists
  80077. * @returns true if the navigator object exists
  80078. */
  80079. static IsNavigatorAvailable(): boolean;
  80080. /**
  80081. * Check if the document object exists
  80082. * @returns true if the document object exists
  80083. */
  80084. static IsDocumentAvailable(): boolean;
  80085. /**
  80086. * Extracts text content from a DOM element hierarchy
  80087. * @param element defines the root element
  80088. * @returns a string
  80089. */
  80090. static GetDOMTextContent(element: HTMLElement): string;
  80091. }
  80092. }
  80093. declare module BABYLON {
  80094. /**
  80095. * Logger used througouht the application to allow configuration of
  80096. * the log level required for the messages.
  80097. */
  80098. export class Logger {
  80099. /**
  80100. * No log
  80101. */
  80102. static readonly NoneLogLevel: number;
  80103. /**
  80104. * Only message logs
  80105. */
  80106. static readonly MessageLogLevel: number;
  80107. /**
  80108. * Only warning logs
  80109. */
  80110. static readonly WarningLogLevel: number;
  80111. /**
  80112. * Only error logs
  80113. */
  80114. static readonly ErrorLogLevel: number;
  80115. /**
  80116. * All logs
  80117. */
  80118. static readonly AllLogLevel: number;
  80119. private static _LogCache;
  80120. /**
  80121. * Gets a value indicating the number of loading errors
  80122. * @ignorenaming
  80123. */
  80124. static errorsCount: number;
  80125. /**
  80126. * Callback called when a new log is added
  80127. */
  80128. static OnNewCacheEntry: (entry: string) => void;
  80129. private static _AddLogEntry;
  80130. private static _FormatMessage;
  80131. private static _LogDisabled;
  80132. private static _LogEnabled;
  80133. private static _WarnDisabled;
  80134. private static _WarnEnabled;
  80135. private static _ErrorDisabled;
  80136. private static _ErrorEnabled;
  80137. /**
  80138. * Log a message to the console
  80139. */
  80140. static Log: (message: string) => void;
  80141. /**
  80142. * Write a warning message to the console
  80143. */
  80144. static Warn: (message: string) => void;
  80145. /**
  80146. * Write an error message to the console
  80147. */
  80148. static Error: (message: string) => void;
  80149. /**
  80150. * Gets current log cache (list of logs)
  80151. */
  80152. static get LogCache(): string;
  80153. /**
  80154. * Clears the log cache
  80155. */
  80156. static ClearLogCache(): void;
  80157. /**
  80158. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  80159. */
  80160. static set LogLevels(level: number);
  80161. }
  80162. }
  80163. declare module BABYLON {
  80164. /** @hidden */
  80165. export class _TypeStore {
  80166. /** @hidden */
  80167. static RegisteredTypes: {
  80168. [key: string]: Object;
  80169. };
  80170. /** @hidden */
  80171. static GetClass(fqdn: string): any;
  80172. }
  80173. }
  80174. declare module BABYLON {
  80175. /**
  80176. * Helper to manipulate strings
  80177. */
  80178. export class StringTools {
  80179. /**
  80180. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  80181. * @param str Source string
  80182. * @param suffix Suffix to search for in the source string
  80183. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80184. */
  80185. static EndsWith(str: string, suffix: string): boolean;
  80186. /**
  80187. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  80188. * @param str Source string
  80189. * @param suffix Suffix to search for in the source string
  80190. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80191. */
  80192. static StartsWith(str: string, suffix: string): boolean;
  80193. /**
  80194. * Decodes a buffer into a string
  80195. * @param buffer The buffer to decode
  80196. * @returns The decoded string
  80197. */
  80198. static Decode(buffer: Uint8Array | Uint16Array): string;
  80199. /**
  80200. * Encode a buffer to a base64 string
  80201. * @param buffer defines the buffer to encode
  80202. * @returns the encoded string
  80203. */
  80204. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  80205. /**
  80206. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  80207. * @param num the number to convert and pad
  80208. * @param length the expected length of the string
  80209. * @returns the padded string
  80210. */
  80211. static PadNumber(num: number, length: number): string;
  80212. }
  80213. }
  80214. declare module BABYLON {
  80215. /**
  80216. * Class containing a set of static utilities functions for deep copy.
  80217. */
  80218. export class DeepCopier {
  80219. /**
  80220. * Tries to copy an object by duplicating every property
  80221. * @param source defines the source object
  80222. * @param destination defines the target object
  80223. * @param doNotCopyList defines a list of properties to avoid
  80224. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  80225. */
  80226. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  80227. }
  80228. }
  80229. declare module BABYLON {
  80230. /**
  80231. * Class containing a set of static utilities functions for precision date
  80232. */
  80233. export class PrecisionDate {
  80234. /**
  80235. * Gets either window.performance.now() if supported or Date.now() else
  80236. */
  80237. static get Now(): number;
  80238. }
  80239. }
  80240. declare module BABYLON {
  80241. /** @hidden */
  80242. export class _DevTools {
  80243. static WarnImport(name: string): string;
  80244. }
  80245. }
  80246. declare module BABYLON {
  80247. /**
  80248. * Interface used to define the mechanism to get data from the network
  80249. */
  80250. export interface IWebRequest {
  80251. /**
  80252. * Returns client's response url
  80253. */
  80254. responseURL: string;
  80255. /**
  80256. * Returns client's status
  80257. */
  80258. status: number;
  80259. /**
  80260. * Returns client's status as a text
  80261. */
  80262. statusText: string;
  80263. }
  80264. }
  80265. declare module BABYLON {
  80266. /**
  80267. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  80268. */
  80269. export class WebRequest implements IWebRequest {
  80270. private _xhr;
  80271. /**
  80272. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  80273. * i.e. when loading files, where the server/service expects an Authorization header
  80274. */
  80275. static CustomRequestHeaders: {
  80276. [key: string]: string;
  80277. };
  80278. /**
  80279. * Add callback functions in this array to update all the requests before they get sent to the network
  80280. */
  80281. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  80282. private _injectCustomRequestHeaders;
  80283. /**
  80284. * Gets or sets a function to be called when loading progress changes
  80285. */
  80286. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  80287. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  80288. /**
  80289. * Returns client's state
  80290. */
  80291. get readyState(): number;
  80292. /**
  80293. * Returns client's status
  80294. */
  80295. get status(): number;
  80296. /**
  80297. * Returns client's status as a text
  80298. */
  80299. get statusText(): string;
  80300. /**
  80301. * Returns client's response
  80302. */
  80303. get response(): any;
  80304. /**
  80305. * Returns client's response url
  80306. */
  80307. get responseURL(): string;
  80308. /**
  80309. * Returns client's response as text
  80310. */
  80311. get responseText(): string;
  80312. /**
  80313. * Gets or sets the expected response type
  80314. */
  80315. get responseType(): XMLHttpRequestResponseType;
  80316. set responseType(value: XMLHttpRequestResponseType);
  80317. /** @hidden */
  80318. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  80319. /** @hidden */
  80320. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  80321. /**
  80322. * Cancels any network activity
  80323. */
  80324. abort(): void;
  80325. /**
  80326. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  80327. * @param body defines an optional request body
  80328. */
  80329. send(body?: Document | BodyInit | null): void;
  80330. /**
  80331. * Sets the request method, request URL
  80332. * @param method defines the method to use (GET, POST, etc..)
  80333. * @param url defines the url to connect with
  80334. */
  80335. open(method: string, url: string): void;
  80336. /**
  80337. * Sets the value of a request header.
  80338. * @param name The name of the header whose value is to be set
  80339. * @param value The value to set as the body of the header
  80340. */
  80341. setRequestHeader(name: string, value: string): void;
  80342. /**
  80343. * Get the string containing the text of a particular header's value.
  80344. * @param name The name of the header
  80345. * @returns The string containing the text of the given header name
  80346. */
  80347. getResponseHeader(name: string): Nullable<string>;
  80348. }
  80349. }
  80350. declare module BABYLON {
  80351. /**
  80352. * File request interface
  80353. */
  80354. export interface IFileRequest {
  80355. /**
  80356. * Raised when the request is complete (success or error).
  80357. */
  80358. onCompleteObservable: Observable<IFileRequest>;
  80359. /**
  80360. * Aborts the request for a file.
  80361. */
  80362. abort: () => void;
  80363. }
  80364. }
  80365. declare module BABYLON {
  80366. /**
  80367. * Define options used to create a render target texture
  80368. */
  80369. export class RenderTargetCreationOptions {
  80370. /**
  80371. * Specifies is mipmaps must be generated
  80372. */
  80373. generateMipMaps?: boolean;
  80374. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  80375. generateDepthBuffer?: boolean;
  80376. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  80377. generateStencilBuffer?: boolean;
  80378. /** Defines texture type (int by default) */
  80379. type?: number;
  80380. /** Defines sampling mode (trilinear by default) */
  80381. samplingMode?: number;
  80382. /** Defines format (RGBA by default) */
  80383. format?: number;
  80384. }
  80385. }
  80386. declare module BABYLON {
  80387. /** Defines the cross module used constants to avoid circular dependncies */
  80388. export class Constants {
  80389. /** Defines that alpha blending is disabled */
  80390. static readonly ALPHA_DISABLE: number;
  80391. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  80392. static readonly ALPHA_ADD: number;
  80393. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  80394. static readonly ALPHA_COMBINE: number;
  80395. /** Defines that alpha blending is DEST - SRC * DEST */
  80396. static readonly ALPHA_SUBTRACT: number;
  80397. /** Defines that alpha blending is SRC * DEST */
  80398. static readonly ALPHA_MULTIPLY: number;
  80399. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  80400. static readonly ALPHA_MAXIMIZED: number;
  80401. /** Defines that alpha blending is SRC + DEST */
  80402. static readonly ALPHA_ONEONE: number;
  80403. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  80404. static readonly ALPHA_PREMULTIPLIED: number;
  80405. /**
  80406. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  80407. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  80408. */
  80409. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  80410. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  80411. static readonly ALPHA_INTERPOLATE: number;
  80412. /**
  80413. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  80414. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  80415. */
  80416. static readonly ALPHA_SCREENMODE: number;
  80417. /**
  80418. * Defines that alpha blending is SRC + DST
  80419. * Alpha will be set to SRC ALPHA + DST ALPHA
  80420. */
  80421. static readonly ALPHA_ONEONE_ONEONE: number;
  80422. /**
  80423. * Defines that alpha blending is SRC * DST ALPHA + DST
  80424. * Alpha will be set to 0
  80425. */
  80426. static readonly ALPHA_ALPHATOCOLOR: number;
  80427. /**
  80428. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  80429. */
  80430. static readonly ALPHA_REVERSEONEMINUS: number;
  80431. /**
  80432. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  80433. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  80434. */
  80435. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  80436. /**
  80437. * Defines that alpha blending is SRC + DST
  80438. * Alpha will be set to SRC ALPHA
  80439. */
  80440. static readonly ALPHA_ONEONE_ONEZERO: number;
  80441. /**
  80442. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  80443. * Alpha will be set to DST ALPHA
  80444. */
  80445. static readonly ALPHA_EXCLUSION: number;
  80446. /** Defines that alpha blending equation a SUM */
  80447. static readonly ALPHA_EQUATION_ADD: number;
  80448. /** Defines that alpha blending equation a SUBSTRACTION */
  80449. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  80450. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  80451. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  80452. /** Defines that alpha blending equation a MAX operation */
  80453. static readonly ALPHA_EQUATION_MAX: number;
  80454. /** Defines that alpha blending equation a MIN operation */
  80455. static readonly ALPHA_EQUATION_MIN: number;
  80456. /**
  80457. * Defines that alpha blending equation a DARKEN operation:
  80458. * It takes the min of the src and sums the alpha channels.
  80459. */
  80460. static readonly ALPHA_EQUATION_DARKEN: number;
  80461. /** Defines that the ressource is not delayed*/
  80462. static readonly DELAYLOADSTATE_NONE: number;
  80463. /** Defines that the ressource was successfully delay loaded */
  80464. static readonly DELAYLOADSTATE_LOADED: number;
  80465. /** Defines that the ressource is currently delay loading */
  80466. static readonly DELAYLOADSTATE_LOADING: number;
  80467. /** Defines that the ressource is delayed and has not started loading */
  80468. static readonly DELAYLOADSTATE_NOTLOADED: number;
  80469. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  80470. static readonly NEVER: number;
  80471. /** 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 */
  80472. static readonly ALWAYS: number;
  80473. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  80474. static readonly LESS: number;
  80475. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  80476. static readonly EQUAL: number;
  80477. /** 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 */
  80478. static readonly LEQUAL: number;
  80479. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  80480. static readonly GREATER: number;
  80481. /** 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 */
  80482. static readonly GEQUAL: number;
  80483. /** 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 */
  80484. static readonly NOTEQUAL: number;
  80485. /** Passed to stencilOperation to specify that stencil value must be kept */
  80486. static readonly KEEP: number;
  80487. /** Passed to stencilOperation to specify that stencil value must be replaced */
  80488. static readonly REPLACE: number;
  80489. /** Passed to stencilOperation to specify that stencil value must be incremented */
  80490. static readonly INCR: number;
  80491. /** Passed to stencilOperation to specify that stencil value must be decremented */
  80492. static readonly DECR: number;
  80493. /** Passed to stencilOperation to specify that stencil value must be inverted */
  80494. static readonly INVERT: number;
  80495. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  80496. static readonly INCR_WRAP: number;
  80497. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  80498. static readonly DECR_WRAP: number;
  80499. /** Texture is not repeating outside of 0..1 UVs */
  80500. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  80501. /** Texture is repeating outside of 0..1 UVs */
  80502. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  80503. /** Texture is repeating and mirrored */
  80504. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  80505. /** ALPHA */
  80506. static readonly TEXTUREFORMAT_ALPHA: number;
  80507. /** LUMINANCE */
  80508. static readonly TEXTUREFORMAT_LUMINANCE: number;
  80509. /** LUMINANCE_ALPHA */
  80510. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  80511. /** RGB */
  80512. static readonly TEXTUREFORMAT_RGB: number;
  80513. /** RGBA */
  80514. static readonly TEXTUREFORMAT_RGBA: number;
  80515. /** RED */
  80516. static readonly TEXTUREFORMAT_RED: number;
  80517. /** RED (2nd reference) */
  80518. static readonly TEXTUREFORMAT_R: number;
  80519. /** RG */
  80520. static readonly TEXTUREFORMAT_RG: number;
  80521. /** RED_INTEGER */
  80522. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  80523. /** RED_INTEGER (2nd reference) */
  80524. static readonly TEXTUREFORMAT_R_INTEGER: number;
  80525. /** RG_INTEGER */
  80526. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  80527. /** RGB_INTEGER */
  80528. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  80529. /** RGBA_INTEGER */
  80530. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  80531. /** UNSIGNED_BYTE */
  80532. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  80533. /** UNSIGNED_BYTE (2nd reference) */
  80534. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  80535. /** FLOAT */
  80536. static readonly TEXTURETYPE_FLOAT: number;
  80537. /** HALF_FLOAT */
  80538. static readonly TEXTURETYPE_HALF_FLOAT: number;
  80539. /** BYTE */
  80540. static readonly TEXTURETYPE_BYTE: number;
  80541. /** SHORT */
  80542. static readonly TEXTURETYPE_SHORT: number;
  80543. /** UNSIGNED_SHORT */
  80544. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  80545. /** INT */
  80546. static readonly TEXTURETYPE_INT: number;
  80547. /** UNSIGNED_INT */
  80548. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  80549. /** UNSIGNED_SHORT_4_4_4_4 */
  80550. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  80551. /** UNSIGNED_SHORT_5_5_5_1 */
  80552. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  80553. /** UNSIGNED_SHORT_5_6_5 */
  80554. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  80555. /** UNSIGNED_INT_2_10_10_10_REV */
  80556. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  80557. /** UNSIGNED_INT_24_8 */
  80558. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  80559. /** UNSIGNED_INT_10F_11F_11F_REV */
  80560. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  80561. /** UNSIGNED_INT_5_9_9_9_REV */
  80562. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  80563. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  80564. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  80565. /** nearest is mag = nearest and min = nearest and no mip */
  80566. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  80567. /** mag = nearest and min = nearest and mip = none */
  80568. static readonly TEXTURE_NEAREST_NEAREST: number;
  80569. /** Bilinear is mag = linear and min = linear and no mip */
  80570. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  80571. /** mag = linear and min = linear and mip = none */
  80572. static readonly TEXTURE_LINEAR_LINEAR: number;
  80573. /** Trilinear is mag = linear and min = linear and mip = linear */
  80574. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  80575. /** Trilinear is mag = linear and min = linear and mip = linear */
  80576. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  80577. /** mag = nearest and min = nearest and mip = nearest */
  80578. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  80579. /** mag = nearest and min = linear and mip = nearest */
  80580. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  80581. /** mag = nearest and min = linear and mip = linear */
  80582. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  80583. /** mag = nearest and min = linear and mip = none */
  80584. static readonly TEXTURE_NEAREST_LINEAR: number;
  80585. /** nearest is mag = nearest and min = nearest and mip = linear */
  80586. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  80587. /** mag = linear and min = nearest and mip = nearest */
  80588. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  80589. /** mag = linear and min = nearest and mip = linear */
  80590. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  80591. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80592. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  80593. /** mag = linear and min = nearest and mip = none */
  80594. static readonly TEXTURE_LINEAR_NEAREST: number;
  80595. /** Explicit coordinates mode */
  80596. static readonly TEXTURE_EXPLICIT_MODE: number;
  80597. /** Spherical coordinates mode */
  80598. static readonly TEXTURE_SPHERICAL_MODE: number;
  80599. /** Planar coordinates mode */
  80600. static readonly TEXTURE_PLANAR_MODE: number;
  80601. /** Cubic coordinates mode */
  80602. static readonly TEXTURE_CUBIC_MODE: number;
  80603. /** Projection coordinates mode */
  80604. static readonly TEXTURE_PROJECTION_MODE: number;
  80605. /** Skybox coordinates mode */
  80606. static readonly TEXTURE_SKYBOX_MODE: number;
  80607. /** Inverse Cubic coordinates mode */
  80608. static readonly TEXTURE_INVCUBIC_MODE: number;
  80609. /** Equirectangular coordinates mode */
  80610. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  80611. /** Equirectangular Fixed coordinates mode */
  80612. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  80613. /** Equirectangular Fixed Mirrored coordinates mode */
  80614. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  80615. /** Offline (baking) quality for texture filtering */
  80616. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  80617. /** High quality for texture filtering */
  80618. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  80619. /** Medium quality for texture filtering */
  80620. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  80621. /** Low quality for texture filtering */
  80622. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  80623. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  80624. static readonly SCALEMODE_FLOOR: number;
  80625. /** Defines that texture rescaling will look for the nearest power of 2 size */
  80626. static readonly SCALEMODE_NEAREST: number;
  80627. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  80628. static readonly SCALEMODE_CEILING: number;
  80629. /**
  80630. * The dirty texture flag value
  80631. */
  80632. static readonly MATERIAL_TextureDirtyFlag: number;
  80633. /**
  80634. * The dirty light flag value
  80635. */
  80636. static readonly MATERIAL_LightDirtyFlag: number;
  80637. /**
  80638. * The dirty fresnel flag value
  80639. */
  80640. static readonly MATERIAL_FresnelDirtyFlag: number;
  80641. /**
  80642. * The dirty attribute flag value
  80643. */
  80644. static readonly MATERIAL_AttributesDirtyFlag: number;
  80645. /**
  80646. * The dirty misc flag value
  80647. */
  80648. static readonly MATERIAL_MiscDirtyFlag: number;
  80649. /**
  80650. * The all dirty flag value
  80651. */
  80652. static readonly MATERIAL_AllDirtyFlag: number;
  80653. /**
  80654. * Returns the triangle fill mode
  80655. */
  80656. static readonly MATERIAL_TriangleFillMode: number;
  80657. /**
  80658. * Returns the wireframe mode
  80659. */
  80660. static readonly MATERIAL_WireFrameFillMode: number;
  80661. /**
  80662. * Returns the point fill mode
  80663. */
  80664. static readonly MATERIAL_PointFillMode: number;
  80665. /**
  80666. * Returns the point list draw mode
  80667. */
  80668. static readonly MATERIAL_PointListDrawMode: number;
  80669. /**
  80670. * Returns the line list draw mode
  80671. */
  80672. static readonly MATERIAL_LineListDrawMode: number;
  80673. /**
  80674. * Returns the line loop draw mode
  80675. */
  80676. static readonly MATERIAL_LineLoopDrawMode: number;
  80677. /**
  80678. * Returns the line strip draw mode
  80679. */
  80680. static readonly MATERIAL_LineStripDrawMode: number;
  80681. /**
  80682. * Returns the triangle strip draw mode
  80683. */
  80684. static readonly MATERIAL_TriangleStripDrawMode: number;
  80685. /**
  80686. * Returns the triangle fan draw mode
  80687. */
  80688. static readonly MATERIAL_TriangleFanDrawMode: number;
  80689. /**
  80690. * Stores the clock-wise side orientation
  80691. */
  80692. static readonly MATERIAL_ClockWiseSideOrientation: number;
  80693. /**
  80694. * Stores the counter clock-wise side orientation
  80695. */
  80696. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  80697. /**
  80698. * Nothing
  80699. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80700. */
  80701. static readonly ACTION_NothingTrigger: number;
  80702. /**
  80703. * On pick
  80704. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80705. */
  80706. static readonly ACTION_OnPickTrigger: number;
  80707. /**
  80708. * On left pick
  80709. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80710. */
  80711. static readonly ACTION_OnLeftPickTrigger: number;
  80712. /**
  80713. * On right pick
  80714. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80715. */
  80716. static readonly ACTION_OnRightPickTrigger: number;
  80717. /**
  80718. * On center pick
  80719. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80720. */
  80721. static readonly ACTION_OnCenterPickTrigger: number;
  80722. /**
  80723. * On pick down
  80724. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80725. */
  80726. static readonly ACTION_OnPickDownTrigger: number;
  80727. /**
  80728. * On double pick
  80729. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80730. */
  80731. static readonly ACTION_OnDoublePickTrigger: number;
  80732. /**
  80733. * On pick up
  80734. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80735. */
  80736. static readonly ACTION_OnPickUpTrigger: number;
  80737. /**
  80738. * On pick out.
  80739. * This trigger will only be raised if you also declared a OnPickDown
  80740. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80741. */
  80742. static readonly ACTION_OnPickOutTrigger: number;
  80743. /**
  80744. * On long press
  80745. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80746. */
  80747. static readonly ACTION_OnLongPressTrigger: number;
  80748. /**
  80749. * On pointer over
  80750. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80751. */
  80752. static readonly ACTION_OnPointerOverTrigger: number;
  80753. /**
  80754. * On pointer out
  80755. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80756. */
  80757. static readonly ACTION_OnPointerOutTrigger: number;
  80758. /**
  80759. * On every frame
  80760. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80761. */
  80762. static readonly ACTION_OnEveryFrameTrigger: number;
  80763. /**
  80764. * On intersection enter
  80765. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80766. */
  80767. static readonly ACTION_OnIntersectionEnterTrigger: number;
  80768. /**
  80769. * On intersection exit
  80770. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80771. */
  80772. static readonly ACTION_OnIntersectionExitTrigger: number;
  80773. /**
  80774. * On key down
  80775. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80776. */
  80777. static readonly ACTION_OnKeyDownTrigger: number;
  80778. /**
  80779. * On key up
  80780. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  80781. */
  80782. static readonly ACTION_OnKeyUpTrigger: number;
  80783. /**
  80784. * Billboard mode will only apply to Y axis
  80785. */
  80786. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  80787. /**
  80788. * Billboard mode will apply to all axes
  80789. */
  80790. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  80791. /**
  80792. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  80793. */
  80794. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  80795. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  80796. * Test order :
  80797. * Is the bounding sphere outside the frustum ?
  80798. * If not, are the bounding box vertices outside the frustum ?
  80799. * It not, then the cullable object is in the frustum.
  80800. */
  80801. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  80802. /** Culling strategy : Bounding Sphere Only.
  80803. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  80804. * It's also less accurate than the standard because some not visible objects can still be selected.
  80805. * Test : is the bounding sphere outside the frustum ?
  80806. * If not, then the cullable object is in the frustum.
  80807. */
  80808. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  80809. /** Culling strategy : Optimistic Inclusion.
  80810. * This in an inclusion test first, then the standard exclusion test.
  80811. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  80812. * 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.
  80813. * Anyway, it's as accurate as the standard strategy.
  80814. * Test :
  80815. * Is the cullable object bounding sphere center in the frustum ?
  80816. * If not, apply the default culling strategy.
  80817. */
  80818. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  80819. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  80820. * This in an inclusion test first, then the bounding sphere only exclusion test.
  80821. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  80822. * 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.
  80823. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  80824. * Test :
  80825. * Is the cullable object bounding sphere center in the frustum ?
  80826. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  80827. */
  80828. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  80829. /**
  80830. * No logging while loading
  80831. */
  80832. static readonly SCENELOADER_NO_LOGGING: number;
  80833. /**
  80834. * Minimal logging while loading
  80835. */
  80836. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  80837. /**
  80838. * Summary logging while loading
  80839. */
  80840. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  80841. /**
  80842. * Detailled logging while loading
  80843. */
  80844. static readonly SCENELOADER_DETAILED_LOGGING: number;
  80845. /**
  80846. * Prepass texture index for color
  80847. */
  80848. static readonly PREPASS_COLOR_INDEX: number;
  80849. /**
  80850. * Prepass texture index for irradiance
  80851. */
  80852. static readonly PREPASS_IRRADIANCE_INDEX: number;
  80853. /**
  80854. * Prepass texture index for depth + normal
  80855. */
  80856. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  80857. /**
  80858. * Prepass texture index for albedo
  80859. */
  80860. static readonly PREPASS_ALBEDO_INDEX: number;
  80861. }
  80862. }
  80863. declare module BABYLON {
  80864. /**
  80865. * This represents the required contract to create a new type of texture loader.
  80866. */
  80867. export interface IInternalTextureLoader {
  80868. /**
  80869. * Defines wether the loader supports cascade loading the different faces.
  80870. */
  80871. supportCascades: boolean;
  80872. /**
  80873. * This returns if the loader support the current file information.
  80874. * @param extension defines the file extension of the file being loaded
  80875. * @param mimeType defines the optional mime type of the file being loaded
  80876. * @returns true if the loader can load the specified file
  80877. */
  80878. canLoad(extension: string, mimeType?: string): boolean;
  80879. /**
  80880. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  80881. * @param data contains the texture data
  80882. * @param texture defines the BabylonJS internal texture
  80883. * @param createPolynomials will be true if polynomials have been requested
  80884. * @param onLoad defines the callback to trigger once the texture is ready
  80885. * @param onError defines the callback to trigger in case of error
  80886. */
  80887. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  80888. /**
  80889. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  80890. * @param data contains the texture data
  80891. * @param texture defines the BabylonJS internal texture
  80892. * @param callback defines the method to call once ready to upload
  80893. */
  80894. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  80895. }
  80896. }
  80897. declare module BABYLON {
  80898. /**
  80899. * Class used to store and describe the pipeline context associated with an effect
  80900. */
  80901. export interface IPipelineContext {
  80902. /**
  80903. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  80904. */
  80905. isAsync: boolean;
  80906. /**
  80907. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  80908. */
  80909. isReady: boolean;
  80910. /** @hidden */
  80911. _getVertexShaderCode(): string | null;
  80912. /** @hidden */
  80913. _getFragmentShaderCode(): string | null;
  80914. /** @hidden */
  80915. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  80916. }
  80917. }
  80918. declare module BABYLON {
  80919. /**
  80920. * Class used to store gfx data (like WebGLBuffer)
  80921. */
  80922. export class DataBuffer {
  80923. /**
  80924. * Gets or sets the number of objects referencing this buffer
  80925. */
  80926. references: number;
  80927. /** Gets or sets the size of the underlying buffer */
  80928. capacity: number;
  80929. /**
  80930. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  80931. */
  80932. is32Bits: boolean;
  80933. /**
  80934. * Gets the underlying buffer
  80935. */
  80936. get underlyingResource(): any;
  80937. }
  80938. }
  80939. declare module BABYLON {
  80940. /** @hidden */
  80941. export interface IShaderProcessor {
  80942. attributeProcessor?: (attribute: string) => string;
  80943. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  80944. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  80945. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  80946. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  80947. lineProcessor?: (line: string, isFragment: boolean) => string;
  80948. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  80949. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  80950. }
  80951. }
  80952. declare module BABYLON {
  80953. /** @hidden */
  80954. export interface ProcessingOptions {
  80955. defines: string[];
  80956. indexParameters: any;
  80957. isFragment: boolean;
  80958. shouldUseHighPrecisionShader: boolean;
  80959. supportsUniformBuffers: boolean;
  80960. shadersRepository: string;
  80961. includesShadersStore: {
  80962. [key: string]: string;
  80963. };
  80964. processor?: IShaderProcessor;
  80965. version: string;
  80966. platformName: string;
  80967. lookForClosingBracketForUniformBuffer?: boolean;
  80968. }
  80969. }
  80970. declare module BABYLON {
  80971. /** @hidden */
  80972. export class ShaderCodeNode {
  80973. line: string;
  80974. children: ShaderCodeNode[];
  80975. additionalDefineKey?: string;
  80976. additionalDefineValue?: string;
  80977. isValid(preprocessors: {
  80978. [key: string]: string;
  80979. }): boolean;
  80980. process(preprocessors: {
  80981. [key: string]: string;
  80982. }, options: ProcessingOptions): string;
  80983. }
  80984. }
  80985. declare module BABYLON {
  80986. /** @hidden */
  80987. export class ShaderCodeCursor {
  80988. private _lines;
  80989. lineIndex: number;
  80990. get currentLine(): string;
  80991. get canRead(): boolean;
  80992. set lines(value: string[]);
  80993. }
  80994. }
  80995. declare module BABYLON {
  80996. /** @hidden */
  80997. export class ShaderCodeConditionNode extends ShaderCodeNode {
  80998. process(preprocessors: {
  80999. [key: string]: string;
  81000. }, options: ProcessingOptions): string;
  81001. }
  81002. }
  81003. declare module BABYLON {
  81004. /** @hidden */
  81005. export class ShaderDefineExpression {
  81006. isTrue(preprocessors: {
  81007. [key: string]: string;
  81008. }): boolean;
  81009. private static _OperatorPriority;
  81010. private static _Stack;
  81011. static postfixToInfix(postfix: string[]): string;
  81012. static infixToPostfix(infix: string): string[];
  81013. }
  81014. }
  81015. declare module BABYLON {
  81016. /** @hidden */
  81017. export class ShaderCodeTestNode extends ShaderCodeNode {
  81018. testExpression: ShaderDefineExpression;
  81019. isValid(preprocessors: {
  81020. [key: string]: string;
  81021. }): boolean;
  81022. }
  81023. }
  81024. declare module BABYLON {
  81025. /** @hidden */
  81026. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  81027. define: string;
  81028. not: boolean;
  81029. constructor(define: string, not?: boolean);
  81030. isTrue(preprocessors: {
  81031. [key: string]: string;
  81032. }): boolean;
  81033. }
  81034. }
  81035. declare module BABYLON {
  81036. /** @hidden */
  81037. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  81038. leftOperand: ShaderDefineExpression;
  81039. rightOperand: ShaderDefineExpression;
  81040. isTrue(preprocessors: {
  81041. [key: string]: string;
  81042. }): boolean;
  81043. }
  81044. }
  81045. declare module BABYLON {
  81046. /** @hidden */
  81047. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  81048. leftOperand: ShaderDefineExpression;
  81049. rightOperand: ShaderDefineExpression;
  81050. isTrue(preprocessors: {
  81051. [key: string]: string;
  81052. }): boolean;
  81053. }
  81054. }
  81055. declare module BABYLON {
  81056. /** @hidden */
  81057. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  81058. define: string;
  81059. operand: string;
  81060. testValue: string;
  81061. constructor(define: string, operand: string, testValue: string);
  81062. isTrue(preprocessors: {
  81063. [key: string]: string;
  81064. }): boolean;
  81065. }
  81066. }
  81067. declare module BABYLON {
  81068. /**
  81069. * Class used to enable access to offline support
  81070. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  81071. */
  81072. export interface IOfflineProvider {
  81073. /**
  81074. * Gets a boolean indicating if scene must be saved in the database
  81075. */
  81076. enableSceneOffline: boolean;
  81077. /**
  81078. * Gets a boolean indicating if textures must be saved in the database
  81079. */
  81080. enableTexturesOffline: boolean;
  81081. /**
  81082. * Open the offline support and make it available
  81083. * @param successCallback defines the callback to call on success
  81084. * @param errorCallback defines the callback to call on error
  81085. */
  81086. open(successCallback: () => void, errorCallback: () => void): void;
  81087. /**
  81088. * Loads an image from the offline support
  81089. * @param url defines the url to load from
  81090. * @param image defines the target DOM image
  81091. */
  81092. loadImage(url: string, image: HTMLImageElement): void;
  81093. /**
  81094. * Loads a file from offline support
  81095. * @param url defines the URL to load from
  81096. * @param sceneLoaded defines a callback to call on success
  81097. * @param progressCallBack defines a callback to call when progress changed
  81098. * @param errorCallback defines a callback to call on error
  81099. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  81100. */
  81101. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  81102. }
  81103. }
  81104. declare module BABYLON {
  81105. /**
  81106. * Class used to help managing file picking and drag'n'drop
  81107. * File Storage
  81108. */
  81109. export class FilesInputStore {
  81110. /**
  81111. * List of files ready to be loaded
  81112. */
  81113. static FilesToLoad: {
  81114. [key: string]: File;
  81115. };
  81116. }
  81117. }
  81118. declare module BABYLON {
  81119. /**
  81120. * Class used to define a retry strategy when error happens while loading assets
  81121. */
  81122. export class RetryStrategy {
  81123. /**
  81124. * Function used to defines an exponential back off strategy
  81125. * @param maxRetries defines the maximum number of retries (3 by default)
  81126. * @param baseInterval defines the interval between retries
  81127. * @returns the strategy function to use
  81128. */
  81129. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  81130. }
  81131. }
  81132. declare module BABYLON {
  81133. /**
  81134. * @ignore
  81135. * Application error to support additional information when loading a file
  81136. */
  81137. export abstract class BaseError extends Error {
  81138. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  81139. }
  81140. }
  81141. declare module BABYLON {
  81142. /** @ignore */
  81143. export class LoadFileError extends BaseError {
  81144. request?: WebRequest;
  81145. file?: File;
  81146. /**
  81147. * Creates a new LoadFileError
  81148. * @param message defines the message of the error
  81149. * @param request defines the optional web request
  81150. * @param file defines the optional file
  81151. */
  81152. constructor(message: string, object?: WebRequest | File);
  81153. }
  81154. /** @ignore */
  81155. export class RequestFileError extends BaseError {
  81156. request: WebRequest;
  81157. /**
  81158. * Creates a new LoadFileError
  81159. * @param message defines the message of the error
  81160. * @param request defines the optional web request
  81161. */
  81162. constructor(message: string, request: WebRequest);
  81163. }
  81164. /** @ignore */
  81165. export class ReadFileError extends BaseError {
  81166. file: File;
  81167. /**
  81168. * Creates a new ReadFileError
  81169. * @param message defines the message of the error
  81170. * @param file defines the optional file
  81171. */
  81172. constructor(message: string, file: File);
  81173. }
  81174. /**
  81175. * @hidden
  81176. */
  81177. export class FileTools {
  81178. /**
  81179. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  81180. */
  81181. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  81182. /**
  81183. * Gets or sets the base URL to use to load assets
  81184. */
  81185. static BaseUrl: string;
  81186. /**
  81187. * Default behaviour for cors in the application.
  81188. * It can be a string if the expected behavior is identical in the entire app.
  81189. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  81190. */
  81191. static CorsBehavior: string | ((url: string | string[]) => string);
  81192. /**
  81193. * Gets or sets a function used to pre-process url before using them to load assets
  81194. */
  81195. static PreprocessUrl: (url: string) => string;
  81196. /**
  81197. * Removes unwanted characters from an url
  81198. * @param url defines the url to clean
  81199. * @returns the cleaned url
  81200. */
  81201. private static _CleanUrl;
  81202. /**
  81203. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  81204. * @param url define the url we are trying
  81205. * @param element define the dom element where to configure the cors policy
  81206. */
  81207. static SetCorsBehavior(url: string | string[], element: {
  81208. crossOrigin: string | null;
  81209. }): void;
  81210. /**
  81211. * Loads an image as an HTMLImageElement.
  81212. * @param input url string, ArrayBuffer, or Blob to load
  81213. * @param onLoad callback called when the image successfully loads
  81214. * @param onError callback called when the image fails to load
  81215. * @param offlineProvider offline provider for caching
  81216. * @param mimeType optional mime type
  81217. * @returns the HTMLImageElement of the loaded image
  81218. */
  81219. 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>;
  81220. /**
  81221. * Reads a file from a File object
  81222. * @param file defines the file to load
  81223. * @param onSuccess defines the callback to call when data is loaded
  81224. * @param onProgress defines the callback to call during loading process
  81225. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  81226. * @param onError defines the callback to call when an error occurs
  81227. * @returns a file request object
  81228. */
  81229. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  81230. /**
  81231. * Loads a file from a url
  81232. * @param url url to load
  81233. * @param onSuccess callback called when the file successfully loads
  81234. * @param onProgress callback called while file is loading (if the server supports this mode)
  81235. * @param offlineProvider defines the offline provider for caching
  81236. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81237. * @param onError callback called when the file fails to load
  81238. * @returns a file request object
  81239. */
  81240. 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;
  81241. /**
  81242. * Loads a file
  81243. * @param url url to load
  81244. * @param onSuccess callback called when the file successfully loads
  81245. * @param onProgress callback called while file is loading (if the server supports this mode)
  81246. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81247. * @param onError callback called when the file fails to load
  81248. * @param onOpened callback called when the web request is opened
  81249. * @returns a file request object
  81250. */
  81251. 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;
  81252. /**
  81253. * Checks if the loaded document was accessed via `file:`-Protocol.
  81254. * @returns boolean
  81255. */
  81256. static IsFileURL(): boolean;
  81257. }
  81258. }
  81259. declare module BABYLON {
  81260. /** @hidden */
  81261. export class ShaderProcessor {
  81262. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  81263. private static _ProcessPrecision;
  81264. private static _ExtractOperation;
  81265. private static _BuildSubExpression;
  81266. private static _BuildExpression;
  81267. private static _MoveCursorWithinIf;
  81268. private static _MoveCursor;
  81269. private static _EvaluatePreProcessors;
  81270. private static _PreparePreProcessors;
  81271. private static _ProcessShaderConversion;
  81272. private static _ProcessIncludes;
  81273. /**
  81274. * Loads a file from a url
  81275. * @param url url to load
  81276. * @param onSuccess callback called when the file successfully loads
  81277. * @param onProgress callback called while file is loading (if the server supports this mode)
  81278. * @param offlineProvider defines the offline provider for caching
  81279. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81280. * @param onError callback called when the file fails to load
  81281. * @returns a file request object
  81282. * @hidden
  81283. */
  81284. 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;
  81285. }
  81286. }
  81287. declare module BABYLON {
  81288. /**
  81289. * @hidden
  81290. */
  81291. export interface IColor4Like {
  81292. r: float;
  81293. g: float;
  81294. b: float;
  81295. a: float;
  81296. }
  81297. /**
  81298. * @hidden
  81299. */
  81300. export interface IColor3Like {
  81301. r: float;
  81302. g: float;
  81303. b: float;
  81304. }
  81305. /**
  81306. * @hidden
  81307. */
  81308. export interface IVector4Like {
  81309. x: float;
  81310. y: float;
  81311. z: float;
  81312. w: float;
  81313. }
  81314. /**
  81315. * @hidden
  81316. */
  81317. export interface IVector3Like {
  81318. x: float;
  81319. y: float;
  81320. z: float;
  81321. }
  81322. /**
  81323. * @hidden
  81324. */
  81325. export interface IVector2Like {
  81326. x: float;
  81327. y: float;
  81328. }
  81329. /**
  81330. * @hidden
  81331. */
  81332. export interface IMatrixLike {
  81333. toArray(): DeepImmutable<Float32Array | Array<number>>;
  81334. updateFlag: int;
  81335. }
  81336. /**
  81337. * @hidden
  81338. */
  81339. export interface IViewportLike {
  81340. x: float;
  81341. y: float;
  81342. width: float;
  81343. height: float;
  81344. }
  81345. /**
  81346. * @hidden
  81347. */
  81348. export interface IPlaneLike {
  81349. normal: IVector3Like;
  81350. d: float;
  81351. normalize(): void;
  81352. }
  81353. }
  81354. declare module BABYLON {
  81355. /**
  81356. * Interface used to define common properties for effect fallbacks
  81357. */
  81358. export interface IEffectFallbacks {
  81359. /**
  81360. * Removes the defines that should be removed when falling back.
  81361. * @param currentDefines defines the current define statements for the shader.
  81362. * @param effect defines the current effect we try to compile
  81363. * @returns The resulting defines with defines of the current rank removed.
  81364. */
  81365. reduce(currentDefines: string, effect: Effect): string;
  81366. /**
  81367. * Removes the fallback from the bound mesh.
  81368. */
  81369. unBindMesh(): void;
  81370. /**
  81371. * Checks to see if more fallbacks are still availible.
  81372. */
  81373. hasMoreFallbacks: boolean;
  81374. }
  81375. }
  81376. declare module BABYLON {
  81377. /**
  81378. * Class used to evalaute queries containing `and` and `or` operators
  81379. */
  81380. export class AndOrNotEvaluator {
  81381. /**
  81382. * Evaluate a query
  81383. * @param query defines the query to evaluate
  81384. * @param evaluateCallback defines the callback used to filter result
  81385. * @returns true if the query matches
  81386. */
  81387. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  81388. private static _HandleParenthesisContent;
  81389. private static _SimplifyNegation;
  81390. }
  81391. }
  81392. declare module BABYLON {
  81393. /**
  81394. * Class used to store custom tags
  81395. */
  81396. export class Tags {
  81397. /**
  81398. * Adds support for tags on the given object
  81399. * @param obj defines the object to use
  81400. */
  81401. static EnableFor(obj: any): void;
  81402. /**
  81403. * Removes tags support
  81404. * @param obj defines the object to use
  81405. */
  81406. static DisableFor(obj: any): void;
  81407. /**
  81408. * Gets a boolean indicating if the given object has tags
  81409. * @param obj defines the object to use
  81410. * @returns a boolean
  81411. */
  81412. static HasTags(obj: any): boolean;
  81413. /**
  81414. * Gets the tags available on a given object
  81415. * @param obj defines the object to use
  81416. * @param asString defines if the tags must be returned as a string instead of an array of strings
  81417. * @returns the tags
  81418. */
  81419. static GetTags(obj: any, asString?: boolean): any;
  81420. /**
  81421. * Adds tags to an object
  81422. * @param obj defines the object to use
  81423. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  81424. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  81425. */
  81426. static AddTagsTo(obj: any, tagsString: string): void;
  81427. /**
  81428. * @hidden
  81429. */
  81430. static _AddTagTo(obj: any, tag: string): void;
  81431. /**
  81432. * Removes specific tags from a specific object
  81433. * @param obj defines the object to use
  81434. * @param tagsString defines the tags to remove
  81435. */
  81436. static RemoveTagsFrom(obj: any, tagsString: string): void;
  81437. /**
  81438. * @hidden
  81439. */
  81440. static _RemoveTagFrom(obj: any, tag: string): void;
  81441. /**
  81442. * Defines if tags hosted on an object match a given query
  81443. * @param obj defines the object to use
  81444. * @param tagsQuery defines the tag query
  81445. * @returns a boolean
  81446. */
  81447. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  81448. }
  81449. }
  81450. declare module BABYLON {
  81451. /**
  81452. * Scalar computation library
  81453. */
  81454. export class Scalar {
  81455. /**
  81456. * Two pi constants convenient for computation.
  81457. */
  81458. static TwoPi: number;
  81459. /**
  81460. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  81461. * @param a number
  81462. * @param b number
  81463. * @param epsilon (default = 1.401298E-45)
  81464. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  81465. */
  81466. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  81467. /**
  81468. * Returns a string : the upper case translation of the number i to hexadecimal.
  81469. * @param i number
  81470. * @returns the upper case translation of the number i to hexadecimal.
  81471. */
  81472. static ToHex(i: number): string;
  81473. /**
  81474. * Returns -1 if value is negative and +1 is value is positive.
  81475. * @param value the value
  81476. * @returns the value itself if it's equal to zero.
  81477. */
  81478. static Sign(value: number): number;
  81479. /**
  81480. * Returns the value itself if it's between min and max.
  81481. * Returns min if the value is lower than min.
  81482. * Returns max if the value is greater than max.
  81483. * @param value the value to clmap
  81484. * @param min the min value to clamp to (default: 0)
  81485. * @param max the max value to clamp to (default: 1)
  81486. * @returns the clamped value
  81487. */
  81488. static Clamp(value: number, min?: number, max?: number): number;
  81489. /**
  81490. * the log2 of value.
  81491. * @param value the value to compute log2 of
  81492. * @returns the log2 of value.
  81493. */
  81494. static Log2(value: number): number;
  81495. /**
  81496. * Loops the value, so that it is never larger than length and never smaller than 0.
  81497. *
  81498. * This is similar to the modulo operator but it works with floating point numbers.
  81499. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  81500. * With t = 5 and length = 2.5, the result would be 0.0.
  81501. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  81502. * @param value the value
  81503. * @param length the length
  81504. * @returns the looped value
  81505. */
  81506. static Repeat(value: number, length: number): number;
  81507. /**
  81508. * Normalize the value between 0.0 and 1.0 using min and max values
  81509. * @param value value to normalize
  81510. * @param min max to normalize between
  81511. * @param max min to normalize between
  81512. * @returns the normalized value
  81513. */
  81514. static Normalize(value: number, min: number, max: number): number;
  81515. /**
  81516. * Denormalize the value from 0.0 and 1.0 using min and max values
  81517. * @param normalized value to denormalize
  81518. * @param min max to denormalize between
  81519. * @param max min to denormalize between
  81520. * @returns the denormalized value
  81521. */
  81522. static Denormalize(normalized: number, min: number, max: number): number;
  81523. /**
  81524. * Calculates the shortest difference between two given angles given in degrees.
  81525. * @param current current angle in degrees
  81526. * @param target target angle in degrees
  81527. * @returns the delta
  81528. */
  81529. static DeltaAngle(current: number, target: number): number;
  81530. /**
  81531. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  81532. * @param tx value
  81533. * @param length length
  81534. * @returns The returned value will move back and forth between 0 and length
  81535. */
  81536. static PingPong(tx: number, length: number): number;
  81537. /**
  81538. * Interpolates between min and max with smoothing at the limits.
  81539. *
  81540. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  81541. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  81542. * @param from from
  81543. * @param to to
  81544. * @param tx value
  81545. * @returns the smooth stepped value
  81546. */
  81547. static SmoothStep(from: number, to: number, tx: number): number;
  81548. /**
  81549. * Moves a value current towards target.
  81550. *
  81551. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  81552. * Negative values of maxDelta pushes the value away from target.
  81553. * @param current current value
  81554. * @param target target value
  81555. * @param maxDelta max distance to move
  81556. * @returns resulting value
  81557. */
  81558. static MoveTowards(current: number, target: number, maxDelta: number): number;
  81559. /**
  81560. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  81561. *
  81562. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  81563. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  81564. * @param current current value
  81565. * @param target target value
  81566. * @param maxDelta max distance to move
  81567. * @returns resulting angle
  81568. */
  81569. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  81570. /**
  81571. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  81572. * @param start start value
  81573. * @param end target value
  81574. * @param amount amount to lerp between
  81575. * @returns the lerped value
  81576. */
  81577. static Lerp(start: number, end: number, amount: number): number;
  81578. /**
  81579. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  81580. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  81581. * @param start start value
  81582. * @param end target value
  81583. * @param amount amount to lerp between
  81584. * @returns the lerped value
  81585. */
  81586. static LerpAngle(start: number, end: number, amount: number): number;
  81587. /**
  81588. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  81589. * @param a start value
  81590. * @param b target value
  81591. * @param value value between a and b
  81592. * @returns the inverseLerp value
  81593. */
  81594. static InverseLerp(a: number, b: number, value: number): number;
  81595. /**
  81596. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  81597. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  81598. * @param value1 spline value
  81599. * @param tangent1 spline value
  81600. * @param value2 spline value
  81601. * @param tangent2 spline value
  81602. * @param amount input value
  81603. * @returns hermite result
  81604. */
  81605. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  81606. /**
  81607. * Returns a random float number between and min and max values
  81608. * @param min min value of random
  81609. * @param max max value of random
  81610. * @returns random value
  81611. */
  81612. static RandomRange(min: number, max: number): number;
  81613. /**
  81614. * This function returns percentage of a number in a given range.
  81615. *
  81616. * RangeToPercent(40,20,60) will return 0.5 (50%)
  81617. * RangeToPercent(34,0,100) will return 0.34 (34%)
  81618. * @param number to convert to percentage
  81619. * @param min min range
  81620. * @param max max range
  81621. * @returns the percentage
  81622. */
  81623. static RangeToPercent(number: number, min: number, max: number): number;
  81624. /**
  81625. * This function returns number that corresponds to the percentage in a given range.
  81626. *
  81627. * PercentToRange(0.34,0,100) will return 34.
  81628. * @param percent to convert to number
  81629. * @param min min range
  81630. * @param max max range
  81631. * @returns the number
  81632. */
  81633. static PercentToRange(percent: number, min: number, max: number): number;
  81634. /**
  81635. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  81636. * @param angle The angle to normalize in radian.
  81637. * @return The converted angle.
  81638. */
  81639. static NormalizeRadians(angle: number): number;
  81640. }
  81641. }
  81642. declare module BABYLON {
  81643. /**
  81644. * Constant used to convert a value to gamma space
  81645. * @ignorenaming
  81646. */
  81647. export const ToGammaSpace: number;
  81648. /**
  81649. * Constant used to convert a value to linear space
  81650. * @ignorenaming
  81651. */
  81652. export const ToLinearSpace = 2.2;
  81653. /**
  81654. * Constant used to define the minimal number value in Babylon.js
  81655. * @ignorenaming
  81656. */
  81657. let Epsilon: number;
  81658. }
  81659. declare module BABYLON {
  81660. /**
  81661. * Class used to represent a viewport on screen
  81662. */
  81663. export class Viewport {
  81664. /** viewport left coordinate */
  81665. x: number;
  81666. /** viewport top coordinate */
  81667. y: number;
  81668. /**viewport width */
  81669. width: number;
  81670. /** viewport height */
  81671. height: number;
  81672. /**
  81673. * Creates a Viewport object located at (x, y) and sized (width, height)
  81674. * @param x defines viewport left coordinate
  81675. * @param y defines viewport top coordinate
  81676. * @param width defines the viewport width
  81677. * @param height defines the viewport height
  81678. */
  81679. constructor(
  81680. /** viewport left coordinate */
  81681. x: number,
  81682. /** viewport top coordinate */
  81683. y: number,
  81684. /**viewport width */
  81685. width: number,
  81686. /** viewport height */
  81687. height: number);
  81688. /**
  81689. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  81690. * @param renderWidth defines the rendering width
  81691. * @param renderHeight defines the rendering height
  81692. * @returns a new Viewport
  81693. */
  81694. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  81695. /**
  81696. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  81697. * @param renderWidth defines the rendering width
  81698. * @param renderHeight defines the rendering height
  81699. * @param ref defines the target viewport
  81700. * @returns the current viewport
  81701. */
  81702. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  81703. /**
  81704. * Returns a new Viewport copied from the current one
  81705. * @returns a new Viewport
  81706. */
  81707. clone(): Viewport;
  81708. }
  81709. }
  81710. declare module BABYLON {
  81711. /**
  81712. * Class containing a set of static utilities functions for arrays.
  81713. */
  81714. export class ArrayTools {
  81715. /**
  81716. * Returns an array of the given size filled with element built from the given constructor and the paramters
  81717. * @param size the number of element to construct and put in the array
  81718. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  81719. * @returns a new array filled with new objects
  81720. */
  81721. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  81722. }
  81723. }
  81724. declare module BABYLON {
  81725. /**
  81726. * Represents a plane by the equation ax + by + cz + d = 0
  81727. */
  81728. export class Plane {
  81729. private static _TmpMatrix;
  81730. /**
  81731. * Normal of the plane (a,b,c)
  81732. */
  81733. normal: Vector3;
  81734. /**
  81735. * d component of the plane
  81736. */
  81737. d: number;
  81738. /**
  81739. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  81740. * @param a a component of the plane
  81741. * @param b b component of the plane
  81742. * @param c c component of the plane
  81743. * @param d d component of the plane
  81744. */
  81745. constructor(a: number, b: number, c: number, d: number);
  81746. /**
  81747. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  81748. */
  81749. asArray(): number[];
  81750. /**
  81751. * @returns a new plane copied from the current Plane.
  81752. */
  81753. clone(): Plane;
  81754. /**
  81755. * @returns the string "Plane".
  81756. */
  81757. getClassName(): string;
  81758. /**
  81759. * @returns the Plane hash code.
  81760. */
  81761. getHashCode(): number;
  81762. /**
  81763. * Normalize the current Plane in place.
  81764. * @returns the updated Plane.
  81765. */
  81766. normalize(): Plane;
  81767. /**
  81768. * Applies a transformation the plane and returns the result
  81769. * @param transformation the transformation matrix to be applied to the plane
  81770. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  81771. */
  81772. transform(transformation: DeepImmutable<Matrix>): Plane;
  81773. /**
  81774. * Compute the dot product between the point and the plane normal
  81775. * @param point point to calculate the dot product with
  81776. * @returns the dot product (float) of the point coordinates and the plane normal.
  81777. */
  81778. dotCoordinate(point: DeepImmutable<Vector3>): number;
  81779. /**
  81780. * Updates the current Plane from the plane defined by the three given points.
  81781. * @param point1 one of the points used to contruct the plane
  81782. * @param point2 one of the points used to contruct the plane
  81783. * @param point3 one of the points used to contruct the plane
  81784. * @returns the updated Plane.
  81785. */
  81786. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  81787. /**
  81788. * Checks if the plane is facing a given direction
  81789. * @param direction the direction to check if the plane is facing
  81790. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  81791. * @returns True is the vector "direction" is the same side than the plane normal.
  81792. */
  81793. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  81794. /**
  81795. * Calculates the distance to a point
  81796. * @param point point to calculate distance to
  81797. * @returns the signed distance (float) from the given point to the Plane.
  81798. */
  81799. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  81800. /**
  81801. * Creates a plane from an array
  81802. * @param array the array to create a plane from
  81803. * @returns a new Plane from the given array.
  81804. */
  81805. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  81806. /**
  81807. * Creates a plane from three points
  81808. * @param point1 point used to create the plane
  81809. * @param point2 point used to create the plane
  81810. * @param point3 point used to create the plane
  81811. * @returns a new Plane defined by the three given points.
  81812. */
  81813. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  81814. /**
  81815. * Creates a plane from an origin point and a normal
  81816. * @param origin origin of the plane to be constructed
  81817. * @param normal normal of the plane to be constructed
  81818. * @returns a new Plane the normal vector to this plane at the given origin point.
  81819. * Note : the vector "normal" is updated because normalized.
  81820. */
  81821. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  81822. /**
  81823. * Calculates the distance from a plane and a point
  81824. * @param origin origin of the plane to be constructed
  81825. * @param normal normal of the plane to be constructed
  81826. * @param point point to calculate distance to
  81827. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  81828. */
  81829. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  81830. }
  81831. }
  81832. declare module BABYLON {
  81833. /** @hidden */
  81834. export class PerformanceConfigurator {
  81835. /** @hidden */
  81836. static MatrixUse64Bits: boolean;
  81837. /** @hidden */
  81838. static MatrixTrackPrecisionChange: boolean;
  81839. /** @hidden */
  81840. static MatrixCurrentType: any;
  81841. /** @hidden */
  81842. static MatrixTrackedMatrices: Array<any> | null;
  81843. /** @hidden */
  81844. static SetMatrixPrecision(use64bits: boolean): void;
  81845. }
  81846. }
  81847. declare module BABYLON {
  81848. /**
  81849. * Class representing a vector containing 2 coordinates
  81850. */
  81851. export class Vector2 {
  81852. /** defines the first coordinate */
  81853. x: number;
  81854. /** defines the second coordinate */
  81855. y: number;
  81856. /**
  81857. * Creates a new Vector2 from the given x and y coordinates
  81858. * @param x defines the first coordinate
  81859. * @param y defines the second coordinate
  81860. */
  81861. constructor(
  81862. /** defines the first coordinate */
  81863. x?: number,
  81864. /** defines the second coordinate */
  81865. y?: number);
  81866. /**
  81867. * Gets a string with the Vector2 coordinates
  81868. * @returns a string with the Vector2 coordinates
  81869. */
  81870. toString(): string;
  81871. /**
  81872. * Gets class name
  81873. * @returns the string "Vector2"
  81874. */
  81875. getClassName(): string;
  81876. /**
  81877. * Gets current vector hash code
  81878. * @returns the Vector2 hash code as a number
  81879. */
  81880. getHashCode(): number;
  81881. /**
  81882. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  81883. * @param array defines the source array
  81884. * @param index defines the offset in source array
  81885. * @returns the current Vector2
  81886. */
  81887. toArray(array: FloatArray, index?: number): Vector2;
  81888. /**
  81889. * Update the current vector from an array
  81890. * @param array defines the destination array
  81891. * @param index defines the offset in the destination array
  81892. * @returns the current Vector3
  81893. */
  81894. fromArray(array: FloatArray, index?: number): Vector2;
  81895. /**
  81896. * Copy the current vector to an array
  81897. * @returns a new array with 2 elements: the Vector2 coordinates.
  81898. */
  81899. asArray(): number[];
  81900. /**
  81901. * Sets the Vector2 coordinates with the given Vector2 coordinates
  81902. * @param source defines the source Vector2
  81903. * @returns the current updated Vector2
  81904. */
  81905. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  81906. /**
  81907. * Sets the Vector2 coordinates with the given floats
  81908. * @param x defines the first coordinate
  81909. * @param y defines the second coordinate
  81910. * @returns the current updated Vector2
  81911. */
  81912. copyFromFloats(x: number, y: number): Vector2;
  81913. /**
  81914. * Sets the Vector2 coordinates with the given floats
  81915. * @param x defines the first coordinate
  81916. * @param y defines the second coordinate
  81917. * @returns the current updated Vector2
  81918. */
  81919. set(x: number, y: number): Vector2;
  81920. /**
  81921. * Add another vector with the current one
  81922. * @param otherVector defines the other vector
  81923. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  81924. */
  81925. add(otherVector: DeepImmutable<Vector2>): Vector2;
  81926. /**
  81927. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  81928. * @param otherVector defines the other vector
  81929. * @param result defines the target vector
  81930. * @returns the unmodified current Vector2
  81931. */
  81932. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81933. /**
  81934. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  81935. * @param otherVector defines the other vector
  81936. * @returns the current updated Vector2
  81937. */
  81938. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81939. /**
  81940. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  81941. * @param otherVector defines the other vector
  81942. * @returns a new Vector2
  81943. */
  81944. addVector3(otherVector: Vector3): Vector2;
  81945. /**
  81946. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  81947. * @param otherVector defines the other vector
  81948. * @returns a new Vector2
  81949. */
  81950. subtract(otherVector: Vector2): Vector2;
  81951. /**
  81952. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  81953. * @param otherVector defines the other vector
  81954. * @param result defines the target vector
  81955. * @returns the unmodified current Vector2
  81956. */
  81957. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81958. /**
  81959. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  81960. * @param otherVector defines the other vector
  81961. * @returns the current updated Vector2
  81962. */
  81963. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81964. /**
  81965. * Multiplies in place the current Vector2 coordinates by the given ones
  81966. * @param otherVector defines the other vector
  81967. * @returns the current updated Vector2
  81968. */
  81969. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  81970. /**
  81971. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  81972. * @param otherVector defines the other vector
  81973. * @returns a new Vector2
  81974. */
  81975. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  81976. /**
  81977. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  81978. * @param otherVector defines the other vector
  81979. * @param result defines the target vector
  81980. * @returns the unmodified current Vector2
  81981. */
  81982. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  81983. /**
  81984. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  81985. * @param x defines the first coordinate
  81986. * @param y defines the second coordinate
  81987. * @returns a new Vector2
  81988. */
  81989. multiplyByFloats(x: number, y: number): Vector2;
  81990. /**
  81991. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  81992. * @param otherVector defines the other vector
  81993. * @returns a new Vector2
  81994. */
  81995. divide(otherVector: Vector2): Vector2;
  81996. /**
  81997. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  81998. * @param otherVector defines the other vector
  81999. * @param result defines the target vector
  82000. * @returns the unmodified current Vector2
  82001. */
  82002. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82003. /**
  82004. * Divides the current Vector2 coordinates by the given ones
  82005. * @param otherVector defines the other vector
  82006. * @returns the current updated Vector2
  82007. */
  82008. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82009. /**
  82010. * Gets a new Vector2 with current Vector2 negated coordinates
  82011. * @returns a new Vector2
  82012. */
  82013. negate(): Vector2;
  82014. /**
  82015. * Negate this vector in place
  82016. * @returns this
  82017. */
  82018. negateInPlace(): Vector2;
  82019. /**
  82020. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  82021. * @param result defines the Vector3 object where to store the result
  82022. * @returns the current Vector2
  82023. */
  82024. negateToRef(result: Vector2): Vector2;
  82025. /**
  82026. * Multiply the Vector2 coordinates by scale
  82027. * @param scale defines the scaling factor
  82028. * @returns the current updated Vector2
  82029. */
  82030. scaleInPlace(scale: number): Vector2;
  82031. /**
  82032. * Returns a new Vector2 scaled by "scale" from the current Vector2
  82033. * @param scale defines the scaling factor
  82034. * @returns a new Vector2
  82035. */
  82036. scale(scale: number): Vector2;
  82037. /**
  82038. * Scale the current Vector2 values by a factor to a given Vector2
  82039. * @param scale defines the scale factor
  82040. * @param result defines the Vector2 object where to store the result
  82041. * @returns the unmodified current Vector2
  82042. */
  82043. scaleToRef(scale: number, result: Vector2): Vector2;
  82044. /**
  82045. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  82046. * @param scale defines the scale factor
  82047. * @param result defines the Vector2 object where to store the result
  82048. * @returns the unmodified current Vector2
  82049. */
  82050. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  82051. /**
  82052. * Gets a boolean if two vectors are equals
  82053. * @param otherVector defines the other vector
  82054. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  82055. */
  82056. equals(otherVector: DeepImmutable<Vector2>): boolean;
  82057. /**
  82058. * Gets a boolean if two vectors are equals (using an epsilon value)
  82059. * @param otherVector defines the other vector
  82060. * @param epsilon defines the minimal distance to consider equality
  82061. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  82062. */
  82063. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  82064. /**
  82065. * Gets a new Vector2 from current Vector2 floored values
  82066. * @returns a new Vector2
  82067. */
  82068. floor(): Vector2;
  82069. /**
  82070. * Gets a new Vector2 from current Vector2 floored values
  82071. * @returns a new Vector2
  82072. */
  82073. fract(): Vector2;
  82074. /**
  82075. * Gets the length of the vector
  82076. * @returns the vector length (float)
  82077. */
  82078. length(): number;
  82079. /**
  82080. * Gets the vector squared length
  82081. * @returns the vector squared length (float)
  82082. */
  82083. lengthSquared(): number;
  82084. /**
  82085. * Normalize the vector
  82086. * @returns the current updated Vector2
  82087. */
  82088. normalize(): Vector2;
  82089. /**
  82090. * Gets a new Vector2 copied from the Vector2
  82091. * @returns a new Vector2
  82092. */
  82093. clone(): Vector2;
  82094. /**
  82095. * Gets a new Vector2(0, 0)
  82096. * @returns a new Vector2
  82097. */
  82098. static Zero(): Vector2;
  82099. /**
  82100. * Gets a new Vector2(1, 1)
  82101. * @returns a new Vector2
  82102. */
  82103. static One(): Vector2;
  82104. /**
  82105. * Gets a new Vector2 set from the given index element of the given array
  82106. * @param array defines the data source
  82107. * @param offset defines the offset in the data source
  82108. * @returns a new Vector2
  82109. */
  82110. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  82111. /**
  82112. * Sets "result" from the given index element of the given array
  82113. * @param array defines the data source
  82114. * @param offset defines the offset in the data source
  82115. * @param result defines the target vector
  82116. */
  82117. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  82118. /**
  82119. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  82120. * @param value1 defines 1st point of control
  82121. * @param value2 defines 2nd point of control
  82122. * @param value3 defines 3rd point of control
  82123. * @param value4 defines 4th point of control
  82124. * @param amount defines the interpolation factor
  82125. * @returns a new Vector2
  82126. */
  82127. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  82128. /**
  82129. * 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".
  82130. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  82131. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  82132. * @param value defines the value to clamp
  82133. * @param min defines the lower limit
  82134. * @param max defines the upper limit
  82135. * @returns a new Vector2
  82136. */
  82137. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  82138. /**
  82139. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  82140. * @param value1 defines the 1st control point
  82141. * @param tangent1 defines the outgoing tangent
  82142. * @param value2 defines the 2nd control point
  82143. * @param tangent2 defines the incoming tangent
  82144. * @param amount defines the interpolation factor
  82145. * @returns a new Vector2
  82146. */
  82147. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  82148. /**
  82149. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  82150. * @param start defines the start vector
  82151. * @param end defines the end vector
  82152. * @param amount defines the interpolation factor
  82153. * @returns a new Vector2
  82154. */
  82155. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  82156. /**
  82157. * Gets the dot product of the vector "left" and the vector "right"
  82158. * @param left defines first vector
  82159. * @param right defines second vector
  82160. * @returns the dot product (float)
  82161. */
  82162. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  82163. /**
  82164. * Returns a new Vector2 equal to the normalized given vector
  82165. * @param vector defines the vector to normalize
  82166. * @returns a new Vector2
  82167. */
  82168. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  82169. /**
  82170. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  82171. * @param left defines 1st vector
  82172. * @param right defines 2nd vector
  82173. * @returns a new Vector2
  82174. */
  82175. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82176. /**
  82177. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  82178. * @param left defines 1st vector
  82179. * @param right defines 2nd vector
  82180. * @returns a new Vector2
  82181. */
  82182. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82183. /**
  82184. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  82185. * @param vector defines the vector to transform
  82186. * @param transformation defines the matrix to apply
  82187. * @returns a new Vector2
  82188. */
  82189. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  82190. /**
  82191. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  82192. * @param vector defines the vector to transform
  82193. * @param transformation defines the matrix to apply
  82194. * @param result defines the target vector
  82195. */
  82196. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  82197. /**
  82198. * Determines if a given vector is included in a triangle
  82199. * @param p defines the vector to test
  82200. * @param p0 defines 1st triangle point
  82201. * @param p1 defines 2nd triangle point
  82202. * @param p2 defines 3rd triangle point
  82203. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  82204. */
  82205. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  82206. /**
  82207. * Gets the distance between the vectors "value1" and "value2"
  82208. * @param value1 defines first vector
  82209. * @param value2 defines second vector
  82210. * @returns the distance between vectors
  82211. */
  82212. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82213. /**
  82214. * Returns the squared distance between the vectors "value1" and "value2"
  82215. * @param value1 defines first vector
  82216. * @param value2 defines second vector
  82217. * @returns the squared distance between vectors
  82218. */
  82219. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82220. /**
  82221. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  82222. * @param value1 defines first vector
  82223. * @param value2 defines second vector
  82224. * @returns a new Vector2
  82225. */
  82226. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  82227. /**
  82228. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  82229. * @param p defines the middle point
  82230. * @param segA defines one point of the segment
  82231. * @param segB defines the other point of the segment
  82232. * @returns the shortest distance
  82233. */
  82234. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  82235. }
  82236. /**
  82237. * Class used to store (x,y,z) vector representation
  82238. * A Vector3 is the main object used in 3D geometry
  82239. * It can represent etiher the coordinates of a point the space, either a direction
  82240. * Reminder: js uses a left handed forward facing system
  82241. */
  82242. export class Vector3 {
  82243. private static _UpReadOnly;
  82244. private static _ZeroReadOnly;
  82245. /** @hidden */
  82246. _x: number;
  82247. /** @hidden */
  82248. _y: number;
  82249. /** @hidden */
  82250. _z: number;
  82251. /** @hidden */
  82252. _isDirty: boolean;
  82253. /** Gets or sets the x coordinate */
  82254. get x(): number;
  82255. set x(value: number);
  82256. /** Gets or sets the y coordinate */
  82257. get y(): number;
  82258. set y(value: number);
  82259. /** Gets or sets the z coordinate */
  82260. get z(): number;
  82261. set z(value: number);
  82262. /**
  82263. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  82264. * @param x defines the first coordinates (on X axis)
  82265. * @param y defines the second coordinates (on Y axis)
  82266. * @param z defines the third coordinates (on Z axis)
  82267. */
  82268. constructor(x?: number, y?: number, z?: number);
  82269. /**
  82270. * Creates a string representation of the Vector3
  82271. * @returns a string with the Vector3 coordinates.
  82272. */
  82273. toString(): string;
  82274. /**
  82275. * Gets the class name
  82276. * @returns the string "Vector3"
  82277. */
  82278. getClassName(): string;
  82279. /**
  82280. * Creates the Vector3 hash code
  82281. * @returns a number which tends to be unique between Vector3 instances
  82282. */
  82283. getHashCode(): number;
  82284. /**
  82285. * Creates an array containing three elements : the coordinates of the Vector3
  82286. * @returns a new array of numbers
  82287. */
  82288. asArray(): number[];
  82289. /**
  82290. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  82291. * @param array defines the destination array
  82292. * @param index defines the offset in the destination array
  82293. * @returns the current Vector3
  82294. */
  82295. toArray(array: FloatArray, index?: number): Vector3;
  82296. /**
  82297. * Update the current vector from an array
  82298. * @param array defines the destination array
  82299. * @param index defines the offset in the destination array
  82300. * @returns the current Vector3
  82301. */
  82302. fromArray(array: FloatArray, index?: number): Vector3;
  82303. /**
  82304. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  82305. * @returns a new Quaternion object, computed from the Vector3 coordinates
  82306. */
  82307. toQuaternion(): Quaternion;
  82308. /**
  82309. * Adds the given vector to the current Vector3
  82310. * @param otherVector defines the second operand
  82311. * @returns the current updated Vector3
  82312. */
  82313. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82314. /**
  82315. * Adds the given coordinates to the current Vector3
  82316. * @param x defines the x coordinate of the operand
  82317. * @param y defines the y coordinate of the operand
  82318. * @param z defines the z coordinate of the operand
  82319. * @returns the current updated Vector3
  82320. */
  82321. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82322. /**
  82323. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  82324. * @param otherVector defines the second operand
  82325. * @returns the resulting Vector3
  82326. */
  82327. add(otherVector: DeepImmutable<Vector3>): Vector3;
  82328. /**
  82329. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  82330. * @param otherVector defines the second operand
  82331. * @param result defines the Vector3 object where to store the result
  82332. * @returns the current Vector3
  82333. */
  82334. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82335. /**
  82336. * Subtract the given vector from the current Vector3
  82337. * @param otherVector defines the second operand
  82338. * @returns the current updated Vector3
  82339. */
  82340. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82341. /**
  82342. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  82343. * @param otherVector defines the second operand
  82344. * @returns the resulting Vector3
  82345. */
  82346. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  82347. /**
  82348. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  82349. * @param otherVector defines the second operand
  82350. * @param result defines the Vector3 object where to store the result
  82351. * @returns the current Vector3
  82352. */
  82353. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82354. /**
  82355. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  82356. * @param x defines the x coordinate of the operand
  82357. * @param y defines the y coordinate of the operand
  82358. * @param z defines the z coordinate of the operand
  82359. * @returns the resulting Vector3
  82360. */
  82361. subtractFromFloats(x: number, y: number, z: number): Vector3;
  82362. /**
  82363. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  82364. * @param x defines the x coordinate of the operand
  82365. * @param y defines the y coordinate of the operand
  82366. * @param z defines the z coordinate of the operand
  82367. * @param result defines the Vector3 object where to store the result
  82368. * @returns the current Vector3
  82369. */
  82370. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  82371. /**
  82372. * Gets a new Vector3 set with the current Vector3 negated coordinates
  82373. * @returns a new Vector3
  82374. */
  82375. negate(): Vector3;
  82376. /**
  82377. * Negate this vector in place
  82378. * @returns this
  82379. */
  82380. negateInPlace(): Vector3;
  82381. /**
  82382. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  82383. * @param result defines the Vector3 object where to store the result
  82384. * @returns the current Vector3
  82385. */
  82386. negateToRef(result: Vector3): Vector3;
  82387. /**
  82388. * Multiplies the Vector3 coordinates by the float "scale"
  82389. * @param scale defines the multiplier factor
  82390. * @returns the current updated Vector3
  82391. */
  82392. scaleInPlace(scale: number): Vector3;
  82393. /**
  82394. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  82395. * @param scale defines the multiplier factor
  82396. * @returns a new Vector3
  82397. */
  82398. scale(scale: number): Vector3;
  82399. /**
  82400. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  82401. * @param scale defines the multiplier factor
  82402. * @param result defines the Vector3 object where to store the result
  82403. * @returns the current Vector3
  82404. */
  82405. scaleToRef(scale: number, result: Vector3): Vector3;
  82406. /**
  82407. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  82408. * @param scale defines the scale factor
  82409. * @param result defines the Vector3 object where to store the result
  82410. * @returns the unmodified current Vector3
  82411. */
  82412. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  82413. /**
  82414. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  82415. * @param origin defines the origin of the projection ray
  82416. * @param plane defines the plane to project to
  82417. * @returns the projected vector3
  82418. */
  82419. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  82420. /**
  82421. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  82422. * @param origin defines the origin of the projection ray
  82423. * @param plane defines the plane to project to
  82424. * @param result defines the Vector3 where to store the result
  82425. */
  82426. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  82427. /**
  82428. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  82429. * @param otherVector defines the second operand
  82430. * @returns true if both vectors are equals
  82431. */
  82432. equals(otherVector: DeepImmutable<Vector3>): boolean;
  82433. /**
  82434. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  82435. * @param otherVector defines the second operand
  82436. * @param epsilon defines the minimal distance to define values as equals
  82437. * @returns true if both vectors are distant less than epsilon
  82438. */
  82439. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  82440. /**
  82441. * Returns true if the current Vector3 coordinates equals the given floats
  82442. * @param x defines the x coordinate of the operand
  82443. * @param y defines the y coordinate of the operand
  82444. * @param z defines the z coordinate of the operand
  82445. * @returns true if both vectors are equals
  82446. */
  82447. equalsToFloats(x: number, y: number, z: number): boolean;
  82448. /**
  82449. * Multiplies the current Vector3 coordinates by the given ones
  82450. * @param otherVector defines the second operand
  82451. * @returns the current updated Vector3
  82452. */
  82453. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82454. /**
  82455. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  82456. * @param otherVector defines the second operand
  82457. * @returns the new Vector3
  82458. */
  82459. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  82460. /**
  82461. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  82462. * @param otherVector defines the second operand
  82463. * @param result defines the Vector3 object where to store the result
  82464. * @returns the current Vector3
  82465. */
  82466. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82467. /**
  82468. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  82469. * @param x defines the x coordinate of the operand
  82470. * @param y defines the y coordinate of the operand
  82471. * @param z defines the z coordinate of the operand
  82472. * @returns the new Vector3
  82473. */
  82474. multiplyByFloats(x: number, y: number, z: number): Vector3;
  82475. /**
  82476. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  82477. * @param otherVector defines the second operand
  82478. * @returns the new Vector3
  82479. */
  82480. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  82481. /**
  82482. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  82483. * @param otherVector defines the second operand
  82484. * @param result defines the Vector3 object where to store the result
  82485. * @returns the current Vector3
  82486. */
  82487. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82488. /**
  82489. * Divides the current Vector3 coordinates by the given ones.
  82490. * @param otherVector defines the second operand
  82491. * @returns the current updated Vector3
  82492. */
  82493. divideInPlace(otherVector: Vector3): Vector3;
  82494. /**
  82495. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  82496. * @param other defines the second operand
  82497. * @returns the current updated Vector3
  82498. */
  82499. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  82500. /**
  82501. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  82502. * @param other defines the second operand
  82503. * @returns the current updated Vector3
  82504. */
  82505. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  82506. /**
  82507. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  82508. * @param x defines the x coordinate of the operand
  82509. * @param y defines the y coordinate of the operand
  82510. * @param z defines the z coordinate of the operand
  82511. * @returns the current updated Vector3
  82512. */
  82513. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82514. /**
  82515. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  82516. * @param x defines the x coordinate of the operand
  82517. * @param y defines the y coordinate of the operand
  82518. * @param z defines the z coordinate of the operand
  82519. * @returns the current updated Vector3
  82520. */
  82521. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82522. /**
  82523. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  82524. * Check if is non uniform within a certain amount of decimal places to account for this
  82525. * @param epsilon the amount the values can differ
  82526. * @returns if the the vector is non uniform to a certain number of decimal places
  82527. */
  82528. isNonUniformWithinEpsilon(epsilon: number): boolean;
  82529. /**
  82530. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  82531. */
  82532. get isNonUniform(): boolean;
  82533. /**
  82534. * Gets a new Vector3 from current Vector3 floored values
  82535. * @returns a new Vector3
  82536. */
  82537. floor(): Vector3;
  82538. /**
  82539. * Gets a new Vector3 from current Vector3 floored values
  82540. * @returns a new Vector3
  82541. */
  82542. fract(): Vector3;
  82543. /**
  82544. * Gets the length of the Vector3
  82545. * @returns the length of the Vector3
  82546. */
  82547. length(): number;
  82548. /**
  82549. * Gets the squared length of the Vector3
  82550. * @returns squared length of the Vector3
  82551. */
  82552. lengthSquared(): number;
  82553. /**
  82554. * Normalize the current Vector3.
  82555. * Please note that this is an in place operation.
  82556. * @returns the current updated Vector3
  82557. */
  82558. normalize(): Vector3;
  82559. /**
  82560. * Reorders the x y z properties of the vector in place
  82561. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  82562. * @returns the current updated vector
  82563. */
  82564. reorderInPlace(order: string): this;
  82565. /**
  82566. * Rotates the vector around 0,0,0 by a quaternion
  82567. * @param quaternion the rotation quaternion
  82568. * @param result vector to store the result
  82569. * @returns the resulting vector
  82570. */
  82571. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  82572. /**
  82573. * Rotates a vector around a given point
  82574. * @param quaternion the rotation quaternion
  82575. * @param point the point to rotate around
  82576. * @param result vector to store the result
  82577. * @returns the resulting vector
  82578. */
  82579. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  82580. /**
  82581. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  82582. * The cross product is then orthogonal to both current and "other"
  82583. * @param other defines the right operand
  82584. * @returns the cross product
  82585. */
  82586. cross(other: Vector3): Vector3;
  82587. /**
  82588. * Normalize the current Vector3 with the given input length.
  82589. * Please note that this is an in place operation.
  82590. * @param len the length of the vector
  82591. * @returns the current updated Vector3
  82592. */
  82593. normalizeFromLength(len: number): Vector3;
  82594. /**
  82595. * Normalize the current Vector3 to a new vector
  82596. * @returns the new Vector3
  82597. */
  82598. normalizeToNew(): Vector3;
  82599. /**
  82600. * Normalize the current Vector3 to the reference
  82601. * @param reference define the Vector3 to update
  82602. * @returns the updated Vector3
  82603. */
  82604. normalizeToRef(reference: Vector3): Vector3;
  82605. /**
  82606. * Creates a new Vector3 copied from the current Vector3
  82607. * @returns the new Vector3
  82608. */
  82609. clone(): Vector3;
  82610. /**
  82611. * Copies the given vector coordinates to the current Vector3 ones
  82612. * @param source defines the source Vector3
  82613. * @returns the current updated Vector3
  82614. */
  82615. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  82616. /**
  82617. * Copies the given floats to the current Vector3 coordinates
  82618. * @param x defines the x coordinate of the operand
  82619. * @param y defines the y coordinate of the operand
  82620. * @param z defines the z coordinate of the operand
  82621. * @returns the current updated Vector3
  82622. */
  82623. copyFromFloats(x: number, y: number, z: number): Vector3;
  82624. /**
  82625. * Copies the given floats to the current Vector3 coordinates
  82626. * @param x defines the x coordinate of the operand
  82627. * @param y defines the y coordinate of the operand
  82628. * @param z defines the z coordinate of the operand
  82629. * @returns the current updated Vector3
  82630. */
  82631. set(x: number, y: number, z: number): Vector3;
  82632. /**
  82633. * Copies the given float to the current Vector3 coordinates
  82634. * @param v defines the x, y and z coordinates of the operand
  82635. * @returns the current updated Vector3
  82636. */
  82637. setAll(v: number): Vector3;
  82638. /**
  82639. * Get the clip factor between two vectors
  82640. * @param vector0 defines the first operand
  82641. * @param vector1 defines the second operand
  82642. * @param axis defines the axis to use
  82643. * @param size defines the size along the axis
  82644. * @returns the clip factor
  82645. */
  82646. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  82647. /**
  82648. * Get angle between two vectors
  82649. * @param vector0 angle between vector0 and vector1
  82650. * @param vector1 angle between vector0 and vector1
  82651. * @param normal direction of the normal
  82652. * @return the angle between vector0 and vector1
  82653. */
  82654. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  82655. /**
  82656. * Returns a new Vector3 set from the index "offset" of the given array
  82657. * @param array defines the source array
  82658. * @param offset defines the offset in the source array
  82659. * @returns the new Vector3
  82660. */
  82661. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  82662. /**
  82663. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  82664. * @param array defines the source array
  82665. * @param offset defines the offset in the source array
  82666. * @returns the new Vector3
  82667. * @deprecated Please use FromArray instead.
  82668. */
  82669. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  82670. /**
  82671. * Sets the given vector "result" with the element values from the index "offset" of the given array
  82672. * @param array defines the source array
  82673. * @param offset defines the offset in the source array
  82674. * @param result defines the Vector3 where to store the result
  82675. */
  82676. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  82677. /**
  82678. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  82679. * @param array defines the source array
  82680. * @param offset defines the offset in the source array
  82681. * @param result defines the Vector3 where to store the result
  82682. * @deprecated Please use FromArrayToRef instead.
  82683. */
  82684. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  82685. /**
  82686. * Sets the given vector "result" with the given floats.
  82687. * @param x defines the x coordinate of the source
  82688. * @param y defines the y coordinate of the source
  82689. * @param z defines the z coordinate of the source
  82690. * @param result defines the Vector3 where to store the result
  82691. */
  82692. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  82693. /**
  82694. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  82695. * @returns a new empty Vector3
  82696. */
  82697. static Zero(): Vector3;
  82698. /**
  82699. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  82700. * @returns a new unit Vector3
  82701. */
  82702. static One(): Vector3;
  82703. /**
  82704. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  82705. * @returns a new up Vector3
  82706. */
  82707. static Up(): Vector3;
  82708. /**
  82709. * Gets a up Vector3 that must not be updated
  82710. */
  82711. static get UpReadOnly(): DeepImmutable<Vector3>;
  82712. /**
  82713. * Gets a zero Vector3 that must not be updated
  82714. */
  82715. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  82716. /**
  82717. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  82718. * @returns a new down Vector3
  82719. */
  82720. static Down(): Vector3;
  82721. /**
  82722. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  82723. * @param rightHandedSystem is the scene right-handed (negative z)
  82724. * @returns a new forward Vector3
  82725. */
  82726. static Forward(rightHandedSystem?: boolean): Vector3;
  82727. /**
  82728. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  82729. * @param rightHandedSystem is the scene right-handed (negative-z)
  82730. * @returns a new forward Vector3
  82731. */
  82732. static Backward(rightHandedSystem?: boolean): Vector3;
  82733. /**
  82734. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  82735. * @returns a new right Vector3
  82736. */
  82737. static Right(): Vector3;
  82738. /**
  82739. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  82740. * @returns a new left Vector3
  82741. */
  82742. static Left(): Vector3;
  82743. /**
  82744. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  82745. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  82746. * @param vector defines the Vector3 to transform
  82747. * @param transformation defines the transformation matrix
  82748. * @returns the transformed Vector3
  82749. */
  82750. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  82751. /**
  82752. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  82753. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  82754. * @param vector defines the Vector3 to transform
  82755. * @param transformation defines the transformation matrix
  82756. * @param result defines the Vector3 where to store the result
  82757. */
  82758. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82759. /**
  82760. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  82761. * This method computes tranformed coordinates only, not transformed direction vectors
  82762. * @param x define the x coordinate of the source vector
  82763. * @param y define the y coordinate of the source vector
  82764. * @param z define the z coordinate of the source vector
  82765. * @param transformation defines the transformation matrix
  82766. * @param result defines the Vector3 where to store the result
  82767. */
  82768. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82769. /**
  82770. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  82771. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  82772. * @param vector defines the Vector3 to transform
  82773. * @param transformation defines the transformation matrix
  82774. * @returns the new Vector3
  82775. */
  82776. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  82777. /**
  82778. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  82779. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  82780. * @param vector defines the Vector3 to transform
  82781. * @param transformation defines the transformation matrix
  82782. * @param result defines the Vector3 where to store the result
  82783. */
  82784. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82785. /**
  82786. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  82787. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  82788. * @param x define the x coordinate of the source vector
  82789. * @param y define the y coordinate of the source vector
  82790. * @param z define the z coordinate of the source vector
  82791. * @param transformation defines the transformation matrix
  82792. * @param result defines the Vector3 where to store the result
  82793. */
  82794. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  82795. /**
  82796. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  82797. * @param value1 defines the first control point
  82798. * @param value2 defines the second control point
  82799. * @param value3 defines the third control point
  82800. * @param value4 defines the fourth control point
  82801. * @param amount defines the amount on the spline to use
  82802. * @returns the new Vector3
  82803. */
  82804. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  82805. /**
  82806. * 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"
  82807. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  82808. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  82809. * @param value defines the current value
  82810. * @param min defines the lower range value
  82811. * @param max defines the upper range value
  82812. * @returns the new Vector3
  82813. */
  82814. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  82815. /**
  82816. * 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"
  82817. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  82818. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  82819. * @param value defines the current value
  82820. * @param min defines the lower range value
  82821. * @param max defines the upper range value
  82822. * @param result defines the Vector3 where to store the result
  82823. */
  82824. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  82825. /**
  82826. * Checks if a given vector is inside a specific range
  82827. * @param v defines the vector to test
  82828. * @param min defines the minimum range
  82829. * @param max defines the maximum range
  82830. */
  82831. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  82832. /**
  82833. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  82834. * @param value1 defines the first control point
  82835. * @param tangent1 defines the first tangent vector
  82836. * @param value2 defines the second control point
  82837. * @param tangent2 defines the second tangent vector
  82838. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  82839. * @returns the new Vector3
  82840. */
  82841. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  82842. /**
  82843. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  82844. * @param start defines the start value
  82845. * @param end defines the end value
  82846. * @param amount max defines amount between both (between 0 and 1)
  82847. * @returns the new Vector3
  82848. */
  82849. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  82850. /**
  82851. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  82852. * @param start defines the start value
  82853. * @param end defines the end value
  82854. * @param amount max defines amount between both (between 0 and 1)
  82855. * @param result defines the Vector3 where to store the result
  82856. */
  82857. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  82858. /**
  82859. * Returns the dot product (float) between the vectors "left" and "right"
  82860. * @param left defines the left operand
  82861. * @param right defines the right operand
  82862. * @returns the dot product
  82863. */
  82864. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  82865. /**
  82866. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  82867. * The cross product is then orthogonal to both "left" and "right"
  82868. * @param left defines the left operand
  82869. * @param right defines the right operand
  82870. * @returns the cross product
  82871. */
  82872. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82873. /**
  82874. * Sets the given vector "result" with the cross product of "left" and "right"
  82875. * The cross product is then orthogonal to both "left" and "right"
  82876. * @param left defines the left operand
  82877. * @param right defines the right operand
  82878. * @param result defines the Vector3 where to store the result
  82879. */
  82880. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  82881. /**
  82882. * Returns a new Vector3 as the normalization of the given vector
  82883. * @param vector defines the Vector3 to normalize
  82884. * @returns the new Vector3
  82885. */
  82886. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  82887. /**
  82888. * Sets the given vector "result" with the normalization of the given first vector
  82889. * @param vector defines the Vector3 to normalize
  82890. * @param result defines the Vector3 where to store the result
  82891. */
  82892. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  82893. /**
  82894. * Project a Vector3 onto screen space
  82895. * @param vector defines the Vector3 to project
  82896. * @param world defines the world matrix to use
  82897. * @param transform defines the transform (view x projection) matrix to use
  82898. * @param viewport defines the screen viewport to use
  82899. * @returns the new Vector3
  82900. */
  82901. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  82902. /** @hidden */
  82903. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  82904. /**
  82905. * Unproject from screen space to object space
  82906. * @param source defines the screen space Vector3 to use
  82907. * @param viewportWidth defines the current width of the viewport
  82908. * @param viewportHeight defines the current height of the viewport
  82909. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82910. * @param transform defines the transform (view x projection) matrix to use
  82911. * @returns the new Vector3
  82912. */
  82913. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  82914. /**
  82915. * Unproject from screen space to object space
  82916. * @param source defines the screen space Vector3 to use
  82917. * @param viewportWidth defines the current width of the viewport
  82918. * @param viewportHeight defines the current height of the viewport
  82919. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82920. * @param view defines the view matrix to use
  82921. * @param projection defines the projection matrix to use
  82922. * @returns the new Vector3
  82923. */
  82924. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  82925. /**
  82926. * Unproject from screen space to object space
  82927. * @param source defines the screen space Vector3 to use
  82928. * @param viewportWidth defines the current width of the viewport
  82929. * @param viewportHeight defines the current height of the viewport
  82930. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82931. * @param view defines the view matrix to use
  82932. * @param projection defines the projection matrix to use
  82933. * @param result defines the Vector3 where to store the result
  82934. */
  82935. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  82936. /**
  82937. * Unproject from screen space to object space
  82938. * @param sourceX defines the screen space x coordinate to use
  82939. * @param sourceY defines the screen space y coordinate to use
  82940. * @param sourceZ defines the screen space z coordinate to use
  82941. * @param viewportWidth defines the current width of the viewport
  82942. * @param viewportHeight defines the current height of the viewport
  82943. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82944. * @param view defines the view matrix to use
  82945. * @param projection defines the projection matrix to use
  82946. * @param result defines the Vector3 where to store the result
  82947. */
  82948. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  82949. /**
  82950. * Gets the minimal coordinate values between two Vector3
  82951. * @param left defines the first operand
  82952. * @param right defines the second operand
  82953. * @returns the new Vector3
  82954. */
  82955. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82956. /**
  82957. * Gets the maximal coordinate values between two Vector3
  82958. * @param left defines the first operand
  82959. * @param right defines the second operand
  82960. * @returns the new Vector3
  82961. */
  82962. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  82963. /**
  82964. * Returns the distance between the vectors "value1" and "value2"
  82965. * @param value1 defines the first operand
  82966. * @param value2 defines the second operand
  82967. * @returns the distance
  82968. */
  82969. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  82970. /**
  82971. * Returns the squared distance between the vectors "value1" and "value2"
  82972. * @param value1 defines the first operand
  82973. * @param value2 defines the second operand
  82974. * @returns the squared distance
  82975. */
  82976. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  82977. /**
  82978. * Returns a new Vector3 located at the center between "value1" and "value2"
  82979. * @param value1 defines the first operand
  82980. * @param value2 defines the second operand
  82981. * @returns the new Vector3
  82982. */
  82983. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  82984. /**
  82985. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  82986. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  82987. * to something in order to rotate it from its local system to the given target system
  82988. * Note: axis1, axis2 and axis3 are normalized during this operation
  82989. * @param axis1 defines the first axis
  82990. * @param axis2 defines the second axis
  82991. * @param axis3 defines the third axis
  82992. * @returns a new Vector3
  82993. */
  82994. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  82995. /**
  82996. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  82997. * @param axis1 defines the first axis
  82998. * @param axis2 defines the second axis
  82999. * @param axis3 defines the third axis
  83000. * @param ref defines the Vector3 where to store the result
  83001. */
  83002. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  83003. }
  83004. /**
  83005. * Vector4 class created for EulerAngle class conversion to Quaternion
  83006. */
  83007. export class Vector4 {
  83008. /** x value of the vector */
  83009. x: number;
  83010. /** y value of the vector */
  83011. y: number;
  83012. /** z value of the vector */
  83013. z: number;
  83014. /** w value of the vector */
  83015. w: number;
  83016. /**
  83017. * Creates a Vector4 object from the given floats.
  83018. * @param x x value of the vector
  83019. * @param y y value of the vector
  83020. * @param z z value of the vector
  83021. * @param w w value of the vector
  83022. */
  83023. constructor(
  83024. /** x value of the vector */
  83025. x: number,
  83026. /** y value of the vector */
  83027. y: number,
  83028. /** z value of the vector */
  83029. z: number,
  83030. /** w value of the vector */
  83031. w: number);
  83032. /**
  83033. * Returns the string with the Vector4 coordinates.
  83034. * @returns a string containing all the vector values
  83035. */
  83036. toString(): string;
  83037. /**
  83038. * Returns the string "Vector4".
  83039. * @returns "Vector4"
  83040. */
  83041. getClassName(): string;
  83042. /**
  83043. * Returns the Vector4 hash code.
  83044. * @returns a unique hash code
  83045. */
  83046. getHashCode(): number;
  83047. /**
  83048. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  83049. * @returns the resulting array
  83050. */
  83051. asArray(): number[];
  83052. /**
  83053. * Populates the given array from the given index with the Vector4 coordinates.
  83054. * @param array array to populate
  83055. * @param index index of the array to start at (default: 0)
  83056. * @returns the Vector4.
  83057. */
  83058. toArray(array: FloatArray, index?: number): Vector4;
  83059. /**
  83060. * Update the current vector from an array
  83061. * @param array defines the destination array
  83062. * @param index defines the offset in the destination array
  83063. * @returns the current Vector3
  83064. */
  83065. fromArray(array: FloatArray, index?: number): Vector4;
  83066. /**
  83067. * Adds the given vector to the current Vector4.
  83068. * @param otherVector the vector to add
  83069. * @returns the updated Vector4.
  83070. */
  83071. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83072. /**
  83073. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  83074. * @param otherVector the vector to add
  83075. * @returns the resulting vector
  83076. */
  83077. add(otherVector: DeepImmutable<Vector4>): Vector4;
  83078. /**
  83079. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  83080. * @param otherVector the vector to add
  83081. * @param result the vector to store the result
  83082. * @returns the current Vector4.
  83083. */
  83084. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83085. /**
  83086. * Subtract in place the given vector from the current Vector4.
  83087. * @param otherVector the vector to subtract
  83088. * @returns the updated Vector4.
  83089. */
  83090. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83091. /**
  83092. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  83093. * @param otherVector the vector to add
  83094. * @returns the new vector with the result
  83095. */
  83096. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  83097. /**
  83098. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  83099. * @param otherVector the vector to subtract
  83100. * @param result the vector to store the result
  83101. * @returns the current Vector4.
  83102. */
  83103. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83104. /**
  83105. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83106. */
  83107. /**
  83108. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83109. * @param x value to subtract
  83110. * @param y value to subtract
  83111. * @param z value to subtract
  83112. * @param w value to subtract
  83113. * @returns new vector containing the result
  83114. */
  83115. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83116. /**
  83117. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83118. * @param x value to subtract
  83119. * @param y value to subtract
  83120. * @param z value to subtract
  83121. * @param w value to subtract
  83122. * @param result the vector to store the result in
  83123. * @returns the current Vector4.
  83124. */
  83125. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  83126. /**
  83127. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  83128. * @returns a new vector with the negated values
  83129. */
  83130. negate(): Vector4;
  83131. /**
  83132. * Negate this vector in place
  83133. * @returns this
  83134. */
  83135. negateInPlace(): Vector4;
  83136. /**
  83137. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  83138. * @param result defines the Vector3 object where to store the result
  83139. * @returns the current Vector4
  83140. */
  83141. negateToRef(result: Vector4): Vector4;
  83142. /**
  83143. * Multiplies the current Vector4 coordinates by scale (float).
  83144. * @param scale the number to scale with
  83145. * @returns the updated Vector4.
  83146. */
  83147. scaleInPlace(scale: number): Vector4;
  83148. /**
  83149. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  83150. * @param scale the number to scale with
  83151. * @returns a new vector with the result
  83152. */
  83153. scale(scale: number): Vector4;
  83154. /**
  83155. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  83156. * @param scale the number to scale with
  83157. * @param result a vector to store the result in
  83158. * @returns the current Vector4.
  83159. */
  83160. scaleToRef(scale: number, result: Vector4): Vector4;
  83161. /**
  83162. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  83163. * @param scale defines the scale factor
  83164. * @param result defines the Vector4 object where to store the result
  83165. * @returns the unmodified current Vector4
  83166. */
  83167. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  83168. /**
  83169. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  83170. * @param otherVector the vector to compare against
  83171. * @returns true if they are equal
  83172. */
  83173. equals(otherVector: DeepImmutable<Vector4>): boolean;
  83174. /**
  83175. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  83176. * @param otherVector vector to compare against
  83177. * @param epsilon (Default: very small number)
  83178. * @returns true if they are equal
  83179. */
  83180. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  83181. /**
  83182. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  83183. * @param x x value to compare against
  83184. * @param y y value to compare against
  83185. * @param z z value to compare against
  83186. * @param w w value to compare against
  83187. * @returns true if equal
  83188. */
  83189. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  83190. /**
  83191. * Multiplies in place the current Vector4 by the given one.
  83192. * @param otherVector vector to multiple with
  83193. * @returns the updated Vector4.
  83194. */
  83195. multiplyInPlace(otherVector: Vector4): Vector4;
  83196. /**
  83197. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  83198. * @param otherVector vector to multiple with
  83199. * @returns resulting new vector
  83200. */
  83201. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  83202. /**
  83203. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  83204. * @param otherVector vector to multiple with
  83205. * @param result vector to store the result
  83206. * @returns the current Vector4.
  83207. */
  83208. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83209. /**
  83210. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  83211. * @param x x value multiply with
  83212. * @param y y value multiply with
  83213. * @param z z value multiply with
  83214. * @param w w value multiply with
  83215. * @returns resulting new vector
  83216. */
  83217. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  83218. /**
  83219. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  83220. * @param otherVector vector to devide with
  83221. * @returns resulting new vector
  83222. */
  83223. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  83224. /**
  83225. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  83226. * @param otherVector vector to devide with
  83227. * @param result vector to store the result
  83228. * @returns the current Vector4.
  83229. */
  83230. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83231. /**
  83232. * Divides the current Vector3 coordinates by the given ones.
  83233. * @param otherVector vector to devide with
  83234. * @returns the updated Vector3.
  83235. */
  83236. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83237. /**
  83238. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  83239. * @param other defines the second operand
  83240. * @returns the current updated Vector4
  83241. */
  83242. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83243. /**
  83244. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  83245. * @param other defines the second operand
  83246. * @returns the current updated Vector4
  83247. */
  83248. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83249. /**
  83250. * Gets a new Vector4 from current Vector4 floored values
  83251. * @returns a new Vector4
  83252. */
  83253. floor(): Vector4;
  83254. /**
  83255. * Gets a new Vector4 from current Vector3 floored values
  83256. * @returns a new Vector4
  83257. */
  83258. fract(): Vector4;
  83259. /**
  83260. * Returns the Vector4 length (float).
  83261. * @returns the length
  83262. */
  83263. length(): number;
  83264. /**
  83265. * Returns the Vector4 squared length (float).
  83266. * @returns the length squared
  83267. */
  83268. lengthSquared(): number;
  83269. /**
  83270. * Normalizes in place the Vector4.
  83271. * @returns the updated Vector4.
  83272. */
  83273. normalize(): Vector4;
  83274. /**
  83275. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  83276. * @returns this converted to a new vector3
  83277. */
  83278. toVector3(): Vector3;
  83279. /**
  83280. * Returns a new Vector4 copied from the current one.
  83281. * @returns the new cloned vector
  83282. */
  83283. clone(): Vector4;
  83284. /**
  83285. * Updates the current Vector4 with the given one coordinates.
  83286. * @param source the source vector to copy from
  83287. * @returns the updated Vector4.
  83288. */
  83289. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  83290. /**
  83291. * Updates the current Vector4 coordinates with the given floats.
  83292. * @param x float to copy from
  83293. * @param y float to copy from
  83294. * @param z float to copy from
  83295. * @param w float to copy from
  83296. * @returns the updated Vector4.
  83297. */
  83298. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83299. /**
  83300. * Updates the current Vector4 coordinates with the given floats.
  83301. * @param x float to set from
  83302. * @param y float to set from
  83303. * @param z float to set from
  83304. * @param w float to set from
  83305. * @returns the updated Vector4.
  83306. */
  83307. set(x: number, y: number, z: number, w: number): Vector4;
  83308. /**
  83309. * Copies the given float to the current Vector3 coordinates
  83310. * @param v defines the x, y, z and w coordinates of the operand
  83311. * @returns the current updated Vector3
  83312. */
  83313. setAll(v: number): Vector4;
  83314. /**
  83315. * Returns a new Vector4 set from the starting index of the given array.
  83316. * @param array the array to pull values from
  83317. * @param offset the offset into the array to start at
  83318. * @returns the new vector
  83319. */
  83320. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  83321. /**
  83322. * Updates the given vector "result" from the starting index of the given array.
  83323. * @param array the array to pull values from
  83324. * @param offset the offset into the array to start at
  83325. * @param result the vector to store the result in
  83326. */
  83327. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  83328. /**
  83329. * Updates the given vector "result" from the starting index of the given Float32Array.
  83330. * @param array the array to pull values from
  83331. * @param offset the offset into the array to start at
  83332. * @param result the vector to store the result in
  83333. */
  83334. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  83335. /**
  83336. * Updates the given vector "result" coordinates from the given floats.
  83337. * @param x float to set from
  83338. * @param y float to set from
  83339. * @param z float to set from
  83340. * @param w float to set from
  83341. * @param result the vector to the floats in
  83342. */
  83343. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  83344. /**
  83345. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  83346. * @returns the new vector
  83347. */
  83348. static Zero(): Vector4;
  83349. /**
  83350. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  83351. * @returns the new vector
  83352. */
  83353. static One(): Vector4;
  83354. /**
  83355. * Returns a new normalized Vector4 from the given one.
  83356. * @param vector the vector to normalize
  83357. * @returns the vector
  83358. */
  83359. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  83360. /**
  83361. * Updates the given vector "result" from the normalization of the given one.
  83362. * @param vector the vector to normalize
  83363. * @param result the vector to store the result in
  83364. */
  83365. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  83366. /**
  83367. * Returns a vector with the minimum values from the left and right vectors
  83368. * @param left left vector to minimize
  83369. * @param right right vector to minimize
  83370. * @returns a new vector with the minimum of the left and right vector values
  83371. */
  83372. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  83373. /**
  83374. * Returns a vector with the maximum values from the left and right vectors
  83375. * @param left left vector to maximize
  83376. * @param right right vector to maximize
  83377. * @returns a new vector with the maximum of the left and right vector values
  83378. */
  83379. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  83380. /**
  83381. * Returns the distance (float) between the vectors "value1" and "value2".
  83382. * @param value1 value to calulate the distance between
  83383. * @param value2 value to calulate the distance between
  83384. * @return the distance between the two vectors
  83385. */
  83386. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  83387. /**
  83388. * Returns the squared distance (float) between the vectors "value1" and "value2".
  83389. * @param value1 value to calulate the distance between
  83390. * @param value2 value to calulate the distance between
  83391. * @return the distance between the two vectors squared
  83392. */
  83393. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  83394. /**
  83395. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  83396. * @param value1 value to calulate the center between
  83397. * @param value2 value to calulate the center between
  83398. * @return the center between the two vectors
  83399. */
  83400. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  83401. /**
  83402. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  83403. * This methods computes transformed normalized direction vectors only.
  83404. * @param vector the vector to transform
  83405. * @param transformation the transformation matrix to apply
  83406. * @returns the new vector
  83407. */
  83408. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  83409. /**
  83410. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  83411. * This methods computes transformed normalized direction vectors only.
  83412. * @param vector the vector to transform
  83413. * @param transformation the transformation matrix to apply
  83414. * @param result the vector to store the result in
  83415. */
  83416. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  83417. /**
  83418. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  83419. * This methods computes transformed normalized direction vectors only.
  83420. * @param x value to transform
  83421. * @param y value to transform
  83422. * @param z value to transform
  83423. * @param w value to transform
  83424. * @param transformation the transformation matrix to apply
  83425. * @param result the vector to store the results in
  83426. */
  83427. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  83428. /**
  83429. * Creates a new Vector4 from a Vector3
  83430. * @param source defines the source data
  83431. * @param w defines the 4th component (default is 0)
  83432. * @returns a new Vector4
  83433. */
  83434. static FromVector3(source: Vector3, w?: number): Vector4;
  83435. }
  83436. /**
  83437. * Class used to store quaternion data
  83438. * @see https://en.wikipedia.org/wiki/Quaternion
  83439. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  83440. */
  83441. export class Quaternion {
  83442. /** @hidden */
  83443. _x: number;
  83444. /** @hidden */
  83445. _y: number;
  83446. /** @hidden */
  83447. _z: number;
  83448. /** @hidden */
  83449. _w: number;
  83450. /** @hidden */
  83451. _isDirty: boolean;
  83452. /** Gets or sets the x coordinate */
  83453. get x(): number;
  83454. set x(value: number);
  83455. /** Gets or sets the y coordinate */
  83456. get y(): number;
  83457. set y(value: number);
  83458. /** Gets or sets the z coordinate */
  83459. get z(): number;
  83460. set z(value: number);
  83461. /** Gets or sets the w coordinate */
  83462. get w(): number;
  83463. set w(value: number);
  83464. /**
  83465. * Creates a new Quaternion from the given floats
  83466. * @param x defines the first component (0 by default)
  83467. * @param y defines the second component (0 by default)
  83468. * @param z defines the third component (0 by default)
  83469. * @param w defines the fourth component (1.0 by default)
  83470. */
  83471. constructor(x?: number, y?: number, z?: number, w?: number);
  83472. /**
  83473. * Gets a string representation for the current quaternion
  83474. * @returns a string with the Quaternion coordinates
  83475. */
  83476. toString(): string;
  83477. /**
  83478. * Gets the class name of the quaternion
  83479. * @returns the string "Quaternion"
  83480. */
  83481. getClassName(): string;
  83482. /**
  83483. * Gets a hash code for this quaternion
  83484. * @returns the quaternion hash code
  83485. */
  83486. getHashCode(): number;
  83487. /**
  83488. * Copy the quaternion to an array
  83489. * @returns a new array populated with 4 elements from the quaternion coordinates
  83490. */
  83491. asArray(): number[];
  83492. /**
  83493. * Check if two quaternions are equals
  83494. * @param otherQuaternion defines the second operand
  83495. * @return true if the current quaternion and the given one coordinates are strictly equals
  83496. */
  83497. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  83498. /**
  83499. * Gets a boolean if two quaternions are equals (using an epsilon value)
  83500. * @param otherQuaternion defines the other quaternion
  83501. * @param epsilon defines the minimal distance to consider equality
  83502. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  83503. */
  83504. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  83505. /**
  83506. * Clone the current quaternion
  83507. * @returns a new quaternion copied from the current one
  83508. */
  83509. clone(): Quaternion;
  83510. /**
  83511. * Copy a quaternion to the current one
  83512. * @param other defines the other quaternion
  83513. * @returns the updated current quaternion
  83514. */
  83515. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  83516. /**
  83517. * Updates the current quaternion with the given float coordinates
  83518. * @param x defines the x coordinate
  83519. * @param y defines the y coordinate
  83520. * @param z defines the z coordinate
  83521. * @param w defines the w coordinate
  83522. * @returns the updated current quaternion
  83523. */
  83524. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  83525. /**
  83526. * Updates the current quaternion from the given float coordinates
  83527. * @param x defines the x coordinate
  83528. * @param y defines the y coordinate
  83529. * @param z defines the z coordinate
  83530. * @param w defines the w coordinate
  83531. * @returns the updated current quaternion
  83532. */
  83533. set(x: number, y: number, z: number, w: number): Quaternion;
  83534. /**
  83535. * Adds two quaternions
  83536. * @param other defines the second operand
  83537. * @returns a new quaternion as the addition result of the given one and the current quaternion
  83538. */
  83539. add(other: DeepImmutable<Quaternion>): Quaternion;
  83540. /**
  83541. * Add a quaternion to the current one
  83542. * @param other defines the quaternion to add
  83543. * @returns the current quaternion
  83544. */
  83545. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  83546. /**
  83547. * Subtract two quaternions
  83548. * @param other defines the second operand
  83549. * @returns a new quaternion as the subtraction result of the given one from the current one
  83550. */
  83551. subtract(other: Quaternion): Quaternion;
  83552. /**
  83553. * Multiplies the current quaternion by a scale factor
  83554. * @param value defines the scale factor
  83555. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  83556. */
  83557. scale(value: number): Quaternion;
  83558. /**
  83559. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  83560. * @param scale defines the scale factor
  83561. * @param result defines the Quaternion object where to store the result
  83562. * @returns the unmodified current quaternion
  83563. */
  83564. scaleToRef(scale: number, result: Quaternion): Quaternion;
  83565. /**
  83566. * Multiplies in place the current quaternion by a scale factor
  83567. * @param value defines the scale factor
  83568. * @returns the current modified quaternion
  83569. */
  83570. scaleInPlace(value: number): Quaternion;
  83571. /**
  83572. * Scale the current quaternion values by a factor and add the result to a given quaternion
  83573. * @param scale defines the scale factor
  83574. * @param result defines the Quaternion object where to store the result
  83575. * @returns the unmodified current quaternion
  83576. */
  83577. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  83578. /**
  83579. * Multiplies two quaternions
  83580. * @param q1 defines the second operand
  83581. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  83582. */
  83583. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  83584. /**
  83585. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  83586. * @param q1 defines the second operand
  83587. * @param result defines the target quaternion
  83588. * @returns the current quaternion
  83589. */
  83590. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  83591. /**
  83592. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  83593. * @param q1 defines the second operand
  83594. * @returns the currentupdated quaternion
  83595. */
  83596. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  83597. /**
  83598. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  83599. * @param ref defines the target quaternion
  83600. * @returns the current quaternion
  83601. */
  83602. conjugateToRef(ref: Quaternion): Quaternion;
  83603. /**
  83604. * Conjugates in place (1-q) the current quaternion
  83605. * @returns the current updated quaternion
  83606. */
  83607. conjugateInPlace(): Quaternion;
  83608. /**
  83609. * Conjugates in place (1-q) the current quaternion
  83610. * @returns a new quaternion
  83611. */
  83612. conjugate(): Quaternion;
  83613. /**
  83614. * Gets length of current quaternion
  83615. * @returns the quaternion length (float)
  83616. */
  83617. length(): number;
  83618. /**
  83619. * Normalize in place the current quaternion
  83620. * @returns the current updated quaternion
  83621. */
  83622. normalize(): Quaternion;
  83623. /**
  83624. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  83625. * @param order is a reserved parameter and is ignore for now
  83626. * @returns a new Vector3 containing the Euler angles
  83627. */
  83628. toEulerAngles(order?: string): Vector3;
  83629. /**
  83630. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  83631. * @param result defines the vector which will be filled with the Euler angles
  83632. * @param order is a reserved parameter and is ignore for now
  83633. * @returns the current unchanged quaternion
  83634. */
  83635. toEulerAnglesToRef(result: Vector3): Quaternion;
  83636. /**
  83637. * Updates the given rotation matrix with the current quaternion values
  83638. * @param result defines the target matrix
  83639. * @returns the current unchanged quaternion
  83640. */
  83641. toRotationMatrix(result: Matrix): Quaternion;
  83642. /**
  83643. * Updates the current quaternion from the given rotation matrix values
  83644. * @param matrix defines the source matrix
  83645. * @returns the current updated quaternion
  83646. */
  83647. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  83648. /**
  83649. * Creates a new quaternion from a rotation matrix
  83650. * @param matrix defines the source matrix
  83651. * @returns a new quaternion created from the given rotation matrix values
  83652. */
  83653. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  83654. /**
  83655. * Updates the given quaternion with the given rotation matrix values
  83656. * @param matrix defines the source matrix
  83657. * @param result defines the target quaternion
  83658. */
  83659. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  83660. /**
  83661. * Returns the dot product (float) between the quaternions "left" and "right"
  83662. * @param left defines the left operand
  83663. * @param right defines the right operand
  83664. * @returns the dot product
  83665. */
  83666. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  83667. /**
  83668. * Checks if the two quaternions are close to each other
  83669. * @param quat0 defines the first quaternion to check
  83670. * @param quat1 defines the second quaternion to check
  83671. * @returns true if the two quaternions are close to each other
  83672. */
  83673. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  83674. /**
  83675. * Creates an empty quaternion
  83676. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  83677. */
  83678. static Zero(): Quaternion;
  83679. /**
  83680. * Inverse a given quaternion
  83681. * @param q defines the source quaternion
  83682. * @returns a new quaternion as the inverted current quaternion
  83683. */
  83684. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  83685. /**
  83686. * Inverse a given quaternion
  83687. * @param q defines the source quaternion
  83688. * @param result the quaternion the result will be stored in
  83689. * @returns the result quaternion
  83690. */
  83691. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  83692. /**
  83693. * Creates an identity quaternion
  83694. * @returns the identity quaternion
  83695. */
  83696. static Identity(): Quaternion;
  83697. /**
  83698. * Gets a boolean indicating if the given quaternion is identity
  83699. * @param quaternion defines the quaternion to check
  83700. * @returns true if the quaternion is identity
  83701. */
  83702. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  83703. /**
  83704. * Creates a quaternion from a rotation around an axis
  83705. * @param axis defines the axis to use
  83706. * @param angle defines the angle to use
  83707. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  83708. */
  83709. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  83710. /**
  83711. * Creates a rotation around an axis and stores it into the given quaternion
  83712. * @param axis defines the axis to use
  83713. * @param angle defines the angle to use
  83714. * @param result defines the target quaternion
  83715. * @returns the target quaternion
  83716. */
  83717. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  83718. /**
  83719. * Creates a new quaternion from data stored into an array
  83720. * @param array defines the data source
  83721. * @param offset defines the offset in the source array where the data starts
  83722. * @returns a new quaternion
  83723. */
  83724. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  83725. /**
  83726. * Updates the given quaternion "result" from the starting index of the given array.
  83727. * @param array the array to pull values from
  83728. * @param offset the offset into the array to start at
  83729. * @param result the quaternion to store the result in
  83730. */
  83731. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  83732. /**
  83733. * Create a quaternion from Euler rotation angles
  83734. * @param x Pitch
  83735. * @param y Yaw
  83736. * @param z Roll
  83737. * @returns the new Quaternion
  83738. */
  83739. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  83740. /**
  83741. * Updates a quaternion from Euler rotation angles
  83742. * @param x Pitch
  83743. * @param y Yaw
  83744. * @param z Roll
  83745. * @param result the quaternion to store the result
  83746. * @returns the updated quaternion
  83747. */
  83748. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  83749. /**
  83750. * Create a quaternion from Euler rotation vector
  83751. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  83752. * @returns the new Quaternion
  83753. */
  83754. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  83755. /**
  83756. * Updates a quaternion from Euler rotation vector
  83757. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  83758. * @param result the quaternion to store the result
  83759. * @returns the updated quaternion
  83760. */
  83761. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  83762. /**
  83763. * Creates a new quaternion from the given Euler float angles (y, x, z)
  83764. * @param yaw defines the rotation around Y axis
  83765. * @param pitch defines the rotation around X axis
  83766. * @param roll defines the rotation around Z axis
  83767. * @returns the new quaternion
  83768. */
  83769. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  83770. /**
  83771. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  83772. * @param yaw defines the rotation around Y axis
  83773. * @param pitch defines the rotation around X axis
  83774. * @param roll defines the rotation around Z axis
  83775. * @param result defines the target quaternion
  83776. */
  83777. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  83778. /**
  83779. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  83780. * @param alpha defines the rotation around first axis
  83781. * @param beta defines the rotation around second axis
  83782. * @param gamma defines the rotation around third axis
  83783. * @returns the new quaternion
  83784. */
  83785. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  83786. /**
  83787. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  83788. * @param alpha defines the rotation around first axis
  83789. * @param beta defines the rotation around second axis
  83790. * @param gamma defines the rotation around third axis
  83791. * @param result defines the target quaternion
  83792. */
  83793. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  83794. /**
  83795. * 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)
  83796. * @param axis1 defines the first axis
  83797. * @param axis2 defines the second axis
  83798. * @param axis3 defines the third axis
  83799. * @returns the new quaternion
  83800. */
  83801. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  83802. /**
  83803. * 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
  83804. * @param axis1 defines the first axis
  83805. * @param axis2 defines the second axis
  83806. * @param axis3 defines the third axis
  83807. * @param ref defines the target quaternion
  83808. */
  83809. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  83810. /**
  83811. * Interpolates between two quaternions
  83812. * @param left defines first quaternion
  83813. * @param right defines second quaternion
  83814. * @param amount defines the gradient to use
  83815. * @returns the new interpolated quaternion
  83816. */
  83817. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  83818. /**
  83819. * Interpolates between two quaternions and stores it into a target quaternion
  83820. * @param left defines first quaternion
  83821. * @param right defines second quaternion
  83822. * @param amount defines the gradient to use
  83823. * @param result defines the target quaternion
  83824. */
  83825. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  83826. /**
  83827. * Interpolate between two quaternions using Hermite interpolation
  83828. * @param value1 defines first quaternion
  83829. * @param tangent1 defines the incoming tangent
  83830. * @param value2 defines second quaternion
  83831. * @param tangent2 defines the outgoing tangent
  83832. * @param amount defines the target quaternion
  83833. * @returns the new interpolated quaternion
  83834. */
  83835. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  83836. }
  83837. /**
  83838. * Class used to store matrix data (4x4)
  83839. */
  83840. export class Matrix {
  83841. /**
  83842. * Gets the precision of matrix computations
  83843. */
  83844. static get Use64Bits(): boolean;
  83845. private static _updateFlagSeed;
  83846. private static _identityReadOnly;
  83847. private _isIdentity;
  83848. private _isIdentityDirty;
  83849. private _isIdentity3x2;
  83850. private _isIdentity3x2Dirty;
  83851. /**
  83852. * Gets the update flag of the matrix which is an unique number for the matrix.
  83853. * It will be incremented every time the matrix data change.
  83854. * You can use it to speed the comparison between two versions of the same matrix.
  83855. */
  83856. updateFlag: number;
  83857. private readonly _m;
  83858. /**
  83859. * Gets the internal data of the matrix
  83860. */
  83861. get m(): DeepImmutable<Float32Array | Array<number>>;
  83862. /** @hidden */
  83863. _markAsUpdated(): void;
  83864. /** @hidden */
  83865. private _updateIdentityStatus;
  83866. /**
  83867. * Creates an empty matrix (filled with zeros)
  83868. */
  83869. constructor();
  83870. /**
  83871. * Check if the current matrix is identity
  83872. * @returns true is the matrix is the identity matrix
  83873. */
  83874. isIdentity(): boolean;
  83875. /**
  83876. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  83877. * @returns true is the matrix is the identity matrix
  83878. */
  83879. isIdentityAs3x2(): boolean;
  83880. /**
  83881. * Gets the determinant of the matrix
  83882. * @returns the matrix determinant
  83883. */
  83884. determinant(): number;
  83885. /**
  83886. * Returns the matrix as a Float32Array or Array<number>
  83887. * @returns the matrix underlying array
  83888. */
  83889. toArray(): DeepImmutable<Float32Array | Array<number>>;
  83890. /**
  83891. * Returns the matrix as a Float32Array or Array<number>
  83892. * @returns the matrix underlying array.
  83893. */
  83894. asArray(): DeepImmutable<Float32Array | Array<number>>;
  83895. /**
  83896. * Inverts the current matrix in place
  83897. * @returns the current inverted matrix
  83898. */
  83899. invert(): Matrix;
  83900. /**
  83901. * Sets all the matrix elements to zero
  83902. * @returns the current matrix
  83903. */
  83904. reset(): Matrix;
  83905. /**
  83906. * Adds the current matrix with a second one
  83907. * @param other defines the matrix to add
  83908. * @returns a new matrix as the addition of the current matrix and the given one
  83909. */
  83910. add(other: DeepImmutable<Matrix>): Matrix;
  83911. /**
  83912. * Sets the given matrix "result" to the addition of the current matrix and the given one
  83913. * @param other defines the matrix to add
  83914. * @param result defines the target matrix
  83915. * @returns the current matrix
  83916. */
  83917. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  83918. /**
  83919. * Adds in place the given matrix to the current matrix
  83920. * @param other defines the second operand
  83921. * @returns the current updated matrix
  83922. */
  83923. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  83924. /**
  83925. * Sets the given matrix to the current inverted Matrix
  83926. * @param other defines the target matrix
  83927. * @returns the unmodified current matrix
  83928. */
  83929. invertToRef(other: Matrix): Matrix;
  83930. /**
  83931. * add a value at the specified position in the current Matrix
  83932. * @param index the index of the value within the matrix. between 0 and 15.
  83933. * @param value the value to be added
  83934. * @returns the current updated matrix
  83935. */
  83936. addAtIndex(index: number, value: number): Matrix;
  83937. /**
  83938. * mutiply the specified position in the current Matrix by a value
  83939. * @param index the index of the value within the matrix. between 0 and 15.
  83940. * @param value the value to be added
  83941. * @returns the current updated matrix
  83942. */
  83943. multiplyAtIndex(index: number, value: number): Matrix;
  83944. /**
  83945. * Inserts the translation vector (using 3 floats) in the current matrix
  83946. * @param x defines the 1st component of the translation
  83947. * @param y defines the 2nd component of the translation
  83948. * @param z defines the 3rd component of the translation
  83949. * @returns the current updated matrix
  83950. */
  83951. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  83952. /**
  83953. * Adds the translation vector (using 3 floats) in the current matrix
  83954. * @param x defines the 1st component of the translation
  83955. * @param y defines the 2nd component of the translation
  83956. * @param z defines the 3rd component of the translation
  83957. * @returns the current updated matrix
  83958. */
  83959. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  83960. /**
  83961. * Inserts the translation vector in the current matrix
  83962. * @param vector3 defines the translation to insert
  83963. * @returns the current updated matrix
  83964. */
  83965. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  83966. /**
  83967. * Gets the translation value of the current matrix
  83968. * @returns a new Vector3 as the extracted translation from the matrix
  83969. */
  83970. getTranslation(): Vector3;
  83971. /**
  83972. * Fill a Vector3 with the extracted translation from the matrix
  83973. * @param result defines the Vector3 where to store the translation
  83974. * @returns the current matrix
  83975. */
  83976. getTranslationToRef(result: Vector3): Matrix;
  83977. /**
  83978. * Remove rotation and scaling part from the matrix
  83979. * @returns the updated matrix
  83980. */
  83981. removeRotationAndScaling(): Matrix;
  83982. /**
  83983. * Multiply two matrices
  83984. * @param other defines the second operand
  83985. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  83986. */
  83987. multiply(other: DeepImmutable<Matrix>): Matrix;
  83988. /**
  83989. * Copy the current matrix from the given one
  83990. * @param other defines the source matrix
  83991. * @returns the current updated matrix
  83992. */
  83993. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  83994. /**
  83995. * Populates the given array from the starting index with the current matrix values
  83996. * @param array defines the target array
  83997. * @param offset defines the offset in the target array where to start storing values
  83998. * @returns the current matrix
  83999. */
  84000. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  84001. /**
  84002. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  84003. * @param other defines the second operand
  84004. * @param result defines the matrix where to store the multiplication
  84005. * @returns the current matrix
  84006. */
  84007. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84008. /**
  84009. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  84010. * @param other defines the second operand
  84011. * @param result defines the array where to store the multiplication
  84012. * @param offset defines the offset in the target array where to start storing values
  84013. * @returns the current matrix
  84014. */
  84015. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  84016. /**
  84017. * Check equality between this matrix and a second one
  84018. * @param value defines the second matrix to compare
  84019. * @returns true is the current matrix and the given one values are strictly equal
  84020. */
  84021. equals(value: DeepImmutable<Matrix>): boolean;
  84022. /**
  84023. * Clone the current matrix
  84024. * @returns a new matrix from the current matrix
  84025. */
  84026. clone(): Matrix;
  84027. /**
  84028. * Returns the name of the current matrix class
  84029. * @returns the string "Matrix"
  84030. */
  84031. getClassName(): string;
  84032. /**
  84033. * Gets the hash code of the current matrix
  84034. * @returns the hash code
  84035. */
  84036. getHashCode(): number;
  84037. /**
  84038. * Decomposes the current Matrix into a translation, rotation and scaling components
  84039. * @param scale defines the scale vector3 given as a reference to update
  84040. * @param rotation defines the rotation quaternion given as a reference to update
  84041. * @param translation defines the translation vector3 given as a reference to update
  84042. * @returns true if operation was successful
  84043. */
  84044. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  84045. /**
  84046. * Gets specific row of the matrix
  84047. * @param index defines the number of the row to get
  84048. * @returns the index-th row of the current matrix as a new Vector4
  84049. */
  84050. getRow(index: number): Nullable<Vector4>;
  84051. /**
  84052. * Sets the index-th row of the current matrix to the vector4 values
  84053. * @param index defines the number of the row to set
  84054. * @param row defines the target vector4
  84055. * @returns the updated current matrix
  84056. */
  84057. setRow(index: number, row: Vector4): Matrix;
  84058. /**
  84059. * Compute the transpose of the matrix
  84060. * @returns the new transposed matrix
  84061. */
  84062. transpose(): Matrix;
  84063. /**
  84064. * Compute the transpose of the matrix and store it in a given matrix
  84065. * @param result defines the target matrix
  84066. * @returns the current matrix
  84067. */
  84068. transposeToRef(result: Matrix): Matrix;
  84069. /**
  84070. * Sets the index-th row of the current matrix with the given 4 x float values
  84071. * @param index defines the row index
  84072. * @param x defines the x component to set
  84073. * @param y defines the y component to set
  84074. * @param z defines the z component to set
  84075. * @param w defines the w component to set
  84076. * @returns the updated current matrix
  84077. */
  84078. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  84079. /**
  84080. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  84081. * @param scale defines the scale factor
  84082. * @returns a new matrix
  84083. */
  84084. scale(scale: number): Matrix;
  84085. /**
  84086. * Scale the current matrix values by a factor to a given result matrix
  84087. * @param scale defines the scale factor
  84088. * @param result defines the matrix to store the result
  84089. * @returns the current matrix
  84090. */
  84091. scaleToRef(scale: number, result: Matrix): Matrix;
  84092. /**
  84093. * Scale the current matrix values by a factor and add the result to a given matrix
  84094. * @param scale defines the scale factor
  84095. * @param result defines the Matrix to store the result
  84096. * @returns the current matrix
  84097. */
  84098. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  84099. /**
  84100. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  84101. * @param ref matrix to store the result
  84102. */
  84103. toNormalMatrix(ref: Matrix): void;
  84104. /**
  84105. * Gets only rotation part of the current matrix
  84106. * @returns a new matrix sets to the extracted rotation matrix from the current one
  84107. */
  84108. getRotationMatrix(): Matrix;
  84109. /**
  84110. * Extracts the rotation matrix from the current one and sets it as the given "result"
  84111. * @param result defines the target matrix to store data to
  84112. * @returns the current matrix
  84113. */
  84114. getRotationMatrixToRef(result: Matrix): Matrix;
  84115. /**
  84116. * Toggles model matrix from being right handed to left handed in place and vice versa
  84117. */
  84118. toggleModelMatrixHandInPlace(): void;
  84119. /**
  84120. * Toggles projection matrix from being right handed to left handed in place and vice versa
  84121. */
  84122. toggleProjectionMatrixHandInPlace(): void;
  84123. /**
  84124. * Creates a matrix from an array
  84125. * @param array defines the source array
  84126. * @param offset defines an offset in the source array
  84127. * @returns a new Matrix set from the starting index of the given array
  84128. */
  84129. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  84130. /**
  84131. * Copy the content of an array into a given matrix
  84132. * @param array defines the source array
  84133. * @param offset defines an offset in the source array
  84134. * @param result defines the target matrix
  84135. */
  84136. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  84137. /**
  84138. * Stores an array into a matrix after having multiplied each component by a given factor
  84139. * @param array defines the source array
  84140. * @param offset defines the offset in the source array
  84141. * @param scale defines the scaling factor
  84142. * @param result defines the target matrix
  84143. */
  84144. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  84145. /**
  84146. * Gets an identity matrix that must not be updated
  84147. */
  84148. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  84149. /**
  84150. * Stores a list of values (16) inside a given matrix
  84151. * @param initialM11 defines 1st value of 1st row
  84152. * @param initialM12 defines 2nd value of 1st row
  84153. * @param initialM13 defines 3rd value of 1st row
  84154. * @param initialM14 defines 4th value of 1st row
  84155. * @param initialM21 defines 1st value of 2nd row
  84156. * @param initialM22 defines 2nd value of 2nd row
  84157. * @param initialM23 defines 3rd value of 2nd row
  84158. * @param initialM24 defines 4th value of 2nd row
  84159. * @param initialM31 defines 1st value of 3rd row
  84160. * @param initialM32 defines 2nd value of 3rd row
  84161. * @param initialM33 defines 3rd value of 3rd row
  84162. * @param initialM34 defines 4th value of 3rd row
  84163. * @param initialM41 defines 1st value of 4th row
  84164. * @param initialM42 defines 2nd value of 4th row
  84165. * @param initialM43 defines 3rd value of 4th row
  84166. * @param initialM44 defines 4th value of 4th row
  84167. * @param result defines the target matrix
  84168. */
  84169. 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;
  84170. /**
  84171. * Creates new matrix from a list of values (16)
  84172. * @param initialM11 defines 1st value of 1st row
  84173. * @param initialM12 defines 2nd value of 1st row
  84174. * @param initialM13 defines 3rd value of 1st row
  84175. * @param initialM14 defines 4th value of 1st row
  84176. * @param initialM21 defines 1st value of 2nd row
  84177. * @param initialM22 defines 2nd value of 2nd row
  84178. * @param initialM23 defines 3rd value of 2nd row
  84179. * @param initialM24 defines 4th value of 2nd row
  84180. * @param initialM31 defines 1st value of 3rd row
  84181. * @param initialM32 defines 2nd value of 3rd row
  84182. * @param initialM33 defines 3rd value of 3rd row
  84183. * @param initialM34 defines 4th value of 3rd row
  84184. * @param initialM41 defines 1st value of 4th row
  84185. * @param initialM42 defines 2nd value of 4th row
  84186. * @param initialM43 defines 3rd value of 4th row
  84187. * @param initialM44 defines 4th value of 4th row
  84188. * @returns the new matrix
  84189. */
  84190. 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;
  84191. /**
  84192. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84193. * @param scale defines the scale vector3
  84194. * @param rotation defines the rotation quaternion
  84195. * @param translation defines the translation vector3
  84196. * @returns a new matrix
  84197. */
  84198. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  84199. /**
  84200. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84201. * @param scale defines the scale vector3
  84202. * @param rotation defines the rotation quaternion
  84203. * @param translation defines the translation vector3
  84204. * @param result defines the target matrix
  84205. */
  84206. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  84207. /**
  84208. * Creates a new identity matrix
  84209. * @returns a new identity matrix
  84210. */
  84211. static Identity(): Matrix;
  84212. /**
  84213. * Creates a new identity matrix and stores the result in a given matrix
  84214. * @param result defines the target matrix
  84215. */
  84216. static IdentityToRef(result: Matrix): void;
  84217. /**
  84218. * Creates a new zero matrix
  84219. * @returns a new zero matrix
  84220. */
  84221. static Zero(): Matrix;
  84222. /**
  84223. * Creates a new rotation matrix for "angle" radians around the X axis
  84224. * @param angle defines the angle (in radians) to use
  84225. * @return the new matrix
  84226. */
  84227. static RotationX(angle: number): Matrix;
  84228. /**
  84229. * Creates a new matrix as the invert of a given matrix
  84230. * @param source defines the source matrix
  84231. * @returns the new matrix
  84232. */
  84233. static Invert(source: DeepImmutable<Matrix>): Matrix;
  84234. /**
  84235. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  84236. * @param angle defines the angle (in radians) to use
  84237. * @param result defines the target matrix
  84238. */
  84239. static RotationXToRef(angle: number, result: Matrix): void;
  84240. /**
  84241. * Creates a new rotation matrix for "angle" radians around the Y axis
  84242. * @param angle defines the angle (in radians) to use
  84243. * @return the new matrix
  84244. */
  84245. static RotationY(angle: number): Matrix;
  84246. /**
  84247. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  84248. * @param angle defines the angle (in radians) to use
  84249. * @param result defines the target matrix
  84250. */
  84251. static RotationYToRef(angle: number, result: Matrix): void;
  84252. /**
  84253. * Creates a new rotation matrix for "angle" radians around the Z axis
  84254. * @param angle defines the angle (in radians) to use
  84255. * @return the new matrix
  84256. */
  84257. static RotationZ(angle: number): Matrix;
  84258. /**
  84259. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  84260. * @param angle defines the angle (in radians) to use
  84261. * @param result defines the target matrix
  84262. */
  84263. static RotationZToRef(angle: number, result: Matrix): void;
  84264. /**
  84265. * Creates a new rotation matrix for "angle" radians around the given axis
  84266. * @param axis defines the axis to use
  84267. * @param angle defines the angle (in radians) to use
  84268. * @return the new matrix
  84269. */
  84270. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  84271. /**
  84272. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  84273. * @param axis defines the axis to use
  84274. * @param angle defines the angle (in radians) to use
  84275. * @param result defines the target matrix
  84276. */
  84277. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  84278. /**
  84279. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  84280. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  84281. * @param from defines the vector to align
  84282. * @param to defines the vector to align to
  84283. * @param result defines the target matrix
  84284. */
  84285. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  84286. /**
  84287. * Creates a rotation matrix
  84288. * @param yaw defines the yaw angle in radians (Y axis)
  84289. * @param pitch defines the pitch angle in radians (X axis)
  84290. * @param roll defines the roll angle in radians (Z axis)
  84291. * @returns the new rotation matrix
  84292. */
  84293. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  84294. /**
  84295. * Creates a rotation matrix and stores it in a given matrix
  84296. * @param yaw defines the yaw angle in radians (Y axis)
  84297. * @param pitch defines the pitch angle in radians (X axis)
  84298. * @param roll defines the roll angle in radians (Z axis)
  84299. * @param result defines the target matrix
  84300. */
  84301. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  84302. /**
  84303. * Creates a scaling matrix
  84304. * @param x defines the scale factor on X axis
  84305. * @param y defines the scale factor on Y axis
  84306. * @param z defines the scale factor on Z axis
  84307. * @returns the new matrix
  84308. */
  84309. static Scaling(x: number, y: number, z: number): Matrix;
  84310. /**
  84311. * Creates a scaling matrix and stores it in a given matrix
  84312. * @param x defines the scale factor on X axis
  84313. * @param y defines the scale factor on Y axis
  84314. * @param z defines the scale factor on Z axis
  84315. * @param result defines the target matrix
  84316. */
  84317. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  84318. /**
  84319. * Creates a translation matrix
  84320. * @param x defines the translation on X axis
  84321. * @param y defines the translation on Y axis
  84322. * @param z defines the translationon Z axis
  84323. * @returns the new matrix
  84324. */
  84325. static Translation(x: number, y: number, z: number): Matrix;
  84326. /**
  84327. * Creates a translation matrix and stores it in a given matrix
  84328. * @param x defines the translation on X axis
  84329. * @param y defines the translation on Y axis
  84330. * @param z defines the translationon Z axis
  84331. * @param result defines the target matrix
  84332. */
  84333. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  84334. /**
  84335. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  84336. * @param startValue defines the start value
  84337. * @param endValue defines the end value
  84338. * @param gradient defines the gradient factor
  84339. * @returns the new matrix
  84340. */
  84341. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  84342. /**
  84343. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  84344. * @param startValue defines the start value
  84345. * @param endValue defines the end value
  84346. * @param gradient defines the gradient factor
  84347. * @param result defines the Matrix object where to store data
  84348. */
  84349. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  84350. /**
  84351. * Builds a new matrix whose values are computed by:
  84352. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  84353. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  84354. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  84355. * @param startValue defines the first matrix
  84356. * @param endValue defines the second matrix
  84357. * @param gradient defines the gradient between the two matrices
  84358. * @returns the new matrix
  84359. */
  84360. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  84361. /**
  84362. * Update a matrix to values which are computed by:
  84363. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  84364. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  84365. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  84366. * @param startValue defines the first matrix
  84367. * @param endValue defines the second matrix
  84368. * @param gradient defines the gradient between the two matrices
  84369. * @param result defines the target matrix
  84370. */
  84371. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  84372. /**
  84373. * 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"
  84374. * This function works in left handed mode
  84375. * @param eye defines the final position of the entity
  84376. * @param target defines where the entity should look at
  84377. * @param up defines the up vector for the entity
  84378. * @returns the new matrix
  84379. */
  84380. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  84381. /**
  84382. * 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".
  84383. * This function works in left handed mode
  84384. * @param eye defines the final position of the entity
  84385. * @param target defines where the entity should look at
  84386. * @param up defines the up vector for the entity
  84387. * @param result defines the target matrix
  84388. */
  84389. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  84390. /**
  84391. * 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"
  84392. * This function works in right handed mode
  84393. * @param eye defines the final position of the entity
  84394. * @param target defines where the entity should look at
  84395. * @param up defines the up vector for the entity
  84396. * @returns the new matrix
  84397. */
  84398. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  84399. /**
  84400. * 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".
  84401. * This function works in right handed mode
  84402. * @param eye defines the final position of the entity
  84403. * @param target defines where the entity should look at
  84404. * @param up defines the up vector for the entity
  84405. * @param result defines the target matrix
  84406. */
  84407. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  84408. /**
  84409. * Create a left-handed orthographic projection matrix
  84410. * @param width defines the viewport width
  84411. * @param height defines the viewport height
  84412. * @param znear defines the near clip plane
  84413. * @param zfar defines the far clip plane
  84414. * @returns a new matrix as a left-handed orthographic projection matrix
  84415. */
  84416. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  84417. /**
  84418. * Store a left-handed orthographic projection to a given matrix
  84419. * @param width defines the viewport width
  84420. * @param height defines the viewport height
  84421. * @param znear defines the near clip plane
  84422. * @param zfar defines the far clip plane
  84423. * @param result defines the target matrix
  84424. */
  84425. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  84426. /**
  84427. * Create a left-handed orthographic projection matrix
  84428. * @param left defines the viewport left coordinate
  84429. * @param right defines the viewport right coordinate
  84430. * @param bottom defines the viewport bottom coordinate
  84431. * @param top defines the viewport top coordinate
  84432. * @param znear defines the near clip plane
  84433. * @param zfar defines the far clip plane
  84434. * @returns a new matrix as a left-handed orthographic projection matrix
  84435. */
  84436. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  84437. /**
  84438. * Stores a left-handed orthographic projection into a given matrix
  84439. * @param left defines the viewport left coordinate
  84440. * @param right defines the viewport right coordinate
  84441. * @param bottom defines the viewport bottom coordinate
  84442. * @param top defines the viewport top coordinate
  84443. * @param znear defines the near clip plane
  84444. * @param zfar defines the far clip plane
  84445. * @param result defines the target matrix
  84446. */
  84447. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  84448. /**
  84449. * Creates a right-handed orthographic projection matrix
  84450. * @param left defines the viewport left coordinate
  84451. * @param right defines the viewport right coordinate
  84452. * @param bottom defines the viewport bottom coordinate
  84453. * @param top defines the viewport top coordinate
  84454. * @param znear defines the near clip plane
  84455. * @param zfar defines the far clip plane
  84456. * @returns a new matrix as a right-handed orthographic projection matrix
  84457. */
  84458. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  84459. /**
  84460. * Stores a right-handed orthographic projection into a given matrix
  84461. * @param left defines the viewport left coordinate
  84462. * @param right defines the viewport right coordinate
  84463. * @param bottom defines the viewport bottom coordinate
  84464. * @param top defines the viewport top coordinate
  84465. * @param znear defines the near clip plane
  84466. * @param zfar defines the far clip plane
  84467. * @param result defines the target matrix
  84468. */
  84469. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  84470. /**
  84471. * Creates a left-handed perspective projection matrix
  84472. * @param width defines the viewport width
  84473. * @param height defines the viewport height
  84474. * @param znear defines the near clip plane
  84475. * @param zfar defines the far clip plane
  84476. * @returns a new matrix as a left-handed perspective projection matrix
  84477. */
  84478. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  84479. /**
  84480. * Creates a left-handed perspective projection matrix
  84481. * @param fov defines the horizontal field of view
  84482. * @param aspect defines the aspect ratio
  84483. * @param znear defines the near clip plane
  84484. * @param zfar defines the far clip plane
  84485. * @returns a new matrix as a left-handed perspective projection matrix
  84486. */
  84487. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  84488. /**
  84489. * Stores a left-handed perspective projection into a given matrix
  84490. * @param fov defines the horizontal field of view
  84491. * @param aspect defines the aspect ratio
  84492. * @param znear defines the near clip plane
  84493. * @param zfar defines the far clip plane
  84494. * @param result defines the target matrix
  84495. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84496. */
  84497. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84498. /**
  84499. * Stores a left-handed perspective projection into a given matrix with depth reversed
  84500. * @param fov defines the horizontal field of view
  84501. * @param aspect defines the aspect ratio
  84502. * @param znear defines the near clip plane
  84503. * @param zfar not used as infinity is used as far clip
  84504. * @param result defines the target matrix
  84505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84506. */
  84507. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84508. /**
  84509. * Creates a right-handed perspective projection matrix
  84510. * @param fov defines the horizontal field of view
  84511. * @param aspect defines the aspect ratio
  84512. * @param znear defines the near clip plane
  84513. * @param zfar defines the far clip plane
  84514. * @returns a new matrix as a right-handed perspective projection matrix
  84515. */
  84516. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  84517. /**
  84518. * Stores a right-handed perspective projection into a given matrix
  84519. * @param fov defines the horizontal field of view
  84520. * @param aspect defines the aspect ratio
  84521. * @param znear defines the near clip plane
  84522. * @param zfar defines the far clip plane
  84523. * @param result defines the target matrix
  84524. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84525. */
  84526. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84527. /**
  84528. * Stores a right-handed perspective projection into a given matrix
  84529. * @param fov defines the horizontal field of view
  84530. * @param aspect defines the aspect ratio
  84531. * @param znear defines the near clip plane
  84532. * @param zfar not used as infinity is used as far clip
  84533. * @param result defines the target matrix
  84534. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84535. */
  84536. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84537. /**
  84538. * Stores a perspective projection for WebVR info a given matrix
  84539. * @param fov defines the field of view
  84540. * @param znear defines the near clip plane
  84541. * @param zfar defines the far clip plane
  84542. * @param result defines the target matrix
  84543. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  84544. */
  84545. static PerspectiveFovWebVRToRef(fov: {
  84546. upDegrees: number;
  84547. downDegrees: number;
  84548. leftDegrees: number;
  84549. rightDegrees: number;
  84550. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  84551. /**
  84552. * Computes a complete transformation matrix
  84553. * @param viewport defines the viewport to use
  84554. * @param world defines the world matrix
  84555. * @param view defines the view matrix
  84556. * @param projection defines the projection matrix
  84557. * @param zmin defines the near clip plane
  84558. * @param zmax defines the far clip plane
  84559. * @returns the transformation matrix
  84560. */
  84561. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  84562. /**
  84563. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  84564. * @param matrix defines the matrix to use
  84565. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  84566. */
  84567. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  84568. /**
  84569. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  84570. * @param matrix defines the matrix to use
  84571. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  84572. */
  84573. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  84574. /**
  84575. * Compute the transpose of a given matrix
  84576. * @param matrix defines the matrix to transpose
  84577. * @returns the new matrix
  84578. */
  84579. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  84580. /**
  84581. * Compute the transpose of a matrix and store it in a target matrix
  84582. * @param matrix defines the matrix to transpose
  84583. * @param result defines the target matrix
  84584. */
  84585. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  84586. /**
  84587. * Computes a reflection matrix from a plane
  84588. * @param plane defines the reflection plane
  84589. * @returns a new matrix
  84590. */
  84591. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  84592. /**
  84593. * Computes a reflection matrix from a plane
  84594. * @param plane defines the reflection plane
  84595. * @param result defines the target matrix
  84596. */
  84597. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  84598. /**
  84599. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  84600. * @param xaxis defines the value of the 1st axis
  84601. * @param yaxis defines the value of the 2nd axis
  84602. * @param zaxis defines the value of the 3rd axis
  84603. * @param result defines the target matrix
  84604. */
  84605. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  84606. /**
  84607. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  84608. * @param quat defines the quaternion to use
  84609. * @param result defines the target matrix
  84610. */
  84611. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  84612. }
  84613. /**
  84614. * @hidden
  84615. */
  84616. export class TmpVectors {
  84617. static Vector2: Vector2[];
  84618. static Vector3: Vector3[];
  84619. static Vector4: Vector4[];
  84620. static Quaternion: Quaternion[];
  84621. static Matrix: Matrix[];
  84622. }
  84623. }
  84624. declare module BABYLON {
  84625. /**
  84626. * Defines potential orientation for back face culling
  84627. */
  84628. export enum Orientation {
  84629. /**
  84630. * Clockwise
  84631. */
  84632. CW = 0,
  84633. /** Counter clockwise */
  84634. CCW = 1
  84635. }
  84636. /** Class used to represent a Bezier curve */
  84637. export class BezierCurve {
  84638. /**
  84639. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  84640. * @param t defines the time
  84641. * @param x1 defines the left coordinate on X axis
  84642. * @param y1 defines the left coordinate on Y axis
  84643. * @param x2 defines the right coordinate on X axis
  84644. * @param y2 defines the right coordinate on Y axis
  84645. * @returns the interpolated value
  84646. */
  84647. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  84648. }
  84649. /**
  84650. * Defines angle representation
  84651. */
  84652. export class Angle {
  84653. private _radians;
  84654. /**
  84655. * Creates an Angle object of "radians" radians (float).
  84656. * @param radians the angle in radians
  84657. */
  84658. constructor(radians: number);
  84659. /**
  84660. * Get value in degrees
  84661. * @returns the Angle value in degrees (float)
  84662. */
  84663. degrees(): number;
  84664. /**
  84665. * Get value in radians
  84666. * @returns the Angle value in radians (float)
  84667. */
  84668. radians(): number;
  84669. /**
  84670. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  84671. * @param a defines first point as the origin
  84672. * @param b defines point
  84673. * @returns a new Angle
  84674. */
  84675. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  84676. /**
  84677. * Gets a new Angle object from the given float in radians
  84678. * @param radians defines the angle value in radians
  84679. * @returns a new Angle
  84680. */
  84681. static FromRadians(radians: number): Angle;
  84682. /**
  84683. * Gets a new Angle object from the given float in degrees
  84684. * @param degrees defines the angle value in degrees
  84685. * @returns a new Angle
  84686. */
  84687. static FromDegrees(degrees: number): Angle;
  84688. }
  84689. /**
  84690. * This represents an arc in a 2d space.
  84691. */
  84692. export class Arc2 {
  84693. /** Defines the start point of the arc */
  84694. startPoint: Vector2;
  84695. /** Defines the mid point of the arc */
  84696. midPoint: Vector2;
  84697. /** Defines the end point of the arc */
  84698. endPoint: Vector2;
  84699. /**
  84700. * Defines the center point of the arc.
  84701. */
  84702. centerPoint: Vector2;
  84703. /**
  84704. * Defines the radius of the arc.
  84705. */
  84706. radius: number;
  84707. /**
  84708. * Defines the angle of the arc (from mid point to end point).
  84709. */
  84710. angle: Angle;
  84711. /**
  84712. * Defines the start angle of the arc (from start point to middle point).
  84713. */
  84714. startAngle: Angle;
  84715. /**
  84716. * Defines the orientation of the arc (clock wise/counter clock wise).
  84717. */
  84718. orientation: Orientation;
  84719. /**
  84720. * Creates an Arc object from the three given points : start, middle and end.
  84721. * @param startPoint Defines the start point of the arc
  84722. * @param midPoint Defines the midlle point of the arc
  84723. * @param endPoint Defines the end point of the arc
  84724. */
  84725. constructor(
  84726. /** Defines the start point of the arc */
  84727. startPoint: Vector2,
  84728. /** Defines the mid point of the arc */
  84729. midPoint: Vector2,
  84730. /** Defines the end point of the arc */
  84731. endPoint: Vector2);
  84732. }
  84733. /**
  84734. * Represents a 2D path made up of multiple 2D points
  84735. */
  84736. export class Path2 {
  84737. private _points;
  84738. private _length;
  84739. /**
  84740. * If the path start and end point are the same
  84741. */
  84742. closed: boolean;
  84743. /**
  84744. * Creates a Path2 object from the starting 2D coordinates x and y.
  84745. * @param x the starting points x value
  84746. * @param y the starting points y value
  84747. */
  84748. constructor(x: number, y: number);
  84749. /**
  84750. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  84751. * @param x the added points x value
  84752. * @param y the added points y value
  84753. * @returns the updated Path2.
  84754. */
  84755. addLineTo(x: number, y: number): Path2;
  84756. /**
  84757. * 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.
  84758. * @param midX middle point x value
  84759. * @param midY middle point y value
  84760. * @param endX end point x value
  84761. * @param endY end point y value
  84762. * @param numberOfSegments (default: 36)
  84763. * @returns the updated Path2.
  84764. */
  84765. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  84766. /**
  84767. * Closes the Path2.
  84768. * @returns the Path2.
  84769. */
  84770. close(): Path2;
  84771. /**
  84772. * Gets the sum of the distance between each sequential point in the path
  84773. * @returns the Path2 total length (float).
  84774. */
  84775. length(): number;
  84776. /**
  84777. * Gets the points which construct the path
  84778. * @returns the Path2 internal array of points.
  84779. */
  84780. getPoints(): Vector2[];
  84781. /**
  84782. * Retreives the point at the distance aways from the starting point
  84783. * @param normalizedLengthPosition the length along the path to retreive the point from
  84784. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  84785. */
  84786. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  84787. /**
  84788. * Creates a new path starting from an x and y position
  84789. * @param x starting x value
  84790. * @param y starting y value
  84791. * @returns a new Path2 starting at the coordinates (x, y).
  84792. */
  84793. static StartingAt(x: number, y: number): Path2;
  84794. }
  84795. /**
  84796. * Represents a 3D path made up of multiple 3D points
  84797. */
  84798. export class Path3D {
  84799. /**
  84800. * an array of Vector3, the curve axis of the Path3D
  84801. */
  84802. path: Vector3[];
  84803. private _curve;
  84804. private _distances;
  84805. private _tangents;
  84806. private _normals;
  84807. private _binormals;
  84808. private _raw;
  84809. private _alignTangentsWithPath;
  84810. private readonly _pointAtData;
  84811. /**
  84812. * new Path3D(path, normal, raw)
  84813. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  84814. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  84815. * @param path an array of Vector3, the curve axis of the Path3D
  84816. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  84817. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  84818. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  84819. */
  84820. constructor(
  84821. /**
  84822. * an array of Vector3, the curve axis of the Path3D
  84823. */
  84824. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  84825. /**
  84826. * Returns the Path3D array of successive Vector3 designing its curve.
  84827. * @returns the Path3D array of successive Vector3 designing its curve.
  84828. */
  84829. getCurve(): Vector3[];
  84830. /**
  84831. * Returns the Path3D array of successive Vector3 designing its curve.
  84832. * @returns the Path3D array of successive Vector3 designing its curve.
  84833. */
  84834. getPoints(): Vector3[];
  84835. /**
  84836. * @returns the computed length (float) of the path.
  84837. */
  84838. length(): number;
  84839. /**
  84840. * Returns an array populated with tangent vectors on each Path3D curve point.
  84841. * @returns an array populated with tangent vectors on each Path3D curve point.
  84842. */
  84843. getTangents(): Vector3[];
  84844. /**
  84845. * Returns an array populated with normal vectors on each Path3D curve point.
  84846. * @returns an array populated with normal vectors on each Path3D curve point.
  84847. */
  84848. getNormals(): Vector3[];
  84849. /**
  84850. * Returns an array populated with binormal vectors on each Path3D curve point.
  84851. * @returns an array populated with binormal vectors on each Path3D curve point.
  84852. */
  84853. getBinormals(): Vector3[];
  84854. /**
  84855. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  84856. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  84857. */
  84858. getDistances(): number[];
  84859. /**
  84860. * Returns an interpolated point along this path
  84861. * @param position the position of the point along this path, from 0.0 to 1.0
  84862. * @returns a new Vector3 as the point
  84863. */
  84864. getPointAt(position: number): Vector3;
  84865. /**
  84866. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  84867. * @param position the position of the point along this path, from 0.0 to 1.0
  84868. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  84869. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  84870. */
  84871. getTangentAt(position: number, interpolated?: boolean): Vector3;
  84872. /**
  84873. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  84874. * @param position the position of the point along this path, from 0.0 to 1.0
  84875. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  84876. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  84877. */
  84878. getNormalAt(position: number, interpolated?: boolean): Vector3;
  84879. /**
  84880. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  84881. * @param position the position of the point along this path, from 0.0 to 1.0
  84882. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  84883. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  84884. */
  84885. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  84886. /**
  84887. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  84888. * @param position the position of the point along this path, from 0.0 to 1.0
  84889. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  84890. */
  84891. getDistanceAt(position: number): number;
  84892. /**
  84893. * Returns the array index of the previous point of an interpolated point along this path
  84894. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  84895. * @returns the array index
  84896. */
  84897. getPreviousPointIndexAt(position: number): number;
  84898. /**
  84899. * 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)
  84900. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  84901. * @returns the sub position
  84902. */
  84903. getSubPositionAt(position: number): number;
  84904. /**
  84905. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  84906. * @param target the vector of which to get the closest position to
  84907. * @returns the position of the closest virtual point on this path to the target vector
  84908. */
  84909. getClosestPositionTo(target: Vector3): number;
  84910. /**
  84911. * Returns a sub path (slice) of this path
  84912. * @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
  84913. * @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
  84914. * @returns a sub path (slice) of this path
  84915. */
  84916. slice(start?: number, end?: number): Path3D;
  84917. /**
  84918. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  84919. * @param path path which all values are copied into the curves points
  84920. * @param firstNormal which should be projected onto the curve
  84921. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  84922. * @returns the same object updated.
  84923. */
  84924. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  84925. private _compute;
  84926. private _getFirstNonNullVector;
  84927. private _getLastNonNullVector;
  84928. private _normalVector;
  84929. /**
  84930. * Updates the point at data for an interpolated point along this curve
  84931. * @param position the position of the point along this curve, from 0.0 to 1.0
  84932. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  84933. * @returns the (updated) point at data
  84934. */
  84935. private _updatePointAtData;
  84936. /**
  84937. * Updates the point at data from the specified parameters
  84938. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  84939. * @param point the interpolated point
  84940. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  84941. */
  84942. private _setPointAtData;
  84943. /**
  84944. * Updates the point at interpolation matrix for the tangents, normals and binormals
  84945. */
  84946. private _updateInterpolationMatrix;
  84947. }
  84948. /**
  84949. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  84950. * A Curve3 is designed from a series of successive Vector3.
  84951. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  84952. */
  84953. export class Curve3 {
  84954. private _points;
  84955. private _length;
  84956. /**
  84957. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  84958. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  84959. * @param v1 (Vector3) the control point
  84960. * @param v2 (Vector3) the end point of the Quadratic Bezier
  84961. * @param nbPoints (integer) the wanted number of points in the curve
  84962. * @returns the created Curve3
  84963. */
  84964. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84965. /**
  84966. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  84967. * @param v0 (Vector3) the origin point of the Cubic Bezier
  84968. * @param v1 (Vector3) the first control point
  84969. * @param v2 (Vector3) the second control point
  84970. * @param v3 (Vector3) the end point of the Cubic Bezier
  84971. * @param nbPoints (integer) the wanted number of points in the curve
  84972. * @returns the created Curve3
  84973. */
  84974. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84975. /**
  84976. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  84977. * @param p1 (Vector3) the origin point of the Hermite Spline
  84978. * @param t1 (Vector3) the tangent vector at the origin point
  84979. * @param p2 (Vector3) the end point of the Hermite Spline
  84980. * @param t2 (Vector3) the tangent vector at the end point
  84981. * @param nbPoints (integer) the wanted number of points in the curve
  84982. * @returns the created Curve3
  84983. */
  84984. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  84985. /**
  84986. * Returns a Curve3 object along a CatmullRom Spline curve :
  84987. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  84988. * @param nbPoints (integer) the wanted number of points between each curve control points
  84989. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  84990. * @returns the created Curve3
  84991. */
  84992. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  84993. /**
  84994. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  84995. * A Curve3 is designed from a series of successive Vector3.
  84996. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  84997. * @param points points which make up the curve
  84998. */
  84999. constructor(points: Vector3[]);
  85000. /**
  85001. * @returns the Curve3 stored array of successive Vector3
  85002. */
  85003. getPoints(): Vector3[];
  85004. /**
  85005. * @returns the computed length (float) of the curve.
  85006. */
  85007. length(): number;
  85008. /**
  85009. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  85010. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  85011. * curveA and curveB keep unchanged.
  85012. * @param curve the curve to continue from this curve
  85013. * @returns the newly constructed curve
  85014. */
  85015. continue(curve: DeepImmutable<Curve3>): Curve3;
  85016. private _computeLength;
  85017. }
  85018. }
  85019. declare module BABYLON {
  85020. /**
  85021. * This represents the main contract an easing function should follow.
  85022. * Easing functions are used throughout the animation system.
  85023. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85024. */
  85025. export interface IEasingFunction {
  85026. /**
  85027. * Given an input gradient between 0 and 1, this returns the corrseponding value
  85028. * of the easing function.
  85029. * The link below provides some of the most common examples of easing functions.
  85030. * @see https://easings.net/
  85031. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85032. * @returns the corresponding value on the curve defined by the easing function
  85033. */
  85034. ease(gradient: number): number;
  85035. }
  85036. /**
  85037. * Base class used for every default easing function.
  85038. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85039. */
  85040. export class EasingFunction implements IEasingFunction {
  85041. /**
  85042. * Interpolation follows the mathematical formula associated with the easing function.
  85043. */
  85044. static readonly EASINGMODE_EASEIN: number;
  85045. /**
  85046. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  85047. */
  85048. static readonly EASINGMODE_EASEOUT: number;
  85049. /**
  85050. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  85051. */
  85052. static readonly EASINGMODE_EASEINOUT: number;
  85053. private _easingMode;
  85054. /**
  85055. * Sets the easing mode of the current function.
  85056. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  85057. */
  85058. setEasingMode(easingMode: number): void;
  85059. /**
  85060. * Gets the current easing mode.
  85061. * @returns the easing mode
  85062. */
  85063. getEasingMode(): number;
  85064. /**
  85065. * @hidden
  85066. */
  85067. easeInCore(gradient: number): number;
  85068. /**
  85069. * Given an input gradient between 0 and 1, this returns the corresponding value
  85070. * of the easing function.
  85071. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85072. * @returns the corresponding value on the curve defined by the easing function
  85073. */
  85074. ease(gradient: number): number;
  85075. }
  85076. /**
  85077. * Easing function with a circle shape (see link below).
  85078. * @see https://easings.net/#easeInCirc
  85079. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85080. */
  85081. export class CircleEase extends EasingFunction implements IEasingFunction {
  85082. /** @hidden */
  85083. easeInCore(gradient: number): number;
  85084. }
  85085. /**
  85086. * Easing function with a ease back shape (see link below).
  85087. * @see https://easings.net/#easeInBack
  85088. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85089. */
  85090. export class BackEase extends EasingFunction implements IEasingFunction {
  85091. /** Defines the amplitude of the function */
  85092. amplitude: number;
  85093. /**
  85094. * Instantiates a back ease easing
  85095. * @see https://easings.net/#easeInBack
  85096. * @param amplitude Defines the amplitude of the function
  85097. */
  85098. constructor(
  85099. /** Defines the amplitude of the function */
  85100. amplitude?: number);
  85101. /** @hidden */
  85102. easeInCore(gradient: number): number;
  85103. }
  85104. /**
  85105. * Easing function with a bouncing shape (see link below).
  85106. * @see https://easings.net/#easeInBounce
  85107. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85108. */
  85109. export class BounceEase extends EasingFunction implements IEasingFunction {
  85110. /** Defines the number of bounces */
  85111. bounces: number;
  85112. /** Defines the amplitude of the bounce */
  85113. bounciness: number;
  85114. /**
  85115. * Instantiates a bounce easing
  85116. * @see https://easings.net/#easeInBounce
  85117. * @param bounces Defines the number of bounces
  85118. * @param bounciness Defines the amplitude of the bounce
  85119. */
  85120. constructor(
  85121. /** Defines the number of bounces */
  85122. bounces?: number,
  85123. /** Defines the amplitude of the bounce */
  85124. bounciness?: number);
  85125. /** @hidden */
  85126. easeInCore(gradient: number): number;
  85127. }
  85128. /**
  85129. * Easing function with a power of 3 shape (see link below).
  85130. * @see https://easings.net/#easeInCubic
  85131. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85132. */
  85133. export class CubicEase extends EasingFunction implements IEasingFunction {
  85134. /** @hidden */
  85135. easeInCore(gradient: number): number;
  85136. }
  85137. /**
  85138. * Easing function with an elastic shape (see link below).
  85139. * @see https://easings.net/#easeInElastic
  85140. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85141. */
  85142. export class ElasticEase extends EasingFunction implements IEasingFunction {
  85143. /** Defines the number of oscillations*/
  85144. oscillations: number;
  85145. /** Defines the amplitude of the oscillations*/
  85146. springiness: number;
  85147. /**
  85148. * Instantiates an elastic easing function
  85149. * @see https://easings.net/#easeInElastic
  85150. * @param oscillations Defines the number of oscillations
  85151. * @param springiness Defines the amplitude of the oscillations
  85152. */
  85153. constructor(
  85154. /** Defines the number of oscillations*/
  85155. oscillations?: number,
  85156. /** Defines the amplitude of the oscillations*/
  85157. springiness?: number);
  85158. /** @hidden */
  85159. easeInCore(gradient: number): number;
  85160. }
  85161. /**
  85162. * Easing function with an exponential shape (see link below).
  85163. * @see https://easings.net/#easeInExpo
  85164. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85165. */
  85166. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  85167. /** Defines the exponent of the function */
  85168. exponent: number;
  85169. /**
  85170. * Instantiates an exponential easing function
  85171. * @see https://easings.net/#easeInExpo
  85172. * @param exponent Defines the exponent of the function
  85173. */
  85174. constructor(
  85175. /** Defines the exponent of the function */
  85176. exponent?: number);
  85177. /** @hidden */
  85178. easeInCore(gradient: number): number;
  85179. }
  85180. /**
  85181. * Easing function with a power shape (see link below).
  85182. * @see https://easings.net/#easeInQuad
  85183. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85184. */
  85185. export class PowerEase extends EasingFunction implements IEasingFunction {
  85186. /** Defines the power of the function */
  85187. power: number;
  85188. /**
  85189. * Instantiates an power base easing function
  85190. * @see https://easings.net/#easeInQuad
  85191. * @param power Defines the power of the function
  85192. */
  85193. constructor(
  85194. /** Defines the power of the function */
  85195. power?: number);
  85196. /** @hidden */
  85197. easeInCore(gradient: number): number;
  85198. }
  85199. /**
  85200. * Easing function with a power of 2 shape (see link below).
  85201. * @see https://easings.net/#easeInQuad
  85202. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85203. */
  85204. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  85205. /** @hidden */
  85206. easeInCore(gradient: number): number;
  85207. }
  85208. /**
  85209. * Easing function with a power of 4 shape (see link below).
  85210. * @see https://easings.net/#easeInQuart
  85211. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85212. */
  85213. export class QuarticEase extends EasingFunction implements IEasingFunction {
  85214. /** @hidden */
  85215. easeInCore(gradient: number): number;
  85216. }
  85217. /**
  85218. * Easing function with a power of 5 shape (see link below).
  85219. * @see https://easings.net/#easeInQuint
  85220. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85221. */
  85222. export class QuinticEase extends EasingFunction implements IEasingFunction {
  85223. /** @hidden */
  85224. easeInCore(gradient: number): number;
  85225. }
  85226. /**
  85227. * Easing function with a sin shape (see link below).
  85228. * @see https://easings.net/#easeInSine
  85229. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85230. */
  85231. export class SineEase extends EasingFunction implements IEasingFunction {
  85232. /** @hidden */
  85233. easeInCore(gradient: number): number;
  85234. }
  85235. /**
  85236. * Easing function with a bezier shape (see link below).
  85237. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85238. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85239. */
  85240. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  85241. /** Defines the x component of the start tangent in the bezier curve */
  85242. x1: number;
  85243. /** Defines the y component of the start tangent in the bezier curve */
  85244. y1: number;
  85245. /** Defines the x component of the end tangent in the bezier curve */
  85246. x2: number;
  85247. /** Defines the y component of the end tangent in the bezier curve */
  85248. y2: number;
  85249. /**
  85250. * Instantiates a bezier function
  85251. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85252. * @param x1 Defines the x component of the start tangent in the bezier curve
  85253. * @param y1 Defines the y component of the start tangent in the bezier curve
  85254. * @param x2 Defines the x component of the end tangent in the bezier curve
  85255. * @param y2 Defines the y component of the end tangent in the bezier curve
  85256. */
  85257. constructor(
  85258. /** Defines the x component of the start tangent in the bezier curve */
  85259. x1?: number,
  85260. /** Defines the y component of the start tangent in the bezier curve */
  85261. y1?: number,
  85262. /** Defines the x component of the end tangent in the bezier curve */
  85263. x2?: number,
  85264. /** Defines the y component of the end tangent in the bezier curve */
  85265. y2?: number);
  85266. /** @hidden */
  85267. easeInCore(gradient: number): number;
  85268. }
  85269. }
  85270. declare module BABYLON {
  85271. /**
  85272. * Class used to hold a RBG color
  85273. */
  85274. export class Color3 {
  85275. /**
  85276. * Defines the red component (between 0 and 1, default is 0)
  85277. */
  85278. r: number;
  85279. /**
  85280. * Defines the green component (between 0 and 1, default is 0)
  85281. */
  85282. g: number;
  85283. /**
  85284. * Defines the blue component (between 0 and 1, default is 0)
  85285. */
  85286. b: number;
  85287. /**
  85288. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  85289. * @param r defines the red component (between 0 and 1, default is 0)
  85290. * @param g defines the green component (between 0 and 1, default is 0)
  85291. * @param b defines the blue component (between 0 and 1, default is 0)
  85292. */
  85293. constructor(
  85294. /**
  85295. * Defines the red component (between 0 and 1, default is 0)
  85296. */
  85297. r?: number,
  85298. /**
  85299. * Defines the green component (between 0 and 1, default is 0)
  85300. */
  85301. g?: number,
  85302. /**
  85303. * Defines the blue component (between 0 and 1, default is 0)
  85304. */
  85305. b?: number);
  85306. /**
  85307. * Creates a string with the Color3 current values
  85308. * @returns the string representation of the Color3 object
  85309. */
  85310. toString(): string;
  85311. /**
  85312. * Returns the string "Color3"
  85313. * @returns "Color3"
  85314. */
  85315. getClassName(): string;
  85316. /**
  85317. * Compute the Color3 hash code
  85318. * @returns an unique number that can be used to hash Color3 objects
  85319. */
  85320. getHashCode(): number;
  85321. /**
  85322. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  85323. * @param array defines the array where to store the r,g,b components
  85324. * @param index defines an optional index in the target array to define where to start storing values
  85325. * @returns the current Color3 object
  85326. */
  85327. toArray(array: FloatArray, index?: number): Color3;
  85328. /**
  85329. * Update the current color with values stored in an array from the starting index of the given array
  85330. * @param array defines the source array
  85331. * @param offset defines an offset in the source array
  85332. * @returns the current Color3 object
  85333. */
  85334. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  85335. /**
  85336. * Returns a new Color4 object from the current Color3 and the given alpha
  85337. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  85338. * @returns a new Color4 object
  85339. */
  85340. toColor4(alpha?: number): Color4;
  85341. /**
  85342. * Returns a new array populated with 3 numeric elements : red, green and blue values
  85343. * @returns the new array
  85344. */
  85345. asArray(): number[];
  85346. /**
  85347. * Returns the luminance value
  85348. * @returns a float value
  85349. */
  85350. toLuminance(): number;
  85351. /**
  85352. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  85353. * @param otherColor defines the second operand
  85354. * @returns the new Color3 object
  85355. */
  85356. multiply(otherColor: DeepImmutable<Color3>): Color3;
  85357. /**
  85358. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  85359. * @param otherColor defines the second operand
  85360. * @param result defines the Color3 object where to store the result
  85361. * @returns the current Color3
  85362. */
  85363. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85364. /**
  85365. * Determines equality between Color3 objects
  85366. * @param otherColor defines the second operand
  85367. * @returns true if the rgb values are equal to the given ones
  85368. */
  85369. equals(otherColor: DeepImmutable<Color3>): boolean;
  85370. /**
  85371. * Determines equality between the current Color3 object and a set of r,b,g values
  85372. * @param r defines the red component to check
  85373. * @param g defines the green component to check
  85374. * @param b defines the blue component to check
  85375. * @returns true if the rgb values are equal to the given ones
  85376. */
  85377. equalsFloats(r: number, g: number, b: number): boolean;
  85378. /**
  85379. * Multiplies in place each rgb value by scale
  85380. * @param scale defines the scaling factor
  85381. * @returns the updated Color3
  85382. */
  85383. scale(scale: number): Color3;
  85384. /**
  85385. * Multiplies the rgb values by scale and stores the result into "result"
  85386. * @param scale defines the scaling factor
  85387. * @param result defines the Color3 object where to store the result
  85388. * @returns the unmodified current Color3
  85389. */
  85390. scaleToRef(scale: number, result: Color3): Color3;
  85391. /**
  85392. * Scale the current Color3 values by a factor and add the result to a given Color3
  85393. * @param scale defines the scale factor
  85394. * @param result defines color to store the result into
  85395. * @returns the unmodified current Color3
  85396. */
  85397. scaleAndAddToRef(scale: number, result: Color3): Color3;
  85398. /**
  85399. * Clamps the rgb values by the min and max values and stores the result into "result"
  85400. * @param min defines minimum clamping value (default is 0)
  85401. * @param max defines maximum clamping value (default is 1)
  85402. * @param result defines color to store the result into
  85403. * @returns the original Color3
  85404. */
  85405. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  85406. /**
  85407. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  85408. * @param otherColor defines the second operand
  85409. * @returns the new Color3
  85410. */
  85411. add(otherColor: DeepImmutable<Color3>): Color3;
  85412. /**
  85413. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  85414. * @param otherColor defines the second operand
  85415. * @param result defines Color3 object to store the result into
  85416. * @returns the unmodified current Color3
  85417. */
  85418. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85419. /**
  85420. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  85421. * @param otherColor defines the second operand
  85422. * @returns the new Color3
  85423. */
  85424. subtract(otherColor: DeepImmutable<Color3>): Color3;
  85425. /**
  85426. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  85427. * @param otherColor defines the second operand
  85428. * @param result defines Color3 object to store the result into
  85429. * @returns the unmodified current Color3
  85430. */
  85431. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85432. /**
  85433. * Copy the current object
  85434. * @returns a new Color3 copied the current one
  85435. */
  85436. clone(): Color3;
  85437. /**
  85438. * Copies the rgb values from the source in the current Color3
  85439. * @param source defines the source Color3 object
  85440. * @returns the updated Color3 object
  85441. */
  85442. copyFrom(source: DeepImmutable<Color3>): Color3;
  85443. /**
  85444. * Updates the Color3 rgb values from the given floats
  85445. * @param r defines the red component to read from
  85446. * @param g defines the green component to read from
  85447. * @param b defines the blue component to read from
  85448. * @returns the current Color3 object
  85449. */
  85450. copyFromFloats(r: number, g: number, b: number): Color3;
  85451. /**
  85452. * Updates the Color3 rgb values from the given floats
  85453. * @param r defines the red component to read from
  85454. * @param g defines the green component to read from
  85455. * @param b defines the blue component to read from
  85456. * @returns the current Color3 object
  85457. */
  85458. set(r: number, g: number, b: number): Color3;
  85459. /**
  85460. * Compute the Color3 hexadecimal code as a string
  85461. * @returns a string containing the hexadecimal representation of the Color3 object
  85462. */
  85463. toHexString(): string;
  85464. /**
  85465. * Computes a new Color3 converted from the current one to linear space
  85466. * @returns a new Color3 object
  85467. */
  85468. toLinearSpace(): Color3;
  85469. /**
  85470. * Converts current color in rgb space to HSV values
  85471. * @returns a new color3 representing the HSV values
  85472. */
  85473. toHSV(): Color3;
  85474. /**
  85475. * Converts current color in rgb space to HSV values
  85476. * @param result defines the Color3 where to store the HSV values
  85477. */
  85478. toHSVToRef(result: Color3): void;
  85479. /**
  85480. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  85481. * @param convertedColor defines the Color3 object where to store the linear space version
  85482. * @returns the unmodified Color3
  85483. */
  85484. toLinearSpaceToRef(convertedColor: Color3): Color3;
  85485. /**
  85486. * Computes a new Color3 converted from the current one to gamma space
  85487. * @returns a new Color3 object
  85488. */
  85489. toGammaSpace(): Color3;
  85490. /**
  85491. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  85492. * @param convertedColor defines the Color3 object where to store the gamma space version
  85493. * @returns the unmodified Color3
  85494. */
  85495. toGammaSpaceToRef(convertedColor: Color3): Color3;
  85496. private static _BlackReadOnly;
  85497. /**
  85498. * Convert Hue, saturation and value to a Color3 (RGB)
  85499. * @param hue defines the hue
  85500. * @param saturation defines the saturation
  85501. * @param value defines the value
  85502. * @param result defines the Color3 where to store the RGB values
  85503. */
  85504. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  85505. /**
  85506. * Creates a new Color3 from the string containing valid hexadecimal values
  85507. * @param hex defines a string containing valid hexadecimal values
  85508. * @returns a new Color3 object
  85509. */
  85510. static FromHexString(hex: string): Color3;
  85511. /**
  85512. * Creates a new Color3 from the starting index of the given array
  85513. * @param array defines the source array
  85514. * @param offset defines an offset in the source array
  85515. * @returns a new Color3 object
  85516. */
  85517. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  85518. /**
  85519. * Creates a new Color3 from the starting index element of the given array
  85520. * @param array defines the source array to read from
  85521. * @param offset defines the offset in the source array
  85522. * @param result defines the target Color3 object
  85523. */
  85524. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  85525. /**
  85526. * Creates a new Color3 from integer values (< 256)
  85527. * @param r defines the red component to read from (value between 0 and 255)
  85528. * @param g defines the green component to read from (value between 0 and 255)
  85529. * @param b defines the blue component to read from (value between 0 and 255)
  85530. * @returns a new Color3 object
  85531. */
  85532. static FromInts(r: number, g: number, b: number): Color3;
  85533. /**
  85534. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  85535. * @param start defines the start Color3 value
  85536. * @param end defines the end Color3 value
  85537. * @param amount defines the gradient value between start and end
  85538. * @returns a new Color3 object
  85539. */
  85540. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  85541. /**
  85542. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  85543. * @param left defines the start value
  85544. * @param right defines the end value
  85545. * @param amount defines the gradient factor
  85546. * @param result defines the Color3 object where to store the result
  85547. */
  85548. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  85549. /**
  85550. * Returns a Color3 value containing a red color
  85551. * @returns a new Color3 object
  85552. */
  85553. static Red(): Color3;
  85554. /**
  85555. * Returns a Color3 value containing a green color
  85556. * @returns a new Color3 object
  85557. */
  85558. static Green(): Color3;
  85559. /**
  85560. * Returns a Color3 value containing a blue color
  85561. * @returns a new Color3 object
  85562. */
  85563. static Blue(): Color3;
  85564. /**
  85565. * Returns a Color3 value containing a black color
  85566. * @returns a new Color3 object
  85567. */
  85568. static Black(): Color3;
  85569. /**
  85570. * Gets a Color3 value containing a black color that must not be updated
  85571. */
  85572. static get BlackReadOnly(): DeepImmutable<Color3>;
  85573. /**
  85574. * Returns a Color3 value containing a white color
  85575. * @returns a new Color3 object
  85576. */
  85577. static White(): Color3;
  85578. /**
  85579. * Returns a Color3 value containing a purple color
  85580. * @returns a new Color3 object
  85581. */
  85582. static Purple(): Color3;
  85583. /**
  85584. * Returns a Color3 value containing a magenta color
  85585. * @returns a new Color3 object
  85586. */
  85587. static Magenta(): Color3;
  85588. /**
  85589. * Returns a Color3 value containing a yellow color
  85590. * @returns a new Color3 object
  85591. */
  85592. static Yellow(): Color3;
  85593. /**
  85594. * Returns a Color3 value containing a gray color
  85595. * @returns a new Color3 object
  85596. */
  85597. static Gray(): Color3;
  85598. /**
  85599. * Returns a Color3 value containing a teal color
  85600. * @returns a new Color3 object
  85601. */
  85602. static Teal(): Color3;
  85603. /**
  85604. * Returns a Color3 value containing a random color
  85605. * @returns a new Color3 object
  85606. */
  85607. static Random(): Color3;
  85608. }
  85609. /**
  85610. * Class used to hold a RBGA color
  85611. */
  85612. export class Color4 {
  85613. /**
  85614. * Defines the red component (between 0 and 1, default is 0)
  85615. */
  85616. r: number;
  85617. /**
  85618. * Defines the green component (between 0 and 1, default is 0)
  85619. */
  85620. g: number;
  85621. /**
  85622. * Defines the blue component (between 0 and 1, default is 0)
  85623. */
  85624. b: number;
  85625. /**
  85626. * Defines the alpha component (between 0 and 1, default is 1)
  85627. */
  85628. a: number;
  85629. /**
  85630. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  85631. * @param r defines the red component (between 0 and 1, default is 0)
  85632. * @param g defines the green component (between 0 and 1, default is 0)
  85633. * @param b defines the blue component (between 0 and 1, default is 0)
  85634. * @param a defines the alpha component (between 0 and 1, default is 1)
  85635. */
  85636. constructor(
  85637. /**
  85638. * Defines the red component (between 0 and 1, default is 0)
  85639. */
  85640. r?: number,
  85641. /**
  85642. * Defines the green component (between 0 and 1, default is 0)
  85643. */
  85644. g?: number,
  85645. /**
  85646. * Defines the blue component (between 0 and 1, default is 0)
  85647. */
  85648. b?: number,
  85649. /**
  85650. * Defines the alpha component (between 0 and 1, default is 1)
  85651. */
  85652. a?: number);
  85653. /**
  85654. * Adds in place the given Color4 values to the current Color4 object
  85655. * @param right defines the second operand
  85656. * @returns the current updated Color4 object
  85657. */
  85658. addInPlace(right: DeepImmutable<Color4>): Color4;
  85659. /**
  85660. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  85661. * @returns the new array
  85662. */
  85663. asArray(): number[];
  85664. /**
  85665. * Stores from the starting index in the given array the Color4 successive values
  85666. * @param array defines the array where to store the r,g,b components
  85667. * @param index defines an optional index in the target array to define where to start storing values
  85668. * @returns the current Color4 object
  85669. */
  85670. toArray(array: number[], index?: number): Color4;
  85671. /**
  85672. * Update the current color with values stored in an array from the starting index of the given array
  85673. * @param array defines the source array
  85674. * @param offset defines an offset in the source array
  85675. * @returns the current Color4 object
  85676. */
  85677. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  85678. /**
  85679. * Determines equality between Color4 objects
  85680. * @param otherColor defines the second operand
  85681. * @returns true if the rgba values are equal to the given ones
  85682. */
  85683. equals(otherColor: DeepImmutable<Color4>): boolean;
  85684. /**
  85685. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  85686. * @param right defines the second operand
  85687. * @returns a new Color4 object
  85688. */
  85689. add(right: DeepImmutable<Color4>): Color4;
  85690. /**
  85691. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  85692. * @param right defines the second operand
  85693. * @returns a new Color4 object
  85694. */
  85695. subtract(right: DeepImmutable<Color4>): Color4;
  85696. /**
  85697. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  85698. * @param right defines the second operand
  85699. * @param result defines the Color4 object where to store the result
  85700. * @returns the current Color4 object
  85701. */
  85702. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  85703. /**
  85704. * Creates a new Color4 with the current Color4 values multiplied by scale
  85705. * @param scale defines the scaling factor to apply
  85706. * @returns a new Color4 object
  85707. */
  85708. scale(scale: number): Color4;
  85709. /**
  85710. * Multiplies the current Color4 values by scale and stores the result in "result"
  85711. * @param scale defines the scaling factor to apply
  85712. * @param result defines the Color4 object where to store the result
  85713. * @returns the current unmodified Color4
  85714. */
  85715. scaleToRef(scale: number, result: Color4): Color4;
  85716. /**
  85717. * Scale the current Color4 values by a factor and add the result to a given Color4
  85718. * @param scale defines the scale factor
  85719. * @param result defines the Color4 object where to store the result
  85720. * @returns the unmodified current Color4
  85721. */
  85722. scaleAndAddToRef(scale: number, result: Color4): Color4;
  85723. /**
  85724. * Clamps the rgb values by the min and max values and stores the result into "result"
  85725. * @param min defines minimum clamping value (default is 0)
  85726. * @param max defines maximum clamping value (default is 1)
  85727. * @param result defines color to store the result into.
  85728. * @returns the cuurent Color4
  85729. */
  85730. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  85731. /**
  85732. * Multipy an Color4 value by another and return a new Color4 object
  85733. * @param color defines the Color4 value to multiply by
  85734. * @returns a new Color4 object
  85735. */
  85736. multiply(color: Color4): Color4;
  85737. /**
  85738. * Multipy a Color4 value by another and push the result in a reference value
  85739. * @param color defines the Color4 value to multiply by
  85740. * @param result defines the Color4 to fill the result in
  85741. * @returns the result Color4
  85742. */
  85743. multiplyToRef(color: Color4, result: Color4): Color4;
  85744. /**
  85745. * Creates a string with the Color4 current values
  85746. * @returns the string representation of the Color4 object
  85747. */
  85748. toString(): string;
  85749. /**
  85750. * Returns the string "Color4"
  85751. * @returns "Color4"
  85752. */
  85753. getClassName(): string;
  85754. /**
  85755. * Compute the Color4 hash code
  85756. * @returns an unique number that can be used to hash Color4 objects
  85757. */
  85758. getHashCode(): number;
  85759. /**
  85760. * Creates a new Color4 copied from the current one
  85761. * @returns a new Color4 object
  85762. */
  85763. clone(): Color4;
  85764. /**
  85765. * Copies the given Color4 values into the current one
  85766. * @param source defines the source Color4 object
  85767. * @returns the current updated Color4 object
  85768. */
  85769. copyFrom(source: Color4): Color4;
  85770. /**
  85771. * Copies the given float values into the current one
  85772. * @param r defines the red component to read from
  85773. * @param g defines the green component to read from
  85774. * @param b defines the blue component to read from
  85775. * @param a defines the alpha component to read from
  85776. * @returns the current updated Color4 object
  85777. */
  85778. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  85779. /**
  85780. * Copies the given float values into the current one
  85781. * @param r defines the red component to read from
  85782. * @param g defines the green component to read from
  85783. * @param b defines the blue component to read from
  85784. * @param a defines the alpha component to read from
  85785. * @returns the current updated Color4 object
  85786. */
  85787. set(r: number, g: number, b: number, a: number): Color4;
  85788. /**
  85789. * Compute the Color4 hexadecimal code as a string
  85790. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  85791. * @returns a string containing the hexadecimal representation of the Color4 object
  85792. */
  85793. toHexString(returnAsColor3?: boolean): string;
  85794. /**
  85795. * Computes a new Color4 converted from the current one to linear space
  85796. * @returns a new Color4 object
  85797. */
  85798. toLinearSpace(): Color4;
  85799. /**
  85800. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  85801. * @param convertedColor defines the Color4 object where to store the linear space version
  85802. * @returns the unmodified Color4
  85803. */
  85804. toLinearSpaceToRef(convertedColor: Color4): Color4;
  85805. /**
  85806. * Computes a new Color4 converted from the current one to gamma space
  85807. * @returns a new Color4 object
  85808. */
  85809. toGammaSpace(): Color4;
  85810. /**
  85811. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  85812. * @param convertedColor defines the Color4 object where to store the gamma space version
  85813. * @returns the unmodified Color4
  85814. */
  85815. toGammaSpaceToRef(convertedColor: Color4): Color4;
  85816. /**
  85817. * Creates a new Color4 from the string containing valid hexadecimal values
  85818. * @param hex defines a string containing valid hexadecimal values
  85819. * @returns a new Color4 object
  85820. */
  85821. static FromHexString(hex: string): Color4;
  85822. /**
  85823. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  85824. * @param left defines the start value
  85825. * @param right defines the end value
  85826. * @param amount defines the gradient factor
  85827. * @returns a new Color4 object
  85828. */
  85829. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  85830. /**
  85831. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  85832. * @param left defines the start value
  85833. * @param right defines the end value
  85834. * @param amount defines the gradient factor
  85835. * @param result defines the Color4 object where to store data
  85836. */
  85837. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  85838. /**
  85839. * Creates a new Color4 from a Color3 and an alpha value
  85840. * @param color3 defines the source Color3 to read from
  85841. * @param alpha defines the alpha component (1.0 by default)
  85842. * @returns a new Color4 object
  85843. */
  85844. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  85845. /**
  85846. * Creates a new Color4 from the starting index element of the given array
  85847. * @param array defines the source array to read from
  85848. * @param offset defines the offset in the source array
  85849. * @returns a new Color4 object
  85850. */
  85851. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  85852. /**
  85853. * Creates a new Color4 from the starting index element of the given array
  85854. * @param array defines the source array to read from
  85855. * @param offset defines the offset in the source array
  85856. * @param result defines the target Color4 object
  85857. */
  85858. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  85859. /**
  85860. * Creates a new Color3 from integer values (< 256)
  85861. * @param r defines the red component to read from (value between 0 and 255)
  85862. * @param g defines the green component to read from (value between 0 and 255)
  85863. * @param b defines the blue component to read from (value between 0 and 255)
  85864. * @param a defines the alpha component to read from (value between 0 and 255)
  85865. * @returns a new Color3 object
  85866. */
  85867. static FromInts(r: number, g: number, b: number, a: number): Color4;
  85868. /**
  85869. * Check the content of a given array and convert it to an array containing RGBA data
  85870. * If the original array was already containing count * 4 values then it is returned directly
  85871. * @param colors defines the array to check
  85872. * @param count defines the number of RGBA data to expect
  85873. * @returns an array containing count * 4 values (RGBA)
  85874. */
  85875. static CheckColors4(colors: number[], count: number): number[];
  85876. }
  85877. /**
  85878. * @hidden
  85879. */
  85880. export class TmpColors {
  85881. static Color3: Color3[];
  85882. static Color4: Color4[];
  85883. }
  85884. }
  85885. declare module BABYLON {
  85886. /**
  85887. * Defines an interface which represents an animation key frame
  85888. */
  85889. export interface IAnimationKey {
  85890. /**
  85891. * Frame of the key frame
  85892. */
  85893. frame: number;
  85894. /**
  85895. * Value at the specifies key frame
  85896. */
  85897. value: any;
  85898. /**
  85899. * The input tangent for the cubic hermite spline
  85900. */
  85901. inTangent?: any;
  85902. /**
  85903. * The output tangent for the cubic hermite spline
  85904. */
  85905. outTangent?: any;
  85906. /**
  85907. * The animation interpolation type
  85908. */
  85909. interpolation?: AnimationKeyInterpolation;
  85910. }
  85911. /**
  85912. * Enum for the animation key frame interpolation type
  85913. */
  85914. export enum AnimationKeyInterpolation {
  85915. /**
  85916. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  85917. */
  85918. STEP = 1
  85919. }
  85920. }
  85921. declare module BABYLON {
  85922. /**
  85923. * Represents the range of an animation
  85924. */
  85925. export class AnimationRange {
  85926. /**The name of the animation range**/
  85927. name: string;
  85928. /**The starting frame of the animation */
  85929. from: number;
  85930. /**The ending frame of the animation*/
  85931. to: number;
  85932. /**
  85933. * Initializes the range of an animation
  85934. * @param name The name of the animation range
  85935. * @param from The starting frame of the animation
  85936. * @param to The ending frame of the animation
  85937. */
  85938. constructor(
  85939. /**The name of the animation range**/
  85940. name: string,
  85941. /**The starting frame of the animation */
  85942. from: number,
  85943. /**The ending frame of the animation*/
  85944. to: number);
  85945. /**
  85946. * Makes a copy of the animation range
  85947. * @returns A copy of the animation range
  85948. */
  85949. clone(): AnimationRange;
  85950. }
  85951. }
  85952. declare module BABYLON {
  85953. /**
  85954. * Composed of a frame, and an action function
  85955. */
  85956. export class AnimationEvent {
  85957. /** The frame for which the event is triggered **/
  85958. frame: number;
  85959. /** The event to perform when triggered **/
  85960. action: (currentFrame: number) => void;
  85961. /** Specifies if the event should be triggered only once**/
  85962. onlyOnce?: boolean | undefined;
  85963. /**
  85964. * Specifies if the animation event is done
  85965. */
  85966. isDone: boolean;
  85967. /**
  85968. * Initializes the animation event
  85969. * @param frame The frame for which the event is triggered
  85970. * @param action The event to perform when triggered
  85971. * @param onlyOnce Specifies if the event should be triggered only once
  85972. */
  85973. constructor(
  85974. /** The frame for which the event is triggered **/
  85975. frame: number,
  85976. /** The event to perform when triggered **/
  85977. action: (currentFrame: number) => void,
  85978. /** Specifies if the event should be triggered only once**/
  85979. onlyOnce?: boolean | undefined);
  85980. /** @hidden */
  85981. _clone(): AnimationEvent;
  85982. }
  85983. }
  85984. declare module BABYLON {
  85985. /**
  85986. * Interface used to define a behavior
  85987. */
  85988. export interface Behavior<T> {
  85989. /** gets or sets behavior's name */
  85990. name: string;
  85991. /**
  85992. * Function called when the behavior needs to be initialized (after attaching it to a target)
  85993. */
  85994. init(): void;
  85995. /**
  85996. * Called when the behavior is attached to a target
  85997. * @param target defines the target where the behavior is attached to
  85998. */
  85999. attach(target: T): void;
  86000. /**
  86001. * Called when the behavior is detached from its target
  86002. */
  86003. detach(): void;
  86004. }
  86005. /**
  86006. * Interface implemented by classes supporting behaviors
  86007. */
  86008. export interface IBehaviorAware<T> {
  86009. /**
  86010. * Attach a behavior
  86011. * @param behavior defines the behavior to attach
  86012. * @returns the current host
  86013. */
  86014. addBehavior(behavior: Behavior<T>): T;
  86015. /**
  86016. * Remove a behavior from the current object
  86017. * @param behavior defines the behavior to detach
  86018. * @returns the current host
  86019. */
  86020. removeBehavior(behavior: Behavior<T>): T;
  86021. /**
  86022. * Gets a behavior using its name to search
  86023. * @param name defines the name to search
  86024. * @returns the behavior or null if not found
  86025. */
  86026. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  86027. }
  86028. }
  86029. declare module BABYLON {
  86030. /**
  86031. * Defines an array and its length.
  86032. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  86033. */
  86034. export interface ISmartArrayLike<T> {
  86035. /**
  86036. * The data of the array.
  86037. */
  86038. data: Array<T>;
  86039. /**
  86040. * The active length of the array.
  86041. */
  86042. length: number;
  86043. }
  86044. /**
  86045. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86046. */
  86047. export class SmartArray<T> implements ISmartArrayLike<T> {
  86048. /**
  86049. * The full set of data from the array.
  86050. */
  86051. data: Array<T>;
  86052. /**
  86053. * The active length of the array.
  86054. */
  86055. length: number;
  86056. protected _id: number;
  86057. /**
  86058. * Instantiates a Smart Array.
  86059. * @param capacity defines the default capacity of the array.
  86060. */
  86061. constructor(capacity: number);
  86062. /**
  86063. * Pushes a value at the end of the active data.
  86064. * @param value defines the object to push in the array.
  86065. */
  86066. push(value: T): void;
  86067. /**
  86068. * Iterates over the active data and apply the lambda to them.
  86069. * @param func defines the action to apply on each value.
  86070. */
  86071. forEach(func: (content: T) => void): void;
  86072. /**
  86073. * Sorts the full sets of data.
  86074. * @param compareFn defines the comparison function to apply.
  86075. */
  86076. sort(compareFn: (a: T, b: T) => number): void;
  86077. /**
  86078. * Resets the active data to an empty array.
  86079. */
  86080. reset(): void;
  86081. /**
  86082. * Releases all the data from the array as well as the array.
  86083. */
  86084. dispose(): void;
  86085. /**
  86086. * Concats the active data with a given array.
  86087. * @param array defines the data to concatenate with.
  86088. */
  86089. concat(array: any): void;
  86090. /**
  86091. * Returns the position of a value in the active data.
  86092. * @param value defines the value to find the index for
  86093. * @returns the index if found in the active data otherwise -1
  86094. */
  86095. indexOf(value: T): number;
  86096. /**
  86097. * Returns whether an element is part of the active data.
  86098. * @param value defines the value to look for
  86099. * @returns true if found in the active data otherwise false
  86100. */
  86101. contains(value: T): boolean;
  86102. private static _GlobalId;
  86103. }
  86104. /**
  86105. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86106. * The data in this array can only be present once
  86107. */
  86108. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  86109. private _duplicateId;
  86110. /**
  86111. * Pushes a value at the end of the active data.
  86112. * THIS DOES NOT PREVENT DUPPLICATE DATA
  86113. * @param value defines the object to push in the array.
  86114. */
  86115. push(value: T): void;
  86116. /**
  86117. * Pushes a value at the end of the active data.
  86118. * If the data is already present, it won t be added again
  86119. * @param value defines the object to push in the array.
  86120. * @returns true if added false if it was already present
  86121. */
  86122. pushNoDuplicate(value: T): boolean;
  86123. /**
  86124. * Resets the active data to an empty array.
  86125. */
  86126. reset(): void;
  86127. /**
  86128. * Concats the active data with a given array.
  86129. * This ensures no dupplicate will be present in the result.
  86130. * @param array defines the data to concatenate with.
  86131. */
  86132. concatWithNoDuplicate(array: any): void;
  86133. }
  86134. }
  86135. declare module BABYLON {
  86136. /**
  86137. * @ignore
  86138. * This is a list of all the different input types that are available in the application.
  86139. * Fo instance: ArcRotateCameraGamepadInput...
  86140. */
  86141. export var CameraInputTypes: {};
  86142. /**
  86143. * This is the contract to implement in order to create a new input class.
  86144. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  86145. */
  86146. export interface ICameraInput<TCamera extends Camera> {
  86147. /**
  86148. * Defines the camera the input is attached to.
  86149. */
  86150. camera: Nullable<TCamera>;
  86151. /**
  86152. * Gets the class name of the current intput.
  86153. * @returns the class name
  86154. */
  86155. getClassName(): string;
  86156. /**
  86157. * Get the friendly name associated with the input class.
  86158. * @returns the input friendly name
  86159. */
  86160. getSimpleName(): string;
  86161. /**
  86162. * Attach the input controls to a specific dom element to get the input from.
  86163. * @param element Defines the element the controls should be listened from
  86164. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86165. */
  86166. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86167. /**
  86168. * Detach the current controls from the specified dom element.
  86169. * @param element Defines the element to stop listening the inputs from
  86170. */
  86171. detachControl(element: Nullable<HTMLElement>): void;
  86172. /**
  86173. * Update the current camera state depending on the inputs that have been used this frame.
  86174. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86175. */
  86176. checkInputs?: () => void;
  86177. }
  86178. /**
  86179. * Represents a map of input types to input instance or input index to input instance.
  86180. */
  86181. export interface CameraInputsMap<TCamera extends Camera> {
  86182. /**
  86183. * Accessor to the input by input type.
  86184. */
  86185. [name: string]: ICameraInput<TCamera>;
  86186. /**
  86187. * Accessor to the input by input index.
  86188. */
  86189. [idx: number]: ICameraInput<TCamera>;
  86190. }
  86191. /**
  86192. * This represents the input manager used within a camera.
  86193. * It helps dealing with all the different kind of input attached to a camera.
  86194. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86195. */
  86196. export class CameraInputsManager<TCamera extends Camera> {
  86197. /**
  86198. * Defines the list of inputs attahed to the camera.
  86199. */
  86200. attached: CameraInputsMap<TCamera>;
  86201. /**
  86202. * Defines the dom element the camera is collecting inputs from.
  86203. * This is null if the controls have not been attached.
  86204. */
  86205. attachedElement: Nullable<HTMLElement>;
  86206. /**
  86207. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86208. */
  86209. noPreventDefault: boolean;
  86210. /**
  86211. * Defined the camera the input manager belongs to.
  86212. */
  86213. camera: TCamera;
  86214. /**
  86215. * Update the current camera state depending on the inputs that have been used this frame.
  86216. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86217. */
  86218. checkInputs: () => void;
  86219. /**
  86220. * Instantiate a new Camera Input Manager.
  86221. * @param camera Defines the camera the input manager blongs to
  86222. */
  86223. constructor(camera: TCamera);
  86224. /**
  86225. * Add an input method to a camera
  86226. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86227. * @param input camera input method
  86228. */
  86229. add(input: ICameraInput<TCamera>): void;
  86230. /**
  86231. * Remove a specific input method from a camera
  86232. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  86233. * @param inputToRemove camera input method
  86234. */
  86235. remove(inputToRemove: ICameraInput<TCamera>): void;
  86236. /**
  86237. * Remove a specific input type from a camera
  86238. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  86239. * @param inputType the type of the input to remove
  86240. */
  86241. removeByType(inputType: string): void;
  86242. private _addCheckInputs;
  86243. /**
  86244. * Attach the input controls to the currently attached dom element to listen the events from.
  86245. * @param input Defines the input to attach
  86246. */
  86247. attachInput(input: ICameraInput<TCamera>): void;
  86248. /**
  86249. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  86250. * @param element Defines the dom element to collect the events from
  86251. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86252. */
  86253. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  86254. /**
  86255. * Detach the current manager inputs controls from a specific dom element.
  86256. * @param element Defines the dom element to collect the events from
  86257. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  86258. */
  86259. detachElement(element: HTMLElement, disconnect?: boolean): void;
  86260. /**
  86261. * Rebuild the dynamic inputCheck function from the current list of
  86262. * defined inputs in the manager.
  86263. */
  86264. rebuildInputCheck(): void;
  86265. /**
  86266. * Remove all attached input methods from a camera
  86267. */
  86268. clear(): void;
  86269. /**
  86270. * Serialize the current input manager attached to a camera.
  86271. * This ensures than once parsed,
  86272. * the input associated to the camera will be identical to the current ones
  86273. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  86274. */
  86275. serialize(serializedCamera: any): void;
  86276. /**
  86277. * Parses an input manager serialized JSON to restore the previous list of inputs
  86278. * and states associated to a camera.
  86279. * @param parsedCamera Defines the JSON to parse
  86280. */
  86281. parse(parsedCamera: any): void;
  86282. }
  86283. }
  86284. declare module BABYLON {
  86285. /**
  86286. * Class used to store data that will be store in GPU memory
  86287. */
  86288. export class Buffer {
  86289. private _engine;
  86290. private _buffer;
  86291. /** @hidden */
  86292. _data: Nullable<DataArray>;
  86293. private _updatable;
  86294. private _instanced;
  86295. private _divisor;
  86296. /**
  86297. * Gets the byte stride.
  86298. */
  86299. readonly byteStride: number;
  86300. /**
  86301. * Constructor
  86302. * @param engine the engine
  86303. * @param data the data to use for this buffer
  86304. * @param updatable whether the data is updatable
  86305. * @param stride the stride (optional)
  86306. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  86307. * @param instanced whether the buffer is instanced (optional)
  86308. * @param useBytes set to true if the stride in in bytes (optional)
  86309. * @param divisor sets an optional divisor for instances (1 by default)
  86310. */
  86311. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  86312. /**
  86313. * Create a new VertexBuffer based on the current buffer
  86314. * @param kind defines the vertex buffer kind (position, normal, etc.)
  86315. * @param offset defines offset in the buffer (0 by default)
  86316. * @param size defines the size in floats of attributes (position is 3 for instance)
  86317. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  86318. * @param instanced defines if the vertex buffer contains indexed data
  86319. * @param useBytes defines if the offset and stride are in bytes *
  86320. * @param divisor sets an optional divisor for instances (1 by default)
  86321. * @returns the new vertex buffer
  86322. */
  86323. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  86324. /**
  86325. * Gets a boolean indicating if the Buffer is updatable?
  86326. * @returns true if the buffer is updatable
  86327. */
  86328. isUpdatable(): boolean;
  86329. /**
  86330. * Gets current buffer's data
  86331. * @returns a DataArray or null
  86332. */
  86333. getData(): Nullable<DataArray>;
  86334. /**
  86335. * Gets underlying native buffer
  86336. * @returns underlying native buffer
  86337. */
  86338. getBuffer(): Nullable<DataBuffer>;
  86339. /**
  86340. * Gets the stride in float32 units (i.e. byte stride / 4).
  86341. * May not be an integer if the byte stride is not divisible by 4.
  86342. * @returns the stride in float32 units
  86343. * @deprecated Please use byteStride instead.
  86344. */
  86345. getStrideSize(): number;
  86346. /**
  86347. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  86348. * @param data defines the data to store
  86349. */
  86350. create(data?: Nullable<DataArray>): void;
  86351. /** @hidden */
  86352. _rebuild(): void;
  86353. /**
  86354. * Update current buffer data
  86355. * @param data defines the data to store
  86356. */
  86357. update(data: DataArray): void;
  86358. /**
  86359. * Updates the data directly.
  86360. * @param data the new data
  86361. * @param offset the new offset
  86362. * @param vertexCount the vertex count (optional)
  86363. * @param useBytes set to true if the offset is in bytes
  86364. */
  86365. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  86366. /**
  86367. * Release all resources
  86368. */
  86369. dispose(): void;
  86370. }
  86371. /**
  86372. * Specialized buffer used to store vertex data
  86373. */
  86374. export class VertexBuffer {
  86375. /** @hidden */
  86376. _buffer: Buffer;
  86377. private _kind;
  86378. private _size;
  86379. private _ownsBuffer;
  86380. private _instanced;
  86381. private _instanceDivisor;
  86382. /**
  86383. * The byte type.
  86384. */
  86385. static readonly BYTE: number;
  86386. /**
  86387. * The unsigned byte type.
  86388. */
  86389. static readonly UNSIGNED_BYTE: number;
  86390. /**
  86391. * The short type.
  86392. */
  86393. static readonly SHORT: number;
  86394. /**
  86395. * The unsigned short type.
  86396. */
  86397. static readonly UNSIGNED_SHORT: number;
  86398. /**
  86399. * The integer type.
  86400. */
  86401. static readonly INT: number;
  86402. /**
  86403. * The unsigned integer type.
  86404. */
  86405. static readonly UNSIGNED_INT: number;
  86406. /**
  86407. * The float type.
  86408. */
  86409. static readonly FLOAT: number;
  86410. /**
  86411. * Gets or sets the instance divisor when in instanced mode
  86412. */
  86413. get instanceDivisor(): number;
  86414. set instanceDivisor(value: number);
  86415. /**
  86416. * Gets the byte stride.
  86417. */
  86418. readonly byteStride: number;
  86419. /**
  86420. * Gets the byte offset.
  86421. */
  86422. readonly byteOffset: number;
  86423. /**
  86424. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  86425. */
  86426. readonly normalized: boolean;
  86427. /**
  86428. * Gets the data type of each component in the array.
  86429. */
  86430. readonly type: number;
  86431. /**
  86432. * Constructor
  86433. * @param engine the engine
  86434. * @param data the data to use for this vertex buffer
  86435. * @param kind the vertex buffer kind
  86436. * @param updatable whether the data is updatable
  86437. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  86438. * @param stride the stride (optional)
  86439. * @param instanced whether the buffer is instanced (optional)
  86440. * @param offset the offset of the data (optional)
  86441. * @param size the number of components (optional)
  86442. * @param type the type of the component (optional)
  86443. * @param normalized whether the data contains normalized data (optional)
  86444. * @param useBytes set to true if stride and offset are in bytes (optional)
  86445. * @param divisor defines the instance divisor to use (1 by default)
  86446. */
  86447. 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);
  86448. /** @hidden */
  86449. _rebuild(): void;
  86450. /**
  86451. * Returns the kind of the VertexBuffer (string)
  86452. * @returns a string
  86453. */
  86454. getKind(): string;
  86455. /**
  86456. * Gets a boolean indicating if the VertexBuffer is updatable?
  86457. * @returns true if the buffer is updatable
  86458. */
  86459. isUpdatable(): boolean;
  86460. /**
  86461. * Gets current buffer's data
  86462. * @returns a DataArray or null
  86463. */
  86464. getData(): Nullable<DataArray>;
  86465. /**
  86466. * Gets underlying native buffer
  86467. * @returns underlying native buffer
  86468. */
  86469. getBuffer(): Nullable<DataBuffer>;
  86470. /**
  86471. * Gets the stride in float32 units (i.e. byte stride / 4).
  86472. * May not be an integer if the byte stride is not divisible by 4.
  86473. * @returns the stride in float32 units
  86474. * @deprecated Please use byteStride instead.
  86475. */
  86476. getStrideSize(): number;
  86477. /**
  86478. * Returns the offset as a multiple of the type byte length.
  86479. * @returns the offset in bytes
  86480. * @deprecated Please use byteOffset instead.
  86481. */
  86482. getOffset(): number;
  86483. /**
  86484. * Returns the number of components per vertex attribute (integer)
  86485. * @returns the size in float
  86486. */
  86487. getSize(): number;
  86488. /**
  86489. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  86490. * @returns true if this buffer is instanced
  86491. */
  86492. getIsInstanced(): boolean;
  86493. /**
  86494. * Returns the instancing divisor, zero for non-instanced (integer).
  86495. * @returns a number
  86496. */
  86497. getInstanceDivisor(): number;
  86498. /**
  86499. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  86500. * @param data defines the data to store
  86501. */
  86502. create(data?: DataArray): void;
  86503. /**
  86504. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  86505. * This function will create a new buffer if the current one is not updatable
  86506. * @param data defines the data to store
  86507. */
  86508. update(data: DataArray): void;
  86509. /**
  86510. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  86511. * Returns the directly updated WebGLBuffer.
  86512. * @param data the new data
  86513. * @param offset the new offset
  86514. * @param useBytes set to true if the offset is in bytes
  86515. */
  86516. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  86517. /**
  86518. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  86519. */
  86520. dispose(): void;
  86521. /**
  86522. * Enumerates each value of this vertex buffer as numbers.
  86523. * @param count the number of values to enumerate
  86524. * @param callback the callback function called for each value
  86525. */
  86526. forEach(count: number, callback: (value: number, index: number) => void): void;
  86527. /**
  86528. * Positions
  86529. */
  86530. static readonly PositionKind: string;
  86531. /**
  86532. * Normals
  86533. */
  86534. static readonly NormalKind: string;
  86535. /**
  86536. * Tangents
  86537. */
  86538. static readonly TangentKind: string;
  86539. /**
  86540. * Texture coordinates
  86541. */
  86542. static readonly UVKind: string;
  86543. /**
  86544. * Texture coordinates 2
  86545. */
  86546. static readonly UV2Kind: string;
  86547. /**
  86548. * Texture coordinates 3
  86549. */
  86550. static readonly UV3Kind: string;
  86551. /**
  86552. * Texture coordinates 4
  86553. */
  86554. static readonly UV4Kind: string;
  86555. /**
  86556. * Texture coordinates 5
  86557. */
  86558. static readonly UV5Kind: string;
  86559. /**
  86560. * Texture coordinates 6
  86561. */
  86562. static readonly UV6Kind: string;
  86563. /**
  86564. * Colors
  86565. */
  86566. static readonly ColorKind: string;
  86567. /**
  86568. * Matrix indices (for bones)
  86569. */
  86570. static readonly MatricesIndicesKind: string;
  86571. /**
  86572. * Matrix weights (for bones)
  86573. */
  86574. static readonly MatricesWeightsKind: string;
  86575. /**
  86576. * Additional matrix indices (for bones)
  86577. */
  86578. static readonly MatricesIndicesExtraKind: string;
  86579. /**
  86580. * Additional matrix weights (for bones)
  86581. */
  86582. static readonly MatricesWeightsExtraKind: string;
  86583. /**
  86584. * Deduces the stride given a kind.
  86585. * @param kind The kind string to deduce
  86586. * @returns The deduced stride
  86587. */
  86588. static DeduceStride(kind: string): number;
  86589. /**
  86590. * Gets the byte length of the given type.
  86591. * @param type the type
  86592. * @returns the number of bytes
  86593. */
  86594. static GetTypeByteLength(type: number): number;
  86595. /**
  86596. * Enumerates each value of the given parameters as numbers.
  86597. * @param data the data to enumerate
  86598. * @param byteOffset the byte offset of the data
  86599. * @param byteStride the byte stride of the data
  86600. * @param componentCount the number of components per element
  86601. * @param componentType the type of the component
  86602. * @param count the number of values to enumerate
  86603. * @param normalized whether the data is normalized
  86604. * @param callback the callback function called for each value
  86605. */
  86606. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  86607. private static _GetFloatValue;
  86608. }
  86609. }
  86610. declare module BABYLON {
  86611. /**
  86612. * @hidden
  86613. */
  86614. export class IntersectionInfo {
  86615. bu: Nullable<number>;
  86616. bv: Nullable<number>;
  86617. distance: number;
  86618. faceId: number;
  86619. subMeshId: number;
  86620. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  86621. }
  86622. }
  86623. declare module BABYLON {
  86624. /**
  86625. * Class used to store bounding sphere information
  86626. */
  86627. export class BoundingSphere {
  86628. /**
  86629. * Gets the center of the bounding sphere in local space
  86630. */
  86631. readonly center: Vector3;
  86632. /**
  86633. * Radius of the bounding sphere in local space
  86634. */
  86635. radius: number;
  86636. /**
  86637. * Gets the center of the bounding sphere in world space
  86638. */
  86639. readonly centerWorld: Vector3;
  86640. /**
  86641. * Radius of the bounding sphere in world space
  86642. */
  86643. radiusWorld: number;
  86644. /**
  86645. * Gets the minimum vector in local space
  86646. */
  86647. readonly minimum: Vector3;
  86648. /**
  86649. * Gets the maximum vector in local space
  86650. */
  86651. readonly maximum: Vector3;
  86652. private _worldMatrix;
  86653. private static readonly TmpVector3;
  86654. /**
  86655. * Creates a new bounding sphere
  86656. * @param min defines the minimum vector (in local space)
  86657. * @param max defines the maximum vector (in local space)
  86658. * @param worldMatrix defines the new world matrix
  86659. */
  86660. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86661. /**
  86662. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  86663. * @param min defines the new minimum vector (in local space)
  86664. * @param max defines the new maximum vector (in local space)
  86665. * @param worldMatrix defines the new world matrix
  86666. */
  86667. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86668. /**
  86669. * Scale the current bounding sphere by applying a scale factor
  86670. * @param factor defines the scale factor to apply
  86671. * @returns the current bounding box
  86672. */
  86673. scale(factor: number): BoundingSphere;
  86674. /**
  86675. * Gets the world matrix of the bounding box
  86676. * @returns a matrix
  86677. */
  86678. getWorldMatrix(): DeepImmutable<Matrix>;
  86679. /** @hidden */
  86680. _update(worldMatrix: DeepImmutable<Matrix>): void;
  86681. /**
  86682. * Tests if the bounding sphere is intersecting the frustum planes
  86683. * @param frustumPlanes defines the frustum planes to test
  86684. * @returns true if there is an intersection
  86685. */
  86686. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86687. /**
  86688. * Tests if the bounding sphere center is in between the frustum planes.
  86689. * Used for optimistic fast inclusion.
  86690. * @param frustumPlanes defines the frustum planes to test
  86691. * @returns true if the sphere center is in between the frustum planes
  86692. */
  86693. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86694. /**
  86695. * Tests if a point is inside the bounding sphere
  86696. * @param point defines the point to test
  86697. * @returns true if the point is inside the bounding sphere
  86698. */
  86699. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  86700. /**
  86701. * Checks if two sphere intersct
  86702. * @param sphere0 sphere 0
  86703. * @param sphere1 sphere 1
  86704. * @returns true if the speres intersect
  86705. */
  86706. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  86707. }
  86708. }
  86709. declare module BABYLON {
  86710. /**
  86711. * Class used to store bounding box information
  86712. */
  86713. export class BoundingBox implements ICullable {
  86714. /**
  86715. * Gets the 8 vectors representing the bounding box in local space
  86716. */
  86717. readonly vectors: Vector3[];
  86718. /**
  86719. * Gets the center of the bounding box in local space
  86720. */
  86721. readonly center: Vector3;
  86722. /**
  86723. * Gets the center of the bounding box in world space
  86724. */
  86725. readonly centerWorld: Vector3;
  86726. /**
  86727. * Gets the extend size in local space
  86728. */
  86729. readonly extendSize: Vector3;
  86730. /**
  86731. * Gets the extend size in world space
  86732. */
  86733. readonly extendSizeWorld: Vector3;
  86734. /**
  86735. * Gets the OBB (object bounding box) directions
  86736. */
  86737. readonly directions: Vector3[];
  86738. /**
  86739. * Gets the 8 vectors representing the bounding box in world space
  86740. */
  86741. readonly vectorsWorld: Vector3[];
  86742. /**
  86743. * Gets the minimum vector in world space
  86744. */
  86745. readonly minimumWorld: Vector3;
  86746. /**
  86747. * Gets the maximum vector in world space
  86748. */
  86749. readonly maximumWorld: Vector3;
  86750. /**
  86751. * Gets the minimum vector in local space
  86752. */
  86753. readonly minimum: Vector3;
  86754. /**
  86755. * Gets the maximum vector in local space
  86756. */
  86757. readonly maximum: Vector3;
  86758. private _worldMatrix;
  86759. private static readonly TmpVector3;
  86760. /**
  86761. * @hidden
  86762. */
  86763. _tag: number;
  86764. /**
  86765. * Creates a new bounding box
  86766. * @param min defines the minimum vector (in local space)
  86767. * @param max defines the maximum vector (in local space)
  86768. * @param worldMatrix defines the new world matrix
  86769. */
  86770. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86771. /**
  86772. * Recreates the entire bounding box from scratch as if we call the constructor in place
  86773. * @param min defines the new minimum vector (in local space)
  86774. * @param max defines the new maximum vector (in local space)
  86775. * @param worldMatrix defines the new world matrix
  86776. */
  86777. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86778. /**
  86779. * Scale the current bounding box by applying a scale factor
  86780. * @param factor defines the scale factor to apply
  86781. * @returns the current bounding box
  86782. */
  86783. scale(factor: number): BoundingBox;
  86784. /**
  86785. * Gets the world matrix of the bounding box
  86786. * @returns a matrix
  86787. */
  86788. getWorldMatrix(): DeepImmutable<Matrix>;
  86789. /** @hidden */
  86790. _update(world: DeepImmutable<Matrix>): void;
  86791. /**
  86792. * Tests if the bounding box is intersecting the frustum planes
  86793. * @param frustumPlanes defines the frustum planes to test
  86794. * @returns true if there is an intersection
  86795. */
  86796. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86797. /**
  86798. * Tests if the bounding box is entirely inside the frustum planes
  86799. * @param frustumPlanes defines the frustum planes to test
  86800. * @returns true if there is an inclusion
  86801. */
  86802. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86803. /**
  86804. * Tests if a point is inside the bounding box
  86805. * @param point defines the point to test
  86806. * @returns true if the point is inside the bounding box
  86807. */
  86808. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  86809. /**
  86810. * Tests if the bounding box intersects with a bounding sphere
  86811. * @param sphere defines the sphere to test
  86812. * @returns true if there is an intersection
  86813. */
  86814. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  86815. /**
  86816. * Tests if the bounding box intersects with a box defined by a min and max vectors
  86817. * @param min defines the min vector to use
  86818. * @param max defines the max vector to use
  86819. * @returns true if there is an intersection
  86820. */
  86821. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  86822. /**
  86823. * Tests if two bounding boxes are intersections
  86824. * @param box0 defines the first box to test
  86825. * @param box1 defines the second box to test
  86826. * @returns true if there is an intersection
  86827. */
  86828. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  86829. /**
  86830. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  86831. * @param minPoint defines the minimum vector of the bounding box
  86832. * @param maxPoint defines the maximum vector of the bounding box
  86833. * @param sphereCenter defines the sphere center
  86834. * @param sphereRadius defines the sphere radius
  86835. * @returns true if there is an intersection
  86836. */
  86837. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  86838. /**
  86839. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  86840. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  86841. * @param frustumPlanes defines the frustum planes to test
  86842. * @return true if there is an inclusion
  86843. */
  86844. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86845. /**
  86846. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  86847. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  86848. * @param frustumPlanes defines the frustum planes to test
  86849. * @return true if there is an intersection
  86850. */
  86851. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  86852. }
  86853. }
  86854. declare module BABYLON {
  86855. /** @hidden */
  86856. export class Collider {
  86857. /** Define if a collision was found */
  86858. collisionFound: boolean;
  86859. /**
  86860. * Define last intersection point in local space
  86861. */
  86862. intersectionPoint: Vector3;
  86863. /**
  86864. * Define last collided mesh
  86865. */
  86866. collidedMesh: Nullable<AbstractMesh>;
  86867. private _collisionPoint;
  86868. private _planeIntersectionPoint;
  86869. private _tempVector;
  86870. private _tempVector2;
  86871. private _tempVector3;
  86872. private _tempVector4;
  86873. private _edge;
  86874. private _baseToVertex;
  86875. private _destinationPoint;
  86876. private _slidePlaneNormal;
  86877. private _displacementVector;
  86878. /** @hidden */
  86879. _radius: Vector3;
  86880. /** @hidden */
  86881. _retry: number;
  86882. private _velocity;
  86883. private _basePoint;
  86884. private _epsilon;
  86885. /** @hidden */
  86886. _velocityWorldLength: number;
  86887. /** @hidden */
  86888. _basePointWorld: Vector3;
  86889. private _velocityWorld;
  86890. private _normalizedVelocity;
  86891. /** @hidden */
  86892. _initialVelocity: Vector3;
  86893. /** @hidden */
  86894. _initialPosition: Vector3;
  86895. private _nearestDistance;
  86896. private _collisionMask;
  86897. get collisionMask(): number;
  86898. set collisionMask(mask: number);
  86899. /**
  86900. * Gets the plane normal used to compute the sliding response (in local space)
  86901. */
  86902. get slidePlaneNormal(): Vector3;
  86903. /** @hidden */
  86904. _initialize(source: Vector3, dir: Vector3, e: number): void;
  86905. /** @hidden */
  86906. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  86907. /** @hidden */
  86908. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  86909. /** @hidden */
  86910. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  86911. /** @hidden */
  86912. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  86913. /** @hidden */
  86914. _getResponse(pos: Vector3, vel: Vector3): void;
  86915. }
  86916. }
  86917. declare module BABYLON {
  86918. /**
  86919. * Interface for cullable objects
  86920. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  86921. */
  86922. export interface ICullable {
  86923. /**
  86924. * Checks if the object or part of the object is in the frustum
  86925. * @param frustumPlanes Camera near/planes
  86926. * @returns true if the object is in frustum otherwise false
  86927. */
  86928. isInFrustum(frustumPlanes: Plane[]): boolean;
  86929. /**
  86930. * Checks if a cullable object (mesh...) is in the camera frustum
  86931. * Unlike isInFrustum this cheks the full bounding box
  86932. * @param frustumPlanes Camera near/planes
  86933. * @returns true if the object is in frustum otherwise false
  86934. */
  86935. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  86936. }
  86937. /**
  86938. * Info for a bounding data of a mesh
  86939. */
  86940. export class BoundingInfo implements ICullable {
  86941. /**
  86942. * Bounding box for the mesh
  86943. */
  86944. readonly boundingBox: BoundingBox;
  86945. /**
  86946. * Bounding sphere for the mesh
  86947. */
  86948. readonly boundingSphere: BoundingSphere;
  86949. private _isLocked;
  86950. private static readonly TmpVector3;
  86951. /**
  86952. * Constructs bounding info
  86953. * @param minimum min vector of the bounding box/sphere
  86954. * @param maximum max vector of the bounding box/sphere
  86955. * @param worldMatrix defines the new world matrix
  86956. */
  86957. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  86958. /**
  86959. * Recreates the entire bounding info from scratch as if we call the constructor in place
  86960. * @param min defines the new minimum vector (in local space)
  86961. * @param max defines the new maximum vector (in local space)
  86962. * @param worldMatrix defines the new world matrix
  86963. */
  86964. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  86965. /**
  86966. * min vector of the bounding box/sphere
  86967. */
  86968. get minimum(): Vector3;
  86969. /**
  86970. * max vector of the bounding box/sphere
  86971. */
  86972. get maximum(): Vector3;
  86973. /**
  86974. * If the info is locked and won't be updated to avoid perf overhead
  86975. */
  86976. get isLocked(): boolean;
  86977. set isLocked(value: boolean);
  86978. /**
  86979. * Updates the bounding sphere and box
  86980. * @param world world matrix to be used to update
  86981. */
  86982. update(world: DeepImmutable<Matrix>): void;
  86983. /**
  86984. * Recreate the bounding info to be centered around a specific point given a specific extend.
  86985. * @param center New center of the bounding info
  86986. * @param extend New extend of the bounding info
  86987. * @returns the current bounding info
  86988. */
  86989. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  86990. /**
  86991. * Scale the current bounding info by applying a scale factor
  86992. * @param factor defines the scale factor to apply
  86993. * @returns the current bounding info
  86994. */
  86995. scale(factor: number): BoundingInfo;
  86996. /**
  86997. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  86998. * @param frustumPlanes defines the frustum to test
  86999. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  87000. * @returns true if the bounding info is in the frustum planes
  87001. */
  87002. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  87003. /**
  87004. * Gets the world distance between the min and max points of the bounding box
  87005. */
  87006. get diagonalLength(): number;
  87007. /**
  87008. * Checks if a cullable object (mesh...) is in the camera frustum
  87009. * Unlike isInFrustum this cheks the full bounding box
  87010. * @param frustumPlanes Camera near/planes
  87011. * @returns true if the object is in frustum otherwise false
  87012. */
  87013. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87014. /** @hidden */
  87015. _checkCollision(collider: Collider): boolean;
  87016. /**
  87017. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  87018. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87019. * @param point the point to check intersection with
  87020. * @returns if the point intersects
  87021. */
  87022. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87023. /**
  87024. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  87025. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87026. * @param boundingInfo the bounding info to check intersection with
  87027. * @param precise if the intersection should be done using OBB
  87028. * @returns if the bounding info intersects
  87029. */
  87030. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  87031. }
  87032. }
  87033. declare module BABYLON {
  87034. /**
  87035. * Extracts minimum and maximum values from a list of indexed positions
  87036. * @param positions defines the positions to use
  87037. * @param indices defines the indices to the positions
  87038. * @param indexStart defines the start index
  87039. * @param indexCount defines the end index
  87040. * @param bias defines bias value to add to the result
  87041. * @return minimum and maximum values
  87042. */
  87043. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87044. minimum: Vector3;
  87045. maximum: Vector3;
  87046. };
  87047. /**
  87048. * Extracts minimum and maximum values from a list of positions
  87049. * @param positions defines the positions to use
  87050. * @param start defines the start index in the positions array
  87051. * @param count defines the number of positions to handle
  87052. * @param bias defines bias value to add to the result
  87053. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87054. * @return minimum and maximum values
  87055. */
  87056. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87057. minimum: Vector3;
  87058. maximum: Vector3;
  87059. };
  87060. }
  87061. declare module BABYLON {
  87062. /** @hidden */
  87063. export class WebGLDataBuffer extends DataBuffer {
  87064. private _buffer;
  87065. constructor(resource: WebGLBuffer);
  87066. get underlyingResource(): any;
  87067. }
  87068. }
  87069. declare module BABYLON {
  87070. /** @hidden */
  87071. export class WebGLPipelineContext implements IPipelineContext {
  87072. engine: ThinEngine;
  87073. program: Nullable<WebGLProgram>;
  87074. context?: WebGLRenderingContext;
  87075. vertexShader?: WebGLShader;
  87076. fragmentShader?: WebGLShader;
  87077. isParallelCompiled: boolean;
  87078. onCompiled?: () => void;
  87079. transformFeedback?: WebGLTransformFeedback | null;
  87080. vertexCompilationError: Nullable<string>;
  87081. fragmentCompilationError: Nullable<string>;
  87082. programLinkError: Nullable<string>;
  87083. programValidationError: Nullable<string>;
  87084. get isAsync(): boolean;
  87085. get isReady(): boolean;
  87086. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  87087. _getVertexShaderCode(): string | null;
  87088. _getFragmentShaderCode(): string | null;
  87089. }
  87090. }
  87091. declare module BABYLON {
  87092. interface ThinEngine {
  87093. /**
  87094. * Create an uniform buffer
  87095. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87096. * @param elements defines the content of the uniform buffer
  87097. * @returns the webGL uniform buffer
  87098. */
  87099. createUniformBuffer(elements: FloatArray): DataBuffer;
  87100. /**
  87101. * Create a dynamic uniform buffer
  87102. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87103. * @param elements defines the content of the uniform buffer
  87104. * @returns the webGL uniform buffer
  87105. */
  87106. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  87107. /**
  87108. * Update an existing uniform buffer
  87109. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87110. * @param uniformBuffer defines the target uniform buffer
  87111. * @param elements defines the content to update
  87112. * @param offset defines the offset in the uniform buffer where update should start
  87113. * @param count defines the size of the data to update
  87114. */
  87115. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  87116. /**
  87117. * Bind an uniform buffer to the current webGL context
  87118. * @param buffer defines the buffer to bind
  87119. */
  87120. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  87121. /**
  87122. * Bind a buffer to the current webGL context at a given location
  87123. * @param buffer defines the buffer to bind
  87124. * @param location defines the index where to bind the buffer
  87125. */
  87126. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  87127. /**
  87128. * Bind a specific block at a given index in a specific shader program
  87129. * @param pipelineContext defines the pipeline context to use
  87130. * @param blockName defines the block name
  87131. * @param index defines the index where to bind the block
  87132. */
  87133. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  87134. }
  87135. }
  87136. declare module BABYLON {
  87137. /**
  87138. * Uniform buffer objects.
  87139. *
  87140. * Handles blocks of uniform on the GPU.
  87141. *
  87142. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87143. *
  87144. * For more information, please refer to :
  87145. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87146. */
  87147. export class UniformBuffer {
  87148. private _engine;
  87149. private _buffer;
  87150. private _data;
  87151. private _bufferData;
  87152. private _dynamic?;
  87153. private _uniformLocations;
  87154. private _uniformSizes;
  87155. private _uniformLocationPointer;
  87156. private _needSync;
  87157. private _noUBO;
  87158. private _currentEffect;
  87159. /** @hidden */
  87160. _alreadyBound: boolean;
  87161. private static _MAX_UNIFORM_SIZE;
  87162. private static _tempBuffer;
  87163. /**
  87164. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  87165. * This is dynamic to allow compat with webgl 1 and 2.
  87166. * You will need to pass the name of the uniform as well as the value.
  87167. */
  87168. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  87169. /**
  87170. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  87171. * This is dynamic to allow compat with webgl 1 and 2.
  87172. * You will need to pass the name of the uniform as well as the value.
  87173. */
  87174. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  87175. /**
  87176. * Lambda to Update a single float in a uniform buffer.
  87177. * This is dynamic to allow compat with webgl 1 and 2.
  87178. * You will need to pass the name of the uniform as well as the value.
  87179. */
  87180. updateFloat: (name: string, x: number) => void;
  87181. /**
  87182. * Lambda to Update a vec2 of float in a uniform buffer.
  87183. * This is dynamic to allow compat with webgl 1 and 2.
  87184. * You will need to pass the name of the uniform as well as the value.
  87185. */
  87186. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  87187. /**
  87188. * Lambda to Update a vec3 of float in a uniform buffer.
  87189. * This is dynamic to allow compat with webgl 1 and 2.
  87190. * You will need to pass the name of the uniform as well as the value.
  87191. */
  87192. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  87193. /**
  87194. * Lambda to Update a vec4 of float in a uniform buffer.
  87195. * This is dynamic to allow compat with webgl 1 and 2.
  87196. * You will need to pass the name of the uniform as well as the value.
  87197. */
  87198. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  87199. /**
  87200. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  87201. * This is dynamic to allow compat with webgl 1 and 2.
  87202. * You will need to pass the name of the uniform as well as the value.
  87203. */
  87204. updateMatrix: (name: string, mat: Matrix) => void;
  87205. /**
  87206. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  87207. * This is dynamic to allow compat with webgl 1 and 2.
  87208. * You will need to pass the name of the uniform as well as the value.
  87209. */
  87210. updateVector3: (name: string, vector: Vector3) => void;
  87211. /**
  87212. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  87213. * This is dynamic to allow compat with webgl 1 and 2.
  87214. * You will need to pass the name of the uniform as well as the value.
  87215. */
  87216. updateVector4: (name: string, vector: Vector4) => void;
  87217. /**
  87218. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  87219. * This is dynamic to allow compat with webgl 1 and 2.
  87220. * You will need to pass the name of the uniform as well as the value.
  87221. */
  87222. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  87223. /**
  87224. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  87225. * This is dynamic to allow compat with webgl 1 and 2.
  87226. * You will need to pass the name of the uniform as well as the value.
  87227. */
  87228. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  87229. /**
  87230. * Instantiates a new Uniform buffer objects.
  87231. *
  87232. * Handles blocks of uniform on the GPU.
  87233. *
  87234. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87235. *
  87236. * For more information, please refer to :
  87237. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87238. * @param engine Define the engine the buffer is associated with
  87239. * @param data Define the data contained in the buffer
  87240. * @param dynamic Define if the buffer is updatable
  87241. */
  87242. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  87243. /**
  87244. * Indicates if the buffer is using the WebGL2 UBO implementation,
  87245. * or just falling back on setUniformXXX calls.
  87246. */
  87247. get useUbo(): boolean;
  87248. /**
  87249. * Indicates if the WebGL underlying uniform buffer is in sync
  87250. * with the javascript cache data.
  87251. */
  87252. get isSync(): boolean;
  87253. /**
  87254. * Indicates if the WebGL underlying uniform buffer is dynamic.
  87255. * Also, a dynamic UniformBuffer will disable cache verification and always
  87256. * update the underlying WebGL uniform buffer to the GPU.
  87257. * @returns if Dynamic, otherwise false
  87258. */
  87259. isDynamic(): boolean;
  87260. /**
  87261. * The data cache on JS side.
  87262. * @returns the underlying data as a float array
  87263. */
  87264. getData(): Float32Array;
  87265. /**
  87266. * The underlying WebGL Uniform buffer.
  87267. * @returns the webgl buffer
  87268. */
  87269. getBuffer(): Nullable<DataBuffer>;
  87270. /**
  87271. * std140 layout specifies how to align data within an UBO structure.
  87272. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  87273. * for specs.
  87274. */
  87275. private _fillAlignment;
  87276. /**
  87277. * Adds an uniform in the buffer.
  87278. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  87279. * for the layout to be correct !
  87280. * @param name Name of the uniform, as used in the uniform block in the shader.
  87281. * @param size Data size, or data directly.
  87282. */
  87283. addUniform(name: string, size: number | number[]): void;
  87284. /**
  87285. * Adds a Matrix 4x4 to the uniform buffer.
  87286. * @param name Name of the uniform, as used in the uniform block in the shader.
  87287. * @param mat A 4x4 matrix.
  87288. */
  87289. addMatrix(name: string, mat: Matrix): void;
  87290. /**
  87291. * Adds a vec2 to the uniform buffer.
  87292. * @param name Name of the uniform, as used in the uniform block in the shader.
  87293. * @param x Define the x component value of the vec2
  87294. * @param y Define the y component value of the vec2
  87295. */
  87296. addFloat2(name: string, x: number, y: number): void;
  87297. /**
  87298. * Adds a vec3 to the uniform buffer.
  87299. * @param name Name of the uniform, as used in the uniform block in the shader.
  87300. * @param x Define the x component value of the vec3
  87301. * @param y Define the y component value of the vec3
  87302. * @param z Define the z component value of the vec3
  87303. */
  87304. addFloat3(name: string, x: number, y: number, z: number): void;
  87305. /**
  87306. * Adds a vec3 to the uniform buffer.
  87307. * @param name Name of the uniform, as used in the uniform block in the shader.
  87308. * @param color Define the vec3 from a Color
  87309. */
  87310. addColor3(name: string, color: Color3): void;
  87311. /**
  87312. * Adds a vec4 to the uniform buffer.
  87313. * @param name Name of the uniform, as used in the uniform block in the shader.
  87314. * @param color Define the rgb components from a Color
  87315. * @param alpha Define the a component of the vec4
  87316. */
  87317. addColor4(name: string, color: Color3, alpha: number): void;
  87318. /**
  87319. * Adds a vec3 to the uniform buffer.
  87320. * @param name Name of the uniform, as used in the uniform block in the shader.
  87321. * @param vector Define the vec3 components from a Vector
  87322. */
  87323. addVector3(name: string, vector: Vector3): void;
  87324. /**
  87325. * Adds a Matrix 3x3 to the uniform buffer.
  87326. * @param name Name of the uniform, as used in the uniform block in the shader.
  87327. */
  87328. addMatrix3x3(name: string): void;
  87329. /**
  87330. * Adds a Matrix 2x2 to the uniform buffer.
  87331. * @param name Name of the uniform, as used in the uniform block in the shader.
  87332. */
  87333. addMatrix2x2(name: string): void;
  87334. /**
  87335. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  87336. */
  87337. create(): void;
  87338. /** @hidden */
  87339. _rebuild(): void;
  87340. /**
  87341. * Updates the WebGL Uniform Buffer on the GPU.
  87342. * If the `dynamic` flag is set to true, no cache comparison is done.
  87343. * Otherwise, the buffer will be updated only if the cache differs.
  87344. */
  87345. update(): void;
  87346. /**
  87347. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  87348. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  87349. * @param data Define the flattened data
  87350. * @param size Define the size of the data.
  87351. */
  87352. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  87353. private _valueCache;
  87354. private _cacheMatrix;
  87355. private _updateMatrix3x3ForUniform;
  87356. private _updateMatrix3x3ForEffect;
  87357. private _updateMatrix2x2ForEffect;
  87358. private _updateMatrix2x2ForUniform;
  87359. private _updateFloatForEffect;
  87360. private _updateFloatForUniform;
  87361. private _updateFloat2ForEffect;
  87362. private _updateFloat2ForUniform;
  87363. private _updateFloat3ForEffect;
  87364. private _updateFloat3ForUniform;
  87365. private _updateFloat4ForEffect;
  87366. private _updateFloat4ForUniform;
  87367. private _updateMatrixForEffect;
  87368. private _updateMatrixForUniform;
  87369. private _updateVector3ForEffect;
  87370. private _updateVector3ForUniform;
  87371. private _updateVector4ForEffect;
  87372. private _updateVector4ForUniform;
  87373. private _updateColor3ForEffect;
  87374. private _updateColor3ForUniform;
  87375. private _updateColor4ForEffect;
  87376. private _updateColor4ForUniform;
  87377. /**
  87378. * Sets a sampler uniform on the effect.
  87379. * @param name Define the name of the sampler.
  87380. * @param texture Define the texture to set in the sampler
  87381. */
  87382. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  87383. /**
  87384. * Directly updates the value of the uniform in the cache AND on the GPU.
  87385. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  87386. * @param data Define the flattened data
  87387. */
  87388. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  87389. /**
  87390. * Binds this uniform buffer to an effect.
  87391. * @param effect Define the effect to bind the buffer to
  87392. * @param name Name of the uniform block in the shader.
  87393. */
  87394. bindToEffect(effect: Effect, name: string): void;
  87395. /**
  87396. * Disposes the uniform buffer.
  87397. */
  87398. dispose(): void;
  87399. }
  87400. }
  87401. declare module BABYLON {
  87402. /**
  87403. * Enum that determines the text-wrapping mode to use.
  87404. */
  87405. export enum InspectableType {
  87406. /**
  87407. * Checkbox for booleans
  87408. */
  87409. Checkbox = 0,
  87410. /**
  87411. * Sliders for numbers
  87412. */
  87413. Slider = 1,
  87414. /**
  87415. * Vector3
  87416. */
  87417. Vector3 = 2,
  87418. /**
  87419. * Quaternions
  87420. */
  87421. Quaternion = 3,
  87422. /**
  87423. * Color3
  87424. */
  87425. Color3 = 4,
  87426. /**
  87427. * String
  87428. */
  87429. String = 5
  87430. }
  87431. /**
  87432. * Interface used to define custom inspectable properties.
  87433. * This interface is used by the inspector to display custom property grids
  87434. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87435. */
  87436. export interface IInspectable {
  87437. /**
  87438. * Gets the label to display
  87439. */
  87440. label: string;
  87441. /**
  87442. * Gets the name of the property to edit
  87443. */
  87444. propertyName: string;
  87445. /**
  87446. * Gets the type of the editor to use
  87447. */
  87448. type: InspectableType;
  87449. /**
  87450. * Gets the minimum value of the property when using in "slider" mode
  87451. */
  87452. min?: number;
  87453. /**
  87454. * Gets the maximum value of the property when using in "slider" mode
  87455. */
  87456. max?: number;
  87457. /**
  87458. * Gets the setp to use when using in "slider" mode
  87459. */
  87460. step?: number;
  87461. }
  87462. }
  87463. declare module BABYLON {
  87464. /**
  87465. * Class used to provide helper for timing
  87466. */
  87467. export class TimingTools {
  87468. /**
  87469. * Polyfill for setImmediate
  87470. * @param action defines the action to execute after the current execution block
  87471. */
  87472. static SetImmediate(action: () => void): void;
  87473. }
  87474. }
  87475. declare module BABYLON {
  87476. /**
  87477. * Class used to enable instatition of objects by class name
  87478. */
  87479. export class InstantiationTools {
  87480. /**
  87481. * Use this object to register external classes like custom textures or material
  87482. * to allow the laoders to instantiate them
  87483. */
  87484. static RegisteredExternalClasses: {
  87485. [key: string]: Object;
  87486. };
  87487. /**
  87488. * Tries to instantiate a new object from a given class name
  87489. * @param className defines the class name to instantiate
  87490. * @returns the new object or null if the system was not able to do the instantiation
  87491. */
  87492. static Instantiate(className: string): any;
  87493. }
  87494. }
  87495. declare module BABYLON {
  87496. /**
  87497. * Define options used to create a depth texture
  87498. */
  87499. export class DepthTextureCreationOptions {
  87500. /** Specifies whether or not a stencil should be allocated in the texture */
  87501. generateStencil?: boolean;
  87502. /** Specifies whether or not bilinear filtering is enable on the texture */
  87503. bilinearFiltering?: boolean;
  87504. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  87505. comparisonFunction?: number;
  87506. /** Specifies if the created texture is a cube texture */
  87507. isCube?: boolean;
  87508. }
  87509. }
  87510. declare module BABYLON {
  87511. interface ThinEngine {
  87512. /**
  87513. * Creates a depth stencil cube texture.
  87514. * This is only available in WebGL 2.
  87515. * @param size The size of face edge in the cube texture.
  87516. * @param options The options defining the cube texture.
  87517. * @returns The cube texture
  87518. */
  87519. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  87520. /**
  87521. * Creates a cube texture
  87522. * @param rootUrl defines the url where the files to load is located
  87523. * @param scene defines the current scene
  87524. * @param files defines the list of files to load (1 per face)
  87525. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87526. * @param onLoad defines an optional callback raised when the texture is loaded
  87527. * @param onError defines an optional callback raised if there is an issue to load the texture
  87528. * @param format defines the format of the data
  87529. * @param forcedExtension defines the extension to use to pick the right loader
  87530. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  87531. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87532. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87533. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  87534. * @returns the cube texture as an InternalTexture
  87535. */
  87536. 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;
  87537. /**
  87538. * Creates a cube texture
  87539. * @param rootUrl defines the url where the files to load is located
  87540. * @param scene defines the current scene
  87541. * @param files defines the list of files to load (1 per face)
  87542. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87543. * @param onLoad defines an optional callback raised when the texture is loaded
  87544. * @param onError defines an optional callback raised if there is an issue to load the texture
  87545. * @param format defines the format of the data
  87546. * @param forcedExtension defines the extension to use to pick the right loader
  87547. * @returns the cube texture as an InternalTexture
  87548. */
  87549. 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;
  87550. /**
  87551. * Creates a cube texture
  87552. * @param rootUrl defines the url where the files to load is located
  87553. * @param scene defines the current scene
  87554. * @param files defines the list of files to load (1 per face)
  87555. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87556. * @param onLoad defines an optional callback raised when the texture is loaded
  87557. * @param onError defines an optional callback raised if there is an issue to load the texture
  87558. * @param format defines the format of the data
  87559. * @param forcedExtension defines the extension to use to pick the right loader
  87560. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  87561. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87562. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87563. * @returns the cube texture as an InternalTexture
  87564. */
  87565. 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;
  87566. /** @hidden */
  87567. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  87568. /** @hidden */
  87569. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  87570. /** @hidden */
  87571. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  87572. /** @hidden */
  87573. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  87574. /**
  87575. * @hidden
  87576. */
  87577. _setCubeMapTextureParams(loadMipmap: boolean): void;
  87578. }
  87579. }
  87580. declare module BABYLON {
  87581. /**
  87582. * Class for creating a cube texture
  87583. */
  87584. export class CubeTexture extends BaseTexture {
  87585. private _delayedOnLoad;
  87586. /**
  87587. * Observable triggered once the texture has been loaded.
  87588. */
  87589. onLoadObservable: Observable<CubeTexture>;
  87590. /**
  87591. * The url of the texture
  87592. */
  87593. url: string;
  87594. /**
  87595. * Gets or sets the center of the bounding box associated with the cube texture.
  87596. * It must define where the camera used to render the texture was set
  87597. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  87598. */
  87599. boundingBoxPosition: Vector3;
  87600. private _boundingBoxSize;
  87601. /**
  87602. * Gets or sets the size of the bounding box associated with the cube texture
  87603. * When defined, the cubemap will switch to local mode
  87604. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  87605. * @example https://www.babylonjs-playground.com/#RNASML
  87606. */
  87607. set boundingBoxSize(value: Vector3);
  87608. /**
  87609. * Returns the bounding box size
  87610. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  87611. */
  87612. get boundingBoxSize(): Vector3;
  87613. protected _rotationY: number;
  87614. /**
  87615. * Sets texture matrix rotation angle around Y axis in radians.
  87616. */
  87617. set rotationY(value: number);
  87618. /**
  87619. * Gets texture matrix rotation angle around Y axis radians.
  87620. */
  87621. get rotationY(): number;
  87622. /**
  87623. * Are mip maps generated for this texture or not.
  87624. */
  87625. get noMipmap(): boolean;
  87626. private _noMipmap;
  87627. private _files;
  87628. protected _forcedExtension: Nullable<string>;
  87629. private _extensions;
  87630. private _textureMatrix;
  87631. private _format;
  87632. private _createPolynomials;
  87633. /**
  87634. * Creates a cube texture from an array of image urls
  87635. * @param files defines an array of image urls
  87636. * @param scene defines the hosting scene
  87637. * @param noMipmap specifies if mip maps are not used
  87638. * @returns a cube texture
  87639. */
  87640. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  87641. /**
  87642. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  87643. * @param url defines the url of the prefiltered texture
  87644. * @param scene defines the scene the texture is attached to
  87645. * @param forcedExtension defines the extension of the file if different from the url
  87646. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  87647. * @return the prefiltered texture
  87648. */
  87649. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  87650. /**
  87651. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  87652. * as prefiltered data.
  87653. * @param rootUrl defines the url of the texture or the root name of the six images
  87654. * @param null defines the scene or engine the texture is attached to
  87655. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  87656. * @param noMipmap defines if mipmaps should be created or not
  87657. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  87658. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  87659. * @param onError defines a callback triggered in case of error during load
  87660. * @param format defines the internal format to use for the texture once loaded
  87661. * @param prefiltered defines whether or not the texture is created from prefiltered data
  87662. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  87663. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  87664. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  87665. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  87666. * @return the cube texture
  87667. */
  87668. 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);
  87669. /**
  87670. * Get the current class name of the texture useful for serialization or dynamic coding.
  87671. * @returns "CubeTexture"
  87672. */
  87673. getClassName(): string;
  87674. /**
  87675. * Update the url (and optional buffer) of this texture if url was null during construction.
  87676. * @param url the url of the texture
  87677. * @param forcedExtension defines the extension to use
  87678. * @param onLoad callback called when the texture is loaded (defaults to null)
  87679. * @param prefiltered Defines whether the updated texture is prefiltered or not
  87680. */
  87681. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  87682. /**
  87683. * Delays loading of the cube texture
  87684. * @param forcedExtension defines the extension to use
  87685. */
  87686. delayLoad(forcedExtension?: string): void;
  87687. /**
  87688. * Returns the reflection texture matrix
  87689. * @returns the reflection texture matrix
  87690. */
  87691. getReflectionTextureMatrix(): Matrix;
  87692. /**
  87693. * Sets the reflection texture matrix
  87694. * @param value Reflection texture matrix
  87695. */
  87696. setReflectionTextureMatrix(value: Matrix): void;
  87697. /**
  87698. * Parses text to create a cube texture
  87699. * @param parsedTexture define the serialized text to read from
  87700. * @param scene defines the hosting scene
  87701. * @param rootUrl defines the root url of the cube texture
  87702. * @returns a cube texture
  87703. */
  87704. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  87705. /**
  87706. * Makes a clone, or deep copy, of the cube texture
  87707. * @returns a new cube texture
  87708. */
  87709. clone(): CubeTexture;
  87710. }
  87711. }
  87712. declare module BABYLON {
  87713. /**
  87714. * Manages the defines for the Material
  87715. */
  87716. export class MaterialDefines {
  87717. /** @hidden */
  87718. protected _keys: string[];
  87719. private _isDirty;
  87720. /** @hidden */
  87721. _renderId: number;
  87722. /** @hidden */
  87723. _areLightsDirty: boolean;
  87724. /** @hidden */
  87725. _areLightsDisposed: boolean;
  87726. /** @hidden */
  87727. _areAttributesDirty: boolean;
  87728. /** @hidden */
  87729. _areTexturesDirty: boolean;
  87730. /** @hidden */
  87731. _areFresnelDirty: boolean;
  87732. /** @hidden */
  87733. _areMiscDirty: boolean;
  87734. /** @hidden */
  87735. _areImageProcessingDirty: boolean;
  87736. /** @hidden */
  87737. _normals: boolean;
  87738. /** @hidden */
  87739. _uvs: boolean;
  87740. /** @hidden */
  87741. _needNormals: boolean;
  87742. /** @hidden */
  87743. _needUVs: boolean;
  87744. [id: string]: any;
  87745. /**
  87746. * Specifies if the material needs to be re-calculated
  87747. */
  87748. get isDirty(): boolean;
  87749. /**
  87750. * Marks the material to indicate that it has been re-calculated
  87751. */
  87752. markAsProcessed(): void;
  87753. /**
  87754. * Marks the material to indicate that it needs to be re-calculated
  87755. */
  87756. markAsUnprocessed(): void;
  87757. /**
  87758. * Marks the material to indicate all of its defines need to be re-calculated
  87759. */
  87760. markAllAsDirty(): void;
  87761. /**
  87762. * Marks the material to indicate that image processing needs to be re-calculated
  87763. */
  87764. markAsImageProcessingDirty(): void;
  87765. /**
  87766. * Marks the material to indicate the lights need to be re-calculated
  87767. * @param disposed Defines whether the light is dirty due to dispose or not
  87768. */
  87769. markAsLightDirty(disposed?: boolean): void;
  87770. /**
  87771. * Marks the attribute state as changed
  87772. */
  87773. markAsAttributesDirty(): void;
  87774. /**
  87775. * Marks the texture state as changed
  87776. */
  87777. markAsTexturesDirty(): void;
  87778. /**
  87779. * Marks the fresnel state as changed
  87780. */
  87781. markAsFresnelDirty(): void;
  87782. /**
  87783. * Marks the misc state as changed
  87784. */
  87785. markAsMiscDirty(): void;
  87786. /**
  87787. * Rebuilds the material defines
  87788. */
  87789. rebuild(): void;
  87790. /**
  87791. * Specifies if two material defines are equal
  87792. * @param other - A material define instance to compare to
  87793. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  87794. */
  87795. isEqual(other: MaterialDefines): boolean;
  87796. /**
  87797. * Clones this instance's defines to another instance
  87798. * @param other - material defines to clone values to
  87799. */
  87800. cloneTo(other: MaterialDefines): void;
  87801. /**
  87802. * Resets the material define values
  87803. */
  87804. reset(): void;
  87805. /**
  87806. * Converts the material define values to a string
  87807. * @returns - String of material define information
  87808. */
  87809. toString(): string;
  87810. }
  87811. }
  87812. declare module BABYLON {
  87813. /**
  87814. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  87815. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  87816. * 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;
  87817. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  87818. */
  87819. export class ColorCurves {
  87820. private _dirty;
  87821. private _tempColor;
  87822. private _globalCurve;
  87823. private _highlightsCurve;
  87824. private _midtonesCurve;
  87825. private _shadowsCurve;
  87826. private _positiveCurve;
  87827. private _negativeCurve;
  87828. private _globalHue;
  87829. private _globalDensity;
  87830. private _globalSaturation;
  87831. private _globalExposure;
  87832. /**
  87833. * Gets the global Hue value.
  87834. * 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).
  87835. */
  87836. get globalHue(): number;
  87837. /**
  87838. * Sets the global Hue value.
  87839. * 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).
  87840. */
  87841. set globalHue(value: number);
  87842. /**
  87843. * Gets the global Density value.
  87844. * 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.
  87845. * Values less than zero provide a filter of opposite hue.
  87846. */
  87847. get globalDensity(): number;
  87848. /**
  87849. * Sets the global Density value.
  87850. * 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.
  87851. * Values less than zero provide a filter of opposite hue.
  87852. */
  87853. set globalDensity(value: number);
  87854. /**
  87855. * Gets the global Saturation value.
  87856. * 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.
  87857. */
  87858. get globalSaturation(): number;
  87859. /**
  87860. * Sets the global Saturation value.
  87861. * 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.
  87862. */
  87863. set globalSaturation(value: number);
  87864. /**
  87865. * Gets the global Exposure value.
  87866. * 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.
  87867. */
  87868. get globalExposure(): number;
  87869. /**
  87870. * Sets the global Exposure value.
  87871. * 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.
  87872. */
  87873. set globalExposure(value: number);
  87874. private _highlightsHue;
  87875. private _highlightsDensity;
  87876. private _highlightsSaturation;
  87877. private _highlightsExposure;
  87878. /**
  87879. * Gets the highlights Hue value.
  87880. * 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).
  87881. */
  87882. get highlightsHue(): number;
  87883. /**
  87884. * Sets the highlights Hue value.
  87885. * 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).
  87886. */
  87887. set highlightsHue(value: number);
  87888. /**
  87889. * Gets the highlights Density value.
  87890. * 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.
  87891. * Values less than zero provide a filter of opposite hue.
  87892. */
  87893. get highlightsDensity(): number;
  87894. /**
  87895. * Sets the highlights Density value.
  87896. * 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.
  87897. * Values less than zero provide a filter of opposite hue.
  87898. */
  87899. set highlightsDensity(value: number);
  87900. /**
  87901. * Gets the highlights Saturation value.
  87902. * 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.
  87903. */
  87904. get highlightsSaturation(): number;
  87905. /**
  87906. * Sets the highlights Saturation value.
  87907. * 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.
  87908. */
  87909. set highlightsSaturation(value: number);
  87910. /**
  87911. * Gets the highlights Exposure value.
  87912. * 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.
  87913. */
  87914. get highlightsExposure(): number;
  87915. /**
  87916. * Sets the highlights Exposure value.
  87917. * 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.
  87918. */
  87919. set highlightsExposure(value: number);
  87920. private _midtonesHue;
  87921. private _midtonesDensity;
  87922. private _midtonesSaturation;
  87923. private _midtonesExposure;
  87924. /**
  87925. * Gets the midtones Hue value.
  87926. * 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).
  87927. */
  87928. get midtonesHue(): number;
  87929. /**
  87930. * Sets the midtones Hue value.
  87931. * 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).
  87932. */
  87933. set midtonesHue(value: number);
  87934. /**
  87935. * Gets the midtones Density value.
  87936. * 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.
  87937. * Values less than zero provide a filter of opposite hue.
  87938. */
  87939. get midtonesDensity(): number;
  87940. /**
  87941. * Sets the midtones Density value.
  87942. * 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.
  87943. * Values less than zero provide a filter of opposite hue.
  87944. */
  87945. set midtonesDensity(value: number);
  87946. /**
  87947. * Gets the midtones Saturation value.
  87948. * 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.
  87949. */
  87950. get midtonesSaturation(): number;
  87951. /**
  87952. * Sets the midtones Saturation value.
  87953. * 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.
  87954. */
  87955. set midtonesSaturation(value: number);
  87956. /**
  87957. * Gets the midtones Exposure value.
  87958. * 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.
  87959. */
  87960. get midtonesExposure(): number;
  87961. /**
  87962. * Sets the midtones Exposure value.
  87963. * 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.
  87964. */
  87965. set midtonesExposure(value: number);
  87966. private _shadowsHue;
  87967. private _shadowsDensity;
  87968. private _shadowsSaturation;
  87969. private _shadowsExposure;
  87970. /**
  87971. * Gets the shadows Hue value.
  87972. * 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).
  87973. */
  87974. get shadowsHue(): number;
  87975. /**
  87976. * Sets the shadows Hue value.
  87977. * 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).
  87978. */
  87979. set shadowsHue(value: number);
  87980. /**
  87981. * Gets the shadows Density value.
  87982. * 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.
  87983. * Values less than zero provide a filter of opposite hue.
  87984. */
  87985. get shadowsDensity(): number;
  87986. /**
  87987. * Sets the shadows Density value.
  87988. * 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.
  87989. * Values less than zero provide a filter of opposite hue.
  87990. */
  87991. set shadowsDensity(value: number);
  87992. /**
  87993. * Gets the shadows Saturation value.
  87994. * 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.
  87995. */
  87996. get shadowsSaturation(): number;
  87997. /**
  87998. * Sets the shadows Saturation value.
  87999. * 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.
  88000. */
  88001. set shadowsSaturation(value: number);
  88002. /**
  88003. * Gets the shadows Exposure value.
  88004. * 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.
  88005. */
  88006. get shadowsExposure(): number;
  88007. /**
  88008. * Sets the shadows Exposure value.
  88009. * 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.
  88010. */
  88011. set shadowsExposure(value: number);
  88012. /**
  88013. * Returns the class name
  88014. * @returns The class name
  88015. */
  88016. getClassName(): string;
  88017. /**
  88018. * Binds the color curves to the shader.
  88019. * @param colorCurves The color curve to bind
  88020. * @param effect The effect to bind to
  88021. * @param positiveUniform The positive uniform shader parameter
  88022. * @param neutralUniform The neutral uniform shader parameter
  88023. * @param negativeUniform The negative uniform shader parameter
  88024. */
  88025. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  88026. /**
  88027. * Prepare the list of uniforms associated with the ColorCurves effects.
  88028. * @param uniformsList The list of uniforms used in the effect
  88029. */
  88030. static PrepareUniforms(uniformsList: string[]): void;
  88031. /**
  88032. * Returns color grading data based on a hue, density, saturation and exposure value.
  88033. * @param filterHue The hue of the color filter.
  88034. * @param filterDensity The density of the color filter.
  88035. * @param saturation The saturation.
  88036. * @param exposure The exposure.
  88037. * @param result The result data container.
  88038. */
  88039. private getColorGradingDataToRef;
  88040. /**
  88041. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  88042. * @param value The input slider value in range [-100,100].
  88043. * @returns Adjusted value.
  88044. */
  88045. private static applyColorGradingSliderNonlinear;
  88046. /**
  88047. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  88048. * @param hue The hue (H) input.
  88049. * @param saturation The saturation (S) input.
  88050. * @param brightness The brightness (B) input.
  88051. * @result An RGBA color represented as Vector4.
  88052. */
  88053. private static fromHSBToRef;
  88054. /**
  88055. * Returns a value clamped between min and max
  88056. * @param value The value to clamp
  88057. * @param min The minimum of value
  88058. * @param max The maximum of value
  88059. * @returns The clamped value.
  88060. */
  88061. private static clamp;
  88062. /**
  88063. * Clones the current color curve instance.
  88064. * @return The cloned curves
  88065. */
  88066. clone(): ColorCurves;
  88067. /**
  88068. * Serializes the current color curve instance to a json representation.
  88069. * @return a JSON representation
  88070. */
  88071. serialize(): any;
  88072. /**
  88073. * Parses the color curve from a json representation.
  88074. * @param source the JSON source to parse
  88075. * @return The parsed curves
  88076. */
  88077. static Parse(source: any): ColorCurves;
  88078. }
  88079. }
  88080. declare module BABYLON {
  88081. /**
  88082. * Interface to follow in your material defines to integrate easily the
  88083. * Image proccessing functions.
  88084. * @hidden
  88085. */
  88086. export interface IImageProcessingConfigurationDefines {
  88087. IMAGEPROCESSING: boolean;
  88088. VIGNETTE: boolean;
  88089. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88090. VIGNETTEBLENDMODEOPAQUE: boolean;
  88091. TONEMAPPING: boolean;
  88092. TONEMAPPING_ACES: boolean;
  88093. CONTRAST: boolean;
  88094. EXPOSURE: boolean;
  88095. COLORCURVES: boolean;
  88096. COLORGRADING: boolean;
  88097. COLORGRADING3D: boolean;
  88098. SAMPLER3DGREENDEPTH: boolean;
  88099. SAMPLER3DBGRMAP: boolean;
  88100. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88101. }
  88102. /**
  88103. * @hidden
  88104. */
  88105. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  88106. IMAGEPROCESSING: boolean;
  88107. VIGNETTE: boolean;
  88108. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88109. VIGNETTEBLENDMODEOPAQUE: boolean;
  88110. TONEMAPPING: boolean;
  88111. TONEMAPPING_ACES: boolean;
  88112. CONTRAST: boolean;
  88113. COLORCURVES: boolean;
  88114. COLORGRADING: boolean;
  88115. COLORGRADING3D: boolean;
  88116. SAMPLER3DGREENDEPTH: boolean;
  88117. SAMPLER3DBGRMAP: boolean;
  88118. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88119. EXPOSURE: boolean;
  88120. constructor();
  88121. }
  88122. /**
  88123. * This groups together the common properties used for image processing either in direct forward pass
  88124. * or through post processing effect depending on the use of the image processing pipeline in your scene
  88125. * or not.
  88126. */
  88127. export class ImageProcessingConfiguration {
  88128. /**
  88129. * Default tone mapping applied in BabylonJS.
  88130. */
  88131. static readonly TONEMAPPING_STANDARD: number;
  88132. /**
  88133. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  88134. * to other engines rendering to increase portability.
  88135. */
  88136. static readonly TONEMAPPING_ACES: number;
  88137. /**
  88138. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  88139. */
  88140. colorCurves: Nullable<ColorCurves>;
  88141. private _colorCurvesEnabled;
  88142. /**
  88143. * Gets wether the color curves effect is enabled.
  88144. */
  88145. get colorCurvesEnabled(): boolean;
  88146. /**
  88147. * Sets wether the color curves effect is enabled.
  88148. */
  88149. set colorCurvesEnabled(value: boolean);
  88150. private _colorGradingTexture;
  88151. /**
  88152. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88153. */
  88154. get colorGradingTexture(): Nullable<BaseTexture>;
  88155. /**
  88156. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88157. */
  88158. set colorGradingTexture(value: Nullable<BaseTexture>);
  88159. private _colorGradingEnabled;
  88160. /**
  88161. * Gets wether the color grading effect is enabled.
  88162. */
  88163. get colorGradingEnabled(): boolean;
  88164. /**
  88165. * Sets wether the color grading effect is enabled.
  88166. */
  88167. set colorGradingEnabled(value: boolean);
  88168. private _colorGradingWithGreenDepth;
  88169. /**
  88170. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  88171. */
  88172. get colorGradingWithGreenDepth(): boolean;
  88173. /**
  88174. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  88175. */
  88176. set colorGradingWithGreenDepth(value: boolean);
  88177. private _colorGradingBGR;
  88178. /**
  88179. * Gets wether the color grading texture contains BGR values.
  88180. */
  88181. get colorGradingBGR(): boolean;
  88182. /**
  88183. * Sets wether the color grading texture contains BGR values.
  88184. */
  88185. set colorGradingBGR(value: boolean);
  88186. /** @hidden */
  88187. _exposure: number;
  88188. /**
  88189. * Gets the Exposure used in the effect.
  88190. */
  88191. get exposure(): number;
  88192. /**
  88193. * Sets the Exposure used in the effect.
  88194. */
  88195. set exposure(value: number);
  88196. private _toneMappingEnabled;
  88197. /**
  88198. * Gets wether the tone mapping effect is enabled.
  88199. */
  88200. get toneMappingEnabled(): boolean;
  88201. /**
  88202. * Sets wether the tone mapping effect is enabled.
  88203. */
  88204. set toneMappingEnabled(value: boolean);
  88205. private _toneMappingType;
  88206. /**
  88207. * Gets the type of tone mapping effect.
  88208. */
  88209. get toneMappingType(): number;
  88210. /**
  88211. * Sets the type of tone mapping effect used in BabylonJS.
  88212. */
  88213. set toneMappingType(value: number);
  88214. protected _contrast: number;
  88215. /**
  88216. * Gets the contrast used in the effect.
  88217. */
  88218. get contrast(): number;
  88219. /**
  88220. * Sets the contrast used in the effect.
  88221. */
  88222. set contrast(value: number);
  88223. /**
  88224. * Vignette stretch size.
  88225. */
  88226. vignetteStretch: number;
  88227. /**
  88228. * Vignette centre X Offset.
  88229. */
  88230. vignetteCentreX: number;
  88231. /**
  88232. * Vignette centre Y Offset.
  88233. */
  88234. vignetteCentreY: number;
  88235. /**
  88236. * Vignette weight or intensity of the vignette effect.
  88237. */
  88238. vignetteWeight: number;
  88239. /**
  88240. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  88241. * if vignetteEnabled is set to true.
  88242. */
  88243. vignetteColor: Color4;
  88244. /**
  88245. * Camera field of view used by the Vignette effect.
  88246. */
  88247. vignetteCameraFov: number;
  88248. private _vignetteBlendMode;
  88249. /**
  88250. * Gets the vignette blend mode allowing different kind of effect.
  88251. */
  88252. get vignetteBlendMode(): number;
  88253. /**
  88254. * Sets the vignette blend mode allowing different kind of effect.
  88255. */
  88256. set vignetteBlendMode(value: number);
  88257. private _vignetteEnabled;
  88258. /**
  88259. * Gets wether the vignette effect is enabled.
  88260. */
  88261. get vignetteEnabled(): boolean;
  88262. /**
  88263. * Sets wether the vignette effect is enabled.
  88264. */
  88265. set vignetteEnabled(value: boolean);
  88266. private _applyByPostProcess;
  88267. /**
  88268. * Gets wether the image processing is applied through a post process or not.
  88269. */
  88270. get applyByPostProcess(): boolean;
  88271. /**
  88272. * Sets wether the image processing is applied through a post process or not.
  88273. */
  88274. set applyByPostProcess(value: boolean);
  88275. private _isEnabled;
  88276. /**
  88277. * Gets wether the image processing is enabled or not.
  88278. */
  88279. get isEnabled(): boolean;
  88280. /**
  88281. * Sets wether the image processing is enabled or not.
  88282. */
  88283. set isEnabled(value: boolean);
  88284. /**
  88285. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  88286. */
  88287. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  88288. /**
  88289. * Method called each time the image processing information changes requires to recompile the effect.
  88290. */
  88291. protected _updateParameters(): void;
  88292. /**
  88293. * Gets the current class name.
  88294. * @return "ImageProcessingConfiguration"
  88295. */
  88296. getClassName(): string;
  88297. /**
  88298. * Prepare the list of uniforms associated with the Image Processing effects.
  88299. * @param uniforms The list of uniforms used in the effect
  88300. * @param defines the list of defines currently in use
  88301. */
  88302. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  88303. /**
  88304. * Prepare the list of samplers associated with the Image Processing effects.
  88305. * @param samplersList The list of uniforms used in the effect
  88306. * @param defines the list of defines currently in use
  88307. */
  88308. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  88309. /**
  88310. * Prepare the list of defines associated to the shader.
  88311. * @param defines the list of defines to complete
  88312. * @param forPostProcess Define if we are currently in post process mode or not
  88313. */
  88314. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  88315. /**
  88316. * Returns true if all the image processing information are ready.
  88317. * @returns True if ready, otherwise, false
  88318. */
  88319. isReady(): boolean;
  88320. /**
  88321. * Binds the image processing to the shader.
  88322. * @param effect The effect to bind to
  88323. * @param overrideAspectRatio Override the aspect ratio of the effect
  88324. */
  88325. bind(effect: Effect, overrideAspectRatio?: number): void;
  88326. /**
  88327. * Clones the current image processing instance.
  88328. * @return The cloned image processing
  88329. */
  88330. clone(): ImageProcessingConfiguration;
  88331. /**
  88332. * Serializes the current image processing instance to a json representation.
  88333. * @return a JSON representation
  88334. */
  88335. serialize(): any;
  88336. /**
  88337. * Parses the image processing from a json representation.
  88338. * @param source the JSON source to parse
  88339. * @return The parsed image processing
  88340. */
  88341. static Parse(source: any): ImageProcessingConfiguration;
  88342. private static _VIGNETTEMODE_MULTIPLY;
  88343. private static _VIGNETTEMODE_OPAQUE;
  88344. /**
  88345. * Used to apply the vignette as a mix with the pixel color.
  88346. */
  88347. static get VIGNETTEMODE_MULTIPLY(): number;
  88348. /**
  88349. * Used to apply the vignette as a replacement of the pixel color.
  88350. */
  88351. static get VIGNETTEMODE_OPAQUE(): number;
  88352. }
  88353. }
  88354. declare module BABYLON {
  88355. /** @hidden */
  88356. export var postprocessVertexShader: {
  88357. name: string;
  88358. shader: string;
  88359. };
  88360. }
  88361. declare module BABYLON {
  88362. interface ThinEngine {
  88363. /**
  88364. * Creates a new render target texture
  88365. * @param size defines the size of the texture
  88366. * @param options defines the options used to create the texture
  88367. * @returns a new render target texture stored in an InternalTexture
  88368. */
  88369. createRenderTargetTexture(size: number | {
  88370. width: number;
  88371. height: number;
  88372. layers?: number;
  88373. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  88374. /**
  88375. * Creates a depth stencil texture.
  88376. * This is only available in WebGL 2 or with the depth texture extension available.
  88377. * @param size The size of face edge in the texture.
  88378. * @param options The options defining the texture.
  88379. * @returns The texture
  88380. */
  88381. createDepthStencilTexture(size: number | {
  88382. width: number;
  88383. height: number;
  88384. layers?: number;
  88385. }, options: DepthTextureCreationOptions): InternalTexture;
  88386. /** @hidden */
  88387. _createDepthStencilTexture(size: number | {
  88388. width: number;
  88389. height: number;
  88390. layers?: number;
  88391. }, options: DepthTextureCreationOptions): InternalTexture;
  88392. }
  88393. }
  88394. declare module BABYLON {
  88395. /**
  88396. * Defines the kind of connection point for node based material
  88397. */
  88398. export enum NodeMaterialBlockConnectionPointTypes {
  88399. /** Float */
  88400. Float = 1,
  88401. /** Int */
  88402. Int = 2,
  88403. /** Vector2 */
  88404. Vector2 = 4,
  88405. /** Vector3 */
  88406. Vector3 = 8,
  88407. /** Vector4 */
  88408. Vector4 = 16,
  88409. /** Color3 */
  88410. Color3 = 32,
  88411. /** Color4 */
  88412. Color4 = 64,
  88413. /** Matrix */
  88414. Matrix = 128,
  88415. /** Custom object */
  88416. Object = 256,
  88417. /** Detect type based on connection */
  88418. AutoDetect = 1024,
  88419. /** Output type that will be defined by input type */
  88420. BasedOnInput = 2048
  88421. }
  88422. }
  88423. declare module BABYLON {
  88424. /**
  88425. * Enum used to define the target of a block
  88426. */
  88427. export enum NodeMaterialBlockTargets {
  88428. /** Vertex shader */
  88429. Vertex = 1,
  88430. /** Fragment shader */
  88431. Fragment = 2,
  88432. /** Neutral */
  88433. Neutral = 4,
  88434. /** Vertex and Fragment */
  88435. VertexAndFragment = 3
  88436. }
  88437. }
  88438. declare module BABYLON {
  88439. /**
  88440. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  88441. */
  88442. export enum NodeMaterialBlockConnectionPointMode {
  88443. /** Value is an uniform */
  88444. Uniform = 0,
  88445. /** Value is a mesh attribute */
  88446. Attribute = 1,
  88447. /** Value is a varying between vertex and fragment shaders */
  88448. Varying = 2,
  88449. /** Mode is undefined */
  88450. Undefined = 3
  88451. }
  88452. }
  88453. declare module BABYLON {
  88454. /**
  88455. * Enum used to define system values e.g. values automatically provided by the system
  88456. */
  88457. export enum NodeMaterialSystemValues {
  88458. /** World */
  88459. World = 1,
  88460. /** View */
  88461. View = 2,
  88462. /** Projection */
  88463. Projection = 3,
  88464. /** ViewProjection */
  88465. ViewProjection = 4,
  88466. /** WorldView */
  88467. WorldView = 5,
  88468. /** WorldViewProjection */
  88469. WorldViewProjection = 6,
  88470. /** CameraPosition */
  88471. CameraPosition = 7,
  88472. /** Fog Color */
  88473. FogColor = 8,
  88474. /** Delta time */
  88475. DeltaTime = 9
  88476. }
  88477. }
  88478. declare module BABYLON {
  88479. /** Defines supported spaces */
  88480. export enum Space {
  88481. /** Local (object) space */
  88482. LOCAL = 0,
  88483. /** World space */
  88484. WORLD = 1,
  88485. /** Bone space */
  88486. BONE = 2
  88487. }
  88488. /** Defines the 3 main axes */
  88489. export class Axis {
  88490. /** X axis */
  88491. static X: Vector3;
  88492. /** Y axis */
  88493. static Y: Vector3;
  88494. /** Z axis */
  88495. static Z: Vector3;
  88496. }
  88497. }
  88498. declare module BABYLON {
  88499. /**
  88500. * Represents a camera frustum
  88501. */
  88502. export class Frustum {
  88503. /**
  88504. * Gets the planes representing the frustum
  88505. * @param transform matrix to be applied to the returned planes
  88506. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  88507. */
  88508. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  88509. /**
  88510. * Gets the near frustum plane transformed by the transform matrix
  88511. * @param transform transformation matrix to be applied to the resulting frustum plane
  88512. * @param frustumPlane the resuling frustum plane
  88513. */
  88514. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88515. /**
  88516. * Gets the far frustum plane transformed by the transform matrix
  88517. * @param transform transformation matrix to be applied to the resulting frustum plane
  88518. * @param frustumPlane the resuling frustum plane
  88519. */
  88520. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88521. /**
  88522. * Gets the left frustum plane transformed by the transform matrix
  88523. * @param transform transformation matrix to be applied to the resulting frustum plane
  88524. * @param frustumPlane the resuling frustum plane
  88525. */
  88526. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88527. /**
  88528. * Gets the right frustum plane transformed by the transform matrix
  88529. * @param transform transformation matrix to be applied to the resulting frustum plane
  88530. * @param frustumPlane the resuling frustum plane
  88531. */
  88532. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88533. /**
  88534. * Gets the top frustum plane transformed by the transform matrix
  88535. * @param transform transformation matrix to be applied to the resulting frustum plane
  88536. * @param frustumPlane the resuling frustum plane
  88537. */
  88538. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88539. /**
  88540. * Gets the bottom frustum plane transformed by the transform matrix
  88541. * @param transform transformation matrix to be applied to the resulting frustum plane
  88542. * @param frustumPlane the resuling frustum plane
  88543. */
  88544. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  88545. /**
  88546. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  88547. * @param transform transformation matrix to be applied to the resulting frustum planes
  88548. * @param frustumPlanes the resuling frustum planes
  88549. */
  88550. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  88551. }
  88552. }
  88553. declare module BABYLON {
  88554. /**
  88555. * Interface for the size containing width and height
  88556. */
  88557. export interface ISize {
  88558. /**
  88559. * Width
  88560. */
  88561. width: number;
  88562. /**
  88563. * Heighht
  88564. */
  88565. height: number;
  88566. }
  88567. /**
  88568. * Size containing widht and height
  88569. */
  88570. export class Size implements ISize {
  88571. /**
  88572. * Width
  88573. */
  88574. width: number;
  88575. /**
  88576. * Height
  88577. */
  88578. height: number;
  88579. /**
  88580. * Creates a Size object from the given width and height (floats).
  88581. * @param width width of the new size
  88582. * @param height height of the new size
  88583. */
  88584. constructor(width: number, height: number);
  88585. /**
  88586. * Returns a string with the Size width and height
  88587. * @returns a string with the Size width and height
  88588. */
  88589. toString(): string;
  88590. /**
  88591. * "Size"
  88592. * @returns the string "Size"
  88593. */
  88594. getClassName(): string;
  88595. /**
  88596. * Returns the Size hash code.
  88597. * @returns a hash code for a unique width and height
  88598. */
  88599. getHashCode(): number;
  88600. /**
  88601. * Updates the current size from the given one.
  88602. * @param src the given size
  88603. */
  88604. copyFrom(src: Size): void;
  88605. /**
  88606. * Updates in place the current Size from the given floats.
  88607. * @param width width of the new size
  88608. * @param height height of the new size
  88609. * @returns the updated Size.
  88610. */
  88611. copyFromFloats(width: number, height: number): Size;
  88612. /**
  88613. * Updates in place the current Size from the given floats.
  88614. * @param width width to set
  88615. * @param height height to set
  88616. * @returns the updated Size.
  88617. */
  88618. set(width: number, height: number): Size;
  88619. /**
  88620. * Multiplies the width and height by numbers
  88621. * @param w factor to multiple the width by
  88622. * @param h factor to multiple the height by
  88623. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  88624. */
  88625. multiplyByFloats(w: number, h: number): Size;
  88626. /**
  88627. * Clones the size
  88628. * @returns a new Size copied from the given one.
  88629. */
  88630. clone(): Size;
  88631. /**
  88632. * True if the current Size and the given one width and height are strictly equal.
  88633. * @param other the other size to compare against
  88634. * @returns True if the current Size and the given one width and height are strictly equal.
  88635. */
  88636. equals(other: Size): boolean;
  88637. /**
  88638. * The surface of the Size : width * height (float).
  88639. */
  88640. get surface(): number;
  88641. /**
  88642. * Create a new size of zero
  88643. * @returns a new Size set to (0.0, 0.0)
  88644. */
  88645. static Zero(): Size;
  88646. /**
  88647. * Sums the width and height of two sizes
  88648. * @param otherSize size to add to this size
  88649. * @returns a new Size set as the addition result of the current Size and the given one.
  88650. */
  88651. add(otherSize: Size): Size;
  88652. /**
  88653. * Subtracts the width and height of two
  88654. * @param otherSize size to subtract to this size
  88655. * @returns a new Size set as the subtraction result of the given one from the current Size.
  88656. */
  88657. subtract(otherSize: Size): Size;
  88658. /**
  88659. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  88660. * @param start starting size to lerp between
  88661. * @param end end size to lerp between
  88662. * @param amount amount to lerp between the start and end values
  88663. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  88664. */
  88665. static Lerp(start: Size, end: Size, amount: number): Size;
  88666. }
  88667. }
  88668. declare module BABYLON {
  88669. /**
  88670. * Contains position and normal vectors for a vertex
  88671. */
  88672. export class PositionNormalVertex {
  88673. /** the position of the vertex (defaut: 0,0,0) */
  88674. position: Vector3;
  88675. /** the normal of the vertex (defaut: 0,1,0) */
  88676. normal: Vector3;
  88677. /**
  88678. * Creates a PositionNormalVertex
  88679. * @param position the position of the vertex (defaut: 0,0,0)
  88680. * @param normal the normal of the vertex (defaut: 0,1,0)
  88681. */
  88682. constructor(
  88683. /** the position of the vertex (defaut: 0,0,0) */
  88684. position?: Vector3,
  88685. /** the normal of the vertex (defaut: 0,1,0) */
  88686. normal?: Vector3);
  88687. /**
  88688. * Clones the PositionNormalVertex
  88689. * @returns the cloned PositionNormalVertex
  88690. */
  88691. clone(): PositionNormalVertex;
  88692. }
  88693. /**
  88694. * Contains position, normal and uv vectors for a vertex
  88695. */
  88696. export class PositionNormalTextureVertex {
  88697. /** the position of the vertex (defaut: 0,0,0) */
  88698. position: Vector3;
  88699. /** the normal of the vertex (defaut: 0,1,0) */
  88700. normal: Vector3;
  88701. /** the uv of the vertex (default: 0,0) */
  88702. uv: Vector2;
  88703. /**
  88704. * Creates a PositionNormalTextureVertex
  88705. * @param position the position of the vertex (defaut: 0,0,0)
  88706. * @param normal the normal of the vertex (defaut: 0,1,0)
  88707. * @param uv the uv of the vertex (default: 0,0)
  88708. */
  88709. constructor(
  88710. /** the position of the vertex (defaut: 0,0,0) */
  88711. position?: Vector3,
  88712. /** the normal of the vertex (defaut: 0,1,0) */
  88713. normal?: Vector3,
  88714. /** the uv of the vertex (default: 0,0) */
  88715. uv?: Vector2);
  88716. /**
  88717. * Clones the PositionNormalTextureVertex
  88718. * @returns the cloned PositionNormalTextureVertex
  88719. */
  88720. clone(): PositionNormalTextureVertex;
  88721. }
  88722. }
  88723. declare module BABYLON {
  88724. /**
  88725. * Enum defining the type of animations supported by InputBlock
  88726. */
  88727. export enum AnimatedInputBlockTypes {
  88728. /** No animation */
  88729. None = 0,
  88730. /** Time based animation. Will only work for floats */
  88731. Time = 1
  88732. }
  88733. }
  88734. declare module BABYLON {
  88735. /**
  88736. * Interface describing all the common properties and methods a shadow light needs to implement.
  88737. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  88738. * as well as binding the different shadow properties to the effects.
  88739. */
  88740. export interface IShadowLight extends Light {
  88741. /**
  88742. * The light id in the scene (used in scene.findLighById for instance)
  88743. */
  88744. id: string;
  88745. /**
  88746. * The position the shdow will be casted from.
  88747. */
  88748. position: Vector3;
  88749. /**
  88750. * In 2d mode (needCube being false), the direction used to cast the shadow.
  88751. */
  88752. direction: Vector3;
  88753. /**
  88754. * The transformed position. Position of the light in world space taking parenting in account.
  88755. */
  88756. transformedPosition: Vector3;
  88757. /**
  88758. * The transformed direction. Direction of the light in world space taking parenting in account.
  88759. */
  88760. transformedDirection: Vector3;
  88761. /**
  88762. * The friendly name of the light in the scene.
  88763. */
  88764. name: string;
  88765. /**
  88766. * Defines the shadow projection clipping minimum z value.
  88767. */
  88768. shadowMinZ: number;
  88769. /**
  88770. * Defines the shadow projection clipping maximum z value.
  88771. */
  88772. shadowMaxZ: number;
  88773. /**
  88774. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  88775. * @returns true if the information has been computed, false if it does not need to (no parenting)
  88776. */
  88777. computeTransformedInformation(): boolean;
  88778. /**
  88779. * Gets the scene the light belongs to.
  88780. * @returns The scene
  88781. */
  88782. getScene(): Scene;
  88783. /**
  88784. * Callback defining a custom Projection Matrix Builder.
  88785. * This can be used to override the default projection matrix computation.
  88786. */
  88787. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  88788. /**
  88789. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  88790. * @param matrix The materix to updated with the projection information
  88791. * @param viewMatrix The transform matrix of the light
  88792. * @param renderList The list of mesh to render in the map
  88793. * @returns The current light
  88794. */
  88795. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  88796. /**
  88797. * Gets the current depth scale used in ESM.
  88798. * @returns The scale
  88799. */
  88800. getDepthScale(): number;
  88801. /**
  88802. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  88803. * @returns true if a cube texture needs to be use
  88804. */
  88805. needCube(): boolean;
  88806. /**
  88807. * Detects if the projection matrix requires to be recomputed this frame.
  88808. * @returns true if it requires to be recomputed otherwise, false.
  88809. */
  88810. needProjectionMatrixCompute(): boolean;
  88811. /**
  88812. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  88813. */
  88814. forceProjectionMatrixCompute(): void;
  88815. /**
  88816. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  88817. * @param faceIndex The index of the face we are computed the direction to generate shadow
  88818. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  88819. */
  88820. getShadowDirection(faceIndex?: number): Vector3;
  88821. /**
  88822. * Gets the minZ used for shadow according to both the scene and the light.
  88823. * @param activeCamera The camera we are returning the min for
  88824. * @returns the depth min z
  88825. */
  88826. getDepthMinZ(activeCamera: Camera): number;
  88827. /**
  88828. * Gets the maxZ used for shadow according to both the scene and the light.
  88829. * @param activeCamera The camera we are returning the max for
  88830. * @returns the depth max z
  88831. */
  88832. getDepthMaxZ(activeCamera: Camera): number;
  88833. }
  88834. /**
  88835. * Base implementation IShadowLight
  88836. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  88837. */
  88838. export abstract class ShadowLight extends Light implements IShadowLight {
  88839. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  88840. protected _position: Vector3;
  88841. protected _setPosition(value: Vector3): void;
  88842. /**
  88843. * Sets the position the shadow will be casted from. Also use as the light position for both
  88844. * point and spot lights.
  88845. */
  88846. get position(): Vector3;
  88847. /**
  88848. * Sets the position the shadow will be casted from. Also use as the light position for both
  88849. * point and spot lights.
  88850. */
  88851. set position(value: Vector3);
  88852. protected _direction: Vector3;
  88853. protected _setDirection(value: Vector3): void;
  88854. /**
  88855. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  88856. * Also use as the light direction on spot and directional lights.
  88857. */
  88858. get direction(): Vector3;
  88859. /**
  88860. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  88861. * Also use as the light direction on spot and directional lights.
  88862. */
  88863. set direction(value: Vector3);
  88864. protected _shadowMinZ: number;
  88865. /**
  88866. * Gets the shadow projection clipping minimum z value.
  88867. */
  88868. get shadowMinZ(): number;
  88869. /**
  88870. * Sets the shadow projection clipping minimum z value.
  88871. */
  88872. set shadowMinZ(value: number);
  88873. protected _shadowMaxZ: number;
  88874. /**
  88875. * Sets the shadow projection clipping maximum z value.
  88876. */
  88877. get shadowMaxZ(): number;
  88878. /**
  88879. * Gets the shadow projection clipping maximum z value.
  88880. */
  88881. set shadowMaxZ(value: number);
  88882. /**
  88883. * Callback defining a custom Projection Matrix Builder.
  88884. * This can be used to override the default projection matrix computation.
  88885. */
  88886. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  88887. /**
  88888. * The transformed position. Position of the light in world space taking parenting in account.
  88889. */
  88890. transformedPosition: Vector3;
  88891. /**
  88892. * The transformed direction. Direction of the light in world space taking parenting in account.
  88893. */
  88894. transformedDirection: Vector3;
  88895. private _needProjectionMatrixCompute;
  88896. /**
  88897. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  88898. * @returns true if the information has been computed, false if it does not need to (no parenting)
  88899. */
  88900. computeTransformedInformation(): boolean;
  88901. /**
  88902. * Return the depth scale used for the shadow map.
  88903. * @returns the depth scale.
  88904. */
  88905. getDepthScale(): number;
  88906. /**
  88907. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  88908. * @param faceIndex The index of the face we are computed the direction to generate shadow
  88909. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  88910. */
  88911. getShadowDirection(faceIndex?: number): Vector3;
  88912. /**
  88913. * Returns the ShadowLight absolute position in the World.
  88914. * @returns the position vector in world space
  88915. */
  88916. getAbsolutePosition(): Vector3;
  88917. /**
  88918. * Sets the ShadowLight direction toward the passed target.
  88919. * @param target The point to target in local space
  88920. * @returns the updated ShadowLight direction
  88921. */
  88922. setDirectionToTarget(target: Vector3): Vector3;
  88923. /**
  88924. * Returns the light rotation in euler definition.
  88925. * @returns the x y z rotation in local space.
  88926. */
  88927. getRotation(): Vector3;
  88928. /**
  88929. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  88930. * @returns true if a cube texture needs to be use
  88931. */
  88932. needCube(): boolean;
  88933. /**
  88934. * Detects if the projection matrix requires to be recomputed this frame.
  88935. * @returns true if it requires to be recomputed otherwise, false.
  88936. */
  88937. needProjectionMatrixCompute(): boolean;
  88938. /**
  88939. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  88940. */
  88941. forceProjectionMatrixCompute(): void;
  88942. /** @hidden */
  88943. _initCache(): void;
  88944. /** @hidden */
  88945. _isSynchronized(): boolean;
  88946. /**
  88947. * Computes the world matrix of the node
  88948. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88949. * @returns the world matrix
  88950. */
  88951. computeWorldMatrix(force?: boolean): Matrix;
  88952. /**
  88953. * Gets the minZ used for shadow according to both the scene and the light.
  88954. * @param activeCamera The camera we are returning the min for
  88955. * @returns the depth min z
  88956. */
  88957. getDepthMinZ(activeCamera: Camera): number;
  88958. /**
  88959. * Gets the maxZ used for shadow according to both the scene and the light.
  88960. * @param activeCamera The camera we are returning the max for
  88961. * @returns the depth max z
  88962. */
  88963. getDepthMaxZ(activeCamera: Camera): number;
  88964. /**
  88965. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  88966. * @param matrix The materix to updated with the projection information
  88967. * @param viewMatrix The transform matrix of the light
  88968. * @param renderList The list of mesh to render in the map
  88969. * @returns The current light
  88970. */
  88971. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  88972. }
  88973. }
  88974. declare module BABYLON {
  88975. /** @hidden */
  88976. export var packingFunctions: {
  88977. name: string;
  88978. shader: string;
  88979. };
  88980. }
  88981. declare module BABYLON {
  88982. /** @hidden */
  88983. export var bayerDitherFunctions: {
  88984. name: string;
  88985. shader: string;
  88986. };
  88987. }
  88988. declare module BABYLON {
  88989. /** @hidden */
  88990. export var shadowMapFragmentDeclaration: {
  88991. name: string;
  88992. shader: string;
  88993. };
  88994. }
  88995. declare module BABYLON {
  88996. /** @hidden */
  88997. export var clipPlaneFragmentDeclaration: {
  88998. name: string;
  88999. shader: string;
  89000. };
  89001. }
  89002. declare module BABYLON {
  89003. /** @hidden */
  89004. export var clipPlaneFragment: {
  89005. name: string;
  89006. shader: string;
  89007. };
  89008. }
  89009. declare module BABYLON {
  89010. /** @hidden */
  89011. export var shadowMapFragment: {
  89012. name: string;
  89013. shader: string;
  89014. };
  89015. }
  89016. declare module BABYLON {
  89017. /** @hidden */
  89018. export var shadowMapPixelShader: {
  89019. name: string;
  89020. shader: string;
  89021. };
  89022. }
  89023. declare module BABYLON {
  89024. /** @hidden */
  89025. export var bonesDeclaration: {
  89026. name: string;
  89027. shader: string;
  89028. };
  89029. }
  89030. declare module BABYLON {
  89031. /** @hidden */
  89032. export var morphTargetsVertexGlobalDeclaration: {
  89033. name: string;
  89034. shader: string;
  89035. };
  89036. }
  89037. declare module BABYLON {
  89038. /** @hidden */
  89039. export var morphTargetsVertexDeclaration: {
  89040. name: string;
  89041. shader: string;
  89042. };
  89043. }
  89044. declare module BABYLON {
  89045. /** @hidden */
  89046. export var instancesDeclaration: {
  89047. name: string;
  89048. shader: string;
  89049. };
  89050. }
  89051. declare module BABYLON {
  89052. /** @hidden */
  89053. export var helperFunctions: {
  89054. name: string;
  89055. shader: string;
  89056. };
  89057. }
  89058. declare module BABYLON {
  89059. /** @hidden */
  89060. export var shadowMapVertexDeclaration: {
  89061. name: string;
  89062. shader: string;
  89063. };
  89064. }
  89065. declare module BABYLON {
  89066. /** @hidden */
  89067. export var clipPlaneVertexDeclaration: {
  89068. name: string;
  89069. shader: string;
  89070. };
  89071. }
  89072. declare module BABYLON {
  89073. /** @hidden */
  89074. export var morphTargetsVertex: {
  89075. name: string;
  89076. shader: string;
  89077. };
  89078. }
  89079. declare module BABYLON {
  89080. /** @hidden */
  89081. export var instancesVertex: {
  89082. name: string;
  89083. shader: string;
  89084. };
  89085. }
  89086. declare module BABYLON {
  89087. /** @hidden */
  89088. export var bonesVertex: {
  89089. name: string;
  89090. shader: string;
  89091. };
  89092. }
  89093. declare module BABYLON {
  89094. /** @hidden */
  89095. export var shadowMapVertexNormalBias: {
  89096. name: string;
  89097. shader: string;
  89098. };
  89099. }
  89100. declare module BABYLON {
  89101. /** @hidden */
  89102. export var shadowMapVertexMetric: {
  89103. name: string;
  89104. shader: string;
  89105. };
  89106. }
  89107. declare module BABYLON {
  89108. /** @hidden */
  89109. export var clipPlaneVertex: {
  89110. name: string;
  89111. shader: string;
  89112. };
  89113. }
  89114. declare module BABYLON {
  89115. /** @hidden */
  89116. export var shadowMapVertexShader: {
  89117. name: string;
  89118. shader: string;
  89119. };
  89120. }
  89121. declare module BABYLON {
  89122. /** @hidden */
  89123. export var depthBoxBlurPixelShader: {
  89124. name: string;
  89125. shader: string;
  89126. };
  89127. }
  89128. declare module BABYLON {
  89129. /** @hidden */
  89130. export var shadowMapFragmentSoftTransparentShadow: {
  89131. name: string;
  89132. shader: string;
  89133. };
  89134. }
  89135. declare module BABYLON {
  89136. /**
  89137. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  89138. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  89139. */
  89140. export class EffectFallbacks implements IEffectFallbacks {
  89141. private _defines;
  89142. private _currentRank;
  89143. private _maxRank;
  89144. private _mesh;
  89145. /**
  89146. * Removes the fallback from the bound mesh.
  89147. */
  89148. unBindMesh(): void;
  89149. /**
  89150. * Adds a fallback on the specified property.
  89151. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89152. * @param define The name of the define in the shader
  89153. */
  89154. addFallback(rank: number, define: string): void;
  89155. /**
  89156. * Sets the mesh to use CPU skinning when needing to fallback.
  89157. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89158. * @param mesh The mesh to use the fallbacks.
  89159. */
  89160. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  89161. /**
  89162. * Checks to see if more fallbacks are still availible.
  89163. */
  89164. get hasMoreFallbacks(): boolean;
  89165. /**
  89166. * Removes the defines that should be removed when falling back.
  89167. * @param currentDefines defines the current define statements for the shader.
  89168. * @param effect defines the current effect we try to compile
  89169. * @returns The resulting defines with defines of the current rank removed.
  89170. */
  89171. reduce(currentDefines: string, effect: Effect): string;
  89172. }
  89173. }
  89174. declare module BABYLON {
  89175. /**
  89176. * Interface used to define Action
  89177. */
  89178. export interface IAction {
  89179. /**
  89180. * Trigger for the action
  89181. */
  89182. trigger: number;
  89183. /** Options of the trigger */
  89184. triggerOptions: any;
  89185. /**
  89186. * Gets the trigger parameters
  89187. * @returns the trigger parameters
  89188. */
  89189. getTriggerParameter(): any;
  89190. /**
  89191. * Internal only - executes current action event
  89192. * @hidden
  89193. */
  89194. _executeCurrent(evt?: ActionEvent): void;
  89195. /**
  89196. * Serialize placeholder for child classes
  89197. * @param parent of child
  89198. * @returns the serialized object
  89199. */
  89200. serialize(parent: any): any;
  89201. /**
  89202. * Internal only
  89203. * @hidden
  89204. */
  89205. _prepare(): void;
  89206. /**
  89207. * Internal only - manager for action
  89208. * @hidden
  89209. */
  89210. _actionManager: Nullable<AbstractActionManager>;
  89211. /**
  89212. * Adds action to chain of actions, may be a DoNothingAction
  89213. * @param action defines the next action to execute
  89214. * @returns The action passed in
  89215. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89216. */
  89217. then(action: IAction): IAction;
  89218. }
  89219. /**
  89220. * The action to be carried out following a trigger
  89221. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  89222. */
  89223. export class Action implements IAction {
  89224. /** the trigger, with or without parameters, for the action */
  89225. triggerOptions: any;
  89226. /**
  89227. * Trigger for the action
  89228. */
  89229. trigger: number;
  89230. /**
  89231. * Internal only - manager for action
  89232. * @hidden
  89233. */
  89234. _actionManager: ActionManager;
  89235. private _nextActiveAction;
  89236. private _child;
  89237. private _condition?;
  89238. private _triggerParameter;
  89239. /**
  89240. * An event triggered prior to action being executed.
  89241. */
  89242. onBeforeExecuteObservable: Observable<Action>;
  89243. /**
  89244. * Creates a new Action
  89245. * @param triggerOptions the trigger, with or without parameters, for the action
  89246. * @param condition an optional determinant of action
  89247. */
  89248. constructor(
  89249. /** the trigger, with or without parameters, for the action */
  89250. triggerOptions: any, condition?: Condition);
  89251. /**
  89252. * Internal only
  89253. * @hidden
  89254. */
  89255. _prepare(): void;
  89256. /**
  89257. * Gets the trigger parameters
  89258. * @returns the trigger parameters
  89259. */
  89260. getTriggerParameter(): any;
  89261. /**
  89262. * Internal only - executes current action event
  89263. * @hidden
  89264. */
  89265. _executeCurrent(evt?: ActionEvent): void;
  89266. /**
  89267. * Execute placeholder for child classes
  89268. * @param evt optional action event
  89269. */
  89270. execute(evt?: ActionEvent): void;
  89271. /**
  89272. * Skips to next active action
  89273. */
  89274. skipToNextActiveAction(): void;
  89275. /**
  89276. * Adds action to chain of actions, may be a DoNothingAction
  89277. * @param action defines the next action to execute
  89278. * @returns The action passed in
  89279. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89280. */
  89281. then(action: Action): Action;
  89282. /**
  89283. * Internal only
  89284. * @hidden
  89285. */
  89286. _getProperty(propertyPath: string): string;
  89287. /**
  89288. * Internal only
  89289. * @hidden
  89290. */
  89291. _getEffectiveTarget(target: any, propertyPath: string): any;
  89292. /**
  89293. * Serialize placeholder for child classes
  89294. * @param parent of child
  89295. * @returns the serialized object
  89296. */
  89297. serialize(parent: any): any;
  89298. /**
  89299. * Internal only called by serialize
  89300. * @hidden
  89301. */
  89302. protected _serialize(serializedAction: any, parent?: any): any;
  89303. /**
  89304. * Internal only
  89305. * @hidden
  89306. */
  89307. static _SerializeValueAsString: (value: any) => string;
  89308. /**
  89309. * Internal only
  89310. * @hidden
  89311. */
  89312. static _GetTargetProperty: (target: Scene | Node) => {
  89313. name: string;
  89314. targetType: string;
  89315. value: string;
  89316. };
  89317. }
  89318. }
  89319. declare module BABYLON {
  89320. /**
  89321. * A Condition applied to an Action
  89322. */
  89323. export class Condition {
  89324. /**
  89325. * Internal only - manager for action
  89326. * @hidden
  89327. */
  89328. _actionManager: ActionManager;
  89329. /**
  89330. * Internal only
  89331. * @hidden
  89332. */
  89333. _evaluationId: number;
  89334. /**
  89335. * Internal only
  89336. * @hidden
  89337. */
  89338. _currentResult: boolean;
  89339. /**
  89340. * Creates a new Condition
  89341. * @param actionManager the manager of the action the condition is applied to
  89342. */
  89343. constructor(actionManager: ActionManager);
  89344. /**
  89345. * Check if the current condition is valid
  89346. * @returns a boolean
  89347. */
  89348. isValid(): boolean;
  89349. /**
  89350. * Internal only
  89351. * @hidden
  89352. */
  89353. _getProperty(propertyPath: string): string;
  89354. /**
  89355. * Internal only
  89356. * @hidden
  89357. */
  89358. _getEffectiveTarget(target: any, propertyPath: string): any;
  89359. /**
  89360. * Serialize placeholder for child classes
  89361. * @returns the serialized object
  89362. */
  89363. serialize(): any;
  89364. /**
  89365. * Internal only
  89366. * @hidden
  89367. */
  89368. protected _serialize(serializedCondition: any): any;
  89369. }
  89370. /**
  89371. * Defines specific conditional operators as extensions of Condition
  89372. */
  89373. export class ValueCondition extends Condition {
  89374. /** path to specify the property of the target the conditional operator uses */
  89375. propertyPath: string;
  89376. /** the value compared by the conditional operator against the current value of the property */
  89377. value: any;
  89378. /** the conditional operator, default ValueCondition.IsEqual */
  89379. operator: number;
  89380. /**
  89381. * Internal only
  89382. * @hidden
  89383. */
  89384. private static _IsEqual;
  89385. /**
  89386. * Internal only
  89387. * @hidden
  89388. */
  89389. private static _IsDifferent;
  89390. /**
  89391. * Internal only
  89392. * @hidden
  89393. */
  89394. private static _IsGreater;
  89395. /**
  89396. * Internal only
  89397. * @hidden
  89398. */
  89399. private static _IsLesser;
  89400. /**
  89401. * returns the number for IsEqual
  89402. */
  89403. static get IsEqual(): number;
  89404. /**
  89405. * Returns the number for IsDifferent
  89406. */
  89407. static get IsDifferent(): number;
  89408. /**
  89409. * Returns the number for IsGreater
  89410. */
  89411. static get IsGreater(): number;
  89412. /**
  89413. * Returns the number for IsLesser
  89414. */
  89415. static get IsLesser(): number;
  89416. /**
  89417. * Internal only The action manager for the condition
  89418. * @hidden
  89419. */
  89420. _actionManager: ActionManager;
  89421. /**
  89422. * Internal only
  89423. * @hidden
  89424. */
  89425. private _target;
  89426. /**
  89427. * Internal only
  89428. * @hidden
  89429. */
  89430. private _effectiveTarget;
  89431. /**
  89432. * Internal only
  89433. * @hidden
  89434. */
  89435. private _property;
  89436. /**
  89437. * Creates a new ValueCondition
  89438. * @param actionManager manager for the action the condition applies to
  89439. * @param target for the action
  89440. * @param propertyPath path to specify the property of the target the conditional operator uses
  89441. * @param value the value compared by the conditional operator against the current value of the property
  89442. * @param operator the conditional operator, default ValueCondition.IsEqual
  89443. */
  89444. constructor(actionManager: ActionManager, target: any,
  89445. /** path to specify the property of the target the conditional operator uses */
  89446. propertyPath: string,
  89447. /** the value compared by the conditional operator against the current value of the property */
  89448. value: any,
  89449. /** the conditional operator, default ValueCondition.IsEqual */
  89450. operator?: number);
  89451. /**
  89452. * Compares the given value with the property value for the specified conditional operator
  89453. * @returns the result of the comparison
  89454. */
  89455. isValid(): boolean;
  89456. /**
  89457. * Serialize the ValueCondition into a JSON compatible object
  89458. * @returns serialization object
  89459. */
  89460. serialize(): any;
  89461. /**
  89462. * Gets the name of the conditional operator for the ValueCondition
  89463. * @param operator the conditional operator
  89464. * @returns the name
  89465. */
  89466. static GetOperatorName(operator: number): string;
  89467. }
  89468. /**
  89469. * Defines a predicate condition as an extension of Condition
  89470. */
  89471. export class PredicateCondition extends Condition {
  89472. /** defines the predicate function used to validate the condition */
  89473. predicate: () => boolean;
  89474. /**
  89475. * Internal only - manager for action
  89476. * @hidden
  89477. */
  89478. _actionManager: ActionManager;
  89479. /**
  89480. * Creates a new PredicateCondition
  89481. * @param actionManager manager for the action the condition applies to
  89482. * @param predicate defines the predicate function used to validate the condition
  89483. */
  89484. constructor(actionManager: ActionManager,
  89485. /** defines the predicate function used to validate the condition */
  89486. predicate: () => boolean);
  89487. /**
  89488. * @returns the validity of the predicate condition
  89489. */
  89490. isValid(): boolean;
  89491. }
  89492. /**
  89493. * Defines a state condition as an extension of Condition
  89494. */
  89495. export class StateCondition extends Condition {
  89496. /** Value to compare with target state */
  89497. value: string;
  89498. /**
  89499. * Internal only - manager for action
  89500. * @hidden
  89501. */
  89502. _actionManager: ActionManager;
  89503. /**
  89504. * Internal only
  89505. * @hidden
  89506. */
  89507. private _target;
  89508. /**
  89509. * Creates a new StateCondition
  89510. * @param actionManager manager for the action the condition applies to
  89511. * @param target of the condition
  89512. * @param value to compare with target state
  89513. */
  89514. constructor(actionManager: ActionManager, target: any,
  89515. /** Value to compare with target state */
  89516. value: string);
  89517. /**
  89518. * Gets a boolean indicating if the current condition is met
  89519. * @returns the validity of the state
  89520. */
  89521. isValid(): boolean;
  89522. /**
  89523. * Serialize the StateCondition into a JSON compatible object
  89524. * @returns serialization object
  89525. */
  89526. serialize(): any;
  89527. }
  89528. }
  89529. declare module BABYLON {
  89530. /**
  89531. * This defines an action responsible to toggle a boolean once triggered.
  89532. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89533. */
  89534. export class SwitchBooleanAction extends Action {
  89535. /**
  89536. * The path to the boolean property in the target object
  89537. */
  89538. propertyPath: string;
  89539. private _target;
  89540. private _effectiveTarget;
  89541. private _property;
  89542. /**
  89543. * Instantiate the action
  89544. * @param triggerOptions defines the trigger options
  89545. * @param target defines the object containing the boolean
  89546. * @param propertyPath defines the path to the boolean property in the target object
  89547. * @param condition defines the trigger related conditions
  89548. */
  89549. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  89550. /** @hidden */
  89551. _prepare(): void;
  89552. /**
  89553. * Execute the action toggle the boolean value.
  89554. */
  89555. execute(): void;
  89556. /**
  89557. * Serializes the actions and its related information.
  89558. * @param parent defines the object to serialize in
  89559. * @returns the serialized object
  89560. */
  89561. serialize(parent: any): any;
  89562. }
  89563. /**
  89564. * This defines an action responsible to set a the state field of the target
  89565. * to a desired value once triggered.
  89566. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89567. */
  89568. export class SetStateAction extends Action {
  89569. /**
  89570. * The value to store in the state field.
  89571. */
  89572. value: string;
  89573. private _target;
  89574. /**
  89575. * Instantiate the action
  89576. * @param triggerOptions defines the trigger options
  89577. * @param target defines the object containing the state property
  89578. * @param value defines the value to store in the state field
  89579. * @param condition defines the trigger related conditions
  89580. */
  89581. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  89582. /**
  89583. * Execute the action and store the value on the target state property.
  89584. */
  89585. execute(): void;
  89586. /**
  89587. * Serializes the actions and its related information.
  89588. * @param parent defines the object to serialize in
  89589. * @returns the serialized object
  89590. */
  89591. serialize(parent: any): any;
  89592. }
  89593. /**
  89594. * This defines an action responsible to set a property of the target
  89595. * to a desired value once triggered.
  89596. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89597. */
  89598. export class SetValueAction extends Action {
  89599. /**
  89600. * The path of the property to set in the target.
  89601. */
  89602. propertyPath: string;
  89603. /**
  89604. * The value to set in the property
  89605. */
  89606. value: any;
  89607. private _target;
  89608. private _effectiveTarget;
  89609. private _property;
  89610. /**
  89611. * Instantiate the action
  89612. * @param triggerOptions defines the trigger options
  89613. * @param target defines the object containing the property
  89614. * @param propertyPath defines the path of the property to set in the target
  89615. * @param value defines the value to set in the property
  89616. * @param condition defines the trigger related conditions
  89617. */
  89618. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  89619. /** @hidden */
  89620. _prepare(): void;
  89621. /**
  89622. * Execute the action and set the targetted property to the desired value.
  89623. */
  89624. execute(): void;
  89625. /**
  89626. * Serializes the actions and its related information.
  89627. * @param parent defines the object to serialize in
  89628. * @returns the serialized object
  89629. */
  89630. serialize(parent: any): any;
  89631. }
  89632. /**
  89633. * This defines an action responsible to increment the target value
  89634. * to a desired value once triggered.
  89635. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89636. */
  89637. export class IncrementValueAction extends Action {
  89638. /**
  89639. * The path of the property to increment in the target.
  89640. */
  89641. propertyPath: string;
  89642. /**
  89643. * The value we should increment the property by.
  89644. */
  89645. value: any;
  89646. private _target;
  89647. private _effectiveTarget;
  89648. private _property;
  89649. /**
  89650. * Instantiate the action
  89651. * @param triggerOptions defines the trigger options
  89652. * @param target defines the object containing the property
  89653. * @param propertyPath defines the path of the property to increment in the target
  89654. * @param value defines the value value we should increment the property by
  89655. * @param condition defines the trigger related conditions
  89656. */
  89657. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  89658. /** @hidden */
  89659. _prepare(): void;
  89660. /**
  89661. * Execute the action and increment the target of the value amount.
  89662. */
  89663. execute(): void;
  89664. /**
  89665. * Serializes the actions and its related information.
  89666. * @param parent defines the object to serialize in
  89667. * @returns the serialized object
  89668. */
  89669. serialize(parent: any): any;
  89670. }
  89671. /**
  89672. * This defines an action responsible to start an animation once triggered.
  89673. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89674. */
  89675. export class PlayAnimationAction extends Action {
  89676. /**
  89677. * Where the animation should start (animation frame)
  89678. */
  89679. from: number;
  89680. /**
  89681. * Where the animation should stop (animation frame)
  89682. */
  89683. to: number;
  89684. /**
  89685. * Define if the animation should loop or stop after the first play.
  89686. */
  89687. loop?: boolean;
  89688. private _target;
  89689. /**
  89690. * Instantiate the action
  89691. * @param triggerOptions defines the trigger options
  89692. * @param target defines the target animation or animation name
  89693. * @param from defines from where the animation should start (animation frame)
  89694. * @param end defines where the animation should stop (animation frame)
  89695. * @param loop defines if the animation should loop or stop after the first play
  89696. * @param condition defines the trigger related conditions
  89697. */
  89698. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  89699. /** @hidden */
  89700. _prepare(): void;
  89701. /**
  89702. * Execute the action and play the animation.
  89703. */
  89704. execute(): void;
  89705. /**
  89706. * Serializes the actions and its related information.
  89707. * @param parent defines the object to serialize in
  89708. * @returns the serialized object
  89709. */
  89710. serialize(parent: any): any;
  89711. }
  89712. /**
  89713. * This defines an action responsible to stop an animation once triggered.
  89714. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89715. */
  89716. export class StopAnimationAction extends Action {
  89717. private _target;
  89718. /**
  89719. * Instantiate the action
  89720. * @param triggerOptions defines the trigger options
  89721. * @param target defines the target animation or animation name
  89722. * @param condition defines the trigger related conditions
  89723. */
  89724. constructor(triggerOptions: any, target: any, condition?: Condition);
  89725. /** @hidden */
  89726. _prepare(): void;
  89727. /**
  89728. * Execute the action and stop the animation.
  89729. */
  89730. execute(): void;
  89731. /**
  89732. * Serializes the actions and its related information.
  89733. * @param parent defines the object to serialize in
  89734. * @returns the serialized object
  89735. */
  89736. serialize(parent: any): any;
  89737. }
  89738. /**
  89739. * This defines an action responsible that does nothing once triggered.
  89740. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89741. */
  89742. export class DoNothingAction extends Action {
  89743. /**
  89744. * Instantiate the action
  89745. * @param triggerOptions defines the trigger options
  89746. * @param condition defines the trigger related conditions
  89747. */
  89748. constructor(triggerOptions?: any, condition?: Condition);
  89749. /**
  89750. * Execute the action and do nothing.
  89751. */
  89752. execute(): void;
  89753. /**
  89754. * Serializes the actions and its related information.
  89755. * @param parent defines the object to serialize in
  89756. * @returns the serialized object
  89757. */
  89758. serialize(parent: any): any;
  89759. }
  89760. /**
  89761. * This defines an action responsible to trigger several actions once triggered.
  89762. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89763. */
  89764. export class CombineAction extends Action {
  89765. /**
  89766. * The list of aggregated animations to run.
  89767. */
  89768. children: Action[];
  89769. /**
  89770. * Instantiate the action
  89771. * @param triggerOptions defines the trigger options
  89772. * @param children defines the list of aggregated animations to run
  89773. * @param condition defines the trigger related conditions
  89774. */
  89775. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  89776. /** @hidden */
  89777. _prepare(): void;
  89778. /**
  89779. * Execute the action and executes all the aggregated actions.
  89780. */
  89781. execute(evt: ActionEvent): void;
  89782. /**
  89783. * Serializes the actions and its related information.
  89784. * @param parent defines the object to serialize in
  89785. * @returns the serialized object
  89786. */
  89787. serialize(parent: any): any;
  89788. }
  89789. /**
  89790. * This defines an action responsible to run code (external event) once triggered.
  89791. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89792. */
  89793. export class ExecuteCodeAction extends Action {
  89794. /**
  89795. * The callback function to run.
  89796. */
  89797. func: (evt: ActionEvent) => void;
  89798. /**
  89799. * Instantiate the action
  89800. * @param triggerOptions defines the trigger options
  89801. * @param func defines the callback function to run
  89802. * @param condition defines the trigger related conditions
  89803. */
  89804. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  89805. /**
  89806. * Execute the action and run the attached code.
  89807. */
  89808. execute(evt: ActionEvent): void;
  89809. }
  89810. /**
  89811. * This defines an action responsible to set the parent property of the target once triggered.
  89812. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89813. */
  89814. export class SetParentAction extends Action {
  89815. private _parent;
  89816. private _target;
  89817. /**
  89818. * Instantiate the action
  89819. * @param triggerOptions defines the trigger options
  89820. * @param target defines the target containing the parent property
  89821. * @param parent defines from where the animation should start (animation frame)
  89822. * @param condition defines the trigger related conditions
  89823. */
  89824. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  89825. /** @hidden */
  89826. _prepare(): void;
  89827. /**
  89828. * Execute the action and set the parent property.
  89829. */
  89830. execute(): void;
  89831. /**
  89832. * Serializes the actions and its related information.
  89833. * @param parent defines the object to serialize in
  89834. * @returns the serialized object
  89835. */
  89836. serialize(parent: any): any;
  89837. }
  89838. }
  89839. declare module BABYLON {
  89840. /**
  89841. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  89842. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  89843. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  89844. */
  89845. export class ActionManager extends AbstractActionManager {
  89846. /**
  89847. * Nothing
  89848. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89849. */
  89850. static readonly NothingTrigger: number;
  89851. /**
  89852. * On pick
  89853. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89854. */
  89855. static readonly OnPickTrigger: number;
  89856. /**
  89857. * On left pick
  89858. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89859. */
  89860. static readonly OnLeftPickTrigger: number;
  89861. /**
  89862. * On right pick
  89863. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89864. */
  89865. static readonly OnRightPickTrigger: number;
  89866. /**
  89867. * On center pick
  89868. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89869. */
  89870. static readonly OnCenterPickTrigger: number;
  89871. /**
  89872. * On pick down
  89873. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89874. */
  89875. static readonly OnPickDownTrigger: number;
  89876. /**
  89877. * On double pick
  89878. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89879. */
  89880. static readonly OnDoublePickTrigger: number;
  89881. /**
  89882. * On pick up
  89883. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89884. */
  89885. static readonly OnPickUpTrigger: number;
  89886. /**
  89887. * On pick out.
  89888. * This trigger will only be raised if you also declared a OnPickDown
  89889. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89890. */
  89891. static readonly OnPickOutTrigger: number;
  89892. /**
  89893. * On long press
  89894. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89895. */
  89896. static readonly OnLongPressTrigger: number;
  89897. /**
  89898. * On pointer over
  89899. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89900. */
  89901. static readonly OnPointerOverTrigger: number;
  89902. /**
  89903. * On pointer out
  89904. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89905. */
  89906. static readonly OnPointerOutTrigger: number;
  89907. /**
  89908. * On every frame
  89909. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89910. */
  89911. static readonly OnEveryFrameTrigger: number;
  89912. /**
  89913. * On intersection enter
  89914. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89915. */
  89916. static readonly OnIntersectionEnterTrigger: number;
  89917. /**
  89918. * On intersection exit
  89919. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89920. */
  89921. static readonly OnIntersectionExitTrigger: number;
  89922. /**
  89923. * On key down
  89924. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89925. */
  89926. static readonly OnKeyDownTrigger: number;
  89927. /**
  89928. * On key up
  89929. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  89930. */
  89931. static readonly OnKeyUpTrigger: number;
  89932. private _scene;
  89933. /**
  89934. * Creates a new action manager
  89935. * @param scene defines the hosting scene
  89936. */
  89937. constructor(scene: Scene);
  89938. /**
  89939. * Releases all associated resources
  89940. */
  89941. dispose(): void;
  89942. /**
  89943. * Gets hosting scene
  89944. * @returns the hosting scene
  89945. */
  89946. getScene(): Scene;
  89947. /**
  89948. * Does this action manager handles actions of any of the given triggers
  89949. * @param triggers defines the triggers to be tested
  89950. * @return a boolean indicating whether one (or more) of the triggers is handled
  89951. */
  89952. hasSpecificTriggers(triggers: number[]): boolean;
  89953. /**
  89954. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  89955. * speed.
  89956. * @param triggerA defines the trigger to be tested
  89957. * @param triggerB defines the trigger to be tested
  89958. * @return a boolean indicating whether one (or more) of the triggers is handled
  89959. */
  89960. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  89961. /**
  89962. * Does this action manager handles actions of a given trigger
  89963. * @param trigger defines the trigger to be tested
  89964. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  89965. * @return whether the trigger is handled
  89966. */
  89967. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  89968. /**
  89969. * Does this action manager has pointer triggers
  89970. */
  89971. get hasPointerTriggers(): boolean;
  89972. /**
  89973. * Does this action manager has pick triggers
  89974. */
  89975. get hasPickTriggers(): boolean;
  89976. /**
  89977. * Registers an action to this action manager
  89978. * @param action defines the action to be registered
  89979. * @return the action amended (prepared) after registration
  89980. */
  89981. registerAction(action: IAction): Nullable<IAction>;
  89982. /**
  89983. * Unregisters an action to this action manager
  89984. * @param action defines the action to be unregistered
  89985. * @return a boolean indicating whether the action has been unregistered
  89986. */
  89987. unregisterAction(action: IAction): Boolean;
  89988. /**
  89989. * Process a specific trigger
  89990. * @param trigger defines the trigger to process
  89991. * @param evt defines the event details to be processed
  89992. */
  89993. processTrigger(trigger: number, evt?: IActionEvent): void;
  89994. /** @hidden */
  89995. _getEffectiveTarget(target: any, propertyPath: string): any;
  89996. /** @hidden */
  89997. _getProperty(propertyPath: string): string;
  89998. /**
  89999. * Serialize this manager to a JSON object
  90000. * @param name defines the property name to store this manager
  90001. * @returns a JSON representation of this manager
  90002. */
  90003. serialize(name: string): any;
  90004. /**
  90005. * Creates a new ActionManager from a JSON data
  90006. * @param parsedActions defines the JSON data to read from
  90007. * @param object defines the hosting mesh
  90008. * @param scene defines the hosting scene
  90009. */
  90010. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  90011. /**
  90012. * Get a trigger name by index
  90013. * @param trigger defines the trigger index
  90014. * @returns a trigger name
  90015. */
  90016. static GetTriggerName(trigger: number): string;
  90017. }
  90018. }
  90019. declare module BABYLON {
  90020. /**
  90021. * Class used to represent a sprite
  90022. * @see https://doc.babylonjs.com/babylon101/sprites
  90023. */
  90024. export class Sprite implements IAnimatable {
  90025. /** defines the name */
  90026. name: string;
  90027. /** Gets or sets the current world position */
  90028. position: Vector3;
  90029. /** Gets or sets the main color */
  90030. color: Color4;
  90031. /** Gets or sets the width */
  90032. width: number;
  90033. /** Gets or sets the height */
  90034. height: number;
  90035. /** Gets or sets rotation angle */
  90036. angle: number;
  90037. /** Gets or sets the cell index in the sprite sheet */
  90038. cellIndex: number;
  90039. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  90040. cellRef: string;
  90041. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  90042. invertU: boolean;
  90043. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  90044. invertV: boolean;
  90045. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  90046. disposeWhenFinishedAnimating: boolean;
  90047. /** Gets the list of attached animations */
  90048. animations: Nullable<Array<Animation>>;
  90049. /** Gets or sets a boolean indicating if the sprite can be picked */
  90050. isPickable: boolean;
  90051. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  90052. useAlphaForPicking: boolean;
  90053. /** @hidden */
  90054. _xOffset: number;
  90055. /** @hidden */
  90056. _yOffset: number;
  90057. /** @hidden */
  90058. _xSize: number;
  90059. /** @hidden */
  90060. _ySize: number;
  90061. /**
  90062. * Gets or sets the associated action manager
  90063. */
  90064. actionManager: Nullable<ActionManager>;
  90065. /**
  90066. * An event triggered when the control has been disposed
  90067. */
  90068. onDisposeObservable: Observable<Sprite>;
  90069. private _animationStarted;
  90070. private _loopAnimation;
  90071. private _fromIndex;
  90072. private _toIndex;
  90073. private _delay;
  90074. private _direction;
  90075. private _manager;
  90076. private _time;
  90077. private _onAnimationEnd;
  90078. /**
  90079. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  90080. */
  90081. isVisible: boolean;
  90082. /**
  90083. * Gets or sets the sprite size
  90084. */
  90085. get size(): number;
  90086. set size(value: number);
  90087. /**
  90088. * Returns a boolean indicating if the animation is started
  90089. */
  90090. get animationStarted(): boolean;
  90091. /**
  90092. * Gets or sets the unique id of the sprite
  90093. */
  90094. uniqueId: number;
  90095. /**
  90096. * Gets the manager of this sprite
  90097. */
  90098. get manager(): ISpriteManager;
  90099. /**
  90100. * Creates a new Sprite
  90101. * @param name defines the name
  90102. * @param manager defines the manager
  90103. */
  90104. constructor(
  90105. /** defines the name */
  90106. name: string, manager: ISpriteManager);
  90107. /**
  90108. * Returns the string "Sprite"
  90109. * @returns "Sprite"
  90110. */
  90111. getClassName(): string;
  90112. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  90113. get fromIndex(): number;
  90114. set fromIndex(value: number);
  90115. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  90116. get toIndex(): number;
  90117. set toIndex(value: number);
  90118. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  90119. get loopAnimation(): boolean;
  90120. set loopAnimation(value: boolean);
  90121. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  90122. get delay(): number;
  90123. set delay(value: number);
  90124. /**
  90125. * Starts an animation
  90126. * @param from defines the initial key
  90127. * @param to defines the end key
  90128. * @param loop defines if the animation must loop
  90129. * @param delay defines the start delay (in ms)
  90130. * @param onAnimationEnd defines a callback to call when animation ends
  90131. */
  90132. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  90133. /** Stops current animation (if any) */
  90134. stopAnimation(): void;
  90135. /** @hidden */
  90136. _animate(deltaTime: number): void;
  90137. /** Release associated resources */
  90138. dispose(): void;
  90139. /**
  90140. * Serializes the sprite to a JSON object
  90141. * @returns the JSON object
  90142. */
  90143. serialize(): any;
  90144. /**
  90145. * Parses a JSON object to create a new sprite
  90146. * @param parsedSprite The JSON object to parse
  90147. * @param manager defines the hosting manager
  90148. * @returns the new sprite
  90149. */
  90150. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  90151. }
  90152. }
  90153. declare module BABYLON {
  90154. /**
  90155. * Information about the result of picking within a scene
  90156. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  90157. */
  90158. export class PickingInfo {
  90159. /** @hidden */
  90160. _pickingUnavailable: boolean;
  90161. /**
  90162. * If the pick collided with an object
  90163. */
  90164. hit: boolean;
  90165. /**
  90166. * Distance away where the pick collided
  90167. */
  90168. distance: number;
  90169. /**
  90170. * The location of pick collision
  90171. */
  90172. pickedPoint: Nullable<Vector3>;
  90173. /**
  90174. * The mesh corresponding the the pick collision
  90175. */
  90176. pickedMesh: Nullable<AbstractMesh>;
  90177. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  90178. bu: number;
  90179. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  90180. bv: number;
  90181. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90182. faceId: number;
  90183. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90184. subMeshFaceId: number;
  90185. /** Id of the the submesh that was picked */
  90186. subMeshId: number;
  90187. /** If a sprite was picked, this will be the sprite the pick collided with */
  90188. pickedSprite: Nullable<Sprite>;
  90189. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  90190. thinInstanceIndex: number;
  90191. /**
  90192. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  90193. */
  90194. originMesh: Nullable<AbstractMesh>;
  90195. /**
  90196. * The ray that was used to perform the picking.
  90197. */
  90198. ray: Nullable<Ray>;
  90199. /**
  90200. * Gets the normal correspodning to the face the pick collided with
  90201. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  90202. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  90203. * @returns The normal correspodning to the face the pick collided with
  90204. */
  90205. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  90206. /**
  90207. * Gets the texture coordinates of where the pick occured
  90208. * @returns the vector containing the coordnates of the texture
  90209. */
  90210. getTextureCoordinates(): Nullable<Vector2>;
  90211. }
  90212. }
  90213. declare module BABYLON {
  90214. /**
  90215. * Class representing a ray with position and direction
  90216. */
  90217. export class Ray {
  90218. /** origin point */
  90219. origin: Vector3;
  90220. /** direction */
  90221. direction: Vector3;
  90222. /** length of the ray */
  90223. length: number;
  90224. private static readonly _TmpVector3;
  90225. private _tmpRay;
  90226. /**
  90227. * Creates a new ray
  90228. * @param origin origin point
  90229. * @param direction direction
  90230. * @param length length of the ray
  90231. */
  90232. constructor(
  90233. /** origin point */
  90234. origin: Vector3,
  90235. /** direction */
  90236. direction: Vector3,
  90237. /** length of the ray */
  90238. length?: number);
  90239. /**
  90240. * Checks if the ray intersects a box
  90241. * This does not account for the ray lenght by design to improve perfs.
  90242. * @param minimum bound of the box
  90243. * @param maximum bound of the box
  90244. * @param intersectionTreshold extra extend to be added to the box in all direction
  90245. * @returns if the box was hit
  90246. */
  90247. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  90248. /**
  90249. * Checks if the ray intersects a box
  90250. * This does not account for the ray lenght by design to improve perfs.
  90251. * @param box the bounding box to check
  90252. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  90253. * @returns if the box was hit
  90254. */
  90255. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  90256. /**
  90257. * If the ray hits a sphere
  90258. * @param sphere the bounding sphere to check
  90259. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  90260. * @returns true if it hits the sphere
  90261. */
  90262. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  90263. /**
  90264. * If the ray hits a triange
  90265. * @param vertex0 triangle vertex
  90266. * @param vertex1 triangle vertex
  90267. * @param vertex2 triangle vertex
  90268. * @returns intersection information if hit
  90269. */
  90270. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  90271. /**
  90272. * Checks if ray intersects a plane
  90273. * @param plane the plane to check
  90274. * @returns the distance away it was hit
  90275. */
  90276. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  90277. /**
  90278. * Calculate the intercept of a ray on a given axis
  90279. * @param axis to check 'x' | 'y' | 'z'
  90280. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  90281. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  90282. */
  90283. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  90284. /**
  90285. * Checks if ray intersects a mesh
  90286. * @param mesh the mesh to check
  90287. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90288. * @returns picking info of the intersecton
  90289. */
  90290. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  90291. /**
  90292. * Checks if ray intersects a mesh
  90293. * @param meshes the meshes to check
  90294. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90295. * @param results array to store result in
  90296. * @returns Array of picking infos
  90297. */
  90298. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  90299. private _comparePickingInfo;
  90300. private static smallnum;
  90301. private static rayl;
  90302. /**
  90303. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  90304. * @param sega the first point of the segment to test the intersection against
  90305. * @param segb the second point of the segment to test the intersection against
  90306. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  90307. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  90308. */
  90309. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  90310. /**
  90311. * Update the ray from viewport position
  90312. * @param x position
  90313. * @param y y position
  90314. * @param viewportWidth viewport width
  90315. * @param viewportHeight viewport height
  90316. * @param world world matrix
  90317. * @param view view matrix
  90318. * @param projection projection matrix
  90319. * @returns this ray updated
  90320. */
  90321. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  90322. /**
  90323. * Creates a ray with origin and direction of 0,0,0
  90324. * @returns the new ray
  90325. */
  90326. static Zero(): Ray;
  90327. /**
  90328. * Creates a new ray from screen space and viewport
  90329. * @param x position
  90330. * @param y y position
  90331. * @param viewportWidth viewport width
  90332. * @param viewportHeight viewport height
  90333. * @param world world matrix
  90334. * @param view view matrix
  90335. * @param projection projection matrix
  90336. * @returns new ray
  90337. */
  90338. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  90339. /**
  90340. * 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
  90341. * transformed to the given world matrix.
  90342. * @param origin The origin point
  90343. * @param end The end point
  90344. * @param world a matrix to transform the ray to. Default is the identity matrix.
  90345. * @returns the new ray
  90346. */
  90347. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  90348. /**
  90349. * Transforms a ray by a matrix
  90350. * @param ray ray to transform
  90351. * @param matrix matrix to apply
  90352. * @returns the resulting new ray
  90353. */
  90354. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  90355. /**
  90356. * Transforms a ray by a matrix
  90357. * @param ray ray to transform
  90358. * @param matrix matrix to apply
  90359. * @param result ray to store result in
  90360. */
  90361. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  90362. /**
  90363. * Unproject a ray from screen space to object space
  90364. * @param sourceX defines the screen space x coordinate to use
  90365. * @param sourceY defines the screen space y coordinate to use
  90366. * @param viewportWidth defines the current width of the viewport
  90367. * @param viewportHeight defines the current height of the viewport
  90368. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  90369. * @param view defines the view matrix to use
  90370. * @param projection defines the projection matrix to use
  90371. */
  90372. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  90373. }
  90374. /**
  90375. * Type used to define predicate used to select faces when a mesh intersection is detected
  90376. */
  90377. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  90378. interface Scene {
  90379. /** @hidden */
  90380. _tempPickingRay: Nullable<Ray>;
  90381. /** @hidden */
  90382. _cachedRayForTransform: Ray;
  90383. /** @hidden */
  90384. _pickWithRayInverseMatrix: Matrix;
  90385. /** @hidden */
  90386. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90387. /** @hidden */
  90388. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90389. /** @hidden */
  90390. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90391. }
  90392. }
  90393. declare module BABYLON {
  90394. /**
  90395. * Groups all the scene component constants in one place to ease maintenance.
  90396. * @hidden
  90397. */
  90398. export class SceneComponentConstants {
  90399. static readonly NAME_EFFECTLAYER: string;
  90400. static readonly NAME_LAYER: string;
  90401. static readonly NAME_LENSFLARESYSTEM: string;
  90402. static readonly NAME_BOUNDINGBOXRENDERER: string;
  90403. static readonly NAME_PARTICLESYSTEM: string;
  90404. static readonly NAME_GAMEPAD: string;
  90405. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  90406. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  90407. static readonly NAME_PREPASSRENDERER: string;
  90408. static readonly NAME_DEPTHRENDERER: string;
  90409. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  90410. static readonly NAME_SPRITE: string;
  90411. static readonly NAME_OUTLINERENDERER: string;
  90412. static readonly NAME_PROCEDURALTEXTURE: string;
  90413. static readonly NAME_SHADOWGENERATOR: string;
  90414. static readonly NAME_OCTREE: string;
  90415. static readonly NAME_PHYSICSENGINE: string;
  90416. static readonly NAME_AUDIO: string;
  90417. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  90418. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  90419. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  90420. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  90421. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  90422. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  90423. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  90424. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  90425. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  90426. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  90427. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  90428. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  90429. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  90430. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  90431. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  90432. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  90433. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  90434. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  90435. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  90436. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  90437. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  90438. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  90439. static readonly STEP_AFTERRENDER_AUDIO: number;
  90440. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  90441. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  90442. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  90443. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  90444. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  90445. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  90446. static readonly STEP_POINTERMOVE_SPRITE: number;
  90447. static readonly STEP_POINTERDOWN_SPRITE: number;
  90448. static readonly STEP_POINTERUP_SPRITE: number;
  90449. }
  90450. /**
  90451. * This represents a scene component.
  90452. *
  90453. * This is used to decouple the dependency the scene is having on the different workloads like
  90454. * layers, post processes...
  90455. */
  90456. export interface ISceneComponent {
  90457. /**
  90458. * The name of the component. Each component must have a unique name.
  90459. */
  90460. name: string;
  90461. /**
  90462. * The scene the component belongs to.
  90463. */
  90464. scene: Scene;
  90465. /**
  90466. * Register the component to one instance of a scene.
  90467. */
  90468. register(): void;
  90469. /**
  90470. * Rebuilds the elements related to this component in case of
  90471. * context lost for instance.
  90472. */
  90473. rebuild(): void;
  90474. /**
  90475. * Disposes the component and the associated ressources.
  90476. */
  90477. dispose(): void;
  90478. }
  90479. /**
  90480. * This represents a SERIALIZABLE scene component.
  90481. *
  90482. * This extends Scene Component to add Serialization methods on top.
  90483. */
  90484. export interface ISceneSerializableComponent extends ISceneComponent {
  90485. /**
  90486. * Adds all the elements from the container to the scene
  90487. * @param container the container holding the elements
  90488. */
  90489. addFromContainer(container: AbstractScene): void;
  90490. /**
  90491. * Removes all the elements in the container from the scene
  90492. * @param container contains the elements to remove
  90493. * @param dispose if the removed element should be disposed (default: false)
  90494. */
  90495. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  90496. /**
  90497. * Serializes the component data to the specified json object
  90498. * @param serializationObject The object to serialize to
  90499. */
  90500. serialize(serializationObject: any): void;
  90501. }
  90502. /**
  90503. * Strong typing of a Mesh related stage step action
  90504. */
  90505. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  90506. /**
  90507. * Strong typing of a Evaluate Sub Mesh related stage step action
  90508. */
  90509. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  90510. /**
  90511. * Strong typing of a Active Mesh related stage step action
  90512. */
  90513. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  90514. /**
  90515. * Strong typing of a Camera related stage step action
  90516. */
  90517. export type CameraStageAction = (camera: Camera) => void;
  90518. /**
  90519. * Strong typing of a Camera Frame buffer related stage step action
  90520. */
  90521. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  90522. /**
  90523. * Strong typing of a Render Target related stage step action
  90524. */
  90525. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  90526. /**
  90527. * Strong typing of a RenderingGroup related stage step action
  90528. */
  90529. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  90530. /**
  90531. * Strong typing of a Mesh Render related stage step action
  90532. */
  90533. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  90534. /**
  90535. * Strong typing of a simple stage step action
  90536. */
  90537. export type SimpleStageAction = () => void;
  90538. /**
  90539. * Strong typing of a render target action.
  90540. */
  90541. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  90542. /**
  90543. * Strong typing of a pointer move action.
  90544. */
  90545. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  90546. /**
  90547. * Strong typing of a pointer up/down action.
  90548. */
  90549. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  90550. /**
  90551. * Representation of a stage in the scene (Basically a list of ordered steps)
  90552. * @hidden
  90553. */
  90554. export class Stage<T extends Function> extends Array<{
  90555. index: number;
  90556. component: ISceneComponent;
  90557. action: T;
  90558. }> {
  90559. /**
  90560. * Hide ctor from the rest of the world.
  90561. * @param items The items to add.
  90562. */
  90563. private constructor();
  90564. /**
  90565. * Creates a new Stage.
  90566. * @returns A new instance of a Stage
  90567. */
  90568. static Create<T extends Function>(): Stage<T>;
  90569. /**
  90570. * Registers a step in an ordered way in the targeted stage.
  90571. * @param index Defines the position to register the step in
  90572. * @param component Defines the component attached to the step
  90573. * @param action Defines the action to launch during the step
  90574. */
  90575. registerStep(index: number, component: ISceneComponent, action: T): void;
  90576. /**
  90577. * Clears all the steps from the stage.
  90578. */
  90579. clear(): void;
  90580. }
  90581. }
  90582. declare module BABYLON {
  90583. interface Scene {
  90584. /** @hidden */
  90585. _pointerOverSprite: Nullable<Sprite>;
  90586. /** @hidden */
  90587. _pickedDownSprite: Nullable<Sprite>;
  90588. /** @hidden */
  90589. _tempSpritePickingRay: Nullable<Ray>;
  90590. /**
  90591. * All of the sprite managers added to this scene
  90592. * @see https://doc.babylonjs.com/babylon101/sprites
  90593. */
  90594. spriteManagers: Array<ISpriteManager>;
  90595. /**
  90596. * An event triggered when sprites rendering is about to start
  90597. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  90598. */
  90599. onBeforeSpritesRenderingObservable: Observable<Scene>;
  90600. /**
  90601. * An event triggered when sprites rendering is done
  90602. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  90603. */
  90604. onAfterSpritesRenderingObservable: Observable<Scene>;
  90605. /** @hidden */
  90606. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  90607. /** Launch a ray to try to pick a sprite in the scene
  90608. * @param x position on screen
  90609. * @param y position on screen
  90610. * @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
  90611. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90612. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90613. * @returns a PickingInfo
  90614. */
  90615. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  90616. /** Use the given ray to pick a sprite in the scene
  90617. * @param ray The ray (in world space) to use to pick meshes
  90618. * @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
  90619. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90620. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  90621. * @returns a PickingInfo
  90622. */
  90623. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  90624. /** @hidden */
  90625. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  90626. /** Launch a ray to try to pick sprites in the scene
  90627. * @param x position on screen
  90628. * @param y position on screen
  90629. * @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
  90630. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  90631. * @returns a PickingInfo array
  90632. */
  90633. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  90634. /** Use the given ray to pick sprites in the scene
  90635. * @param ray The ray (in world space) to use to pick meshes
  90636. * @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
  90637. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  90638. * @returns a PickingInfo array
  90639. */
  90640. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  90641. /**
  90642. * Force the sprite under the pointer
  90643. * @param sprite defines the sprite to use
  90644. */
  90645. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  90646. /**
  90647. * Gets the sprite under the pointer
  90648. * @returns a Sprite or null if no sprite is under the pointer
  90649. */
  90650. getPointerOverSprite(): Nullable<Sprite>;
  90651. }
  90652. /**
  90653. * Defines the sprite scene component responsible to manage sprites
  90654. * in a given scene.
  90655. */
  90656. export class SpriteSceneComponent implements ISceneComponent {
  90657. /**
  90658. * The component name helpfull to identify the component in the list of scene components.
  90659. */
  90660. readonly name: string;
  90661. /**
  90662. * The scene the component belongs to.
  90663. */
  90664. scene: Scene;
  90665. /** @hidden */
  90666. private _spritePredicate;
  90667. /**
  90668. * Creates a new instance of the component for the given scene
  90669. * @param scene Defines the scene to register the component in
  90670. */
  90671. constructor(scene: Scene);
  90672. /**
  90673. * Registers the component in a given scene
  90674. */
  90675. register(): void;
  90676. /**
  90677. * Rebuilds the elements related to this component in case of
  90678. * context lost for instance.
  90679. */
  90680. rebuild(): void;
  90681. /**
  90682. * Disposes the component and the associated ressources.
  90683. */
  90684. dispose(): void;
  90685. private _pickSpriteButKeepRay;
  90686. private _pointerMove;
  90687. private _pointerDown;
  90688. private _pointerUp;
  90689. }
  90690. }
  90691. declare module BABYLON {
  90692. /** @hidden */
  90693. export var fogFragmentDeclaration: {
  90694. name: string;
  90695. shader: string;
  90696. };
  90697. }
  90698. declare module BABYLON {
  90699. /** @hidden */
  90700. export var fogFragment: {
  90701. name: string;
  90702. shader: string;
  90703. };
  90704. }
  90705. declare module BABYLON {
  90706. /** @hidden */
  90707. export var spritesPixelShader: {
  90708. name: string;
  90709. shader: string;
  90710. };
  90711. }
  90712. declare module BABYLON {
  90713. /** @hidden */
  90714. export var fogVertexDeclaration: {
  90715. name: string;
  90716. shader: string;
  90717. };
  90718. }
  90719. declare module BABYLON {
  90720. /** @hidden */
  90721. export var spritesVertexShader: {
  90722. name: string;
  90723. shader: string;
  90724. };
  90725. }
  90726. declare module BABYLON {
  90727. /**
  90728. * Defines the minimum interface to fullfil in order to be a sprite manager.
  90729. */
  90730. export interface ISpriteManager extends IDisposable {
  90731. /**
  90732. * Gets manager's name
  90733. */
  90734. name: string;
  90735. /**
  90736. * Restricts the camera to viewing objects with the same layerMask.
  90737. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  90738. */
  90739. layerMask: number;
  90740. /**
  90741. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  90742. */
  90743. isPickable: boolean;
  90744. /**
  90745. * Gets the hosting scene
  90746. */
  90747. scene: Scene;
  90748. /**
  90749. * Specifies the rendering group id for this mesh (0 by default)
  90750. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  90751. */
  90752. renderingGroupId: number;
  90753. /**
  90754. * Defines the list of sprites managed by the manager.
  90755. */
  90756. sprites: Array<Sprite>;
  90757. /**
  90758. * Gets or sets the spritesheet texture
  90759. */
  90760. texture: Texture;
  90761. /** Defines the default width of a cell in the spritesheet */
  90762. cellWidth: number;
  90763. /** Defines the default height of a cell in the spritesheet */
  90764. cellHeight: number;
  90765. /**
  90766. * Tests the intersection of a sprite with a specific ray.
  90767. * @param ray The ray we are sending to test the collision
  90768. * @param camera The camera space we are sending rays in
  90769. * @param predicate A predicate allowing excluding sprites from the list of object to test
  90770. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90771. * @returns picking info or null.
  90772. */
  90773. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  90774. /**
  90775. * Intersects the sprites with a ray
  90776. * @param ray defines the ray to intersect with
  90777. * @param camera defines the current active camera
  90778. * @param predicate defines a predicate used to select candidate sprites
  90779. * @returns null if no hit or a PickingInfo array
  90780. */
  90781. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  90782. /**
  90783. * Renders the list of sprites on screen.
  90784. */
  90785. render(): void;
  90786. }
  90787. /**
  90788. * Class used to manage multiple sprites on the same spritesheet
  90789. * @see https://doc.babylonjs.com/babylon101/sprites
  90790. */
  90791. export class SpriteManager implements ISpriteManager {
  90792. /** defines the manager's name */
  90793. name: string;
  90794. /** Define the Url to load snippets */
  90795. static SnippetUrl: string;
  90796. /** Snippet ID if the manager was created from the snippet server */
  90797. snippetId: string;
  90798. /** Gets the list of sprites */
  90799. sprites: Sprite[];
  90800. /** Gets or sets the rendering group id (0 by default) */
  90801. renderingGroupId: number;
  90802. /** Gets or sets camera layer mask */
  90803. layerMask: number;
  90804. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  90805. fogEnabled: boolean;
  90806. /** Gets or sets a boolean indicating if the sprites are pickable */
  90807. isPickable: boolean;
  90808. /** Defines the default width of a cell in the spritesheet */
  90809. cellWidth: number;
  90810. /** Defines the default height of a cell in the spritesheet */
  90811. cellHeight: number;
  90812. /** Associative array from JSON sprite data file */
  90813. private _cellData;
  90814. /** Array of sprite names from JSON sprite data file */
  90815. private _spriteMap;
  90816. /** True when packed cell data from JSON file is ready*/
  90817. private _packedAndReady;
  90818. private _textureContent;
  90819. private _useInstancing;
  90820. /**
  90821. * An event triggered when the manager is disposed.
  90822. */
  90823. onDisposeObservable: Observable<SpriteManager>;
  90824. private _onDisposeObserver;
  90825. /**
  90826. * Callback called when the manager is disposed
  90827. */
  90828. set onDispose(callback: () => void);
  90829. private _capacity;
  90830. private _fromPacked;
  90831. private _spriteTexture;
  90832. private _epsilon;
  90833. private _scene;
  90834. private _vertexData;
  90835. private _buffer;
  90836. private _vertexBuffers;
  90837. private _spriteBuffer;
  90838. private _indexBuffer;
  90839. private _effectBase;
  90840. private _effectFog;
  90841. private _vertexBufferSize;
  90842. /**
  90843. * Gets or sets the unique id of the sprite
  90844. */
  90845. uniqueId: number;
  90846. /**
  90847. * Gets the array of sprites
  90848. */
  90849. get children(): Sprite[];
  90850. /**
  90851. * Gets the hosting scene
  90852. */
  90853. get scene(): Scene;
  90854. /**
  90855. * Gets the capacity of the manager
  90856. */
  90857. get capacity(): number;
  90858. /**
  90859. * Gets or sets the spritesheet texture
  90860. */
  90861. get texture(): Texture;
  90862. set texture(value: Texture);
  90863. private _blendMode;
  90864. /**
  90865. * Blend mode use to render the particle, it can be any of
  90866. * the static Constants.ALPHA_x properties provided in this class.
  90867. * Default value is Constants.ALPHA_COMBINE
  90868. */
  90869. get blendMode(): number;
  90870. set blendMode(blendMode: number);
  90871. /** Disables writing to the depth buffer when rendering the sprites.
  90872. * It can be handy to disable depth writing when using textures without alpha channel
  90873. * and setting some specific blend modes.
  90874. */
  90875. disableDepthWrite: boolean;
  90876. /**
  90877. * Creates a new sprite manager
  90878. * @param name defines the manager's name
  90879. * @param imgUrl defines the sprite sheet url
  90880. * @param capacity defines the maximum allowed number of sprites
  90881. * @param cellSize defines the size of a sprite cell
  90882. * @param scene defines the hosting scene
  90883. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  90884. * @param samplingMode defines the smapling mode to use with spritesheet
  90885. * @param fromPacked set to false; do not alter
  90886. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  90887. */
  90888. constructor(
  90889. /** defines the manager's name */
  90890. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  90891. /**
  90892. * Returns the string "SpriteManager"
  90893. * @returns "SpriteManager"
  90894. */
  90895. getClassName(): string;
  90896. private _makePacked;
  90897. private _appendSpriteVertex;
  90898. private _checkTextureAlpha;
  90899. /**
  90900. * Intersects the sprites with a ray
  90901. * @param ray defines the ray to intersect with
  90902. * @param camera defines the current active camera
  90903. * @param predicate defines a predicate used to select candidate sprites
  90904. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  90905. * @returns null if no hit or a PickingInfo
  90906. */
  90907. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  90908. /**
  90909. * Intersects the sprites with a ray
  90910. * @param ray defines the ray to intersect with
  90911. * @param camera defines the current active camera
  90912. * @param predicate defines a predicate used to select candidate sprites
  90913. * @returns null if no hit or a PickingInfo array
  90914. */
  90915. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  90916. /**
  90917. * Render all child sprites
  90918. */
  90919. render(): void;
  90920. /**
  90921. * Release associated resources
  90922. */
  90923. dispose(): void;
  90924. /**
  90925. * Serializes the sprite manager to a JSON object
  90926. * @param serializeTexture defines if the texture must be serialized as well
  90927. * @returns the JSON object
  90928. */
  90929. serialize(serializeTexture?: boolean): any;
  90930. /**
  90931. * Parses a JSON object to create a new sprite manager.
  90932. * @param parsedManager The JSON object to parse
  90933. * @param scene The scene to create the sprite managerin
  90934. * @param rootUrl The root url to use to load external dependencies like texture
  90935. * @returns the new sprite manager
  90936. */
  90937. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  90938. /**
  90939. * Creates a sprite manager from a snippet saved in a remote file
  90940. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  90941. * @param url defines the url to load from
  90942. * @param scene defines the hosting scene
  90943. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90944. * @returns a promise that will resolve to the new sprite manager
  90945. */
  90946. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  90947. /**
  90948. * Creates a sprite manager from a snippet saved by the sprite editor
  90949. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  90950. * @param scene defines the hosting scene
  90951. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90952. * @returns a promise that will resolve to the new sprite manager
  90953. */
  90954. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  90955. }
  90956. }
  90957. declare module BABYLON {
  90958. /** Interface used by value gradients (color, factor, ...) */
  90959. export interface IValueGradient {
  90960. /**
  90961. * Gets or sets the gradient value (between 0 and 1)
  90962. */
  90963. gradient: number;
  90964. }
  90965. /** Class used to store color4 gradient */
  90966. export class ColorGradient implements IValueGradient {
  90967. /**
  90968. * Gets or sets the gradient value (between 0 and 1)
  90969. */
  90970. gradient: number;
  90971. /**
  90972. * Gets or sets first associated color
  90973. */
  90974. color1: Color4;
  90975. /**
  90976. * Gets or sets second associated color
  90977. */
  90978. color2?: Color4 | undefined;
  90979. /**
  90980. * Creates a new color4 gradient
  90981. * @param gradient gets or sets the gradient value (between 0 and 1)
  90982. * @param color1 gets or sets first associated color
  90983. * @param color2 gets or sets first second color
  90984. */
  90985. constructor(
  90986. /**
  90987. * Gets or sets the gradient value (between 0 and 1)
  90988. */
  90989. gradient: number,
  90990. /**
  90991. * Gets or sets first associated color
  90992. */
  90993. color1: Color4,
  90994. /**
  90995. * Gets or sets second associated color
  90996. */
  90997. color2?: Color4 | undefined);
  90998. /**
  90999. * Will get a color picked randomly between color1 and color2.
  91000. * If color2 is undefined then color1 will be used
  91001. * @param result defines the target Color4 to store the result in
  91002. */
  91003. getColorToRef(result: Color4): void;
  91004. }
  91005. /** Class used to store color 3 gradient */
  91006. export class Color3Gradient implements IValueGradient {
  91007. /**
  91008. * Gets or sets the gradient value (between 0 and 1)
  91009. */
  91010. gradient: number;
  91011. /**
  91012. * Gets or sets the associated color
  91013. */
  91014. color: Color3;
  91015. /**
  91016. * Creates a new color3 gradient
  91017. * @param gradient gets or sets the gradient value (between 0 and 1)
  91018. * @param color gets or sets associated color
  91019. */
  91020. constructor(
  91021. /**
  91022. * Gets or sets the gradient value (between 0 and 1)
  91023. */
  91024. gradient: number,
  91025. /**
  91026. * Gets or sets the associated color
  91027. */
  91028. color: Color3);
  91029. }
  91030. /** Class used to store factor gradient */
  91031. export class FactorGradient implements IValueGradient {
  91032. /**
  91033. * Gets or sets the gradient value (between 0 and 1)
  91034. */
  91035. gradient: number;
  91036. /**
  91037. * Gets or sets first associated factor
  91038. */
  91039. factor1: number;
  91040. /**
  91041. * Gets or sets second associated factor
  91042. */
  91043. factor2?: number | undefined;
  91044. /**
  91045. * Creates a new factor gradient
  91046. * @param gradient gets or sets the gradient value (between 0 and 1)
  91047. * @param factor1 gets or sets first associated factor
  91048. * @param factor2 gets or sets second associated factor
  91049. */
  91050. constructor(
  91051. /**
  91052. * Gets or sets the gradient value (between 0 and 1)
  91053. */
  91054. gradient: number,
  91055. /**
  91056. * Gets or sets first associated factor
  91057. */
  91058. factor1: number,
  91059. /**
  91060. * Gets or sets second associated factor
  91061. */
  91062. factor2?: number | undefined);
  91063. /**
  91064. * Will get a number picked randomly between factor1 and factor2.
  91065. * If factor2 is undefined then factor1 will be used
  91066. * @returns the picked number
  91067. */
  91068. getFactor(): number;
  91069. }
  91070. /**
  91071. * Helper used to simplify some generic gradient tasks
  91072. */
  91073. export class GradientHelper {
  91074. /**
  91075. * Gets the current gradient from an array of IValueGradient
  91076. * @param ratio defines the current ratio to get
  91077. * @param gradients defines the array of IValueGradient
  91078. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  91079. */
  91080. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  91081. }
  91082. }
  91083. declare module BABYLON {
  91084. interface ThinEngine {
  91085. /**
  91086. * Creates a raw texture
  91087. * @param data defines the data to store in the texture
  91088. * @param width defines the width of the texture
  91089. * @param height defines the height of the texture
  91090. * @param format defines the format of the data
  91091. * @param generateMipMaps defines if the engine should generate the mip levels
  91092. * @param invertY defines if data must be stored with Y axis inverted
  91093. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91094. * @param compression defines the compression used (null by default)
  91095. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91096. * @returns the raw texture inside an InternalTexture
  91097. */
  91098. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  91099. /**
  91100. * Update a raw texture
  91101. * @param texture defines the texture to update
  91102. * @param data defines the data to store in the texture
  91103. * @param format defines the format of the data
  91104. * @param invertY defines if data must be stored with Y axis inverted
  91105. */
  91106. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91107. /**
  91108. * Update a raw texture
  91109. * @param texture defines the texture to update
  91110. * @param data defines the data to store in the texture
  91111. * @param format defines the format of the data
  91112. * @param invertY defines if data must be stored with Y axis inverted
  91113. * @param compression defines the compression used (null by default)
  91114. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91115. */
  91116. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  91117. /**
  91118. * Creates a new raw cube texture
  91119. * @param data defines the array of data to use to create each face
  91120. * @param size defines the size of the textures
  91121. * @param format defines the format of the data
  91122. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91123. * @param generateMipMaps defines if the engine should generate the mip levels
  91124. * @param invertY defines if data must be stored with Y axis inverted
  91125. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91126. * @param compression defines the compression used (null by default)
  91127. * @returns the cube texture as an InternalTexture
  91128. */
  91129. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  91130. /**
  91131. * Update a raw cube texture
  91132. * @param texture defines the texture to udpdate
  91133. * @param data defines the data to store
  91134. * @param format defines the data format
  91135. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91136. * @param invertY defines if data must be stored with Y axis inverted
  91137. */
  91138. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  91139. /**
  91140. * Update a raw cube texture
  91141. * @param texture defines the texture to udpdate
  91142. * @param data defines the data to store
  91143. * @param format defines the data format
  91144. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91145. * @param invertY defines if data must be stored with Y axis inverted
  91146. * @param compression defines the compression used (null by default)
  91147. */
  91148. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  91149. /**
  91150. * Update a raw cube texture
  91151. * @param texture defines the texture to udpdate
  91152. * @param data defines the data to store
  91153. * @param format defines the data format
  91154. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91155. * @param invertY defines if data must be stored with Y axis inverted
  91156. * @param compression defines the compression used (null by default)
  91157. * @param level defines which level of the texture to update
  91158. */
  91159. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  91160. /**
  91161. * Creates a new raw cube texture from a specified url
  91162. * @param url defines the url where the data is located
  91163. * @param scene defines the current scene
  91164. * @param size defines the size of the textures
  91165. * @param format defines the format of the data
  91166. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91167. * @param noMipmap defines if the engine should avoid generating the mip levels
  91168. * @param callback defines a callback used to extract texture data from loaded data
  91169. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91170. * @param onLoad defines a callback called when texture is loaded
  91171. * @param onError defines a callback called if there is an error
  91172. * @returns the cube texture as an InternalTexture
  91173. */
  91174. 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;
  91175. /**
  91176. * Creates a new raw cube texture from a specified url
  91177. * @param url defines the url where the data is located
  91178. * @param scene defines the current scene
  91179. * @param size defines the size of the textures
  91180. * @param format defines the format of the data
  91181. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91182. * @param noMipmap defines if the engine should avoid generating the mip levels
  91183. * @param callback defines a callback used to extract texture data from loaded data
  91184. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91185. * @param onLoad defines a callback called when texture is loaded
  91186. * @param onError defines a callback called if there is an error
  91187. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91188. * @param invertY defines if data must be stored with Y axis inverted
  91189. * @returns the cube texture as an InternalTexture
  91190. */
  91191. 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;
  91192. /**
  91193. * Creates a new raw 3D texture
  91194. * @param data defines the data used to create the texture
  91195. * @param width defines the width of the texture
  91196. * @param height defines the height of the texture
  91197. * @param depth defines the depth of the texture
  91198. * @param format defines the format of the texture
  91199. * @param generateMipMaps defines if the engine must generate mip levels
  91200. * @param invertY defines if data must be stored with Y axis inverted
  91201. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91202. * @param compression defines the compressed used (can be null)
  91203. * @param textureType defines the compressed used (can be null)
  91204. * @returns a new raw 3D texture (stored in an InternalTexture)
  91205. */
  91206. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91207. /**
  91208. * Update a raw 3D texture
  91209. * @param texture defines the texture to update
  91210. * @param data defines the data to store
  91211. * @param format defines the data format
  91212. * @param invertY defines if data must be stored with Y axis inverted
  91213. */
  91214. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91215. /**
  91216. * Update a raw 3D texture
  91217. * @param texture defines the texture to update
  91218. * @param data defines the data to store
  91219. * @param format defines the data format
  91220. * @param invertY defines if data must be stored with Y axis inverted
  91221. * @param compression defines the used compression (can be null)
  91222. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  91223. */
  91224. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  91225. /**
  91226. * Creates a new raw 2D array texture
  91227. * @param data defines the data used to create the texture
  91228. * @param width defines the width of the texture
  91229. * @param height defines the height of the texture
  91230. * @param depth defines the number of layers of the texture
  91231. * @param format defines the format of the texture
  91232. * @param generateMipMaps defines if the engine must generate mip levels
  91233. * @param invertY defines if data must be stored with Y axis inverted
  91234. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91235. * @param compression defines the compressed used (can be null)
  91236. * @param textureType defines the compressed used (can be null)
  91237. * @returns a new raw 2D array texture (stored in an InternalTexture)
  91238. */
  91239. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91240. /**
  91241. * Update a raw 2D array texture
  91242. * @param texture defines the texture to update
  91243. * @param data defines the data to store
  91244. * @param format defines the data format
  91245. * @param invertY defines if data must be stored with Y axis inverted
  91246. */
  91247. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91248. /**
  91249. * Update a raw 2D array texture
  91250. * @param texture defines the texture to update
  91251. * @param data defines the data to store
  91252. * @param format defines the data format
  91253. * @param invertY defines if data must be stored with Y axis inverted
  91254. * @param compression defines the used compression (can be null)
  91255. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  91256. */
  91257. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  91258. }
  91259. }
  91260. declare module BABYLON {
  91261. /**
  91262. * Raw texture can help creating a texture directly from an array of data.
  91263. * This can be super useful if you either get the data from an uncompressed source or
  91264. * if you wish to create your texture pixel by pixel.
  91265. */
  91266. export class RawTexture extends Texture {
  91267. /**
  91268. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91269. */
  91270. format: number;
  91271. /**
  91272. * Instantiates a new RawTexture.
  91273. * Raw texture can help creating a texture directly from an array of data.
  91274. * This can be super useful if you either get the data from an uncompressed source or
  91275. * if you wish to create your texture pixel by pixel.
  91276. * @param data define the array of data to use to create the texture
  91277. * @param width define the width of the texture
  91278. * @param height define the height of the texture
  91279. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91280. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91281. * @param generateMipMaps define whether mip maps should be generated or not
  91282. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91283. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91284. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91285. */
  91286. constructor(data: ArrayBufferView, width: number, height: number,
  91287. /**
  91288. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91289. */
  91290. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  91291. /**
  91292. * Updates the texture underlying data.
  91293. * @param data Define the new data of the texture
  91294. */
  91295. update(data: ArrayBufferView): void;
  91296. /**
  91297. * Creates a luminance texture from some data.
  91298. * @param data Define the texture data
  91299. * @param width Define the width of the texture
  91300. * @param height Define the height of the texture
  91301. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91302. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91303. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91304. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91305. * @returns the luminance texture
  91306. */
  91307. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91308. /**
  91309. * Creates a luminance alpha texture from some data.
  91310. * @param data Define the texture data
  91311. * @param width Define the width of the texture
  91312. * @param height Define the height of the texture
  91313. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91314. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91315. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91316. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91317. * @returns the luminance alpha texture
  91318. */
  91319. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91320. /**
  91321. * Creates an alpha texture from some data.
  91322. * @param data Define the texture data
  91323. * @param width Define the width of the texture
  91324. * @param height Define the height of the texture
  91325. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91326. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91327. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91328. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91329. * @returns the alpha texture
  91330. */
  91331. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91332. /**
  91333. * Creates a RGB texture from some data.
  91334. * @param data Define the texture data
  91335. * @param width Define the width of the texture
  91336. * @param height Define the height of the texture
  91337. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91338. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91339. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91340. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91341. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91342. * @returns the RGB alpha texture
  91343. */
  91344. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91345. /**
  91346. * Creates a RGBA texture from some data.
  91347. * @param data Define the texture data
  91348. * @param width Define the width of the texture
  91349. * @param height Define the height of the texture
  91350. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91351. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91352. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91353. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91354. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91355. * @returns the RGBA texture
  91356. */
  91357. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91358. /**
  91359. * Creates a R texture from some data.
  91360. * @param data Define the texture data
  91361. * @param width Define the width of the texture
  91362. * @param height Define the height of the texture
  91363. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91364. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91365. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91366. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91367. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91368. * @returns the R texture
  91369. */
  91370. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91371. }
  91372. }
  91373. declare module BABYLON {
  91374. interface ThinEngine {
  91375. /**
  91376. * Update a dynamic index buffer
  91377. * @param indexBuffer defines the target index buffer
  91378. * @param indices defines the data to update
  91379. * @param offset defines the offset in the target index buffer where update should start
  91380. */
  91381. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  91382. /**
  91383. * Updates a dynamic vertex buffer.
  91384. * @param vertexBuffer the vertex buffer to update
  91385. * @param data the data used to update the vertex buffer
  91386. * @param byteOffset the byte offset of the data
  91387. * @param byteLength the byte length of the data
  91388. */
  91389. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  91390. }
  91391. }
  91392. declare module BABYLON {
  91393. interface AbstractScene {
  91394. /**
  91395. * The list of procedural textures added to the scene
  91396. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91397. */
  91398. proceduralTextures: Array<ProceduralTexture>;
  91399. }
  91400. /**
  91401. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  91402. * in a given scene.
  91403. */
  91404. export class ProceduralTextureSceneComponent implements ISceneComponent {
  91405. /**
  91406. * The component name helpfull to identify the component in the list of scene components.
  91407. */
  91408. readonly name: string;
  91409. /**
  91410. * The scene the component belongs to.
  91411. */
  91412. scene: Scene;
  91413. /**
  91414. * Creates a new instance of the component for the given scene
  91415. * @param scene Defines the scene to register the component in
  91416. */
  91417. constructor(scene: Scene);
  91418. /**
  91419. * Registers the component in a given scene
  91420. */
  91421. register(): void;
  91422. /**
  91423. * Rebuilds the elements related to this component in case of
  91424. * context lost for instance.
  91425. */
  91426. rebuild(): void;
  91427. /**
  91428. * Disposes the component and the associated ressources.
  91429. */
  91430. dispose(): void;
  91431. private _beforeClear;
  91432. }
  91433. }
  91434. declare module BABYLON {
  91435. interface ThinEngine {
  91436. /**
  91437. * Creates a new render target cube texture
  91438. * @param size defines the size of the texture
  91439. * @param options defines the options used to create the texture
  91440. * @returns a new render target cube texture stored in an InternalTexture
  91441. */
  91442. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  91443. }
  91444. }
  91445. declare module BABYLON {
  91446. /** @hidden */
  91447. export var proceduralVertexShader: {
  91448. name: string;
  91449. shader: string;
  91450. };
  91451. }
  91452. declare module BABYLON {
  91453. /**
  91454. * 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.
  91455. * This is the base class of any Procedural texture and contains most of the shareable code.
  91456. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91457. */
  91458. export class ProceduralTexture extends Texture {
  91459. /**
  91460. * Define if the texture is enabled or not (disabled texture will not render)
  91461. */
  91462. isEnabled: boolean;
  91463. /**
  91464. * Define if the texture must be cleared before rendering (default is true)
  91465. */
  91466. autoClear: boolean;
  91467. /**
  91468. * Callback called when the texture is generated
  91469. */
  91470. onGenerated: () => void;
  91471. /**
  91472. * Event raised when the texture is generated
  91473. */
  91474. onGeneratedObservable: Observable<ProceduralTexture>;
  91475. /** @hidden */
  91476. _generateMipMaps: boolean;
  91477. /** @hidden **/
  91478. _effect: Effect;
  91479. /** @hidden */
  91480. _textures: {
  91481. [key: string]: Texture;
  91482. };
  91483. /** @hidden */
  91484. protected _fallbackTexture: Nullable<Texture>;
  91485. private _size;
  91486. private _currentRefreshId;
  91487. private _frameId;
  91488. private _refreshRate;
  91489. private _vertexBuffers;
  91490. private _indexBuffer;
  91491. private _uniforms;
  91492. private _samplers;
  91493. private _fragment;
  91494. private _floats;
  91495. private _ints;
  91496. private _floatsArrays;
  91497. private _colors3;
  91498. private _colors4;
  91499. private _vectors2;
  91500. private _vectors3;
  91501. private _matrices;
  91502. private _fallbackTextureUsed;
  91503. private _fullEngine;
  91504. private _cachedDefines;
  91505. private _contentUpdateId;
  91506. private _contentData;
  91507. /**
  91508. * Instantiates a new procedural texture.
  91509. * 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.
  91510. * This is the base class of any Procedural texture and contains most of the shareable code.
  91511. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91512. * @param name Define the name of the texture
  91513. * @param size Define the size of the texture to create
  91514. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  91515. * @param scene Define the scene the texture belongs to
  91516. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  91517. * @param generateMipMaps Define if the texture should creates mip maps or not
  91518. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  91519. */
  91520. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  91521. /**
  91522. * The effect that is created when initializing the post process.
  91523. * @returns The created effect corresponding the the postprocess.
  91524. */
  91525. getEffect(): Effect;
  91526. /**
  91527. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  91528. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  91529. */
  91530. getContent(): Nullable<ArrayBufferView>;
  91531. private _createIndexBuffer;
  91532. /** @hidden */
  91533. _rebuild(): void;
  91534. /**
  91535. * Resets the texture in order to recreate its associated resources.
  91536. * This can be called in case of context loss
  91537. */
  91538. reset(): void;
  91539. protected _getDefines(): string;
  91540. /**
  91541. * Is the texture ready to be used ? (rendered at least once)
  91542. * @returns true if ready, otherwise, false.
  91543. */
  91544. isReady(): boolean;
  91545. /**
  91546. * Resets the refresh counter of the texture and start bak from scratch.
  91547. * Could be useful to regenerate the texture if it is setup to render only once.
  91548. */
  91549. resetRefreshCounter(): void;
  91550. /**
  91551. * Set the fragment shader to use in order to render the texture.
  91552. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  91553. */
  91554. setFragment(fragment: any): void;
  91555. /**
  91556. * Define the refresh rate of the texture or the rendering frequency.
  91557. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  91558. */
  91559. get refreshRate(): number;
  91560. set refreshRate(value: number);
  91561. /** @hidden */
  91562. _shouldRender(): boolean;
  91563. /**
  91564. * Get the size the texture is rendering at.
  91565. * @returns the size (texture is always squared)
  91566. */
  91567. getRenderSize(): number;
  91568. /**
  91569. * Resize the texture to new value.
  91570. * @param size Define the new size the texture should have
  91571. * @param generateMipMaps Define whether the new texture should create mip maps
  91572. */
  91573. resize(size: number, generateMipMaps: boolean): void;
  91574. private _checkUniform;
  91575. /**
  91576. * Set a texture in the shader program used to render.
  91577. * @param name Define the name of the uniform samplers as defined in the shader
  91578. * @param texture Define the texture to bind to this sampler
  91579. * @return the texture itself allowing "fluent" like uniform updates
  91580. */
  91581. setTexture(name: string, texture: Texture): ProceduralTexture;
  91582. /**
  91583. * Set a float in the shader.
  91584. * @param name Define the name of the uniform as defined in the shader
  91585. * @param value Define the value to give to the uniform
  91586. * @return the texture itself allowing "fluent" like uniform updates
  91587. */
  91588. setFloat(name: string, value: number): ProceduralTexture;
  91589. /**
  91590. * Set a int in the shader.
  91591. * @param name Define the name of the uniform as defined in the shader
  91592. * @param value Define the value to give to the uniform
  91593. * @return the texture itself allowing "fluent" like uniform updates
  91594. */
  91595. setInt(name: string, value: number): ProceduralTexture;
  91596. /**
  91597. * Set an array of floats in the shader.
  91598. * @param name Define the name of the uniform as defined in the shader
  91599. * @param value Define the value to give to the uniform
  91600. * @return the texture itself allowing "fluent" like uniform updates
  91601. */
  91602. setFloats(name: string, value: number[]): ProceduralTexture;
  91603. /**
  91604. * Set a vec3 in the shader from a Color3.
  91605. * @param name Define the name of the uniform as defined in the shader
  91606. * @param value Define the value to give to the uniform
  91607. * @return the texture itself allowing "fluent" like uniform updates
  91608. */
  91609. setColor3(name: string, value: Color3): ProceduralTexture;
  91610. /**
  91611. * Set a vec4 in the shader from a Color4.
  91612. * @param name Define the name of the uniform as defined in the shader
  91613. * @param value Define the value to give to the uniform
  91614. * @return the texture itself allowing "fluent" like uniform updates
  91615. */
  91616. setColor4(name: string, value: Color4): ProceduralTexture;
  91617. /**
  91618. * Set a vec2 in the shader from a Vector2.
  91619. * @param name Define the name of the uniform as defined in the shader
  91620. * @param value Define the value to give to the uniform
  91621. * @return the texture itself allowing "fluent" like uniform updates
  91622. */
  91623. setVector2(name: string, value: Vector2): ProceduralTexture;
  91624. /**
  91625. * Set a vec3 in the shader from a Vector3.
  91626. * @param name Define the name of the uniform as defined in the shader
  91627. * @param value Define the value to give to the uniform
  91628. * @return the texture itself allowing "fluent" like uniform updates
  91629. */
  91630. setVector3(name: string, value: Vector3): ProceduralTexture;
  91631. /**
  91632. * Set a mat4 in the shader from a MAtrix.
  91633. * @param name Define the name of the uniform as defined in the shader
  91634. * @param value Define the value to give to the uniform
  91635. * @return the texture itself allowing "fluent" like uniform updates
  91636. */
  91637. setMatrix(name: string, value: Matrix): ProceduralTexture;
  91638. /**
  91639. * Render the texture to its associated render target.
  91640. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  91641. */
  91642. render(useCameraPostProcess?: boolean): void;
  91643. /**
  91644. * Clone the texture.
  91645. * @returns the cloned texture
  91646. */
  91647. clone(): ProceduralTexture;
  91648. /**
  91649. * Dispose the texture and release its asoociated resources.
  91650. */
  91651. dispose(): void;
  91652. }
  91653. }
  91654. declare module BABYLON {
  91655. /**
  91656. * This represents the base class for particle system in Babylon.
  91657. * 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.
  91658. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  91659. * @example https://doc.babylonjs.com/babylon101/particles
  91660. */
  91661. export class BaseParticleSystem {
  91662. /**
  91663. * Source color is added to the destination color without alpha affecting the result
  91664. */
  91665. static BLENDMODE_ONEONE: number;
  91666. /**
  91667. * Blend current color and particle color using particle’s alpha
  91668. */
  91669. static BLENDMODE_STANDARD: number;
  91670. /**
  91671. * Add current color and particle color multiplied by particle’s alpha
  91672. */
  91673. static BLENDMODE_ADD: number;
  91674. /**
  91675. * Multiply current color with particle color
  91676. */
  91677. static BLENDMODE_MULTIPLY: number;
  91678. /**
  91679. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  91680. */
  91681. static BLENDMODE_MULTIPLYADD: number;
  91682. /**
  91683. * List of animations used by the particle system.
  91684. */
  91685. animations: Animation[];
  91686. /**
  91687. * Gets or sets the unique id of the particle system
  91688. */
  91689. uniqueId: number;
  91690. /**
  91691. * The id of the Particle system.
  91692. */
  91693. id: string;
  91694. /**
  91695. * The friendly name of the Particle system.
  91696. */
  91697. name: string;
  91698. /**
  91699. * Snippet ID if the particle system was created from the snippet server
  91700. */
  91701. snippetId: string;
  91702. /**
  91703. * The rendering group used by the Particle system to chose when to render.
  91704. */
  91705. renderingGroupId: number;
  91706. /**
  91707. * The emitter represents the Mesh or position we are attaching the particle system to.
  91708. */
  91709. emitter: Nullable<AbstractMesh | Vector3>;
  91710. /**
  91711. * The maximum number of particles to emit per frame
  91712. */
  91713. emitRate: number;
  91714. /**
  91715. * If you want to launch only a few particles at once, that can be done, as well.
  91716. */
  91717. manualEmitCount: number;
  91718. /**
  91719. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  91720. */
  91721. updateSpeed: number;
  91722. /**
  91723. * The amount of time the particle system is running (depends of the overall update speed).
  91724. */
  91725. targetStopDuration: number;
  91726. /**
  91727. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  91728. */
  91729. disposeOnStop: boolean;
  91730. /**
  91731. * Minimum power of emitting particles.
  91732. */
  91733. minEmitPower: number;
  91734. /**
  91735. * Maximum power of emitting particles.
  91736. */
  91737. maxEmitPower: number;
  91738. /**
  91739. * Minimum life time of emitting particles.
  91740. */
  91741. minLifeTime: number;
  91742. /**
  91743. * Maximum life time of emitting particles.
  91744. */
  91745. maxLifeTime: number;
  91746. /**
  91747. * Minimum Size of emitting particles.
  91748. */
  91749. minSize: number;
  91750. /**
  91751. * Maximum Size of emitting particles.
  91752. */
  91753. maxSize: number;
  91754. /**
  91755. * Minimum scale of emitting particles on X axis.
  91756. */
  91757. minScaleX: number;
  91758. /**
  91759. * Maximum scale of emitting particles on X axis.
  91760. */
  91761. maxScaleX: number;
  91762. /**
  91763. * Minimum scale of emitting particles on Y axis.
  91764. */
  91765. minScaleY: number;
  91766. /**
  91767. * Maximum scale of emitting particles on Y axis.
  91768. */
  91769. maxScaleY: number;
  91770. /**
  91771. * Gets or sets the minimal initial rotation in radians.
  91772. */
  91773. minInitialRotation: number;
  91774. /**
  91775. * Gets or sets the maximal initial rotation in radians.
  91776. */
  91777. maxInitialRotation: number;
  91778. /**
  91779. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  91780. */
  91781. minAngularSpeed: number;
  91782. /**
  91783. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  91784. */
  91785. maxAngularSpeed: number;
  91786. /**
  91787. * The texture used to render each particle. (this can be a spritesheet)
  91788. */
  91789. particleTexture: Nullable<BaseTexture>;
  91790. /**
  91791. * The layer mask we are rendering the particles through.
  91792. */
  91793. layerMask: number;
  91794. /**
  91795. * This can help using your own shader to render the particle system.
  91796. * The according effect will be created
  91797. */
  91798. customShader: any;
  91799. /**
  91800. * By default particle system starts as soon as they are created. This prevents the
  91801. * automatic start to happen and let you decide when to start emitting particles.
  91802. */
  91803. preventAutoStart: boolean;
  91804. private _noiseTexture;
  91805. /**
  91806. * Gets or sets a texture used to add random noise to particle positions
  91807. */
  91808. get noiseTexture(): Nullable<ProceduralTexture>;
  91809. set noiseTexture(value: Nullable<ProceduralTexture>);
  91810. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  91811. noiseStrength: Vector3;
  91812. /**
  91813. * Callback triggered when the particle animation is ending.
  91814. */
  91815. onAnimationEnd: Nullable<() => void>;
  91816. /**
  91817. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  91818. */
  91819. blendMode: number;
  91820. /**
  91821. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  91822. * to override the particles.
  91823. */
  91824. forceDepthWrite: boolean;
  91825. /** 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 */
  91826. preWarmCycles: number;
  91827. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  91828. preWarmStepOffset: number;
  91829. /**
  91830. * 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)
  91831. */
  91832. spriteCellChangeSpeed: number;
  91833. /**
  91834. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  91835. */
  91836. startSpriteCellID: number;
  91837. /**
  91838. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  91839. */
  91840. endSpriteCellID: number;
  91841. /**
  91842. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  91843. */
  91844. spriteCellWidth: number;
  91845. /**
  91846. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  91847. */
  91848. spriteCellHeight: number;
  91849. /**
  91850. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  91851. */
  91852. spriteRandomStartCell: boolean;
  91853. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  91854. translationPivot: Vector2;
  91855. /** @hidden */
  91856. protected _isAnimationSheetEnabled: boolean;
  91857. /**
  91858. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  91859. */
  91860. beginAnimationOnStart: boolean;
  91861. /**
  91862. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  91863. */
  91864. beginAnimationFrom: number;
  91865. /**
  91866. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  91867. */
  91868. beginAnimationTo: number;
  91869. /**
  91870. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  91871. */
  91872. beginAnimationLoop: boolean;
  91873. /**
  91874. * Gets or sets a world offset applied to all particles
  91875. */
  91876. worldOffset: Vector3;
  91877. /**
  91878. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  91879. */
  91880. get isAnimationSheetEnabled(): boolean;
  91881. set isAnimationSheetEnabled(value: boolean);
  91882. /**
  91883. * Get hosting scene
  91884. * @returns the scene
  91885. */
  91886. getScene(): Nullable<Scene>;
  91887. /**
  91888. * You can use gravity if you want to give an orientation to your particles.
  91889. */
  91890. gravity: Vector3;
  91891. protected _colorGradients: Nullable<Array<ColorGradient>>;
  91892. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  91893. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  91894. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  91895. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  91896. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  91897. protected _dragGradients: Nullable<Array<FactorGradient>>;
  91898. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  91899. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  91900. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  91901. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  91902. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  91903. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  91904. /**
  91905. * Defines the delay in milliseconds before starting the system (0 by default)
  91906. */
  91907. startDelay: number;
  91908. /**
  91909. * Gets the current list of drag gradients.
  91910. * You must use addDragGradient and removeDragGradient to udpate this list
  91911. * @returns the list of drag gradients
  91912. */
  91913. getDragGradients(): Nullable<Array<FactorGradient>>;
  91914. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  91915. limitVelocityDamping: number;
  91916. /**
  91917. * Gets the current list of limit velocity gradients.
  91918. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  91919. * @returns the list of limit velocity gradients
  91920. */
  91921. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  91922. /**
  91923. * Gets the current list of color gradients.
  91924. * You must use addColorGradient and removeColorGradient to udpate this list
  91925. * @returns the list of color gradients
  91926. */
  91927. getColorGradients(): Nullable<Array<ColorGradient>>;
  91928. /**
  91929. * Gets the current list of size gradients.
  91930. * You must use addSizeGradient and removeSizeGradient to udpate this list
  91931. * @returns the list of size gradients
  91932. */
  91933. getSizeGradients(): Nullable<Array<FactorGradient>>;
  91934. /**
  91935. * Gets the current list of color remap gradients.
  91936. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  91937. * @returns the list of color remap gradients
  91938. */
  91939. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  91940. /**
  91941. * Gets the current list of alpha remap gradients.
  91942. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  91943. * @returns the list of alpha remap gradients
  91944. */
  91945. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  91946. /**
  91947. * Gets the current list of life time gradients.
  91948. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  91949. * @returns the list of life time gradients
  91950. */
  91951. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  91952. /**
  91953. * Gets the current list of angular speed gradients.
  91954. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  91955. * @returns the list of angular speed gradients
  91956. */
  91957. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  91958. /**
  91959. * Gets the current list of velocity gradients.
  91960. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  91961. * @returns the list of velocity gradients
  91962. */
  91963. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  91964. /**
  91965. * Gets the current list of start size gradients.
  91966. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  91967. * @returns the list of start size gradients
  91968. */
  91969. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  91970. /**
  91971. * Gets the current list of emit rate gradients.
  91972. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  91973. * @returns the list of emit rate gradients
  91974. */
  91975. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  91976. /**
  91977. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91978. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91979. */
  91980. get direction1(): Vector3;
  91981. set direction1(value: Vector3);
  91982. /**
  91983. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91984. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91985. */
  91986. get direction2(): Vector3;
  91987. set direction2(value: Vector3);
  91988. /**
  91989. * 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.
  91990. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91991. */
  91992. get minEmitBox(): Vector3;
  91993. set minEmitBox(value: Vector3);
  91994. /**
  91995. * 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.
  91996. * This only works when particleEmitterTyps is a BoxParticleEmitter
  91997. */
  91998. get maxEmitBox(): Vector3;
  91999. set maxEmitBox(value: Vector3);
  92000. /**
  92001. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92002. */
  92003. color1: Color4;
  92004. /**
  92005. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92006. */
  92007. color2: Color4;
  92008. /**
  92009. * Color the particle will have at the end of its lifetime
  92010. */
  92011. colorDead: Color4;
  92012. /**
  92013. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  92014. */
  92015. textureMask: Color4;
  92016. /**
  92017. * The particle emitter type defines the emitter used by the particle system.
  92018. * It can be for example box, sphere, or cone...
  92019. */
  92020. particleEmitterType: IParticleEmitterType;
  92021. /** @hidden */
  92022. _isSubEmitter: boolean;
  92023. /**
  92024. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92025. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92026. */
  92027. billboardMode: number;
  92028. protected _isBillboardBased: boolean;
  92029. /**
  92030. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92031. */
  92032. get isBillboardBased(): boolean;
  92033. set isBillboardBased(value: boolean);
  92034. /**
  92035. * The scene the particle system belongs to.
  92036. */
  92037. protected _scene: Nullable<Scene>;
  92038. /**
  92039. * The engine the particle system belongs to.
  92040. */
  92041. protected _engine: ThinEngine;
  92042. /**
  92043. * Local cache of defines for image processing.
  92044. */
  92045. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  92046. /**
  92047. * Default configuration related to image processing available in the standard Material.
  92048. */
  92049. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  92050. /**
  92051. * Gets the image processing configuration used either in this material.
  92052. */
  92053. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  92054. /**
  92055. * Sets the Default image processing configuration used either in the this material.
  92056. *
  92057. * If sets to null, the scene one is in use.
  92058. */
  92059. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  92060. /**
  92061. * Attaches a new image processing configuration to the Standard Material.
  92062. * @param configuration
  92063. */
  92064. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  92065. /** @hidden */
  92066. protected _reset(): void;
  92067. /** @hidden */
  92068. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  92069. /**
  92070. * Instantiates a particle system.
  92071. * 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.
  92072. * @param name The name of the particle system
  92073. */
  92074. constructor(name: string);
  92075. /**
  92076. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92077. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92078. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92079. * @returns the emitter
  92080. */
  92081. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92082. /**
  92083. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92084. * @param radius The radius of the hemisphere to emit from
  92085. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92086. * @returns the emitter
  92087. */
  92088. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  92089. /**
  92090. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92091. * @param radius The radius of the sphere to emit from
  92092. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92093. * @returns the emitter
  92094. */
  92095. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  92096. /**
  92097. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92098. * @param radius The radius of the sphere to emit from
  92099. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92100. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92101. * @returns the emitter
  92102. */
  92103. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  92104. /**
  92105. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92106. * @param radius The radius of the emission cylinder
  92107. * @param height The height of the emission cylinder
  92108. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92109. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92110. * @returns the emitter
  92111. */
  92112. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  92113. /**
  92114. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92115. * @param radius The radius of the cylinder to emit from
  92116. * @param height The height of the emission cylinder
  92117. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92118. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92119. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92120. * @returns the emitter
  92121. */
  92122. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  92123. /**
  92124. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92125. * @param radius The radius of the cone to emit from
  92126. * @param angle The base angle of the cone
  92127. * @returns the emitter
  92128. */
  92129. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  92130. /**
  92131. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92132. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92133. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92134. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92135. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92136. * @returns the emitter
  92137. */
  92138. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92139. }
  92140. }
  92141. declare module BABYLON {
  92142. /**
  92143. * Type of sub emitter
  92144. */
  92145. export enum SubEmitterType {
  92146. /**
  92147. * Attached to the particle over it's lifetime
  92148. */
  92149. ATTACHED = 0,
  92150. /**
  92151. * Created when the particle dies
  92152. */
  92153. END = 1
  92154. }
  92155. /**
  92156. * Sub emitter class used to emit particles from an existing particle
  92157. */
  92158. export class SubEmitter {
  92159. /**
  92160. * the particle system to be used by the sub emitter
  92161. */
  92162. particleSystem: ParticleSystem;
  92163. /**
  92164. * Type of the submitter (Default: END)
  92165. */
  92166. type: SubEmitterType;
  92167. /**
  92168. * 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)
  92169. * Note: This only is supported when using an emitter of type Mesh
  92170. */
  92171. inheritDirection: boolean;
  92172. /**
  92173. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  92174. */
  92175. inheritedVelocityAmount: number;
  92176. /**
  92177. * Creates a sub emitter
  92178. * @param particleSystem the particle system to be used by the sub emitter
  92179. */
  92180. constructor(
  92181. /**
  92182. * the particle system to be used by the sub emitter
  92183. */
  92184. particleSystem: ParticleSystem);
  92185. /**
  92186. * Clones the sub emitter
  92187. * @returns the cloned sub emitter
  92188. */
  92189. clone(): SubEmitter;
  92190. /**
  92191. * Serialize current object to a JSON object
  92192. * @returns the serialized object
  92193. */
  92194. serialize(): any;
  92195. /** @hidden */
  92196. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  92197. /**
  92198. * Creates a new SubEmitter from a serialized JSON version
  92199. * @param serializationObject defines the JSON object to read from
  92200. * @param sceneOrEngine defines the hosting scene or the hosting engine
  92201. * @param rootUrl defines the rootUrl for data loading
  92202. * @returns a new SubEmitter
  92203. */
  92204. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  92205. /** Release associated resources */
  92206. dispose(): void;
  92207. }
  92208. }
  92209. declare module BABYLON {
  92210. /** @hidden */
  92211. export var imageProcessingDeclaration: {
  92212. name: string;
  92213. shader: string;
  92214. };
  92215. }
  92216. declare module BABYLON {
  92217. /** @hidden */
  92218. export var imageProcessingFunctions: {
  92219. name: string;
  92220. shader: string;
  92221. };
  92222. }
  92223. declare module BABYLON {
  92224. /** @hidden */
  92225. export var particlesPixelShader: {
  92226. name: string;
  92227. shader: string;
  92228. };
  92229. }
  92230. declare module BABYLON {
  92231. /** @hidden */
  92232. export var particlesVertexShader: {
  92233. name: string;
  92234. shader: string;
  92235. };
  92236. }
  92237. declare module BABYLON {
  92238. /**
  92239. * Interface used to define entities containing multiple clip planes
  92240. */
  92241. export interface IClipPlanesHolder {
  92242. /**
  92243. * Gets or sets the active clipplane 1
  92244. */
  92245. clipPlane: Nullable<Plane>;
  92246. /**
  92247. * Gets or sets the active clipplane 2
  92248. */
  92249. clipPlane2: Nullable<Plane>;
  92250. /**
  92251. * Gets or sets the active clipplane 3
  92252. */
  92253. clipPlane3: Nullable<Plane>;
  92254. /**
  92255. * Gets or sets the active clipplane 4
  92256. */
  92257. clipPlane4: Nullable<Plane>;
  92258. /**
  92259. * Gets or sets the active clipplane 5
  92260. */
  92261. clipPlane5: Nullable<Plane>;
  92262. /**
  92263. * Gets or sets the active clipplane 6
  92264. */
  92265. clipPlane6: Nullable<Plane>;
  92266. }
  92267. }
  92268. declare module BABYLON {
  92269. /**
  92270. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  92271. *
  92272. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  92273. *
  92274. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  92275. */
  92276. export class ThinMaterialHelper {
  92277. /**
  92278. * Binds the clip plane information from the holder to the effect.
  92279. * @param effect The effect we are binding the data to
  92280. * @param holder The entity containing the clip plane information
  92281. */
  92282. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  92283. }
  92284. }
  92285. declare module BABYLON {
  92286. interface ThinEngine {
  92287. /**
  92288. * Sets alpha constants used by some alpha blending modes
  92289. * @param r defines the red component
  92290. * @param g defines the green component
  92291. * @param b defines the blue component
  92292. * @param a defines the alpha component
  92293. */
  92294. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  92295. /**
  92296. * Sets the current alpha mode
  92297. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  92298. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  92299. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  92300. */
  92301. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  92302. /**
  92303. * Gets the current alpha mode
  92304. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  92305. * @returns the current alpha mode
  92306. */
  92307. getAlphaMode(): number;
  92308. /**
  92309. * Sets the current alpha equation
  92310. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  92311. */
  92312. setAlphaEquation(equation: number): void;
  92313. /**
  92314. * Gets the current alpha equation.
  92315. * @returns the current alpha equation
  92316. */
  92317. getAlphaEquation(): number;
  92318. }
  92319. }
  92320. declare module BABYLON {
  92321. /**
  92322. * This represents a particle system in Babylon.
  92323. * 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.
  92324. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92325. * @example https://doc.babylonjs.com/babylon101/particles
  92326. */
  92327. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  92328. /**
  92329. * Billboard mode will only apply to Y axis
  92330. */
  92331. static readonly BILLBOARDMODE_Y: number;
  92332. /**
  92333. * Billboard mode will apply to all axes
  92334. */
  92335. static readonly BILLBOARDMODE_ALL: number;
  92336. /**
  92337. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  92338. */
  92339. static readonly BILLBOARDMODE_STRETCHED: number;
  92340. /**
  92341. * This function can be defined to provide custom update for active particles.
  92342. * This function will be called instead of regular update (age, position, color, etc.).
  92343. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  92344. */
  92345. updateFunction: (particles: Particle[]) => void;
  92346. private _emitterWorldMatrix;
  92347. /**
  92348. * This function can be defined to specify initial direction for every new particle.
  92349. * It by default use the emitterType defined function
  92350. */
  92351. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  92352. /**
  92353. * This function can be defined to specify initial position for every new particle.
  92354. * It by default use the emitterType defined function
  92355. */
  92356. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  92357. /**
  92358. * @hidden
  92359. */
  92360. _inheritedVelocityOffset: Vector3;
  92361. /**
  92362. * An event triggered when the system is disposed
  92363. */
  92364. onDisposeObservable: Observable<IParticleSystem>;
  92365. private _onDisposeObserver;
  92366. /**
  92367. * Sets a callback that will be triggered when the system is disposed
  92368. */
  92369. set onDispose(callback: () => void);
  92370. private _particles;
  92371. private _epsilon;
  92372. private _capacity;
  92373. private _stockParticles;
  92374. private _newPartsExcess;
  92375. private _vertexData;
  92376. private _vertexBuffer;
  92377. private _vertexBuffers;
  92378. private _spriteBuffer;
  92379. private _indexBuffer;
  92380. private _effect;
  92381. private _customEffect;
  92382. private _cachedDefines;
  92383. private _scaledColorStep;
  92384. private _colorDiff;
  92385. private _scaledDirection;
  92386. private _scaledGravity;
  92387. private _currentRenderId;
  92388. private _alive;
  92389. private _useInstancing;
  92390. private _started;
  92391. private _stopped;
  92392. private _actualFrame;
  92393. private _scaledUpdateSpeed;
  92394. private _vertexBufferSize;
  92395. /** @hidden */
  92396. _currentEmitRateGradient: Nullable<FactorGradient>;
  92397. /** @hidden */
  92398. _currentEmitRate1: number;
  92399. /** @hidden */
  92400. _currentEmitRate2: number;
  92401. /** @hidden */
  92402. _currentStartSizeGradient: Nullable<FactorGradient>;
  92403. /** @hidden */
  92404. _currentStartSize1: number;
  92405. /** @hidden */
  92406. _currentStartSize2: number;
  92407. private readonly _rawTextureWidth;
  92408. private _rampGradientsTexture;
  92409. private _useRampGradients;
  92410. /** Gets or sets a matrix to use to compute projection */
  92411. defaultProjectionMatrix: Matrix;
  92412. /** Gets or sets a matrix to use to compute view */
  92413. defaultViewMatrix: Matrix;
  92414. /** Gets or sets a boolean indicating that ramp gradients must be used
  92415. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  92416. */
  92417. get useRampGradients(): boolean;
  92418. set useRampGradients(value: boolean);
  92419. /**
  92420. * 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.
  92421. * 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: [])
  92422. */
  92423. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  92424. private _subEmitters;
  92425. /**
  92426. * @hidden
  92427. * If the particle systems emitter should be disposed when the particle system is disposed
  92428. */
  92429. _disposeEmitterOnDispose: boolean;
  92430. /**
  92431. * The current active Sub-systems, this property is used by the root particle system only.
  92432. */
  92433. activeSubSystems: Array<ParticleSystem>;
  92434. /**
  92435. * Specifies if the particles are updated in emitter local space or world space
  92436. */
  92437. isLocal: boolean;
  92438. private _rootParticleSystem;
  92439. /**
  92440. * Gets the current list of active particles
  92441. */
  92442. get particles(): Particle[];
  92443. /**
  92444. * Gets the number of particles active at the same time.
  92445. * @returns The number of active particles.
  92446. */
  92447. getActiveCount(): number;
  92448. /**
  92449. * Returns the string "ParticleSystem"
  92450. * @returns a string containing the class name
  92451. */
  92452. getClassName(): string;
  92453. /**
  92454. * Gets a boolean indicating that the system is stopping
  92455. * @returns true if the system is currently stopping
  92456. */
  92457. isStopping(): boolean;
  92458. /**
  92459. * Gets the custom effect used to render the particles
  92460. * @param blendMode Blend mode for which the effect should be retrieved
  92461. * @returns The effect
  92462. */
  92463. getCustomEffect(blendMode?: number): Nullable<Effect>;
  92464. /**
  92465. * Sets the custom effect used to render the particles
  92466. * @param effect The effect to set
  92467. * @param blendMode Blend mode for which the effect should be set
  92468. */
  92469. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  92470. /** @hidden */
  92471. private _onBeforeDrawParticlesObservable;
  92472. /**
  92473. * Observable that will be called just before the particles are drawn
  92474. */
  92475. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  92476. /**
  92477. * Gets the name of the particle vertex shader
  92478. */
  92479. get vertexShaderName(): string;
  92480. /**
  92481. * Instantiates a particle system.
  92482. * 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.
  92483. * @param name The name of the particle system
  92484. * @param capacity The max number of particles alive at the same time
  92485. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  92486. * @param customEffect a custom effect used to change the way particles are rendered by default
  92487. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  92488. * @param epsilon Offset used to render the particles
  92489. */
  92490. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  92491. private _addFactorGradient;
  92492. private _removeFactorGradient;
  92493. /**
  92494. * Adds a new life time gradient
  92495. * @param gradient defines the gradient to use (between 0 and 1)
  92496. * @param factor defines the life time factor to affect to the specified gradient
  92497. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92498. * @returns the current particle system
  92499. */
  92500. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92501. /**
  92502. * Remove a specific life time gradient
  92503. * @param gradient defines the gradient to remove
  92504. * @returns the current particle system
  92505. */
  92506. removeLifeTimeGradient(gradient: number): IParticleSystem;
  92507. /**
  92508. * Adds a new size gradient
  92509. * @param gradient defines the gradient to use (between 0 and 1)
  92510. * @param factor defines the size factor to affect to the specified gradient
  92511. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92512. * @returns the current particle system
  92513. */
  92514. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92515. /**
  92516. * Remove a specific size gradient
  92517. * @param gradient defines the gradient to remove
  92518. * @returns the current particle system
  92519. */
  92520. removeSizeGradient(gradient: number): IParticleSystem;
  92521. /**
  92522. * Adds a new color remap gradient
  92523. * @param gradient defines the gradient to use (between 0 and 1)
  92524. * @param min defines the color remap minimal range
  92525. * @param max defines the color remap maximal range
  92526. * @returns the current particle system
  92527. */
  92528. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92529. /**
  92530. * Remove a specific color remap gradient
  92531. * @param gradient defines the gradient to remove
  92532. * @returns the current particle system
  92533. */
  92534. removeColorRemapGradient(gradient: number): IParticleSystem;
  92535. /**
  92536. * Adds a new alpha remap gradient
  92537. * @param gradient defines the gradient to use (between 0 and 1)
  92538. * @param min defines the alpha remap minimal range
  92539. * @param max defines the alpha remap maximal range
  92540. * @returns the current particle system
  92541. */
  92542. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92543. /**
  92544. * Remove a specific alpha remap gradient
  92545. * @param gradient defines the gradient to remove
  92546. * @returns the current particle system
  92547. */
  92548. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  92549. /**
  92550. * Adds a new angular speed gradient
  92551. * @param gradient defines the gradient to use (between 0 and 1)
  92552. * @param factor defines the angular speed to affect to the specified gradient
  92553. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92554. * @returns the current particle system
  92555. */
  92556. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92557. /**
  92558. * Remove a specific angular speed gradient
  92559. * @param gradient defines the gradient to remove
  92560. * @returns the current particle system
  92561. */
  92562. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  92563. /**
  92564. * Adds a new velocity gradient
  92565. * @param gradient defines the gradient to use (between 0 and 1)
  92566. * @param factor defines the velocity to affect to the specified gradient
  92567. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92568. * @returns the current particle system
  92569. */
  92570. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92571. /**
  92572. * Remove a specific velocity gradient
  92573. * @param gradient defines the gradient to remove
  92574. * @returns the current particle system
  92575. */
  92576. removeVelocityGradient(gradient: number): IParticleSystem;
  92577. /**
  92578. * Adds a new limit velocity gradient
  92579. * @param gradient defines the gradient to use (between 0 and 1)
  92580. * @param factor defines the limit velocity value to affect to the specified gradient
  92581. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92582. * @returns the current particle system
  92583. */
  92584. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92585. /**
  92586. * Remove a specific limit velocity gradient
  92587. * @param gradient defines the gradient to remove
  92588. * @returns the current particle system
  92589. */
  92590. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  92591. /**
  92592. * Adds a new drag gradient
  92593. * @param gradient defines the gradient to use (between 0 and 1)
  92594. * @param factor defines the drag value to affect to the specified gradient
  92595. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92596. * @returns the current particle system
  92597. */
  92598. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92599. /**
  92600. * Remove a specific drag gradient
  92601. * @param gradient defines the gradient to remove
  92602. * @returns the current particle system
  92603. */
  92604. removeDragGradient(gradient: number): IParticleSystem;
  92605. /**
  92606. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  92607. * @param gradient defines the gradient to use (between 0 and 1)
  92608. * @param factor defines the emit rate value to affect to the specified gradient
  92609. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92610. * @returns the current particle system
  92611. */
  92612. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92613. /**
  92614. * Remove a specific emit rate gradient
  92615. * @param gradient defines the gradient to remove
  92616. * @returns the current particle system
  92617. */
  92618. removeEmitRateGradient(gradient: number): IParticleSystem;
  92619. /**
  92620. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  92621. * @param gradient defines the gradient to use (between 0 and 1)
  92622. * @param factor defines the start size value to affect to the specified gradient
  92623. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92624. * @returns the current particle system
  92625. */
  92626. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92627. /**
  92628. * Remove a specific start size gradient
  92629. * @param gradient defines the gradient to remove
  92630. * @returns the current particle system
  92631. */
  92632. removeStartSizeGradient(gradient: number): IParticleSystem;
  92633. private _createRampGradientTexture;
  92634. /**
  92635. * Gets the current list of ramp gradients.
  92636. * You must use addRampGradient and removeRampGradient to udpate this list
  92637. * @returns the list of ramp gradients
  92638. */
  92639. getRampGradients(): Nullable<Array<Color3Gradient>>;
  92640. /** Force the system to rebuild all gradients that need to be resync */
  92641. forceRefreshGradients(): void;
  92642. private _syncRampGradientTexture;
  92643. /**
  92644. * Adds a new ramp gradient used to remap particle colors
  92645. * @param gradient defines the gradient to use (between 0 and 1)
  92646. * @param color defines the color to affect to the specified gradient
  92647. * @returns the current particle system
  92648. */
  92649. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  92650. /**
  92651. * Remove a specific ramp gradient
  92652. * @param gradient defines the gradient to remove
  92653. * @returns the current particle system
  92654. */
  92655. removeRampGradient(gradient: number): ParticleSystem;
  92656. /**
  92657. * Adds a new color gradient
  92658. * @param gradient defines the gradient to use (between 0 and 1)
  92659. * @param color1 defines the color to affect to the specified gradient
  92660. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  92661. * @returns this particle system
  92662. */
  92663. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  92664. /**
  92665. * Remove a specific color gradient
  92666. * @param gradient defines the gradient to remove
  92667. * @returns this particle system
  92668. */
  92669. removeColorGradient(gradient: number): IParticleSystem;
  92670. private _fetchR;
  92671. protected _reset(): void;
  92672. private _resetEffect;
  92673. private _createVertexBuffers;
  92674. private _createIndexBuffer;
  92675. /**
  92676. * Gets the maximum number of particles active at the same time.
  92677. * @returns The max number of active particles.
  92678. */
  92679. getCapacity(): number;
  92680. /**
  92681. * Gets whether there are still active particles in the system.
  92682. * @returns True if it is alive, otherwise false.
  92683. */
  92684. isAlive(): boolean;
  92685. /**
  92686. * Gets if the system has been started. (Note: this will still be true after stop is called)
  92687. * @returns True if it has been started, otherwise false.
  92688. */
  92689. isStarted(): boolean;
  92690. private _prepareSubEmitterInternalArray;
  92691. /**
  92692. * Starts the particle system and begins to emit
  92693. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  92694. */
  92695. start(delay?: number): void;
  92696. /**
  92697. * Stops the particle system.
  92698. * @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.
  92699. */
  92700. stop(stopSubEmitters?: boolean): void;
  92701. /**
  92702. * Remove all active particles
  92703. */
  92704. reset(): void;
  92705. /**
  92706. * @hidden (for internal use only)
  92707. */
  92708. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  92709. /**
  92710. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  92711. * Its lifetime will start back at 0.
  92712. */
  92713. recycleParticle: (particle: Particle) => void;
  92714. private _stopSubEmitters;
  92715. private _createParticle;
  92716. private _removeFromRoot;
  92717. private _emitFromParticle;
  92718. private _update;
  92719. /** @hidden */
  92720. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  92721. /** @hidden */
  92722. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  92723. /**
  92724. * Fill the defines array according to the current settings of the particle system
  92725. * @param defines Array to be updated
  92726. * @param blendMode blend mode to take into account when updating the array
  92727. */
  92728. fillDefines(defines: Array<string>, blendMode: number): void;
  92729. /**
  92730. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  92731. * @param uniforms Uniforms array to fill
  92732. * @param attributes Attributes array to fill
  92733. * @param samplers Samplers array to fill
  92734. */
  92735. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  92736. /** @hidden */
  92737. private _getEffect;
  92738. /**
  92739. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  92740. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  92741. */
  92742. animate(preWarmOnly?: boolean): void;
  92743. private _appendParticleVertices;
  92744. /**
  92745. * Rebuilds the particle system.
  92746. */
  92747. rebuild(): void;
  92748. /**
  92749. * Is this system ready to be used/rendered
  92750. * @return true if the system is ready
  92751. */
  92752. isReady(): boolean;
  92753. private _render;
  92754. /**
  92755. * Renders the particle system in its current state.
  92756. * @returns the current number of particles
  92757. */
  92758. render(): number;
  92759. /**
  92760. * Disposes the particle system and free the associated resources
  92761. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  92762. */
  92763. dispose(disposeTexture?: boolean): void;
  92764. /**
  92765. * Clones the particle system.
  92766. * @param name The name of the cloned object
  92767. * @param newEmitter The new emitter to use
  92768. * @returns the cloned particle system
  92769. */
  92770. clone(name: string, newEmitter: any): ParticleSystem;
  92771. /**
  92772. * Serializes the particle system to a JSON object
  92773. * @param serializeTexture defines if the texture must be serialized as well
  92774. * @returns the JSON object
  92775. */
  92776. serialize(serializeTexture?: boolean): any;
  92777. /** @hidden */
  92778. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  92779. /** @hidden */
  92780. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  92781. /**
  92782. * Parses a JSON object to create a particle system.
  92783. * @param parsedParticleSystem The JSON object to parse
  92784. * @param sceneOrEngine The scene or the engine to create the particle system in
  92785. * @param rootUrl The root url to use to load external dependencies like texture
  92786. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  92787. * @returns the Parsed particle system
  92788. */
  92789. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  92790. }
  92791. }
  92792. declare module BABYLON {
  92793. /**
  92794. * A particle represents one of the element emitted by a particle system.
  92795. * This is mainly define by its coordinates, direction, velocity and age.
  92796. */
  92797. export class Particle {
  92798. /**
  92799. * The particle system the particle belongs to.
  92800. */
  92801. particleSystem: ParticleSystem;
  92802. private static _Count;
  92803. /**
  92804. * Unique ID of the particle
  92805. */
  92806. id: number;
  92807. /**
  92808. * The world position of the particle in the scene.
  92809. */
  92810. position: Vector3;
  92811. /**
  92812. * The world direction of the particle in the scene.
  92813. */
  92814. direction: Vector3;
  92815. /**
  92816. * The color of the particle.
  92817. */
  92818. color: Color4;
  92819. /**
  92820. * The color change of the particle per step.
  92821. */
  92822. colorStep: Color4;
  92823. /**
  92824. * Defines how long will the life of the particle be.
  92825. */
  92826. lifeTime: number;
  92827. /**
  92828. * The current age of the particle.
  92829. */
  92830. age: number;
  92831. /**
  92832. * The current size of the particle.
  92833. */
  92834. size: number;
  92835. /**
  92836. * The current scale of the particle.
  92837. */
  92838. scale: Vector2;
  92839. /**
  92840. * The current angle of the particle.
  92841. */
  92842. angle: number;
  92843. /**
  92844. * Defines how fast is the angle changing.
  92845. */
  92846. angularSpeed: number;
  92847. /**
  92848. * Defines the cell index used by the particle to be rendered from a sprite.
  92849. */
  92850. cellIndex: number;
  92851. /**
  92852. * The information required to support color remapping
  92853. */
  92854. remapData: Vector4;
  92855. /** @hidden */
  92856. _randomCellOffset?: number;
  92857. /** @hidden */
  92858. _initialDirection: Nullable<Vector3>;
  92859. /** @hidden */
  92860. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  92861. /** @hidden */
  92862. _initialStartSpriteCellID: number;
  92863. /** @hidden */
  92864. _initialEndSpriteCellID: number;
  92865. /** @hidden */
  92866. _currentColorGradient: Nullable<ColorGradient>;
  92867. /** @hidden */
  92868. _currentColor1: Color4;
  92869. /** @hidden */
  92870. _currentColor2: Color4;
  92871. /** @hidden */
  92872. _currentSizeGradient: Nullable<FactorGradient>;
  92873. /** @hidden */
  92874. _currentSize1: number;
  92875. /** @hidden */
  92876. _currentSize2: number;
  92877. /** @hidden */
  92878. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  92879. /** @hidden */
  92880. _currentAngularSpeed1: number;
  92881. /** @hidden */
  92882. _currentAngularSpeed2: number;
  92883. /** @hidden */
  92884. _currentVelocityGradient: Nullable<FactorGradient>;
  92885. /** @hidden */
  92886. _currentVelocity1: number;
  92887. /** @hidden */
  92888. _currentVelocity2: number;
  92889. /** @hidden */
  92890. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  92891. /** @hidden */
  92892. _currentLimitVelocity1: number;
  92893. /** @hidden */
  92894. _currentLimitVelocity2: number;
  92895. /** @hidden */
  92896. _currentDragGradient: Nullable<FactorGradient>;
  92897. /** @hidden */
  92898. _currentDrag1: number;
  92899. /** @hidden */
  92900. _currentDrag2: number;
  92901. /** @hidden */
  92902. _randomNoiseCoordinates1: Vector3;
  92903. /** @hidden */
  92904. _randomNoiseCoordinates2: Vector3;
  92905. /** @hidden */
  92906. _localPosition?: Vector3;
  92907. /**
  92908. * Creates a new instance Particle
  92909. * @param particleSystem the particle system the particle belongs to
  92910. */
  92911. constructor(
  92912. /**
  92913. * The particle system the particle belongs to.
  92914. */
  92915. particleSystem: ParticleSystem);
  92916. private updateCellInfoFromSystem;
  92917. /**
  92918. * Defines how the sprite cell index is updated for the particle
  92919. */
  92920. updateCellIndex(): void;
  92921. /** @hidden */
  92922. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  92923. /** @hidden */
  92924. _inheritParticleInfoToSubEmitters(): void;
  92925. /** @hidden */
  92926. _reset(): void;
  92927. /**
  92928. * Copy the properties of particle to another one.
  92929. * @param other the particle to copy the information to.
  92930. */
  92931. copyTo(other: Particle): void;
  92932. }
  92933. }
  92934. declare module BABYLON {
  92935. /**
  92936. * Particle emitter represents a volume emitting particles.
  92937. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  92938. */
  92939. export interface IParticleEmitterType {
  92940. /**
  92941. * Called by the particle System when the direction is computed for the created particle.
  92942. * @param worldMatrix is the world matrix of the particle system
  92943. * @param directionToUpdate is the direction vector to update with the result
  92944. * @param particle is the particle we are computed the direction for
  92945. * @param isLocal defines if the direction should be set in local space
  92946. */
  92947. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92948. /**
  92949. * Called by the particle System when the position is computed for the created particle.
  92950. * @param worldMatrix is the world matrix of the particle system
  92951. * @param positionToUpdate is the position vector to update with the result
  92952. * @param particle is the particle we are computed the position for
  92953. * @param isLocal defines if the position should be set in local space
  92954. */
  92955. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92956. /**
  92957. * Clones the current emitter and returns a copy of it
  92958. * @returns the new emitter
  92959. */
  92960. clone(): IParticleEmitterType;
  92961. /**
  92962. * Called by the GPUParticleSystem to setup the update shader
  92963. * @param effect defines the update shader
  92964. */
  92965. applyToShader(effect: Effect): void;
  92966. /**
  92967. * Returns a string to use to update the GPU particles update shader
  92968. * @returns the effect defines string
  92969. */
  92970. getEffectDefines(): string;
  92971. /**
  92972. * Returns a string representing the class name
  92973. * @returns a string containing the class name
  92974. */
  92975. getClassName(): string;
  92976. /**
  92977. * Serializes the particle system to a JSON object.
  92978. * @returns the JSON object
  92979. */
  92980. serialize(): any;
  92981. /**
  92982. * Parse properties from a JSON object
  92983. * @param serializationObject defines the JSON object
  92984. * @param scene defines the hosting scene
  92985. */
  92986. parse(serializationObject: any, scene: Nullable<Scene>): void;
  92987. }
  92988. }
  92989. declare module BABYLON {
  92990. /**
  92991. * Particle emitter emitting particles from the inside of a box.
  92992. * It emits the particles randomly between 2 given directions.
  92993. */
  92994. export class BoxParticleEmitter implements IParticleEmitterType {
  92995. /**
  92996. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92997. */
  92998. direction1: Vector3;
  92999. /**
  93000. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93001. */
  93002. direction2: Vector3;
  93003. /**
  93004. * 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.
  93005. */
  93006. minEmitBox: Vector3;
  93007. /**
  93008. * 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.
  93009. */
  93010. maxEmitBox: Vector3;
  93011. /**
  93012. * Creates a new instance BoxParticleEmitter
  93013. */
  93014. constructor();
  93015. /**
  93016. * Called by the particle System when the direction is computed for the created particle.
  93017. * @param worldMatrix is the world matrix of the particle system
  93018. * @param directionToUpdate is the direction vector to update with the result
  93019. * @param particle is the particle we are computed the direction for
  93020. * @param isLocal defines if the direction should be set in local space
  93021. */
  93022. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93023. /**
  93024. * Called by the particle System when the position is computed for the created particle.
  93025. * @param worldMatrix is the world matrix of the particle system
  93026. * @param positionToUpdate is the position vector to update with the result
  93027. * @param particle is the particle we are computed the position for
  93028. * @param isLocal defines if the position should be set in local space
  93029. */
  93030. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93031. /**
  93032. * Clones the current emitter and returns a copy of it
  93033. * @returns the new emitter
  93034. */
  93035. clone(): BoxParticleEmitter;
  93036. /**
  93037. * Called by the GPUParticleSystem to setup the update shader
  93038. * @param effect defines the update shader
  93039. */
  93040. applyToShader(effect: Effect): void;
  93041. /**
  93042. * Returns a string to use to update the GPU particles update shader
  93043. * @returns a string containng the defines string
  93044. */
  93045. getEffectDefines(): string;
  93046. /**
  93047. * Returns the string "BoxParticleEmitter"
  93048. * @returns a string containing the class name
  93049. */
  93050. getClassName(): string;
  93051. /**
  93052. * Serializes the particle system to a JSON object.
  93053. * @returns the JSON object
  93054. */
  93055. serialize(): any;
  93056. /**
  93057. * Parse properties from a JSON object
  93058. * @param serializationObject defines the JSON object
  93059. */
  93060. parse(serializationObject: any): void;
  93061. }
  93062. }
  93063. declare module BABYLON {
  93064. /**
  93065. * Particle emitter emitting particles from the inside of a cone.
  93066. * It emits the particles alongside the cone volume from the base to the particle.
  93067. * The emission direction might be randomized.
  93068. */
  93069. export class ConeParticleEmitter implements IParticleEmitterType {
  93070. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93071. directionRandomizer: number;
  93072. private _radius;
  93073. private _angle;
  93074. private _height;
  93075. /**
  93076. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  93077. */
  93078. radiusRange: number;
  93079. /**
  93080. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  93081. */
  93082. heightRange: number;
  93083. /**
  93084. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  93085. */
  93086. emitFromSpawnPointOnly: boolean;
  93087. /**
  93088. * Gets or sets the radius of the emission cone
  93089. */
  93090. get radius(): number;
  93091. set radius(value: number);
  93092. /**
  93093. * Gets or sets the angle of the emission cone
  93094. */
  93095. get angle(): number;
  93096. set angle(value: number);
  93097. private _buildHeight;
  93098. /**
  93099. * Creates a new instance ConeParticleEmitter
  93100. * @param radius the radius of the emission cone (1 by default)
  93101. * @param angle the cone base angle (PI by default)
  93102. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  93103. */
  93104. constructor(radius?: number, angle?: number,
  93105. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93106. directionRandomizer?: number);
  93107. /**
  93108. * Called by the particle System when the direction is computed for the created particle.
  93109. * @param worldMatrix is the world matrix of the particle system
  93110. * @param directionToUpdate is the direction vector to update with the result
  93111. * @param particle is the particle we are computed the direction for
  93112. * @param isLocal defines if the direction should be set in local space
  93113. */
  93114. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93115. /**
  93116. * Called by the particle System when the position is computed for the created particle.
  93117. * @param worldMatrix is the world matrix of the particle system
  93118. * @param positionToUpdate is the position vector to update with the result
  93119. * @param particle is the particle we are computed the position for
  93120. * @param isLocal defines if the position should be set in local space
  93121. */
  93122. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93123. /**
  93124. * Clones the current emitter and returns a copy of it
  93125. * @returns the new emitter
  93126. */
  93127. clone(): ConeParticleEmitter;
  93128. /**
  93129. * Called by the GPUParticleSystem to setup the update shader
  93130. * @param effect defines the update shader
  93131. */
  93132. applyToShader(effect: Effect): void;
  93133. /**
  93134. * Returns a string to use to update the GPU particles update shader
  93135. * @returns a string containng the defines string
  93136. */
  93137. getEffectDefines(): string;
  93138. /**
  93139. * Returns the string "ConeParticleEmitter"
  93140. * @returns a string containing the class name
  93141. */
  93142. getClassName(): string;
  93143. /**
  93144. * Serializes the particle system to a JSON object.
  93145. * @returns the JSON object
  93146. */
  93147. serialize(): any;
  93148. /**
  93149. * Parse properties from a JSON object
  93150. * @param serializationObject defines the JSON object
  93151. */
  93152. parse(serializationObject: any): void;
  93153. }
  93154. }
  93155. declare module BABYLON {
  93156. /**
  93157. * Particle emitter emitting particles from the inside of a cylinder.
  93158. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  93159. */
  93160. export class CylinderParticleEmitter implements IParticleEmitterType {
  93161. /**
  93162. * The radius of the emission cylinder.
  93163. */
  93164. radius: number;
  93165. /**
  93166. * The height of the emission cylinder.
  93167. */
  93168. height: number;
  93169. /**
  93170. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93171. */
  93172. radiusRange: number;
  93173. /**
  93174. * How much to randomize the particle direction [0-1].
  93175. */
  93176. directionRandomizer: number;
  93177. /**
  93178. * Creates a new instance CylinderParticleEmitter
  93179. * @param radius the radius of the emission cylinder (1 by default)
  93180. * @param height the height of the emission cylinder (1 by default)
  93181. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93182. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93183. */
  93184. constructor(
  93185. /**
  93186. * The radius of the emission cylinder.
  93187. */
  93188. radius?: number,
  93189. /**
  93190. * The height of the emission cylinder.
  93191. */
  93192. height?: number,
  93193. /**
  93194. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93195. */
  93196. radiusRange?: number,
  93197. /**
  93198. * How much to randomize the particle direction [0-1].
  93199. */
  93200. directionRandomizer?: number);
  93201. /**
  93202. * Called by the particle System when the direction is computed for the created particle.
  93203. * @param worldMatrix is the world matrix of the particle system
  93204. * @param directionToUpdate is the direction vector to update with the result
  93205. * @param particle is the particle we are computed the direction for
  93206. * @param isLocal defines if the direction should be set in local space
  93207. */
  93208. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93209. /**
  93210. * Called by the particle System when the position is computed for the created particle.
  93211. * @param worldMatrix is the world matrix of the particle system
  93212. * @param positionToUpdate is the position vector to update with the result
  93213. * @param particle is the particle we are computed the position for
  93214. * @param isLocal defines if the position should be set in local space
  93215. */
  93216. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93217. /**
  93218. * Clones the current emitter and returns a copy of it
  93219. * @returns the new emitter
  93220. */
  93221. clone(): CylinderParticleEmitter;
  93222. /**
  93223. * Called by the GPUParticleSystem to setup the update shader
  93224. * @param effect defines the update shader
  93225. */
  93226. applyToShader(effect: Effect): void;
  93227. /**
  93228. * Returns a string to use to update the GPU particles update shader
  93229. * @returns a string containng the defines string
  93230. */
  93231. getEffectDefines(): string;
  93232. /**
  93233. * Returns the string "CylinderParticleEmitter"
  93234. * @returns a string containing the class name
  93235. */
  93236. getClassName(): string;
  93237. /**
  93238. * Serializes the particle system to a JSON object.
  93239. * @returns the JSON object
  93240. */
  93241. serialize(): any;
  93242. /**
  93243. * Parse properties from a JSON object
  93244. * @param serializationObject defines the JSON object
  93245. */
  93246. parse(serializationObject: any): void;
  93247. }
  93248. /**
  93249. * Particle emitter emitting particles from the inside of a cylinder.
  93250. * It emits the particles randomly between two vectors.
  93251. */
  93252. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  93253. /**
  93254. * The min limit of the emission direction.
  93255. */
  93256. direction1: Vector3;
  93257. /**
  93258. * The max limit of the emission direction.
  93259. */
  93260. direction2: Vector3;
  93261. /**
  93262. * Creates a new instance CylinderDirectedParticleEmitter
  93263. * @param radius the radius of the emission cylinder (1 by default)
  93264. * @param height the height of the emission cylinder (1 by default)
  93265. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93266. * @param direction1 the min limit of the emission direction (up vector by default)
  93267. * @param direction2 the max limit of the emission direction (up vector by default)
  93268. */
  93269. constructor(radius?: number, height?: number, radiusRange?: number,
  93270. /**
  93271. * The min limit of the emission direction.
  93272. */
  93273. direction1?: Vector3,
  93274. /**
  93275. * The max limit of the emission direction.
  93276. */
  93277. direction2?: Vector3);
  93278. /**
  93279. * Called by the particle System when the direction is computed for the created particle.
  93280. * @param worldMatrix is the world matrix of the particle system
  93281. * @param directionToUpdate is the direction vector to update with the result
  93282. * @param particle is the particle we are computed the direction for
  93283. */
  93284. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  93285. /**
  93286. * Clones the current emitter and returns a copy of it
  93287. * @returns the new emitter
  93288. */
  93289. clone(): CylinderDirectedParticleEmitter;
  93290. /**
  93291. * Called by the GPUParticleSystem to setup the update shader
  93292. * @param effect defines the update shader
  93293. */
  93294. applyToShader(effect: Effect): void;
  93295. /**
  93296. * Returns a string to use to update the GPU particles update shader
  93297. * @returns a string containng the defines string
  93298. */
  93299. getEffectDefines(): string;
  93300. /**
  93301. * Returns the string "CylinderDirectedParticleEmitter"
  93302. * @returns a string containing the class name
  93303. */
  93304. getClassName(): string;
  93305. /**
  93306. * Serializes the particle system to a JSON object.
  93307. * @returns the JSON object
  93308. */
  93309. serialize(): any;
  93310. /**
  93311. * Parse properties from a JSON object
  93312. * @param serializationObject defines the JSON object
  93313. */
  93314. parse(serializationObject: any): void;
  93315. }
  93316. }
  93317. declare module BABYLON {
  93318. /**
  93319. * Particle emitter emitting particles from the inside of a hemisphere.
  93320. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  93321. */
  93322. export class HemisphericParticleEmitter implements IParticleEmitterType {
  93323. /**
  93324. * The radius of the emission hemisphere.
  93325. */
  93326. radius: number;
  93327. /**
  93328. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93329. */
  93330. radiusRange: number;
  93331. /**
  93332. * How much to randomize the particle direction [0-1].
  93333. */
  93334. directionRandomizer: number;
  93335. /**
  93336. * Creates a new instance HemisphericParticleEmitter
  93337. * @param radius the radius of the emission hemisphere (1 by default)
  93338. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93339. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93340. */
  93341. constructor(
  93342. /**
  93343. * The radius of the emission hemisphere.
  93344. */
  93345. radius?: number,
  93346. /**
  93347. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93348. */
  93349. radiusRange?: number,
  93350. /**
  93351. * How much to randomize the particle direction [0-1].
  93352. */
  93353. directionRandomizer?: number);
  93354. /**
  93355. * Called by the particle System when the direction is computed for the created particle.
  93356. * @param worldMatrix is the world matrix of the particle system
  93357. * @param directionToUpdate is the direction vector to update with the result
  93358. * @param particle is the particle we are computed the direction for
  93359. * @param isLocal defines if the direction should be set in local space
  93360. */
  93361. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93362. /**
  93363. * Called by the particle System when the position is computed for the created particle.
  93364. * @param worldMatrix is the world matrix of the particle system
  93365. * @param positionToUpdate is the position vector to update with the result
  93366. * @param particle is the particle we are computed the position for
  93367. * @param isLocal defines if the position should be set in local space
  93368. */
  93369. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93370. /**
  93371. * Clones the current emitter and returns a copy of it
  93372. * @returns the new emitter
  93373. */
  93374. clone(): HemisphericParticleEmitter;
  93375. /**
  93376. * Called by the GPUParticleSystem to setup the update shader
  93377. * @param effect defines the update shader
  93378. */
  93379. applyToShader(effect: Effect): void;
  93380. /**
  93381. * Returns a string to use to update the GPU particles update shader
  93382. * @returns a string containng the defines string
  93383. */
  93384. getEffectDefines(): string;
  93385. /**
  93386. * Returns the string "HemisphericParticleEmitter"
  93387. * @returns a string containing the class name
  93388. */
  93389. getClassName(): string;
  93390. /**
  93391. * Serializes the particle system to a JSON object.
  93392. * @returns the JSON object
  93393. */
  93394. serialize(): any;
  93395. /**
  93396. * Parse properties from a JSON object
  93397. * @param serializationObject defines the JSON object
  93398. */
  93399. parse(serializationObject: any): void;
  93400. }
  93401. }
  93402. declare module BABYLON {
  93403. /**
  93404. * Particle emitter emitting particles from a point.
  93405. * It emits the particles randomly between 2 given directions.
  93406. */
  93407. export class PointParticleEmitter implements IParticleEmitterType {
  93408. /**
  93409. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93410. */
  93411. direction1: Vector3;
  93412. /**
  93413. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93414. */
  93415. direction2: Vector3;
  93416. /**
  93417. * Creates a new instance PointParticleEmitter
  93418. */
  93419. constructor();
  93420. /**
  93421. * Called by the particle System when the direction is computed for the created particle.
  93422. * @param worldMatrix is the world matrix of the particle system
  93423. * @param directionToUpdate is the direction vector to update with the result
  93424. * @param particle is the particle we are computed the direction for
  93425. * @param isLocal defines if the direction should be set in local space
  93426. */
  93427. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93428. /**
  93429. * Called by the particle System when the position is computed for the created particle.
  93430. * @param worldMatrix is the world matrix of the particle system
  93431. * @param positionToUpdate is the position vector to update with the result
  93432. * @param particle is the particle we are computed the position for
  93433. * @param isLocal defines if the position should be set in local space
  93434. */
  93435. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93436. /**
  93437. * Clones the current emitter and returns a copy of it
  93438. * @returns the new emitter
  93439. */
  93440. clone(): PointParticleEmitter;
  93441. /**
  93442. * Called by the GPUParticleSystem to setup the update shader
  93443. * @param effect defines the update shader
  93444. */
  93445. applyToShader(effect: Effect): void;
  93446. /**
  93447. * Returns a string to use to update the GPU particles update shader
  93448. * @returns a string containng the defines string
  93449. */
  93450. getEffectDefines(): string;
  93451. /**
  93452. * Returns the string "PointParticleEmitter"
  93453. * @returns a string containing the class name
  93454. */
  93455. getClassName(): string;
  93456. /**
  93457. * Serializes the particle system to a JSON object.
  93458. * @returns the JSON object
  93459. */
  93460. serialize(): any;
  93461. /**
  93462. * Parse properties from a JSON object
  93463. * @param serializationObject defines the JSON object
  93464. */
  93465. parse(serializationObject: any): void;
  93466. }
  93467. }
  93468. declare module BABYLON {
  93469. /**
  93470. * Particle emitter emitting particles from the inside of a sphere.
  93471. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  93472. */
  93473. export class SphereParticleEmitter implements IParticleEmitterType {
  93474. /**
  93475. * The radius of the emission sphere.
  93476. */
  93477. radius: number;
  93478. /**
  93479. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93480. */
  93481. radiusRange: number;
  93482. /**
  93483. * How much to randomize the particle direction [0-1].
  93484. */
  93485. directionRandomizer: number;
  93486. /**
  93487. * Creates a new instance SphereParticleEmitter
  93488. * @param radius the radius of the emission sphere (1 by default)
  93489. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93490. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93491. */
  93492. constructor(
  93493. /**
  93494. * The radius of the emission sphere.
  93495. */
  93496. radius?: number,
  93497. /**
  93498. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93499. */
  93500. radiusRange?: number,
  93501. /**
  93502. * How much to randomize the particle direction [0-1].
  93503. */
  93504. directionRandomizer?: number);
  93505. /**
  93506. * Called by the particle System when the direction is computed for the created particle.
  93507. * @param worldMatrix is the world matrix of the particle system
  93508. * @param directionToUpdate is the direction vector to update with the result
  93509. * @param particle is the particle we are computed the direction for
  93510. * @param isLocal defines if the direction should be set in local space
  93511. */
  93512. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93513. /**
  93514. * Called by the particle System when the position is computed for the created particle.
  93515. * @param worldMatrix is the world matrix of the particle system
  93516. * @param positionToUpdate is the position vector to update with the result
  93517. * @param particle is the particle we are computed the position for
  93518. * @param isLocal defines if the position should be set in local space
  93519. */
  93520. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93521. /**
  93522. * Clones the current emitter and returns a copy of it
  93523. * @returns the new emitter
  93524. */
  93525. clone(): SphereParticleEmitter;
  93526. /**
  93527. * Called by the GPUParticleSystem to setup the update shader
  93528. * @param effect defines the update shader
  93529. */
  93530. applyToShader(effect: Effect): void;
  93531. /**
  93532. * Returns a string to use to update the GPU particles update shader
  93533. * @returns a string containng the defines string
  93534. */
  93535. getEffectDefines(): string;
  93536. /**
  93537. * Returns the string "SphereParticleEmitter"
  93538. * @returns a string containing the class name
  93539. */
  93540. getClassName(): string;
  93541. /**
  93542. * Serializes the particle system to a JSON object.
  93543. * @returns the JSON object
  93544. */
  93545. serialize(): any;
  93546. /**
  93547. * Parse properties from a JSON object
  93548. * @param serializationObject defines the JSON object
  93549. */
  93550. parse(serializationObject: any): void;
  93551. }
  93552. /**
  93553. * Particle emitter emitting particles from the inside of a sphere.
  93554. * It emits the particles randomly between two vectors.
  93555. */
  93556. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  93557. /**
  93558. * The min limit of the emission direction.
  93559. */
  93560. direction1: Vector3;
  93561. /**
  93562. * The max limit of the emission direction.
  93563. */
  93564. direction2: Vector3;
  93565. /**
  93566. * Creates a new instance SphereDirectedParticleEmitter
  93567. * @param radius the radius of the emission sphere (1 by default)
  93568. * @param direction1 the min limit of the emission direction (up vector by default)
  93569. * @param direction2 the max limit of the emission direction (up vector by default)
  93570. */
  93571. constructor(radius?: number,
  93572. /**
  93573. * The min limit of the emission direction.
  93574. */
  93575. direction1?: Vector3,
  93576. /**
  93577. * The max limit of the emission direction.
  93578. */
  93579. direction2?: Vector3);
  93580. /**
  93581. * Called by the particle System when the direction is computed for the created particle.
  93582. * @param worldMatrix is the world matrix of the particle system
  93583. * @param directionToUpdate is the direction vector to update with the result
  93584. * @param particle is the particle we are computed the direction for
  93585. */
  93586. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  93587. /**
  93588. * Clones the current emitter and returns a copy of it
  93589. * @returns the new emitter
  93590. */
  93591. clone(): SphereDirectedParticleEmitter;
  93592. /**
  93593. * Called by the GPUParticleSystem to setup the update shader
  93594. * @param effect defines the update shader
  93595. */
  93596. applyToShader(effect: Effect): void;
  93597. /**
  93598. * Returns a string to use to update the GPU particles update shader
  93599. * @returns a string containng the defines string
  93600. */
  93601. getEffectDefines(): string;
  93602. /**
  93603. * Returns the string "SphereDirectedParticleEmitter"
  93604. * @returns a string containing the class name
  93605. */
  93606. getClassName(): string;
  93607. /**
  93608. * Serializes the particle system to a JSON object.
  93609. * @returns the JSON object
  93610. */
  93611. serialize(): any;
  93612. /**
  93613. * Parse properties from a JSON object
  93614. * @param serializationObject defines the JSON object
  93615. */
  93616. parse(serializationObject: any): void;
  93617. }
  93618. }
  93619. declare module BABYLON {
  93620. /**
  93621. * Particle emitter emitting particles from a custom list of positions.
  93622. */
  93623. export class CustomParticleEmitter implements IParticleEmitterType {
  93624. /**
  93625. * Gets or sets the position generator that will create the inital position of each particle.
  93626. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  93627. */
  93628. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  93629. /**
  93630. * Gets or sets the destination generator that will create the final destination of each particle.
  93631. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  93632. */
  93633. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  93634. /**
  93635. * Creates a new instance CustomParticleEmitter
  93636. */
  93637. constructor();
  93638. /**
  93639. * Called by the particle System when the direction is computed for the created particle.
  93640. * @param worldMatrix is the world matrix of the particle system
  93641. * @param directionToUpdate is the direction vector to update with the result
  93642. * @param particle is the particle we are computed the direction for
  93643. * @param isLocal defines if the direction should be set in local space
  93644. */
  93645. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93646. /**
  93647. * Called by the particle System when the position is computed for the created particle.
  93648. * @param worldMatrix is the world matrix of the particle system
  93649. * @param positionToUpdate is the position vector to update with the result
  93650. * @param particle is the particle we are computed the position for
  93651. * @param isLocal defines if the position should be set in local space
  93652. */
  93653. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93654. /**
  93655. * Clones the current emitter and returns a copy of it
  93656. * @returns the new emitter
  93657. */
  93658. clone(): CustomParticleEmitter;
  93659. /**
  93660. * Called by the GPUParticleSystem to setup the update shader
  93661. * @param effect defines the update shader
  93662. */
  93663. applyToShader(effect: Effect): void;
  93664. /**
  93665. * Returns a string to use to update the GPU particles update shader
  93666. * @returns a string containng the defines string
  93667. */
  93668. getEffectDefines(): string;
  93669. /**
  93670. * Returns the string "PointParticleEmitter"
  93671. * @returns a string containing the class name
  93672. */
  93673. getClassName(): string;
  93674. /**
  93675. * Serializes the particle system to a JSON object.
  93676. * @returns the JSON object
  93677. */
  93678. serialize(): any;
  93679. /**
  93680. * Parse properties from a JSON object
  93681. * @param serializationObject defines the JSON object
  93682. */
  93683. parse(serializationObject: any): void;
  93684. }
  93685. }
  93686. declare module BABYLON {
  93687. /**
  93688. * Particle emitter emitting particles from the inside of a box.
  93689. * It emits the particles randomly between 2 given directions.
  93690. */
  93691. export class MeshParticleEmitter implements IParticleEmitterType {
  93692. private _indices;
  93693. private _positions;
  93694. private _normals;
  93695. private _storedNormal;
  93696. private _mesh;
  93697. /**
  93698. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93699. */
  93700. direction1: Vector3;
  93701. /**
  93702. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93703. */
  93704. direction2: Vector3;
  93705. /**
  93706. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  93707. */
  93708. useMeshNormalsForDirection: boolean;
  93709. /** Defines the mesh to use as source */
  93710. get mesh(): Nullable<AbstractMesh>;
  93711. set mesh(value: Nullable<AbstractMesh>);
  93712. /**
  93713. * Creates a new instance MeshParticleEmitter
  93714. * @param mesh defines the mesh to use as source
  93715. */
  93716. constructor(mesh?: Nullable<AbstractMesh>);
  93717. /**
  93718. * Called by the particle System when the direction is computed for the created particle.
  93719. * @param worldMatrix is the world matrix of the particle system
  93720. * @param directionToUpdate is the direction vector to update with the result
  93721. * @param particle is the particle we are computed the direction for
  93722. * @param isLocal defines if the direction should be set in local space
  93723. */
  93724. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93725. /**
  93726. * Called by the particle System when the position is computed for the created particle.
  93727. * @param worldMatrix is the world matrix of the particle system
  93728. * @param positionToUpdate is the position vector to update with the result
  93729. * @param particle is the particle we are computed the position for
  93730. * @param isLocal defines if the position should be set in local space
  93731. */
  93732. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93733. /**
  93734. * Clones the current emitter and returns a copy of it
  93735. * @returns the new emitter
  93736. */
  93737. clone(): MeshParticleEmitter;
  93738. /**
  93739. * Called by the GPUParticleSystem to setup the update shader
  93740. * @param effect defines the update shader
  93741. */
  93742. applyToShader(effect: Effect): void;
  93743. /**
  93744. * Returns a string to use to update the GPU particles update shader
  93745. * @returns a string containng the defines string
  93746. */
  93747. getEffectDefines(): string;
  93748. /**
  93749. * Returns the string "BoxParticleEmitter"
  93750. * @returns a string containing the class name
  93751. */
  93752. getClassName(): string;
  93753. /**
  93754. * Serializes the particle system to a JSON object.
  93755. * @returns the JSON object
  93756. */
  93757. serialize(): any;
  93758. /**
  93759. * Parse properties from a JSON object
  93760. * @param serializationObject defines the JSON object
  93761. * @param scene defines the hosting scene
  93762. */
  93763. parse(serializationObject: any, scene: Nullable<Scene>): void;
  93764. }
  93765. }
  93766. declare module BABYLON {
  93767. /**
  93768. * Interface representing a particle system in Babylon.js.
  93769. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  93770. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  93771. */
  93772. export interface IParticleSystem {
  93773. /**
  93774. * List of animations used by the particle system.
  93775. */
  93776. animations: Animation[];
  93777. /**
  93778. * The id of the Particle system.
  93779. */
  93780. id: string;
  93781. /**
  93782. * The name of the Particle system.
  93783. */
  93784. name: string;
  93785. /**
  93786. * The emitter represents the Mesh or position we are attaching the particle system to.
  93787. */
  93788. emitter: Nullable<AbstractMesh | Vector3>;
  93789. /**
  93790. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  93791. */
  93792. isBillboardBased: boolean;
  93793. /**
  93794. * The rendering group used by the Particle system to chose when to render.
  93795. */
  93796. renderingGroupId: number;
  93797. /**
  93798. * The layer mask we are rendering the particles through.
  93799. */
  93800. layerMask: number;
  93801. /**
  93802. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  93803. */
  93804. updateSpeed: number;
  93805. /**
  93806. * The amount of time the particle system is running (depends of the overall update speed).
  93807. */
  93808. targetStopDuration: number;
  93809. /**
  93810. * The texture used to render each particle. (this can be a spritesheet)
  93811. */
  93812. particleTexture: Nullable<BaseTexture>;
  93813. /**
  93814. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  93815. */
  93816. blendMode: number;
  93817. /**
  93818. * Minimum life time of emitting particles.
  93819. */
  93820. minLifeTime: number;
  93821. /**
  93822. * Maximum life time of emitting particles.
  93823. */
  93824. maxLifeTime: number;
  93825. /**
  93826. * Minimum Size of emitting particles.
  93827. */
  93828. minSize: number;
  93829. /**
  93830. * Maximum Size of emitting particles.
  93831. */
  93832. maxSize: number;
  93833. /**
  93834. * Minimum scale of emitting particles on X axis.
  93835. */
  93836. minScaleX: number;
  93837. /**
  93838. * Maximum scale of emitting particles on X axis.
  93839. */
  93840. maxScaleX: number;
  93841. /**
  93842. * Minimum scale of emitting particles on Y axis.
  93843. */
  93844. minScaleY: number;
  93845. /**
  93846. * Maximum scale of emitting particles on Y axis.
  93847. */
  93848. maxScaleY: number;
  93849. /**
  93850. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  93851. */
  93852. color1: Color4;
  93853. /**
  93854. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  93855. */
  93856. color2: Color4;
  93857. /**
  93858. * Color the particle will have at the end of its lifetime.
  93859. */
  93860. colorDead: Color4;
  93861. /**
  93862. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  93863. */
  93864. emitRate: number;
  93865. /**
  93866. * You can use gravity if you want to give an orientation to your particles.
  93867. */
  93868. gravity: Vector3;
  93869. /**
  93870. * Minimum power of emitting particles.
  93871. */
  93872. minEmitPower: number;
  93873. /**
  93874. * Maximum power of emitting particles.
  93875. */
  93876. maxEmitPower: number;
  93877. /**
  93878. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  93879. */
  93880. minAngularSpeed: number;
  93881. /**
  93882. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  93883. */
  93884. maxAngularSpeed: number;
  93885. /**
  93886. * Gets or sets the minimal initial rotation in radians.
  93887. */
  93888. minInitialRotation: number;
  93889. /**
  93890. * Gets or sets the maximal initial rotation in radians.
  93891. */
  93892. maxInitialRotation: number;
  93893. /**
  93894. * The particle emitter type defines the emitter used by the particle system.
  93895. * It can be for example box, sphere, or cone...
  93896. */
  93897. particleEmitterType: Nullable<IParticleEmitterType>;
  93898. /**
  93899. * Defines the delay in milliseconds before starting the system (0 by default)
  93900. */
  93901. startDelay: number;
  93902. /**
  93903. * 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
  93904. */
  93905. preWarmCycles: number;
  93906. /**
  93907. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  93908. */
  93909. preWarmStepOffset: number;
  93910. /**
  93911. * 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)
  93912. */
  93913. spriteCellChangeSpeed: number;
  93914. /**
  93915. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  93916. */
  93917. startSpriteCellID: number;
  93918. /**
  93919. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  93920. */
  93921. endSpriteCellID: number;
  93922. /**
  93923. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  93924. */
  93925. spriteCellWidth: number;
  93926. /**
  93927. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  93928. */
  93929. spriteCellHeight: number;
  93930. /**
  93931. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  93932. */
  93933. spriteRandomStartCell: boolean;
  93934. /**
  93935. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  93936. */
  93937. isAnimationSheetEnabled: boolean;
  93938. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  93939. translationPivot: Vector2;
  93940. /**
  93941. * Gets or sets a texture used to add random noise to particle positions
  93942. */
  93943. noiseTexture: Nullable<BaseTexture>;
  93944. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  93945. noiseStrength: Vector3;
  93946. /**
  93947. * Gets or sets the billboard mode to use when isBillboardBased = true.
  93948. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  93949. */
  93950. billboardMode: number;
  93951. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  93952. limitVelocityDamping: number;
  93953. /**
  93954. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  93955. */
  93956. beginAnimationOnStart: boolean;
  93957. /**
  93958. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  93959. */
  93960. beginAnimationFrom: number;
  93961. /**
  93962. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  93963. */
  93964. beginAnimationTo: number;
  93965. /**
  93966. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  93967. */
  93968. beginAnimationLoop: boolean;
  93969. /**
  93970. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  93971. */
  93972. disposeOnStop: boolean;
  93973. /**
  93974. * Specifies if the particles are updated in emitter local space or world space
  93975. */
  93976. isLocal: boolean;
  93977. /** Snippet ID if the particle system was created from the snippet server */
  93978. snippetId: string;
  93979. /** Gets or sets a matrix to use to compute projection */
  93980. defaultProjectionMatrix: Matrix;
  93981. /**
  93982. * Gets the maximum number of particles active at the same time.
  93983. * @returns The max number of active particles.
  93984. */
  93985. getCapacity(): number;
  93986. /**
  93987. * Gets the number of particles active at the same time.
  93988. * @returns The number of active particles.
  93989. */
  93990. getActiveCount(): number;
  93991. /**
  93992. * Gets if the system has been started. (Note: this will still be true after stop is called)
  93993. * @returns True if it has been started, otherwise false.
  93994. */
  93995. isStarted(): boolean;
  93996. /**
  93997. * Animates the particle system for this frame.
  93998. */
  93999. animate(): void;
  94000. /**
  94001. * Renders the particle system in its current state.
  94002. * @returns the current number of particles
  94003. */
  94004. render(): number;
  94005. /**
  94006. * Dispose the particle system and frees its associated resources.
  94007. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  94008. */
  94009. dispose(disposeTexture?: boolean): void;
  94010. /**
  94011. * An event triggered when the system is disposed
  94012. */
  94013. onDisposeObservable: Observable<IParticleSystem>;
  94014. /**
  94015. * Clones the particle system.
  94016. * @param name The name of the cloned object
  94017. * @param newEmitter The new emitter to use
  94018. * @returns the cloned particle system
  94019. */
  94020. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  94021. /**
  94022. * Serializes the particle system to a JSON object
  94023. * @param serializeTexture defines if the texture must be serialized as well
  94024. * @returns the JSON object
  94025. */
  94026. serialize(serializeTexture: boolean): any;
  94027. /**
  94028. * Rebuild the particle system
  94029. */
  94030. rebuild(): void;
  94031. /** Force the system to rebuild all gradients that need to be resync */
  94032. forceRefreshGradients(): void;
  94033. /**
  94034. * Starts the particle system and begins to emit
  94035. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  94036. */
  94037. start(delay?: number): void;
  94038. /**
  94039. * Stops the particle system.
  94040. */
  94041. stop(): void;
  94042. /**
  94043. * Remove all active particles
  94044. */
  94045. reset(): void;
  94046. /**
  94047. * Gets a boolean indicating that the system is stopping
  94048. * @returns true if the system is currently stopping
  94049. */
  94050. isStopping(): boolean;
  94051. /**
  94052. * Is this system ready to be used/rendered
  94053. * @return true if the system is ready
  94054. */
  94055. isReady(): boolean;
  94056. /**
  94057. * Returns the string "ParticleSystem"
  94058. * @returns a string containing the class name
  94059. */
  94060. getClassName(): string;
  94061. /**
  94062. * Gets the custom effect used to render the particles
  94063. * @param blendMode Blend mode for which the effect should be retrieved
  94064. * @returns The effect
  94065. */
  94066. getCustomEffect(blendMode: number): Nullable<Effect>;
  94067. /**
  94068. * Sets the custom effect used to render the particles
  94069. * @param effect The effect to set
  94070. * @param blendMode Blend mode for which the effect should be set
  94071. */
  94072. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  94073. /**
  94074. * Fill the defines array according to the current settings of the particle system
  94075. * @param defines Array to be updated
  94076. * @param blendMode blend mode to take into account when updating the array
  94077. */
  94078. fillDefines(defines: Array<string>, blendMode: number): void;
  94079. /**
  94080. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  94081. * @param uniforms Uniforms array to fill
  94082. * @param attributes Attributes array to fill
  94083. * @param samplers Samplers array to fill
  94084. */
  94085. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  94086. /**
  94087. * Observable that will be called just before the particles are drawn
  94088. */
  94089. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  94090. /**
  94091. * Gets the name of the particle vertex shader
  94092. */
  94093. vertexShaderName: string;
  94094. /**
  94095. * Adds a new color gradient
  94096. * @param gradient defines the gradient to use (between 0 and 1)
  94097. * @param color1 defines the color to affect to the specified gradient
  94098. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  94099. * @returns the current particle system
  94100. */
  94101. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  94102. /**
  94103. * Remove a specific color gradient
  94104. * @param gradient defines the gradient to remove
  94105. * @returns the current particle system
  94106. */
  94107. removeColorGradient(gradient: number): IParticleSystem;
  94108. /**
  94109. * Adds a new size gradient
  94110. * @param gradient defines the gradient to use (between 0 and 1)
  94111. * @param factor defines the size factor to affect to the specified gradient
  94112. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94113. * @returns the current particle system
  94114. */
  94115. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94116. /**
  94117. * Remove a specific size gradient
  94118. * @param gradient defines the gradient to remove
  94119. * @returns the current particle system
  94120. */
  94121. removeSizeGradient(gradient: number): IParticleSystem;
  94122. /**
  94123. * Gets the current list of color gradients.
  94124. * You must use addColorGradient and removeColorGradient to udpate this list
  94125. * @returns the list of color gradients
  94126. */
  94127. getColorGradients(): Nullable<Array<ColorGradient>>;
  94128. /**
  94129. * Gets the current list of size gradients.
  94130. * You must use addSizeGradient and removeSizeGradient to udpate this list
  94131. * @returns the list of size gradients
  94132. */
  94133. getSizeGradients(): Nullable<Array<FactorGradient>>;
  94134. /**
  94135. * Gets the current list of angular speed gradients.
  94136. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  94137. * @returns the list of angular speed gradients
  94138. */
  94139. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  94140. /**
  94141. * Adds a new angular speed gradient
  94142. * @param gradient defines the gradient to use (between 0 and 1)
  94143. * @param factor defines the angular speed to affect to the specified gradient
  94144. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94145. * @returns the current particle system
  94146. */
  94147. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94148. /**
  94149. * Remove a specific angular speed gradient
  94150. * @param gradient defines the gradient to remove
  94151. * @returns the current particle system
  94152. */
  94153. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  94154. /**
  94155. * Gets the current list of velocity gradients.
  94156. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  94157. * @returns the list of velocity gradients
  94158. */
  94159. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  94160. /**
  94161. * Adds a new velocity gradient
  94162. * @param gradient defines the gradient to use (between 0 and 1)
  94163. * @param factor defines the velocity to affect to the specified gradient
  94164. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94165. * @returns the current particle system
  94166. */
  94167. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94168. /**
  94169. * Remove a specific velocity gradient
  94170. * @param gradient defines the gradient to remove
  94171. * @returns the current particle system
  94172. */
  94173. removeVelocityGradient(gradient: number): IParticleSystem;
  94174. /**
  94175. * Gets the current list of limit velocity gradients.
  94176. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  94177. * @returns the list of limit velocity gradients
  94178. */
  94179. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  94180. /**
  94181. * Adds a new limit velocity gradient
  94182. * @param gradient defines the gradient to use (between 0 and 1)
  94183. * @param factor defines the limit velocity to affect to the specified gradient
  94184. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94185. * @returns the current particle system
  94186. */
  94187. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94188. /**
  94189. * Remove a specific limit velocity gradient
  94190. * @param gradient defines the gradient to remove
  94191. * @returns the current particle system
  94192. */
  94193. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  94194. /**
  94195. * Adds a new drag gradient
  94196. * @param gradient defines the gradient to use (between 0 and 1)
  94197. * @param factor defines the drag to affect to the specified gradient
  94198. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94199. * @returns the current particle system
  94200. */
  94201. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94202. /**
  94203. * Remove a specific drag gradient
  94204. * @param gradient defines the gradient to remove
  94205. * @returns the current particle system
  94206. */
  94207. removeDragGradient(gradient: number): IParticleSystem;
  94208. /**
  94209. * Gets the current list of drag gradients.
  94210. * You must use addDragGradient and removeDragGradient to udpate this list
  94211. * @returns the list of drag gradients
  94212. */
  94213. getDragGradients(): Nullable<Array<FactorGradient>>;
  94214. /**
  94215. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  94216. * @param gradient defines the gradient to use (between 0 and 1)
  94217. * @param factor defines the emit rate to affect to the specified gradient
  94218. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94219. * @returns the current particle system
  94220. */
  94221. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94222. /**
  94223. * Remove a specific emit rate gradient
  94224. * @param gradient defines the gradient to remove
  94225. * @returns the current particle system
  94226. */
  94227. removeEmitRateGradient(gradient: number): IParticleSystem;
  94228. /**
  94229. * Gets the current list of emit rate gradients.
  94230. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  94231. * @returns the list of emit rate gradients
  94232. */
  94233. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  94234. /**
  94235. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  94236. * @param gradient defines the gradient to use (between 0 and 1)
  94237. * @param factor defines the start size to affect to the specified gradient
  94238. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94239. * @returns the current particle system
  94240. */
  94241. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94242. /**
  94243. * Remove a specific start size gradient
  94244. * @param gradient defines the gradient to remove
  94245. * @returns the current particle system
  94246. */
  94247. removeStartSizeGradient(gradient: number): IParticleSystem;
  94248. /**
  94249. * Gets the current list of start size gradients.
  94250. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  94251. * @returns the list of start size gradients
  94252. */
  94253. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  94254. /**
  94255. * Adds a new life time gradient
  94256. * @param gradient defines the gradient to use (between 0 and 1)
  94257. * @param factor defines the life time factor to affect to the specified gradient
  94258. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94259. * @returns the current particle system
  94260. */
  94261. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94262. /**
  94263. * Remove a specific life time gradient
  94264. * @param gradient defines the gradient to remove
  94265. * @returns the current particle system
  94266. */
  94267. removeLifeTimeGradient(gradient: number): IParticleSystem;
  94268. /**
  94269. * Gets the current list of life time gradients.
  94270. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  94271. * @returns the list of life time gradients
  94272. */
  94273. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  94274. /**
  94275. * Gets the current list of color gradients.
  94276. * You must use addColorGradient and removeColorGradient to udpate this list
  94277. * @returns the list of color gradients
  94278. */
  94279. getColorGradients(): Nullable<Array<ColorGradient>>;
  94280. /**
  94281. * Adds a new ramp gradient used to remap particle colors
  94282. * @param gradient defines the gradient to use (between 0 and 1)
  94283. * @param color defines the color to affect to the specified gradient
  94284. * @returns the current particle system
  94285. */
  94286. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  94287. /**
  94288. * Gets the current list of ramp gradients.
  94289. * You must use addRampGradient and removeRampGradient to udpate this list
  94290. * @returns the list of ramp gradients
  94291. */
  94292. getRampGradients(): Nullable<Array<Color3Gradient>>;
  94293. /** Gets or sets a boolean indicating that ramp gradients must be used
  94294. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  94295. */
  94296. useRampGradients: boolean;
  94297. /**
  94298. * Adds a new color remap gradient
  94299. * @param gradient defines the gradient to use (between 0 and 1)
  94300. * @param min defines the color remap minimal range
  94301. * @param max defines the color remap maximal range
  94302. * @returns the current particle system
  94303. */
  94304. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94305. /**
  94306. * Gets the current list of color remap gradients.
  94307. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  94308. * @returns the list of color remap gradients
  94309. */
  94310. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  94311. /**
  94312. * Adds a new alpha remap gradient
  94313. * @param gradient defines the gradient to use (between 0 and 1)
  94314. * @param min defines the alpha remap minimal range
  94315. * @param max defines the alpha remap maximal range
  94316. * @returns the current particle system
  94317. */
  94318. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94319. /**
  94320. * Gets the current list of alpha remap gradients.
  94321. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  94322. * @returns the list of alpha remap gradients
  94323. */
  94324. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  94325. /**
  94326. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  94327. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  94328. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  94329. * @returns the emitter
  94330. */
  94331. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  94332. /**
  94333. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  94334. * @param radius The radius of the hemisphere to emit from
  94335. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  94336. * @returns the emitter
  94337. */
  94338. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  94339. /**
  94340. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  94341. * @param radius The radius of the sphere to emit from
  94342. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  94343. * @returns the emitter
  94344. */
  94345. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  94346. /**
  94347. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  94348. * @param radius The radius of the sphere to emit from
  94349. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  94350. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  94351. * @returns the emitter
  94352. */
  94353. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  94354. /**
  94355. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  94356. * @param radius The radius of the emission cylinder
  94357. * @param height The height of the emission cylinder
  94358. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  94359. * @param directionRandomizer How much to randomize the particle direction [0-1]
  94360. * @returns the emitter
  94361. */
  94362. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  94363. /**
  94364. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  94365. * @param radius The radius of the cylinder to emit from
  94366. * @param height The height of the emission cylinder
  94367. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94368. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  94369. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  94370. * @returns the emitter
  94371. */
  94372. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  94373. /**
  94374. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  94375. * @param radius The radius of the cone to emit from
  94376. * @param angle The base angle of the cone
  94377. * @returns the emitter
  94378. */
  94379. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  94380. /**
  94381. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  94382. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  94383. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  94384. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  94385. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  94386. * @returns the emitter
  94387. */
  94388. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  94389. /**
  94390. * Get hosting scene
  94391. * @returns the scene
  94392. */
  94393. getScene(): Nullable<Scene>;
  94394. }
  94395. }
  94396. declare module BABYLON {
  94397. /**
  94398. * 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.
  94399. * @see https://doc.babylonjs.com/how_to/transformnode
  94400. */
  94401. export class TransformNode extends Node {
  94402. /**
  94403. * Object will not rotate to face the camera
  94404. */
  94405. static BILLBOARDMODE_NONE: number;
  94406. /**
  94407. * Object will rotate to face the camera but only on the x axis
  94408. */
  94409. static BILLBOARDMODE_X: number;
  94410. /**
  94411. * Object will rotate to face the camera but only on the y axis
  94412. */
  94413. static BILLBOARDMODE_Y: number;
  94414. /**
  94415. * Object will rotate to face the camera but only on the z axis
  94416. */
  94417. static BILLBOARDMODE_Z: number;
  94418. /**
  94419. * Object will rotate to face the camera
  94420. */
  94421. static BILLBOARDMODE_ALL: number;
  94422. /**
  94423. * Object will rotate to face the camera's position instead of orientation
  94424. */
  94425. static BILLBOARDMODE_USE_POSITION: number;
  94426. private static _TmpRotation;
  94427. private static _TmpScaling;
  94428. private static _TmpTranslation;
  94429. private _forward;
  94430. private _forwardInverted;
  94431. private _up;
  94432. private _right;
  94433. private _rightInverted;
  94434. private _position;
  94435. private _rotation;
  94436. private _rotationQuaternion;
  94437. protected _scaling: Vector3;
  94438. protected _isDirty: boolean;
  94439. private _transformToBoneReferal;
  94440. private _isAbsoluteSynced;
  94441. private _billboardMode;
  94442. /**
  94443. * Gets or sets the billboard mode. Default is 0.
  94444. *
  94445. * | Value | Type | Description |
  94446. * | --- | --- | --- |
  94447. * | 0 | BILLBOARDMODE_NONE | |
  94448. * | 1 | BILLBOARDMODE_X | |
  94449. * | 2 | BILLBOARDMODE_Y | |
  94450. * | 4 | BILLBOARDMODE_Z | |
  94451. * | 7 | BILLBOARDMODE_ALL | |
  94452. *
  94453. */
  94454. get billboardMode(): number;
  94455. set billboardMode(value: number);
  94456. private _preserveParentRotationForBillboard;
  94457. /**
  94458. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  94459. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  94460. */
  94461. get preserveParentRotationForBillboard(): boolean;
  94462. set preserveParentRotationForBillboard(value: boolean);
  94463. /**
  94464. * 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
  94465. */
  94466. scalingDeterminant: number;
  94467. private _infiniteDistance;
  94468. /**
  94469. * Gets or sets the distance of the object to max, often used by skybox
  94470. */
  94471. get infiniteDistance(): boolean;
  94472. set infiniteDistance(value: boolean);
  94473. /**
  94474. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  94475. * By default the system will update normals to compensate
  94476. */
  94477. ignoreNonUniformScaling: boolean;
  94478. /**
  94479. * 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
  94480. */
  94481. reIntegrateRotationIntoRotationQuaternion: boolean;
  94482. /** @hidden */
  94483. _poseMatrix: Nullable<Matrix>;
  94484. /** @hidden */
  94485. _localMatrix: Matrix;
  94486. private _usePivotMatrix;
  94487. private _absolutePosition;
  94488. private _absoluteScaling;
  94489. private _absoluteRotationQuaternion;
  94490. private _pivotMatrix;
  94491. private _pivotMatrixInverse;
  94492. /** @hidden */
  94493. _postMultiplyPivotMatrix: boolean;
  94494. protected _isWorldMatrixFrozen: boolean;
  94495. /** @hidden */
  94496. _indexInSceneTransformNodesArray: number;
  94497. /**
  94498. * An event triggered after the world matrix is updated
  94499. */
  94500. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  94501. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  94502. /**
  94503. * Gets a string identifying the name of the class
  94504. * @returns "TransformNode" string
  94505. */
  94506. getClassName(): string;
  94507. /**
  94508. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  94509. */
  94510. get position(): Vector3;
  94511. set position(newPosition: Vector3);
  94512. /**
  94513. * 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)).
  94514. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  94515. */
  94516. get rotation(): Vector3;
  94517. set rotation(newRotation: Vector3);
  94518. /**
  94519. * 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)).
  94520. */
  94521. get scaling(): Vector3;
  94522. set scaling(newScaling: Vector3);
  94523. /**
  94524. * 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).
  94525. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  94526. */
  94527. get rotationQuaternion(): Nullable<Quaternion>;
  94528. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  94529. /**
  94530. * The forward direction of that transform in world space.
  94531. */
  94532. get forward(): Vector3;
  94533. /**
  94534. * The up direction of that transform in world space.
  94535. */
  94536. get up(): Vector3;
  94537. /**
  94538. * The right direction of that transform in world space.
  94539. */
  94540. get right(): Vector3;
  94541. /**
  94542. * Copies the parameter passed Matrix into the mesh Pose matrix.
  94543. * @param matrix the matrix to copy the pose from
  94544. * @returns this TransformNode.
  94545. */
  94546. updatePoseMatrix(matrix: Matrix): TransformNode;
  94547. /**
  94548. * Returns the mesh Pose matrix.
  94549. * @returns the pose matrix
  94550. */
  94551. getPoseMatrix(): Matrix;
  94552. /** @hidden */
  94553. _isSynchronized(): boolean;
  94554. /** @hidden */
  94555. _initCache(): void;
  94556. /**
  94557. * Flag the transform node as dirty (Forcing it to update everything)
  94558. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  94559. * @returns this transform node
  94560. */
  94561. markAsDirty(property: string): TransformNode;
  94562. /**
  94563. * Returns the current mesh absolute position.
  94564. * Returns a Vector3.
  94565. */
  94566. get absolutePosition(): Vector3;
  94567. /**
  94568. * Returns the current mesh absolute scaling.
  94569. * Returns a Vector3.
  94570. */
  94571. get absoluteScaling(): Vector3;
  94572. /**
  94573. * Returns the current mesh absolute rotation.
  94574. * Returns a Quaternion.
  94575. */
  94576. get absoluteRotationQuaternion(): Quaternion;
  94577. /**
  94578. * Sets a new matrix to apply before all other transformation
  94579. * @param matrix defines the transform matrix
  94580. * @returns the current TransformNode
  94581. */
  94582. setPreTransformMatrix(matrix: Matrix): TransformNode;
  94583. /**
  94584. * Sets a new pivot matrix to the current node
  94585. * @param matrix defines the new pivot matrix to use
  94586. * @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
  94587. * @returns the current TransformNode
  94588. */
  94589. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  94590. /**
  94591. * Returns the mesh pivot matrix.
  94592. * Default : Identity.
  94593. * @returns the matrix
  94594. */
  94595. getPivotMatrix(): Matrix;
  94596. /**
  94597. * Instantiate (when possible) or clone that node with its hierarchy
  94598. * @param newParent defines the new parent to use for the instance (or clone)
  94599. * @param options defines options to configure how copy is done
  94600. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  94601. * @returns an instance (or a clone) of the current node with its hiearchy
  94602. */
  94603. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  94604. doNotInstantiate: boolean;
  94605. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  94606. /**
  94607. * Prevents the World matrix to be computed any longer
  94608. * @param newWorldMatrix defines an optional matrix to use as world matrix
  94609. * @returns the TransformNode.
  94610. */
  94611. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  94612. /**
  94613. * Allows back the World matrix computation.
  94614. * @returns the TransformNode.
  94615. */
  94616. unfreezeWorldMatrix(): this;
  94617. /**
  94618. * True if the World matrix has been frozen.
  94619. */
  94620. get isWorldMatrixFrozen(): boolean;
  94621. /**
  94622. * Retuns the mesh absolute position in the World.
  94623. * @returns a Vector3.
  94624. */
  94625. getAbsolutePosition(): Vector3;
  94626. /**
  94627. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  94628. * @param absolutePosition the absolute position to set
  94629. * @returns the TransformNode.
  94630. */
  94631. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  94632. /**
  94633. * Sets the mesh position in its local space.
  94634. * @param vector3 the position to set in localspace
  94635. * @returns the TransformNode.
  94636. */
  94637. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  94638. /**
  94639. * Returns the mesh position in the local space from the current World matrix values.
  94640. * @returns a new Vector3.
  94641. */
  94642. getPositionExpressedInLocalSpace(): Vector3;
  94643. /**
  94644. * Translates the mesh along the passed Vector3 in its local space.
  94645. * @param vector3 the distance to translate in localspace
  94646. * @returns the TransformNode.
  94647. */
  94648. locallyTranslate(vector3: Vector3): TransformNode;
  94649. private static _lookAtVectorCache;
  94650. /**
  94651. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  94652. * @param targetPoint the position (must be in same space as current mesh) to look at
  94653. * @param yawCor optional yaw (y-axis) correction in radians
  94654. * @param pitchCor optional pitch (x-axis) correction in radians
  94655. * @param rollCor optional roll (z-axis) correction in radians
  94656. * @param space the choosen space of the target
  94657. * @returns the TransformNode.
  94658. */
  94659. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  94660. /**
  94661. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  94662. * This Vector3 is expressed in the World space.
  94663. * @param localAxis axis to rotate
  94664. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  94665. */
  94666. getDirection(localAxis: Vector3): Vector3;
  94667. /**
  94668. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  94669. * localAxis is expressed in the mesh local space.
  94670. * result is computed in the Wordl space from the mesh World matrix.
  94671. * @param localAxis axis to rotate
  94672. * @param result the resulting transformnode
  94673. * @returns this TransformNode.
  94674. */
  94675. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  94676. /**
  94677. * Sets this transform node rotation to the given local axis.
  94678. * @param localAxis the axis in local space
  94679. * @param yawCor optional yaw (y-axis) correction in radians
  94680. * @param pitchCor optional pitch (x-axis) correction in radians
  94681. * @param rollCor optional roll (z-axis) correction in radians
  94682. * @returns this TransformNode
  94683. */
  94684. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  94685. /**
  94686. * Sets a new pivot point to the current node
  94687. * @param point defines the new pivot point to use
  94688. * @param space defines if the point is in world or local space (local by default)
  94689. * @returns the current TransformNode
  94690. */
  94691. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  94692. /**
  94693. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  94694. * @returns the pivot point
  94695. */
  94696. getPivotPoint(): Vector3;
  94697. /**
  94698. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  94699. * @param result the vector3 to store the result
  94700. * @returns this TransformNode.
  94701. */
  94702. getPivotPointToRef(result: Vector3): TransformNode;
  94703. /**
  94704. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  94705. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  94706. */
  94707. getAbsolutePivotPoint(): Vector3;
  94708. /**
  94709. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  94710. * @param result vector3 to store the result
  94711. * @returns this TransformNode.
  94712. */
  94713. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  94714. /**
  94715. * Defines the passed node as the parent of the current node.
  94716. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  94717. * @see https://doc.babylonjs.com/how_to/parenting
  94718. * @param node the node ot set as the parent
  94719. * @returns this TransformNode.
  94720. */
  94721. setParent(node: Nullable<Node>): TransformNode;
  94722. private _nonUniformScaling;
  94723. /**
  94724. * True if the scaling property of this object is non uniform eg. (1,2,1)
  94725. */
  94726. get nonUniformScaling(): boolean;
  94727. /** @hidden */
  94728. _updateNonUniformScalingState(value: boolean): boolean;
  94729. /**
  94730. * Attach the current TransformNode to another TransformNode associated with a bone
  94731. * @param bone Bone affecting the TransformNode
  94732. * @param affectedTransformNode TransformNode associated with the bone
  94733. * @returns this object
  94734. */
  94735. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  94736. /**
  94737. * Detach the transform node if its associated with a bone
  94738. * @returns this object
  94739. */
  94740. detachFromBone(): TransformNode;
  94741. private static _rotationAxisCache;
  94742. /**
  94743. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  94744. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  94745. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  94746. * The passed axis is also normalized.
  94747. * @param axis the axis to rotate around
  94748. * @param amount the amount to rotate in radians
  94749. * @param space Space to rotate in (Default: local)
  94750. * @returns the TransformNode.
  94751. */
  94752. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  94753. /**
  94754. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  94755. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  94756. * The passed axis is also normalized. .
  94757. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  94758. * @param point the point to rotate around
  94759. * @param axis the axis to rotate around
  94760. * @param amount the amount to rotate in radians
  94761. * @returns the TransformNode
  94762. */
  94763. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  94764. /**
  94765. * Translates the mesh along the axis vector for the passed distance in the given space.
  94766. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  94767. * @param axis the axis to translate in
  94768. * @param distance the distance to translate
  94769. * @param space Space to rotate in (Default: local)
  94770. * @returns the TransformNode.
  94771. */
  94772. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  94773. /**
  94774. * Adds a rotation step to the mesh current rotation.
  94775. * x, y, z are Euler angles expressed in radians.
  94776. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  94777. * This means this rotation is made in the mesh local space only.
  94778. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  94779. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  94780. * ```javascript
  94781. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  94782. * ```
  94783. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  94784. * 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.
  94785. * @param x Rotation to add
  94786. * @param y Rotation to add
  94787. * @param z Rotation to add
  94788. * @returns the TransformNode.
  94789. */
  94790. addRotation(x: number, y: number, z: number): TransformNode;
  94791. /**
  94792. * @hidden
  94793. */
  94794. protected _getEffectiveParent(): Nullable<Node>;
  94795. /**
  94796. * Computes the world matrix of the node
  94797. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  94798. * @returns the world matrix
  94799. */
  94800. computeWorldMatrix(force?: boolean): Matrix;
  94801. /**
  94802. * Resets this nodeTransform's local matrix to Matrix.Identity().
  94803. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  94804. */
  94805. resetLocalMatrix(independentOfChildren?: boolean): void;
  94806. protected _afterComputeWorldMatrix(): void;
  94807. /**
  94808. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  94809. * @param func callback function to add
  94810. *
  94811. * @returns the TransformNode.
  94812. */
  94813. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  94814. /**
  94815. * Removes a registered callback function.
  94816. * @param func callback function to remove
  94817. * @returns the TransformNode.
  94818. */
  94819. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  94820. /**
  94821. * Gets the position of the current mesh in camera space
  94822. * @param camera defines the camera to use
  94823. * @returns a position
  94824. */
  94825. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  94826. /**
  94827. * Returns the distance from the mesh to the active camera
  94828. * @param camera defines the camera to use
  94829. * @returns the distance
  94830. */
  94831. getDistanceToCamera(camera?: Nullable<Camera>): number;
  94832. /**
  94833. * Clone the current transform node
  94834. * @param name Name of the new clone
  94835. * @param newParent New parent for the clone
  94836. * @param doNotCloneChildren Do not clone children hierarchy
  94837. * @returns the new transform node
  94838. */
  94839. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  94840. /**
  94841. * Serializes the objects information.
  94842. * @param currentSerializationObject defines the object to serialize in
  94843. * @returns the serialized object
  94844. */
  94845. serialize(currentSerializationObject?: any): any;
  94846. /**
  94847. * Returns a new TransformNode object parsed from the source provided.
  94848. * @param parsedTransformNode is the source.
  94849. * @param scene the scne the object belongs to
  94850. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  94851. * @returns a new TransformNode object parsed from the source provided.
  94852. */
  94853. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  94854. /**
  94855. * Get all child-transformNodes of this node
  94856. * @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
  94857. * @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
  94858. * @returns an array of TransformNode
  94859. */
  94860. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  94861. /**
  94862. * Releases resources associated with this transform node.
  94863. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  94864. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  94865. */
  94866. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94867. /**
  94868. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  94869. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  94870. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  94871. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  94872. * @returns the current mesh
  94873. */
  94874. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  94875. private _syncAbsoluteScalingAndRotation;
  94876. }
  94877. }
  94878. declare module BABYLON {
  94879. /**
  94880. * Class used to override all child animations of a given target
  94881. */
  94882. export class AnimationPropertiesOverride {
  94883. /**
  94884. * Gets or sets a value indicating if animation blending must be used
  94885. */
  94886. enableBlending: boolean;
  94887. /**
  94888. * Gets or sets the blending speed to use when enableBlending is true
  94889. */
  94890. blendingSpeed: number;
  94891. /**
  94892. * Gets or sets the default loop mode to use
  94893. */
  94894. loopMode: number;
  94895. }
  94896. }
  94897. declare module BABYLON {
  94898. /**
  94899. * Class used to store bone information
  94900. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  94901. */
  94902. export class Bone extends Node {
  94903. /**
  94904. * defines the bone name
  94905. */
  94906. name: string;
  94907. private static _tmpVecs;
  94908. private static _tmpQuat;
  94909. private static _tmpMats;
  94910. /**
  94911. * Gets the list of child bones
  94912. */
  94913. children: Bone[];
  94914. /** Gets the animations associated with this bone */
  94915. animations: Animation[];
  94916. /**
  94917. * Gets or sets bone length
  94918. */
  94919. length: number;
  94920. /**
  94921. * @hidden Internal only
  94922. * Set this value to map this bone to a different index in the transform matrices
  94923. * Set this value to -1 to exclude the bone from the transform matrices
  94924. */
  94925. _index: Nullable<number>;
  94926. private _skeleton;
  94927. private _localMatrix;
  94928. private _restPose;
  94929. private _bindPose;
  94930. private _baseMatrix;
  94931. private _absoluteTransform;
  94932. private _invertedAbsoluteTransform;
  94933. private _parent;
  94934. private _scalingDeterminant;
  94935. private _worldTransform;
  94936. private _localScaling;
  94937. private _localRotation;
  94938. private _localPosition;
  94939. private _needToDecompose;
  94940. private _needToCompose;
  94941. /** @hidden */
  94942. _linkedTransformNode: Nullable<TransformNode>;
  94943. /** @hidden */
  94944. _waitingTransformNodeId: Nullable<string>;
  94945. /** @hidden */
  94946. get _matrix(): Matrix;
  94947. /** @hidden */
  94948. set _matrix(value: Matrix);
  94949. /**
  94950. * Create a new bone
  94951. * @param name defines the bone name
  94952. * @param skeleton defines the parent skeleton
  94953. * @param parentBone defines the parent (can be null if the bone is the root)
  94954. * @param localMatrix defines the local matrix
  94955. * @param restPose defines the rest pose matrix
  94956. * @param baseMatrix defines the base matrix
  94957. * @param index defines index of the bone in the hiearchy
  94958. */
  94959. constructor(
  94960. /**
  94961. * defines the bone name
  94962. */
  94963. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  94964. /**
  94965. * Gets the current object class name.
  94966. * @return the class name
  94967. */
  94968. getClassName(): string;
  94969. /**
  94970. * Gets the parent skeleton
  94971. * @returns a skeleton
  94972. */
  94973. getSkeleton(): Skeleton;
  94974. /**
  94975. * Gets parent bone
  94976. * @returns a bone or null if the bone is the root of the bone hierarchy
  94977. */
  94978. getParent(): Nullable<Bone>;
  94979. /**
  94980. * Returns an array containing the root bones
  94981. * @returns an array containing the root bones
  94982. */
  94983. getChildren(): Array<Bone>;
  94984. /**
  94985. * Gets the node index in matrix array generated for rendering
  94986. * @returns the node index
  94987. */
  94988. getIndex(): number;
  94989. /**
  94990. * Sets the parent bone
  94991. * @param parent defines the parent (can be null if the bone is the root)
  94992. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  94993. */
  94994. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  94995. /**
  94996. * Gets the local matrix
  94997. * @returns a matrix
  94998. */
  94999. getLocalMatrix(): Matrix;
  95000. /**
  95001. * Gets the base matrix (initial matrix which remains unchanged)
  95002. * @returns a matrix
  95003. */
  95004. getBaseMatrix(): Matrix;
  95005. /**
  95006. * Gets the rest pose matrix
  95007. * @returns a matrix
  95008. */
  95009. getRestPose(): Matrix;
  95010. /**
  95011. * Sets the rest pose matrix
  95012. * @param matrix the local-space rest pose to set for this bone
  95013. */
  95014. setRestPose(matrix: Matrix): void;
  95015. /**
  95016. * Gets the bind pose matrix
  95017. * @returns the bind pose matrix
  95018. */
  95019. getBindPose(): Matrix;
  95020. /**
  95021. * Sets the bind pose matrix
  95022. * @param matrix the local-space bind pose to set for this bone
  95023. */
  95024. setBindPose(matrix: Matrix): void;
  95025. /**
  95026. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  95027. */
  95028. getWorldMatrix(): Matrix;
  95029. /**
  95030. * Sets the local matrix to rest pose matrix
  95031. */
  95032. returnToRest(): void;
  95033. /**
  95034. * Gets the inverse of the absolute transform matrix.
  95035. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  95036. * @returns a matrix
  95037. */
  95038. getInvertedAbsoluteTransform(): Matrix;
  95039. /**
  95040. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  95041. * @returns a matrix
  95042. */
  95043. getAbsoluteTransform(): Matrix;
  95044. /**
  95045. * Links with the given transform node.
  95046. * The local matrix of this bone is copied from the transform node every frame.
  95047. * @param transformNode defines the transform node to link to
  95048. */
  95049. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  95050. /**
  95051. * Gets the node used to drive the bone's transformation
  95052. * @returns a transform node or null
  95053. */
  95054. getTransformNode(): Nullable<TransformNode>;
  95055. /** Gets or sets current position (in local space) */
  95056. get position(): Vector3;
  95057. set position(newPosition: Vector3);
  95058. /** Gets or sets current rotation (in local space) */
  95059. get rotation(): Vector3;
  95060. set rotation(newRotation: Vector3);
  95061. /** Gets or sets current rotation quaternion (in local space) */
  95062. get rotationQuaternion(): Quaternion;
  95063. set rotationQuaternion(newRotation: Quaternion);
  95064. /** Gets or sets current scaling (in local space) */
  95065. get scaling(): Vector3;
  95066. set scaling(newScaling: Vector3);
  95067. /**
  95068. * Gets the animation properties override
  95069. */
  95070. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95071. private _decompose;
  95072. private _compose;
  95073. /**
  95074. * Update the base and local matrices
  95075. * @param matrix defines the new base or local matrix
  95076. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95077. * @param updateLocalMatrix defines if the local matrix should be updated
  95078. */
  95079. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  95080. /** @hidden */
  95081. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  95082. /**
  95083. * Flag the bone as dirty (Forcing it to update everything)
  95084. */
  95085. markAsDirty(): void;
  95086. /** @hidden */
  95087. _markAsDirtyAndCompose(): void;
  95088. private _markAsDirtyAndDecompose;
  95089. /**
  95090. * Translate the bone in local or world space
  95091. * @param vec The amount to translate the bone
  95092. * @param space The space that the translation is in
  95093. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95094. */
  95095. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95096. /**
  95097. * Set the postion of the bone in local or world space
  95098. * @param position The position to set the bone
  95099. * @param space The space that the position is in
  95100. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95101. */
  95102. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95103. /**
  95104. * Set the absolute position of the bone (world space)
  95105. * @param position The position to set the bone
  95106. * @param mesh The mesh that this bone is attached to
  95107. */
  95108. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  95109. /**
  95110. * Scale the bone on the x, y and z axes (in local space)
  95111. * @param x The amount to scale the bone on the x axis
  95112. * @param y The amount to scale the bone on the y axis
  95113. * @param z The amount to scale the bone on the z axis
  95114. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  95115. */
  95116. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  95117. /**
  95118. * Set the bone scaling in local space
  95119. * @param scale defines the scaling vector
  95120. */
  95121. setScale(scale: Vector3): void;
  95122. /**
  95123. * Gets the current scaling in local space
  95124. * @returns the current scaling vector
  95125. */
  95126. getScale(): Vector3;
  95127. /**
  95128. * Gets the current scaling in local space and stores it in a target vector
  95129. * @param result defines the target vector
  95130. */
  95131. getScaleToRef(result: Vector3): void;
  95132. /**
  95133. * Set the yaw, pitch, and roll of the bone in local or world space
  95134. * @param yaw The rotation of the bone on the y axis
  95135. * @param pitch The rotation of the bone on the x axis
  95136. * @param roll The rotation of the bone on the z axis
  95137. * @param space The space that the axes of rotation are in
  95138. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95139. */
  95140. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  95141. /**
  95142. * Add a rotation to the bone on an axis in local or world space
  95143. * @param axis The axis to rotate the bone on
  95144. * @param amount The amount to rotate the bone
  95145. * @param space The space that the axis is in
  95146. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95147. */
  95148. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  95149. /**
  95150. * Set the rotation of the bone to a particular axis angle in local or world space
  95151. * @param axis The axis to rotate the bone on
  95152. * @param angle The angle that the bone should be rotated to
  95153. * @param space The space that the axis is in
  95154. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95155. */
  95156. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  95157. /**
  95158. * Set the euler rotation of the bone in local of world space
  95159. * @param rotation The euler rotation that the bone should be set to
  95160. * @param space The space that the rotation is in
  95161. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95162. */
  95163. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95164. /**
  95165. * Set the quaternion rotation of the bone in local of world space
  95166. * @param quat The quaternion rotation that the bone should be set to
  95167. * @param space The space that the rotation is in
  95168. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95169. */
  95170. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  95171. /**
  95172. * Set the rotation matrix of the bone in local of world space
  95173. * @param rotMat The rotation matrix that the bone should be set to
  95174. * @param space The space that the rotation is in
  95175. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95176. */
  95177. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  95178. private _rotateWithMatrix;
  95179. private _getNegativeRotationToRef;
  95180. /**
  95181. * Get the position of the bone in local or world space
  95182. * @param space The space that the returned position is in
  95183. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95184. * @returns The position of the bone
  95185. */
  95186. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95187. /**
  95188. * Copy the position of the bone to a vector3 in local or world space
  95189. * @param space The space that the returned position is in
  95190. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95191. * @param result The vector3 to copy the position to
  95192. */
  95193. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  95194. /**
  95195. * Get the absolute position of the bone (world space)
  95196. * @param mesh The mesh that this bone is attached to
  95197. * @returns The absolute position of the bone
  95198. */
  95199. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  95200. /**
  95201. * Copy the absolute position of the bone (world space) to the result param
  95202. * @param mesh The mesh that this bone is attached to
  95203. * @param result The vector3 to copy the absolute position to
  95204. */
  95205. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  95206. /**
  95207. * Compute the absolute transforms of this bone and its children
  95208. */
  95209. computeAbsoluteTransforms(): void;
  95210. /**
  95211. * Get the world direction from an axis that is in the local space of the bone
  95212. * @param localAxis The local direction that is used to compute the world direction
  95213. * @param mesh The mesh that this bone is attached to
  95214. * @returns The world direction
  95215. */
  95216. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95217. /**
  95218. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  95219. * @param localAxis The local direction that is used to compute the world direction
  95220. * @param mesh The mesh that this bone is attached to
  95221. * @param result The vector3 that the world direction will be copied to
  95222. */
  95223. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95224. /**
  95225. * Get the euler rotation of the bone in local or world space
  95226. * @param space The space that the rotation should be in
  95227. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95228. * @returns The euler rotation
  95229. */
  95230. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95231. /**
  95232. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  95233. * @param space The space that the rotation should be in
  95234. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95235. * @param result The vector3 that the rotation should be copied to
  95236. */
  95237. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95238. /**
  95239. * Get the quaternion rotation of the bone in either local or world space
  95240. * @param space The space that the rotation should be in
  95241. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95242. * @returns The quaternion rotation
  95243. */
  95244. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  95245. /**
  95246. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  95247. * @param space The space that the rotation should be in
  95248. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95249. * @param result The quaternion that the rotation should be copied to
  95250. */
  95251. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  95252. /**
  95253. * Get the rotation matrix of the bone in local or world space
  95254. * @param space The space that the rotation should be in
  95255. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95256. * @returns The rotation matrix
  95257. */
  95258. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  95259. /**
  95260. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  95261. * @param space The space that the rotation should be in
  95262. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95263. * @param result The quaternion that the rotation should be copied to
  95264. */
  95265. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  95266. /**
  95267. * Get the world position of a point that is in the local space of the bone
  95268. * @param position The local position
  95269. * @param mesh The mesh that this bone is attached to
  95270. * @returns The world position
  95271. */
  95272. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95273. /**
  95274. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  95275. * @param position The local position
  95276. * @param mesh The mesh that this bone is attached to
  95277. * @param result The vector3 that the world position should be copied to
  95278. */
  95279. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95280. /**
  95281. * Get the local position of a point that is in world space
  95282. * @param position The world position
  95283. * @param mesh The mesh that this bone is attached to
  95284. * @returns The local position
  95285. */
  95286. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95287. /**
  95288. * Get the local position of a point that is in world space and copy it to the result param
  95289. * @param position The world position
  95290. * @param mesh The mesh that this bone is attached to
  95291. * @param result The vector3 that the local position should be copied to
  95292. */
  95293. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95294. }
  95295. }
  95296. declare module BABYLON {
  95297. /**
  95298. * Defines a runtime animation
  95299. */
  95300. export class RuntimeAnimation {
  95301. private _events;
  95302. /**
  95303. * The current frame of the runtime animation
  95304. */
  95305. private _currentFrame;
  95306. /**
  95307. * The animation used by the runtime animation
  95308. */
  95309. private _animation;
  95310. /**
  95311. * The target of the runtime animation
  95312. */
  95313. private _target;
  95314. /**
  95315. * The initiating animatable
  95316. */
  95317. private _host;
  95318. /**
  95319. * The original value of the runtime animation
  95320. */
  95321. private _originalValue;
  95322. /**
  95323. * The original blend value of the runtime animation
  95324. */
  95325. private _originalBlendValue;
  95326. /**
  95327. * The offsets cache of the runtime animation
  95328. */
  95329. private _offsetsCache;
  95330. /**
  95331. * The high limits cache of the runtime animation
  95332. */
  95333. private _highLimitsCache;
  95334. /**
  95335. * Specifies if the runtime animation has been stopped
  95336. */
  95337. private _stopped;
  95338. /**
  95339. * The blending factor of the runtime animation
  95340. */
  95341. private _blendingFactor;
  95342. /**
  95343. * The BabylonJS scene
  95344. */
  95345. private _scene;
  95346. /**
  95347. * The current value of the runtime animation
  95348. */
  95349. private _currentValue;
  95350. /** @hidden */
  95351. _animationState: _IAnimationState;
  95352. /**
  95353. * The active target of the runtime animation
  95354. */
  95355. private _activeTargets;
  95356. private _currentActiveTarget;
  95357. private _directTarget;
  95358. /**
  95359. * The target path of the runtime animation
  95360. */
  95361. private _targetPath;
  95362. /**
  95363. * The weight of the runtime animation
  95364. */
  95365. private _weight;
  95366. /**
  95367. * The ratio offset of the runtime animation
  95368. */
  95369. private _ratioOffset;
  95370. /**
  95371. * The previous delay of the runtime animation
  95372. */
  95373. private _previousDelay;
  95374. /**
  95375. * The previous ratio of the runtime animation
  95376. */
  95377. private _previousRatio;
  95378. private _enableBlending;
  95379. private _keys;
  95380. private _minFrame;
  95381. private _maxFrame;
  95382. private _minValue;
  95383. private _maxValue;
  95384. private _targetIsArray;
  95385. /**
  95386. * Gets the current frame of the runtime animation
  95387. */
  95388. get currentFrame(): number;
  95389. /**
  95390. * Gets the weight of the runtime animation
  95391. */
  95392. get weight(): number;
  95393. /**
  95394. * Gets the current value of the runtime animation
  95395. */
  95396. get currentValue(): any;
  95397. /**
  95398. * Gets the target path of the runtime animation
  95399. */
  95400. get targetPath(): string;
  95401. /**
  95402. * Gets the actual target of the runtime animation
  95403. */
  95404. get target(): any;
  95405. /**
  95406. * Gets the additive state of the runtime animation
  95407. */
  95408. get isAdditive(): boolean;
  95409. /** @hidden */
  95410. _onLoop: () => void;
  95411. /**
  95412. * Create a new RuntimeAnimation object
  95413. * @param target defines the target of the animation
  95414. * @param animation defines the source animation object
  95415. * @param scene defines the hosting scene
  95416. * @param host defines the initiating Animatable
  95417. */
  95418. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  95419. private _preparePath;
  95420. /**
  95421. * Gets the animation from the runtime animation
  95422. */
  95423. get animation(): Animation;
  95424. /**
  95425. * Resets the runtime animation to the beginning
  95426. * @param restoreOriginal defines whether to restore the target property to the original value
  95427. */
  95428. reset(restoreOriginal?: boolean): void;
  95429. /**
  95430. * Specifies if the runtime animation is stopped
  95431. * @returns Boolean specifying if the runtime animation is stopped
  95432. */
  95433. isStopped(): boolean;
  95434. /**
  95435. * Disposes of the runtime animation
  95436. */
  95437. dispose(): void;
  95438. /**
  95439. * Apply the interpolated value to the target
  95440. * @param currentValue defines the value computed by the animation
  95441. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  95442. */
  95443. setValue(currentValue: any, weight: number): void;
  95444. private _getOriginalValues;
  95445. private _setValue;
  95446. /**
  95447. * Gets the loop pmode of the runtime animation
  95448. * @returns Loop Mode
  95449. */
  95450. private _getCorrectLoopMode;
  95451. /**
  95452. * Move the current animation to a given frame
  95453. * @param frame defines the frame to move to
  95454. */
  95455. goToFrame(frame: number): void;
  95456. /**
  95457. * @hidden Internal use only
  95458. */
  95459. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  95460. /**
  95461. * Execute the current animation
  95462. * @param delay defines the delay to add to the current frame
  95463. * @param from defines the lower bound of the animation range
  95464. * @param to defines the upper bound of the animation range
  95465. * @param loop defines if the current animation must loop
  95466. * @param speedRatio defines the current speed ratio
  95467. * @param weight defines the weight of the animation (default is -1 so no weight)
  95468. * @param onLoop optional callback called when animation loops
  95469. * @returns a boolean indicating if the animation is running
  95470. */
  95471. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  95472. }
  95473. }
  95474. declare module BABYLON {
  95475. /**
  95476. * Class used to store an actual running animation
  95477. */
  95478. export class Animatable {
  95479. /** defines the target object */
  95480. target: any;
  95481. /** defines the starting frame number (default is 0) */
  95482. fromFrame: number;
  95483. /** defines the ending frame number (default is 100) */
  95484. toFrame: number;
  95485. /** defines if the animation must loop (default is false) */
  95486. loopAnimation: boolean;
  95487. /** defines a callback to call when animation ends if it is not looping */
  95488. onAnimationEnd?: (() => void) | null | undefined;
  95489. /** defines a callback to call when animation loops */
  95490. onAnimationLoop?: (() => void) | null | undefined;
  95491. /** defines whether the animation should be evaluated additively */
  95492. isAdditive: boolean;
  95493. private _localDelayOffset;
  95494. private _pausedDelay;
  95495. private _runtimeAnimations;
  95496. private _paused;
  95497. private _scene;
  95498. private _speedRatio;
  95499. private _weight;
  95500. private _syncRoot;
  95501. /**
  95502. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  95503. * This will only apply for non looping animation (default is true)
  95504. */
  95505. disposeOnEnd: boolean;
  95506. /**
  95507. * Gets a boolean indicating if the animation has started
  95508. */
  95509. animationStarted: boolean;
  95510. /**
  95511. * Observer raised when the animation ends
  95512. */
  95513. onAnimationEndObservable: Observable<Animatable>;
  95514. /**
  95515. * Observer raised when the animation loops
  95516. */
  95517. onAnimationLoopObservable: Observable<Animatable>;
  95518. /**
  95519. * Gets the root Animatable used to synchronize and normalize animations
  95520. */
  95521. get syncRoot(): Nullable<Animatable>;
  95522. /**
  95523. * Gets the current frame of the first RuntimeAnimation
  95524. * Used to synchronize Animatables
  95525. */
  95526. get masterFrame(): number;
  95527. /**
  95528. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  95529. */
  95530. get weight(): number;
  95531. set weight(value: number);
  95532. /**
  95533. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  95534. */
  95535. get speedRatio(): number;
  95536. set speedRatio(value: number);
  95537. /**
  95538. * Creates a new Animatable
  95539. * @param scene defines the hosting scene
  95540. * @param target defines the target object
  95541. * @param fromFrame defines the starting frame number (default is 0)
  95542. * @param toFrame defines the ending frame number (default is 100)
  95543. * @param loopAnimation defines if the animation must loop (default is false)
  95544. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  95545. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  95546. * @param animations defines a group of animation to add to the new Animatable
  95547. * @param onAnimationLoop defines a callback to call when animation loops
  95548. * @param isAdditive defines whether the animation should be evaluated additively
  95549. */
  95550. constructor(scene: Scene,
  95551. /** defines the target object */
  95552. target: any,
  95553. /** defines the starting frame number (default is 0) */
  95554. fromFrame?: number,
  95555. /** defines the ending frame number (default is 100) */
  95556. toFrame?: number,
  95557. /** defines if the animation must loop (default is false) */
  95558. loopAnimation?: boolean, speedRatio?: number,
  95559. /** defines a callback to call when animation ends if it is not looping */
  95560. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  95561. /** defines a callback to call when animation loops */
  95562. onAnimationLoop?: (() => void) | null | undefined,
  95563. /** defines whether the animation should be evaluated additively */
  95564. isAdditive?: boolean);
  95565. /**
  95566. * Synchronize and normalize current Animatable with a source Animatable
  95567. * This is useful when using animation weights and when animations are not of the same length
  95568. * @param root defines the root Animatable to synchronize with
  95569. * @returns the current Animatable
  95570. */
  95571. syncWith(root: Animatable): Animatable;
  95572. /**
  95573. * Gets the list of runtime animations
  95574. * @returns an array of RuntimeAnimation
  95575. */
  95576. getAnimations(): RuntimeAnimation[];
  95577. /**
  95578. * Adds more animations to the current animatable
  95579. * @param target defines the target of the animations
  95580. * @param animations defines the new animations to add
  95581. */
  95582. appendAnimations(target: any, animations: Animation[]): void;
  95583. /**
  95584. * Gets the source animation for a specific property
  95585. * @param property defines the propertyu to look for
  95586. * @returns null or the source animation for the given property
  95587. */
  95588. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  95589. /**
  95590. * Gets the runtime animation for a specific property
  95591. * @param property defines the propertyu to look for
  95592. * @returns null or the runtime animation for the given property
  95593. */
  95594. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  95595. /**
  95596. * Resets the animatable to its original state
  95597. */
  95598. reset(): void;
  95599. /**
  95600. * Allows the animatable to blend with current running animations
  95601. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  95602. * @param blendingSpeed defines the blending speed to use
  95603. */
  95604. enableBlending(blendingSpeed: number): void;
  95605. /**
  95606. * Disable animation blending
  95607. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  95608. */
  95609. disableBlending(): void;
  95610. /**
  95611. * Jump directly to a given frame
  95612. * @param frame defines the frame to jump to
  95613. */
  95614. goToFrame(frame: number): void;
  95615. /**
  95616. * Pause the animation
  95617. */
  95618. pause(): void;
  95619. /**
  95620. * Restart the animation
  95621. */
  95622. restart(): void;
  95623. private _raiseOnAnimationEnd;
  95624. /**
  95625. * Stop and delete the current animation
  95626. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  95627. * @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)
  95628. */
  95629. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  95630. /**
  95631. * Wait asynchronously for the animation to end
  95632. * @returns a promise which will be fullfilled when the animation ends
  95633. */
  95634. waitAsync(): Promise<Animatable>;
  95635. /** @hidden */
  95636. _animate(delay: number): boolean;
  95637. }
  95638. interface Scene {
  95639. /** @hidden */
  95640. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  95641. /** @hidden */
  95642. _processLateAnimationBindingsForMatrices(holder: {
  95643. totalWeight: number;
  95644. totalAdditiveWeight: number;
  95645. animations: RuntimeAnimation[];
  95646. additiveAnimations: RuntimeAnimation[];
  95647. originalValue: Matrix;
  95648. }): any;
  95649. /** @hidden */
  95650. _processLateAnimationBindingsForQuaternions(holder: {
  95651. totalWeight: number;
  95652. totalAdditiveWeight: number;
  95653. animations: RuntimeAnimation[];
  95654. additiveAnimations: RuntimeAnimation[];
  95655. originalValue: Quaternion;
  95656. }, refQuaternion: Quaternion): Quaternion;
  95657. /** @hidden */
  95658. _processLateAnimationBindings(): void;
  95659. /**
  95660. * Will start the animation sequence of a given target
  95661. * @param target defines the target
  95662. * @param from defines from which frame should animation start
  95663. * @param to defines until which frame should animation run.
  95664. * @param weight defines the weight to apply to the animation (1.0 by default)
  95665. * @param loop defines if the animation loops
  95666. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  95667. * @param onAnimationEnd defines the function to be executed when the animation ends
  95668. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  95669. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  95670. * @param onAnimationLoop defines the callback to call when an animation loops
  95671. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95672. * @returns the animatable object created for this animation
  95673. */
  95674. 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;
  95675. /**
  95676. * Will start the animation sequence of a given target
  95677. * @param target defines the target
  95678. * @param from defines from which frame should animation start
  95679. * @param to defines until which frame should animation run.
  95680. * @param loop defines if the animation loops
  95681. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  95682. * @param onAnimationEnd defines the function to be executed when the animation ends
  95683. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  95684. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  95685. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  95686. * @param onAnimationLoop defines the callback to call when an animation loops
  95687. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95688. * @returns the animatable object created for this animation
  95689. */
  95690. 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;
  95691. /**
  95692. * Will start the animation sequence of a given target and its hierarchy
  95693. * @param target defines the target
  95694. * @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.
  95695. * @param from defines from which frame should animation start
  95696. * @param to defines until which frame should animation run.
  95697. * @param loop defines if the animation loops
  95698. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  95699. * @param onAnimationEnd defines the function to be executed when the animation ends
  95700. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  95701. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  95702. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  95703. * @param onAnimationLoop defines the callback to call when an animation loops
  95704. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95705. * @returns the list of created animatables
  95706. */
  95707. 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[];
  95708. /**
  95709. * Begin a new animation on a given node
  95710. * @param target defines the target where the animation will take place
  95711. * @param animations defines the list of animations to start
  95712. * @param from defines the initial value
  95713. * @param to defines the final value
  95714. * @param loop defines if you want animation to loop (off by default)
  95715. * @param speedRatio defines the speed ratio to apply to all animations
  95716. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  95717. * @param onAnimationLoop defines the callback to call when an animation loops
  95718. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95719. * @returns the list of created animatables
  95720. */
  95721. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  95722. /**
  95723. * Begin a new animation on a given node and its hierarchy
  95724. * @param target defines the root node where the animation will take place
  95725. * @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.
  95726. * @param animations defines the list of animations to start
  95727. * @param from defines the initial value
  95728. * @param to defines the final value
  95729. * @param loop defines if you want animation to loop (off by default)
  95730. * @param speedRatio defines the speed ratio to apply to all animations
  95731. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  95732. * @param onAnimationLoop defines the callback to call when an animation loops
  95733. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  95734. * @returns the list of animatables created for all nodes
  95735. */
  95736. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  95737. /**
  95738. * Gets the animatable associated with a specific target
  95739. * @param target defines the target of the animatable
  95740. * @returns the required animatable if found
  95741. */
  95742. getAnimatableByTarget(target: any): Nullable<Animatable>;
  95743. /**
  95744. * Gets all animatables associated with a given target
  95745. * @param target defines the target to look animatables for
  95746. * @returns an array of Animatables
  95747. */
  95748. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  95749. /**
  95750. * Stops and removes all animations that have been applied to the scene
  95751. */
  95752. stopAllAnimations(): void;
  95753. /**
  95754. * Gets the current delta time used by animation engine
  95755. */
  95756. deltaTime: number;
  95757. }
  95758. interface Bone {
  95759. /**
  95760. * Copy an animation range from another bone
  95761. * @param source defines the source bone
  95762. * @param rangeName defines the range name to copy
  95763. * @param frameOffset defines the frame offset
  95764. * @param rescaleAsRequired defines if rescaling must be applied if required
  95765. * @param skelDimensionsRatio defines the scaling ratio
  95766. * @returns true if operation was successful
  95767. */
  95768. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  95769. }
  95770. }
  95771. declare module BABYLON {
  95772. /**
  95773. * Class used to handle skinning animations
  95774. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95775. */
  95776. export class Skeleton implements IAnimatable {
  95777. /** defines the skeleton name */
  95778. name: string;
  95779. /** defines the skeleton Id */
  95780. id: string;
  95781. /**
  95782. * Defines the list of child bones
  95783. */
  95784. bones: Bone[];
  95785. /**
  95786. * Defines an estimate of the dimension of the skeleton at rest
  95787. */
  95788. dimensionsAtRest: Vector3;
  95789. /**
  95790. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  95791. */
  95792. needInitialSkinMatrix: boolean;
  95793. /**
  95794. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  95795. */
  95796. overrideMesh: Nullable<AbstractMesh>;
  95797. /**
  95798. * Gets the list of animations attached to this skeleton
  95799. */
  95800. animations: Array<Animation>;
  95801. private _scene;
  95802. private _isDirty;
  95803. private _transformMatrices;
  95804. private _transformMatrixTexture;
  95805. private _meshesWithPoseMatrix;
  95806. private _animatables;
  95807. private _identity;
  95808. private _synchronizedWithMesh;
  95809. private _ranges;
  95810. private _lastAbsoluteTransformsUpdateId;
  95811. private _canUseTextureForBones;
  95812. private _uniqueId;
  95813. /** @hidden */
  95814. _numBonesWithLinkedTransformNode: number;
  95815. /** @hidden */
  95816. _hasWaitingData: Nullable<boolean>;
  95817. /** @hidden */
  95818. _waitingOverrideMeshId: Nullable<string>;
  95819. /**
  95820. * Specifies if the skeleton should be serialized
  95821. */
  95822. doNotSerialize: boolean;
  95823. private _useTextureToStoreBoneMatrices;
  95824. /**
  95825. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  95826. * Please note that this option is not available if the hardware does not support it
  95827. */
  95828. get useTextureToStoreBoneMatrices(): boolean;
  95829. set useTextureToStoreBoneMatrices(value: boolean);
  95830. private _animationPropertiesOverride;
  95831. /**
  95832. * Gets or sets the animation properties override
  95833. */
  95834. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95835. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  95836. /**
  95837. * List of inspectable custom properties (used by the Inspector)
  95838. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95839. */
  95840. inspectableCustomProperties: IInspectable[];
  95841. /**
  95842. * An observable triggered before computing the skeleton's matrices
  95843. */
  95844. onBeforeComputeObservable: Observable<Skeleton>;
  95845. /**
  95846. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  95847. */
  95848. get isUsingTextureForMatrices(): boolean;
  95849. /**
  95850. * Gets the unique ID of this skeleton
  95851. */
  95852. get uniqueId(): number;
  95853. /**
  95854. * Creates a new skeleton
  95855. * @param name defines the skeleton name
  95856. * @param id defines the skeleton Id
  95857. * @param scene defines the hosting scene
  95858. */
  95859. constructor(
  95860. /** defines the skeleton name */
  95861. name: string,
  95862. /** defines the skeleton Id */
  95863. id: string, scene: Scene);
  95864. /**
  95865. * Gets the current object class name.
  95866. * @return the class name
  95867. */
  95868. getClassName(): string;
  95869. /**
  95870. * Returns an array containing the root bones
  95871. * @returns an array containing the root bones
  95872. */
  95873. getChildren(): Array<Bone>;
  95874. /**
  95875. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  95876. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  95877. * @returns a Float32Array containing matrices data
  95878. */
  95879. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  95880. /**
  95881. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  95882. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  95883. * @returns a raw texture containing the data
  95884. */
  95885. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  95886. /**
  95887. * Gets the current hosting scene
  95888. * @returns a scene object
  95889. */
  95890. getScene(): Scene;
  95891. /**
  95892. * Gets a string representing the current skeleton data
  95893. * @param fullDetails defines a boolean indicating if we want a verbose version
  95894. * @returns a string representing the current skeleton data
  95895. */
  95896. toString(fullDetails?: boolean): string;
  95897. /**
  95898. * Get bone's index searching by name
  95899. * @param name defines bone's name to search for
  95900. * @return the indice of the bone. Returns -1 if not found
  95901. */
  95902. getBoneIndexByName(name: string): number;
  95903. /**
  95904. * Creater a new animation range
  95905. * @param name defines the name of the range
  95906. * @param from defines the start key
  95907. * @param to defines the end key
  95908. */
  95909. createAnimationRange(name: string, from: number, to: number): void;
  95910. /**
  95911. * Delete a specific animation range
  95912. * @param name defines the name of the range
  95913. * @param deleteFrames defines if frames must be removed as well
  95914. */
  95915. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  95916. /**
  95917. * Gets a specific animation range
  95918. * @param name defines the name of the range to look for
  95919. * @returns the requested animation range or null if not found
  95920. */
  95921. getAnimationRange(name: string): Nullable<AnimationRange>;
  95922. /**
  95923. * Gets the list of all animation ranges defined on this skeleton
  95924. * @returns an array
  95925. */
  95926. getAnimationRanges(): Nullable<AnimationRange>[];
  95927. /**
  95928. * Copy animation range from a source skeleton.
  95929. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  95930. * @param source defines the source skeleton
  95931. * @param name defines the name of the range to copy
  95932. * @param rescaleAsRequired defines if rescaling must be applied if required
  95933. * @returns true if operation was successful
  95934. */
  95935. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  95936. /**
  95937. * Forces the skeleton to go to rest pose
  95938. */
  95939. returnToRest(): void;
  95940. private _getHighestAnimationFrame;
  95941. /**
  95942. * Begin a specific animation range
  95943. * @param name defines the name of the range to start
  95944. * @param loop defines if looping must be turned on (false by default)
  95945. * @param speedRatio defines the speed ratio to apply (1 by default)
  95946. * @param onAnimationEnd defines a callback which will be called when animation will end
  95947. * @returns a new animatable
  95948. */
  95949. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  95950. /**
  95951. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  95952. * @param skeleton defines the Skeleton containing the animation range to convert
  95953. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  95954. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  95955. * @returns the original skeleton
  95956. */
  95957. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  95958. /** @hidden */
  95959. _markAsDirty(): void;
  95960. /** @hidden */
  95961. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  95962. /** @hidden */
  95963. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  95964. private _computeTransformMatrices;
  95965. /**
  95966. * Build all resources required to render a skeleton
  95967. */
  95968. prepare(): void;
  95969. /**
  95970. * Gets the list of animatables currently running for this skeleton
  95971. * @returns an array of animatables
  95972. */
  95973. getAnimatables(): IAnimatable[];
  95974. /**
  95975. * Clone the current skeleton
  95976. * @param name defines the name of the new skeleton
  95977. * @param id defines the id of the new skeleton
  95978. * @returns the new skeleton
  95979. */
  95980. clone(name: string, id?: string): Skeleton;
  95981. /**
  95982. * Enable animation blending for this skeleton
  95983. * @param blendingSpeed defines the blending speed to apply
  95984. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  95985. */
  95986. enableBlending(blendingSpeed?: number): void;
  95987. /**
  95988. * Releases all resources associated with the current skeleton
  95989. */
  95990. dispose(): void;
  95991. /**
  95992. * Serialize the skeleton in a JSON object
  95993. * @returns a JSON object
  95994. */
  95995. serialize(): any;
  95996. /**
  95997. * Creates a new skeleton from serialized data
  95998. * @param parsedSkeleton defines the serialized data
  95999. * @param scene defines the hosting scene
  96000. * @returns a new skeleton
  96001. */
  96002. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  96003. /**
  96004. * Compute all node absolute transforms
  96005. * @param forceUpdate defines if computation must be done even if cache is up to date
  96006. */
  96007. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  96008. /**
  96009. * Gets the root pose matrix
  96010. * @returns a matrix
  96011. */
  96012. getPoseMatrix(): Nullable<Matrix>;
  96013. /**
  96014. * Sorts bones per internal index
  96015. */
  96016. sortBones(): void;
  96017. private _sortBones;
  96018. }
  96019. }
  96020. declare module BABYLON {
  96021. /**
  96022. * Creates an instance based on a source mesh.
  96023. */
  96024. export class InstancedMesh extends AbstractMesh {
  96025. private _sourceMesh;
  96026. private _currentLOD;
  96027. /** @hidden */
  96028. _indexInSourceMeshInstanceArray: number;
  96029. constructor(name: string, source: Mesh);
  96030. /**
  96031. * Returns the string "InstancedMesh".
  96032. */
  96033. getClassName(): string;
  96034. /** Gets the list of lights affecting that mesh */
  96035. get lightSources(): Light[];
  96036. _resyncLightSources(): void;
  96037. _resyncLightSource(light: Light): void;
  96038. _removeLightSource(light: Light, dispose: boolean): void;
  96039. /**
  96040. * If the source mesh receives shadows
  96041. */
  96042. get receiveShadows(): boolean;
  96043. /**
  96044. * The material of the source mesh
  96045. */
  96046. get material(): Nullable<Material>;
  96047. /**
  96048. * Visibility of the source mesh
  96049. */
  96050. get visibility(): number;
  96051. /**
  96052. * Skeleton of the source mesh
  96053. */
  96054. get skeleton(): Nullable<Skeleton>;
  96055. /**
  96056. * Rendering ground id of the source mesh
  96057. */
  96058. get renderingGroupId(): number;
  96059. set renderingGroupId(value: number);
  96060. /**
  96061. * Returns the total number of vertices (integer).
  96062. */
  96063. getTotalVertices(): number;
  96064. /**
  96065. * Returns a positive integer : the total number of indices in this mesh geometry.
  96066. * @returns the numner of indices or zero if the mesh has no geometry.
  96067. */
  96068. getTotalIndices(): number;
  96069. /**
  96070. * The source mesh of the instance
  96071. */
  96072. get sourceMesh(): Mesh;
  96073. /**
  96074. * Creates a new InstancedMesh object from the mesh model.
  96075. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  96076. * @param name defines the name of the new instance
  96077. * @returns a new InstancedMesh
  96078. */
  96079. createInstance(name: string): InstancedMesh;
  96080. /**
  96081. * Is this node ready to be used/rendered
  96082. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  96083. * @return {boolean} is it ready
  96084. */
  96085. isReady(completeCheck?: boolean): boolean;
  96086. /**
  96087. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  96088. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  96089. * @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.
  96090. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  96091. */
  96092. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  96093. /**
  96094. * Sets the vertex data of the mesh geometry for the requested `kind`.
  96095. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  96096. * The `data` are either a numeric array either a Float32Array.
  96097. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  96098. * 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).
  96099. * Note that a new underlying VertexBuffer object is created each call.
  96100. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  96101. *
  96102. * Possible `kind` values :
  96103. * - VertexBuffer.PositionKind
  96104. * - VertexBuffer.UVKind
  96105. * - VertexBuffer.UV2Kind
  96106. * - VertexBuffer.UV3Kind
  96107. * - VertexBuffer.UV4Kind
  96108. * - VertexBuffer.UV5Kind
  96109. * - VertexBuffer.UV6Kind
  96110. * - VertexBuffer.ColorKind
  96111. * - VertexBuffer.MatricesIndicesKind
  96112. * - VertexBuffer.MatricesIndicesExtraKind
  96113. * - VertexBuffer.MatricesWeightsKind
  96114. * - VertexBuffer.MatricesWeightsExtraKind
  96115. *
  96116. * Returns the Mesh.
  96117. */
  96118. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  96119. /**
  96120. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  96121. * If the mesh has no geometry, it is simply returned as it is.
  96122. * The `data` are either a numeric array either a Float32Array.
  96123. * No new underlying VertexBuffer object is created.
  96124. * 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.
  96125. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  96126. *
  96127. * Possible `kind` values :
  96128. * - VertexBuffer.PositionKind
  96129. * - VertexBuffer.UVKind
  96130. * - VertexBuffer.UV2Kind
  96131. * - VertexBuffer.UV3Kind
  96132. * - VertexBuffer.UV4Kind
  96133. * - VertexBuffer.UV5Kind
  96134. * - VertexBuffer.UV6Kind
  96135. * - VertexBuffer.ColorKind
  96136. * - VertexBuffer.MatricesIndicesKind
  96137. * - VertexBuffer.MatricesIndicesExtraKind
  96138. * - VertexBuffer.MatricesWeightsKind
  96139. * - VertexBuffer.MatricesWeightsExtraKind
  96140. *
  96141. * Returns the Mesh.
  96142. */
  96143. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  96144. /**
  96145. * Sets the mesh indices.
  96146. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  96147. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  96148. * This method creates a new index buffer each call.
  96149. * Returns the Mesh.
  96150. */
  96151. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  96152. /**
  96153. * Boolean : True if the mesh owns the requested kind of data.
  96154. */
  96155. isVerticesDataPresent(kind: string): boolean;
  96156. /**
  96157. * Returns an array of indices (IndicesArray).
  96158. */
  96159. getIndices(): Nullable<IndicesArray>;
  96160. get _positions(): Nullable<Vector3[]>;
  96161. /**
  96162. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  96163. * This means the mesh underlying bounding box and sphere are recomputed.
  96164. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  96165. * @returns the current mesh
  96166. */
  96167. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  96168. /** @hidden */
  96169. _preActivate(): InstancedMesh;
  96170. /** @hidden */
  96171. _activate(renderId: number, intermediateRendering: boolean): boolean;
  96172. /** @hidden */
  96173. _postActivate(): void;
  96174. getWorldMatrix(): Matrix;
  96175. get isAnInstance(): boolean;
  96176. /**
  96177. * Returns the current associated LOD AbstractMesh.
  96178. */
  96179. getLOD(camera: Camera): AbstractMesh;
  96180. /** @hidden */
  96181. _preActivateForIntermediateRendering(renderId: number): Mesh;
  96182. /** @hidden */
  96183. _syncSubMeshes(): InstancedMesh;
  96184. /** @hidden */
  96185. _generatePointsArray(): boolean;
  96186. /** @hidden */
  96187. _updateBoundingInfo(): AbstractMesh;
  96188. /**
  96189. * Creates a new InstancedMesh from the current mesh.
  96190. * - name (string) : the cloned mesh name
  96191. * - newParent (optional Node) : the optional Node to parent the clone to.
  96192. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  96193. *
  96194. * Returns the clone.
  96195. */
  96196. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  96197. /**
  96198. * Disposes the InstancedMesh.
  96199. * Returns nothing.
  96200. */
  96201. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96202. }
  96203. interface Mesh {
  96204. /**
  96205. * Register a custom buffer that will be instanced
  96206. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  96207. * @param kind defines the buffer kind
  96208. * @param stride defines the stride in floats
  96209. */
  96210. registerInstancedBuffer(kind: string, stride: number): void;
  96211. /**
  96212. * true to use the edge renderer for all instances of this mesh
  96213. */
  96214. edgesShareWithInstances: boolean;
  96215. /** @hidden */
  96216. _userInstancedBuffersStorage: {
  96217. data: {
  96218. [key: string]: Float32Array;
  96219. };
  96220. sizes: {
  96221. [key: string]: number;
  96222. };
  96223. vertexBuffers: {
  96224. [key: string]: Nullable<VertexBuffer>;
  96225. };
  96226. strides: {
  96227. [key: string]: number;
  96228. };
  96229. };
  96230. }
  96231. interface AbstractMesh {
  96232. /**
  96233. * Object used to store instanced buffers defined by user
  96234. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  96235. */
  96236. instancedBuffers: {
  96237. [key: string]: any;
  96238. };
  96239. }
  96240. }
  96241. declare module BABYLON {
  96242. /**
  96243. * Defines the options associated with the creation of a shader material.
  96244. */
  96245. export interface IShaderMaterialOptions {
  96246. /**
  96247. * Does the material work in alpha blend mode
  96248. */
  96249. needAlphaBlending: boolean;
  96250. /**
  96251. * Does the material work in alpha test mode
  96252. */
  96253. needAlphaTesting: boolean;
  96254. /**
  96255. * The list of attribute names used in the shader
  96256. */
  96257. attributes: string[];
  96258. /**
  96259. * The list of unifrom names used in the shader
  96260. */
  96261. uniforms: string[];
  96262. /**
  96263. * The list of UBO names used in the shader
  96264. */
  96265. uniformBuffers: string[];
  96266. /**
  96267. * The list of sampler names used in the shader
  96268. */
  96269. samplers: string[];
  96270. /**
  96271. * The list of defines used in the shader
  96272. */
  96273. defines: string[];
  96274. }
  96275. /**
  96276. * 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.
  96277. *
  96278. * This returned material effects how the mesh will look based on the code in the shaders.
  96279. *
  96280. * @see https://doc.babylonjs.com/how_to/shader_material
  96281. */
  96282. export class ShaderMaterial extends Material {
  96283. private _shaderPath;
  96284. private _options;
  96285. private _textures;
  96286. private _textureArrays;
  96287. private _floats;
  96288. private _ints;
  96289. private _floatsArrays;
  96290. private _colors3;
  96291. private _colors3Arrays;
  96292. private _colors4;
  96293. private _colors4Arrays;
  96294. private _vectors2;
  96295. private _vectors3;
  96296. private _vectors4;
  96297. private _matrices;
  96298. private _matrixArrays;
  96299. private _matrices3x3;
  96300. private _matrices2x2;
  96301. private _vectors2Arrays;
  96302. private _vectors3Arrays;
  96303. private _vectors4Arrays;
  96304. private _cachedWorldViewMatrix;
  96305. private _cachedWorldViewProjectionMatrix;
  96306. private _renderId;
  96307. private _multiview;
  96308. private _cachedDefines;
  96309. /** Define the Url to load snippets */
  96310. static SnippetUrl: string;
  96311. /** Snippet ID if the material was created from the snippet server */
  96312. snippetId: string;
  96313. /**
  96314. * Instantiate a new shader material.
  96315. * 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.
  96316. * This returned material effects how the mesh will look based on the code in the shaders.
  96317. * @see https://doc.babylonjs.com/how_to/shader_material
  96318. * @param name Define the name of the material in the scene
  96319. * @param scene Define the scene the material belongs to
  96320. * @param shaderPath Defines the route to the shader code in one of three ways:
  96321. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  96322. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  96323. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  96324. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  96325. * @param options Define the options used to create the shader
  96326. */
  96327. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  96328. /**
  96329. * Gets the shader path used to define the shader code
  96330. * It can be modified to trigger a new compilation
  96331. */
  96332. get shaderPath(): any;
  96333. /**
  96334. * Sets the shader path used to define the shader code
  96335. * It can be modified to trigger a new compilation
  96336. */
  96337. set shaderPath(shaderPath: any);
  96338. /**
  96339. * Gets the options used to compile the shader.
  96340. * They can be modified to trigger a new compilation
  96341. */
  96342. get options(): IShaderMaterialOptions;
  96343. /**
  96344. * Gets the current class name of the material e.g. "ShaderMaterial"
  96345. * Mainly use in serialization.
  96346. * @returns the class name
  96347. */
  96348. getClassName(): string;
  96349. /**
  96350. * Specifies if the material will require alpha blending
  96351. * @returns a boolean specifying if alpha blending is needed
  96352. */
  96353. needAlphaBlending(): boolean;
  96354. /**
  96355. * Specifies if this material should be rendered in alpha test mode
  96356. * @returns a boolean specifying if an alpha test is needed.
  96357. */
  96358. needAlphaTesting(): boolean;
  96359. private _checkUniform;
  96360. /**
  96361. * Set a texture in the shader.
  96362. * @param name Define the name of the uniform samplers as defined in the shader
  96363. * @param texture Define the texture to bind to this sampler
  96364. * @return the material itself allowing "fluent" like uniform updates
  96365. */
  96366. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  96367. /**
  96368. * Set a texture array in the shader.
  96369. * @param name Define the name of the uniform sampler array as defined in the shader
  96370. * @param textures Define the list of textures to bind to this sampler
  96371. * @return the material itself allowing "fluent" like uniform updates
  96372. */
  96373. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  96374. /**
  96375. * Set a float in the shader.
  96376. * @param name Define the name of the uniform as defined in the shader
  96377. * @param value Define the value to give to the uniform
  96378. * @return the material itself allowing "fluent" like uniform updates
  96379. */
  96380. setFloat(name: string, value: number): ShaderMaterial;
  96381. /**
  96382. * Set a int in the shader.
  96383. * @param name Define the name of the uniform as defined in the shader
  96384. * @param value Define the value to give to the uniform
  96385. * @return the material itself allowing "fluent" like uniform updates
  96386. */
  96387. setInt(name: string, value: number): ShaderMaterial;
  96388. /**
  96389. * Set an array of floats in the shader.
  96390. * @param name Define the name of the uniform as defined in the shader
  96391. * @param value Define the value to give to the uniform
  96392. * @return the material itself allowing "fluent" like uniform updates
  96393. */
  96394. setFloats(name: string, value: number[]): ShaderMaterial;
  96395. /**
  96396. * Set a vec3 in the shader from a Color3.
  96397. * @param name Define the name of the uniform as defined in the shader
  96398. * @param value Define the value to give to the uniform
  96399. * @return the material itself allowing "fluent" like uniform updates
  96400. */
  96401. setColor3(name: string, value: Color3): ShaderMaterial;
  96402. /**
  96403. * Set a vec3 array in the shader from a Color3 array.
  96404. * @param name Define the name of the uniform as defined in the shader
  96405. * @param value Define the value to give to the uniform
  96406. * @return the material itself allowing "fluent" like uniform updates
  96407. */
  96408. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  96409. /**
  96410. * Set a vec4 in the shader from a Color4.
  96411. * @param name Define the name of the uniform as defined in the shader
  96412. * @param value Define the value to give to the uniform
  96413. * @return the material itself allowing "fluent" like uniform updates
  96414. */
  96415. setColor4(name: string, value: Color4): ShaderMaterial;
  96416. /**
  96417. * Set a vec4 array in the shader from a Color4 array.
  96418. * @param name Define the name of the uniform as defined in the shader
  96419. * @param value Define the value to give to the uniform
  96420. * @return the material itself allowing "fluent" like uniform updates
  96421. */
  96422. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  96423. /**
  96424. * Set a vec2 in the shader from a Vector2.
  96425. * @param name Define the name of the uniform as defined in the shader
  96426. * @param value Define the value to give to the uniform
  96427. * @return the material itself allowing "fluent" like uniform updates
  96428. */
  96429. setVector2(name: string, value: Vector2): ShaderMaterial;
  96430. /**
  96431. * Set a vec3 in the shader from a Vector3.
  96432. * @param name Define the name of the uniform as defined in the shader
  96433. * @param value Define the value to give to the uniform
  96434. * @return the material itself allowing "fluent" like uniform updates
  96435. */
  96436. setVector3(name: string, value: Vector3): ShaderMaterial;
  96437. /**
  96438. * Set a vec4 in the shader from a Vector4.
  96439. * @param name Define the name of the uniform as defined in the shader
  96440. * @param value Define the value to give to the uniform
  96441. * @return the material itself allowing "fluent" like uniform updates
  96442. */
  96443. setVector4(name: string, value: Vector4): ShaderMaterial;
  96444. /**
  96445. * Set a mat4 in the shader from a Matrix.
  96446. * @param name Define the name of the uniform as defined in the shader
  96447. * @param value Define the value to give to the uniform
  96448. * @return the material itself allowing "fluent" like uniform updates
  96449. */
  96450. setMatrix(name: string, value: Matrix): ShaderMaterial;
  96451. /**
  96452. * Set a float32Array in the shader from a matrix array.
  96453. * @param name Define the name of the uniform as defined in the shader
  96454. * @param value Define the value to give to the uniform
  96455. * @return the material itself allowing "fluent" like uniform updates
  96456. */
  96457. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  96458. /**
  96459. * Set a mat3 in the shader from a Float32Array.
  96460. * @param name Define the name of the uniform as defined in the shader
  96461. * @param value Define the value to give to the uniform
  96462. * @return the material itself allowing "fluent" like uniform updates
  96463. */
  96464. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  96465. /**
  96466. * Set a mat2 in the shader from a Float32Array.
  96467. * @param name Define the name of the uniform as defined in the shader
  96468. * @param value Define the value to give to the uniform
  96469. * @return the material itself allowing "fluent" like uniform updates
  96470. */
  96471. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  96472. /**
  96473. * Set a vec2 array in the shader from a number array.
  96474. * @param name Define the name of the uniform as defined in the shader
  96475. * @param value Define the value to give to the uniform
  96476. * @return the material itself allowing "fluent" like uniform updates
  96477. */
  96478. setArray2(name: string, value: number[]): ShaderMaterial;
  96479. /**
  96480. * Set a vec3 array in the shader from a number array.
  96481. * @param name Define the name of the uniform as defined in the shader
  96482. * @param value Define the value to give to the uniform
  96483. * @return the material itself allowing "fluent" like uniform updates
  96484. */
  96485. setArray3(name: string, value: number[]): ShaderMaterial;
  96486. /**
  96487. * Set a vec4 array in the shader from a number array.
  96488. * @param name Define the name of the uniform as defined in the shader
  96489. * @param value Define the value to give to the uniform
  96490. * @return the material itself allowing "fluent" like uniform updates
  96491. */
  96492. setArray4(name: string, value: number[]): ShaderMaterial;
  96493. private _checkCache;
  96494. /**
  96495. * Specifies that the submesh is ready to be used
  96496. * @param mesh defines the mesh to check
  96497. * @param subMesh defines which submesh to check
  96498. * @param useInstances specifies that instances should be used
  96499. * @returns a boolean indicating that the submesh is ready or not
  96500. */
  96501. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  96502. /**
  96503. * Checks if the material is ready to render the requested mesh
  96504. * @param mesh Define the mesh to render
  96505. * @param useInstances Define whether or not the material is used with instances
  96506. * @returns true if ready, otherwise false
  96507. */
  96508. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  96509. /**
  96510. * Binds the world matrix to the material
  96511. * @param world defines the world transformation matrix
  96512. * @param effectOverride - If provided, use this effect instead of internal effect
  96513. */
  96514. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  96515. /**
  96516. * Binds the submesh to this material by preparing the effect and shader to draw
  96517. * @param world defines the world transformation matrix
  96518. * @param mesh defines the mesh containing the submesh
  96519. * @param subMesh defines the submesh to bind the material to
  96520. */
  96521. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  96522. /**
  96523. * Binds the material to the mesh
  96524. * @param world defines the world transformation matrix
  96525. * @param mesh defines the mesh to bind the material to
  96526. * @param effectOverride - If provided, use this effect instead of internal effect
  96527. */
  96528. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  96529. protected _afterBind(mesh?: Mesh): void;
  96530. /**
  96531. * Gets the active textures from the material
  96532. * @returns an array of textures
  96533. */
  96534. getActiveTextures(): BaseTexture[];
  96535. /**
  96536. * Specifies if the material uses a texture
  96537. * @param texture defines the texture to check against the material
  96538. * @returns a boolean specifying if the material uses the texture
  96539. */
  96540. hasTexture(texture: BaseTexture): boolean;
  96541. /**
  96542. * Makes a duplicate of the material, and gives it a new name
  96543. * @param name defines the new name for the duplicated material
  96544. * @returns the cloned material
  96545. */
  96546. clone(name: string): ShaderMaterial;
  96547. /**
  96548. * Disposes the material
  96549. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  96550. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  96551. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  96552. */
  96553. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  96554. /**
  96555. * Serializes this material in a JSON representation
  96556. * @returns the serialized material object
  96557. */
  96558. serialize(): any;
  96559. /**
  96560. * Creates a shader material from parsed shader material data
  96561. * @param source defines the JSON represnetation of the material
  96562. * @param scene defines the hosting scene
  96563. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96564. * @returns a new material
  96565. */
  96566. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  96567. /**
  96568. * Creates a new ShaderMaterial from a snippet saved in a remote file
  96569. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  96570. * @param url defines the url to load from
  96571. * @param scene defines the hosting scene
  96572. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96573. * @returns a promise that will resolve to the new ShaderMaterial
  96574. */
  96575. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  96576. /**
  96577. * Creates a ShaderMaterial from a snippet saved by the Inspector
  96578. * @param snippetId defines the snippet to load
  96579. * @param scene defines the hosting scene
  96580. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96581. * @returns a promise that will resolve to the new ShaderMaterial
  96582. */
  96583. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  96584. }
  96585. }
  96586. declare module BABYLON {
  96587. /** @hidden */
  96588. export var colorPixelShader: {
  96589. name: string;
  96590. shader: string;
  96591. };
  96592. }
  96593. declare module BABYLON {
  96594. /** @hidden */
  96595. export var colorVertexShader: {
  96596. name: string;
  96597. shader: string;
  96598. };
  96599. }
  96600. declare module BABYLON {
  96601. /**
  96602. * Line mesh
  96603. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  96604. */
  96605. export class LinesMesh extends Mesh {
  96606. /**
  96607. * If vertex color should be applied to the mesh
  96608. */
  96609. readonly useVertexColor?: boolean | undefined;
  96610. /**
  96611. * If vertex alpha should be applied to the mesh
  96612. */
  96613. readonly useVertexAlpha?: boolean | undefined;
  96614. /**
  96615. * Color of the line (Default: White)
  96616. */
  96617. color: Color3;
  96618. /**
  96619. * Alpha of the line (Default: 1)
  96620. */
  96621. alpha: number;
  96622. /**
  96623. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  96624. * This margin is expressed in world space coordinates, so its value may vary.
  96625. * Default value is 0.1
  96626. */
  96627. intersectionThreshold: number;
  96628. private _colorShader;
  96629. private color4;
  96630. /**
  96631. * Creates a new LinesMesh
  96632. * @param name defines the name
  96633. * @param scene defines the hosting scene
  96634. * @param parent defines the parent mesh if any
  96635. * @param source defines the optional source LinesMesh used to clone data from
  96636. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  96637. * When false, achieved by calling a clone(), also passing False.
  96638. * This will make creation of children, recursive.
  96639. * @param useVertexColor defines if this LinesMesh supports vertex color
  96640. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  96641. */
  96642. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  96643. /**
  96644. * If vertex color should be applied to the mesh
  96645. */
  96646. useVertexColor?: boolean | undefined,
  96647. /**
  96648. * If vertex alpha should be applied to the mesh
  96649. */
  96650. useVertexAlpha?: boolean | undefined);
  96651. private _addClipPlaneDefine;
  96652. private _removeClipPlaneDefine;
  96653. isReady(): boolean;
  96654. /**
  96655. * Returns the string "LineMesh"
  96656. */
  96657. getClassName(): string;
  96658. /**
  96659. * @hidden
  96660. */
  96661. get material(): Material;
  96662. /**
  96663. * @hidden
  96664. */
  96665. set material(value: Material);
  96666. /**
  96667. * @hidden
  96668. */
  96669. get checkCollisions(): boolean;
  96670. /** @hidden */
  96671. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  96672. /** @hidden */
  96673. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  96674. /**
  96675. * Disposes of the line mesh
  96676. * @param doNotRecurse If children should be disposed
  96677. */
  96678. dispose(doNotRecurse?: boolean): void;
  96679. /**
  96680. * Returns a new LineMesh object cloned from the current one.
  96681. */
  96682. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  96683. /**
  96684. * Creates a new InstancedLinesMesh object from the mesh model.
  96685. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  96686. * @param name defines the name of the new instance
  96687. * @returns a new InstancedLinesMesh
  96688. */
  96689. createInstance(name: string): InstancedLinesMesh;
  96690. }
  96691. /**
  96692. * Creates an instance based on a source LinesMesh
  96693. */
  96694. export class InstancedLinesMesh extends InstancedMesh {
  96695. /**
  96696. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  96697. * This margin is expressed in world space coordinates, so its value may vary.
  96698. * Initilized with the intersectionThreshold value of the source LinesMesh
  96699. */
  96700. intersectionThreshold: number;
  96701. constructor(name: string, source: LinesMesh);
  96702. /**
  96703. * Returns the string "InstancedLinesMesh".
  96704. */
  96705. getClassName(): string;
  96706. }
  96707. }
  96708. declare module BABYLON {
  96709. /** @hidden */
  96710. export var linePixelShader: {
  96711. name: string;
  96712. shader: string;
  96713. };
  96714. }
  96715. declare module BABYLON {
  96716. /** @hidden */
  96717. export var lineVertexShader: {
  96718. name: string;
  96719. shader: string;
  96720. };
  96721. }
  96722. declare module BABYLON {
  96723. interface Scene {
  96724. /** @hidden */
  96725. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  96726. }
  96727. interface AbstractMesh {
  96728. /**
  96729. * Gets the edgesRenderer associated with the mesh
  96730. */
  96731. edgesRenderer: Nullable<EdgesRenderer>;
  96732. }
  96733. interface LinesMesh {
  96734. /**
  96735. * Enables the edge rendering mode on the mesh.
  96736. * This mode makes the mesh edges visible
  96737. * @param epsilon defines the maximal distance between two angles to detect a face
  96738. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  96739. * @returns the currentAbstractMesh
  96740. * @see https://www.babylonjs-playground.com/#19O9TU#0
  96741. */
  96742. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  96743. }
  96744. interface InstancedLinesMesh {
  96745. /**
  96746. * Enables the edge rendering mode on the mesh.
  96747. * This mode makes the mesh edges visible
  96748. * @param epsilon defines the maximal distance between two angles to detect a face
  96749. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  96750. * @returns the current InstancedLinesMesh
  96751. * @see https://www.babylonjs-playground.com/#19O9TU#0
  96752. */
  96753. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  96754. }
  96755. /**
  96756. * Defines the minimum contract an Edges renderer should follow.
  96757. */
  96758. export interface IEdgesRenderer extends IDisposable {
  96759. /**
  96760. * Gets or sets a boolean indicating if the edgesRenderer is active
  96761. */
  96762. isEnabled: boolean;
  96763. /**
  96764. * Renders the edges of the attached mesh,
  96765. */
  96766. render(): void;
  96767. /**
  96768. * Checks wether or not the edges renderer is ready to render.
  96769. * @return true if ready, otherwise false.
  96770. */
  96771. isReady(): boolean;
  96772. /**
  96773. * List of instances to render in case the source mesh has instances
  96774. */
  96775. customInstances: SmartArray<Matrix>;
  96776. }
  96777. /**
  96778. * Defines the additional options of the edges renderer
  96779. */
  96780. export interface IEdgesRendererOptions {
  96781. /**
  96782. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  96783. * If not defined, the default value is true
  96784. */
  96785. useAlternateEdgeFinder?: boolean;
  96786. /**
  96787. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  96788. * If not defined, the default value is true.
  96789. * 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)
  96790. * This option is used only if useAlternateEdgeFinder = true
  96791. */
  96792. useFastVertexMerger?: boolean;
  96793. /**
  96794. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  96795. * The default value is 1e-6
  96796. * This option is used only if useAlternateEdgeFinder = true
  96797. */
  96798. epsilonVertexMerge?: number;
  96799. /**
  96800. * 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
  96801. * 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.
  96802. * This option is used only if useAlternateEdgeFinder = true
  96803. */
  96804. applyTessellation?: boolean;
  96805. /**
  96806. * 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
  96807. * The default value is 1e-6
  96808. * This option is used only if useAlternateEdgeFinder = true
  96809. */
  96810. epsilonVertexAligned?: number;
  96811. }
  96812. /**
  96813. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  96814. */
  96815. export class EdgesRenderer implements IEdgesRenderer {
  96816. /**
  96817. * Define the size of the edges with an orthographic camera
  96818. */
  96819. edgesWidthScalerForOrthographic: number;
  96820. /**
  96821. * Define the size of the edges with a perspective camera
  96822. */
  96823. edgesWidthScalerForPerspective: number;
  96824. protected _source: AbstractMesh;
  96825. protected _linesPositions: number[];
  96826. protected _linesNormals: number[];
  96827. protected _linesIndices: number[];
  96828. protected _epsilon: number;
  96829. protected _indicesCount: number;
  96830. protected _lineShader: ShaderMaterial;
  96831. protected _ib: DataBuffer;
  96832. protected _buffers: {
  96833. [key: string]: Nullable<VertexBuffer>;
  96834. };
  96835. protected _buffersForInstances: {
  96836. [key: string]: Nullable<VertexBuffer>;
  96837. };
  96838. protected _checkVerticesInsteadOfIndices: boolean;
  96839. protected _options: Nullable<IEdgesRendererOptions>;
  96840. private _meshRebuildObserver;
  96841. private _meshDisposeObserver;
  96842. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  96843. isEnabled: boolean;
  96844. /**
  96845. * List of instances to render in case the source mesh has instances
  96846. */
  96847. customInstances: SmartArray<Matrix>;
  96848. private static GetShader;
  96849. /**
  96850. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  96851. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  96852. * @param source Mesh used to create edges
  96853. * @param epsilon sum of angles in adjacency to check for edge
  96854. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  96855. * @param generateEdgesLines - should generate Lines or only prepare resources.
  96856. * @param options The options to apply when generating the edges
  96857. */
  96858. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  96859. protected _prepareRessources(): void;
  96860. /** @hidden */
  96861. _rebuild(): void;
  96862. /**
  96863. * Releases the required resources for the edges renderer
  96864. */
  96865. dispose(): void;
  96866. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  96867. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  96868. /**
  96869. * Checks if the pair of p0 and p1 is en edge
  96870. * @param faceIndex
  96871. * @param edge
  96872. * @param faceNormals
  96873. * @param p0
  96874. * @param p1
  96875. * @private
  96876. */
  96877. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  96878. /**
  96879. * push line into the position, normal and index buffer
  96880. * @protected
  96881. */
  96882. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  96883. /**
  96884. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  96885. */
  96886. private _tessellateTriangle;
  96887. private _generateEdgesLinesAlternate;
  96888. /**
  96889. * Generates lines edges from adjacencjes
  96890. * @private
  96891. */
  96892. _generateEdgesLines(): void;
  96893. /**
  96894. * Checks wether or not the edges renderer is ready to render.
  96895. * @return true if ready, otherwise false.
  96896. */
  96897. isReady(): boolean;
  96898. /**
  96899. * Renders the edges of the attached mesh,
  96900. */
  96901. render(): void;
  96902. }
  96903. /**
  96904. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  96905. */
  96906. export class LineEdgesRenderer extends EdgesRenderer {
  96907. /**
  96908. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  96909. * @param source LineMesh used to generate edges
  96910. * @param epsilon not important (specified angle for edge detection)
  96911. * @param checkVerticesInsteadOfIndices not important for LineMesh
  96912. */
  96913. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  96914. /**
  96915. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  96916. */
  96917. _generateEdgesLines(): void;
  96918. }
  96919. }
  96920. declare module BABYLON {
  96921. /**
  96922. * This represents the object necessary to create a rendering group.
  96923. * This is exclusively used and created by the rendering manager.
  96924. * To modify the behavior, you use the available helpers in your scene or meshes.
  96925. * @hidden
  96926. */
  96927. export class RenderingGroup {
  96928. index: number;
  96929. private static _zeroVector;
  96930. private _scene;
  96931. private _opaqueSubMeshes;
  96932. private _transparentSubMeshes;
  96933. private _alphaTestSubMeshes;
  96934. private _depthOnlySubMeshes;
  96935. private _particleSystems;
  96936. private _spriteManagers;
  96937. private _opaqueSortCompareFn;
  96938. private _alphaTestSortCompareFn;
  96939. private _transparentSortCompareFn;
  96940. private _renderOpaque;
  96941. private _renderAlphaTest;
  96942. private _renderTransparent;
  96943. /** @hidden */
  96944. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  96945. onBeforeTransparentRendering: () => void;
  96946. /**
  96947. * Set the opaque sort comparison function.
  96948. * If null the sub meshes will be render in the order they were created
  96949. */
  96950. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  96951. /**
  96952. * Set the alpha test sort comparison function.
  96953. * If null the sub meshes will be render in the order they were created
  96954. */
  96955. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  96956. /**
  96957. * Set the transparent sort comparison function.
  96958. * If null the sub meshes will be render in the order they were created
  96959. */
  96960. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  96961. /**
  96962. * Creates a new rendering group.
  96963. * @param index The rendering group index
  96964. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  96965. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  96966. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  96967. */
  96968. 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>);
  96969. /**
  96970. * Render all the sub meshes contained in the group.
  96971. * @param customRenderFunction Used to override the default render behaviour of the group.
  96972. * @returns true if rendered some submeshes.
  96973. */
  96974. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  96975. /**
  96976. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  96977. * @param subMeshes The submeshes to render
  96978. */
  96979. private renderOpaqueSorted;
  96980. /**
  96981. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  96982. * @param subMeshes The submeshes to render
  96983. */
  96984. private renderAlphaTestSorted;
  96985. /**
  96986. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  96987. * @param subMeshes The submeshes to render
  96988. */
  96989. private renderTransparentSorted;
  96990. /**
  96991. * Renders the submeshes in a specified order.
  96992. * @param subMeshes The submeshes to sort before render
  96993. * @param sortCompareFn The comparison function use to sort
  96994. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  96995. * @param transparent Specifies to activate blending if true
  96996. */
  96997. private static renderSorted;
  96998. /**
  96999. * Renders the submeshes in the order they were dispatched (no sort applied).
  97000. * @param subMeshes The submeshes to render
  97001. */
  97002. private static renderUnsorted;
  97003. /**
  97004. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97005. * are rendered back to front if in the same alpha index.
  97006. *
  97007. * @param a The first submesh
  97008. * @param b The second submesh
  97009. * @returns The result of the comparison
  97010. */
  97011. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  97012. /**
  97013. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97014. * are rendered back to front.
  97015. *
  97016. * @param a The first submesh
  97017. * @param b The second submesh
  97018. * @returns The result of the comparison
  97019. */
  97020. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  97021. /**
  97022. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97023. * are rendered front to back (prevent overdraw).
  97024. *
  97025. * @param a The first submesh
  97026. * @param b The second submesh
  97027. * @returns The result of the comparison
  97028. */
  97029. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  97030. /**
  97031. * Resets the different lists of submeshes to prepare a new frame.
  97032. */
  97033. prepare(): void;
  97034. dispose(): void;
  97035. /**
  97036. * Inserts the submesh in its correct queue depending on its material.
  97037. * @param subMesh The submesh to dispatch
  97038. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97039. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97040. */
  97041. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97042. dispatchSprites(spriteManager: ISpriteManager): void;
  97043. dispatchParticles(particleSystem: IParticleSystem): void;
  97044. private _renderParticles;
  97045. private _renderSprites;
  97046. }
  97047. }
  97048. declare module BABYLON {
  97049. /**
  97050. * Interface describing the different options available in the rendering manager
  97051. * regarding Auto Clear between groups.
  97052. */
  97053. export interface IRenderingManagerAutoClearSetup {
  97054. /**
  97055. * Defines whether or not autoclear is enable.
  97056. */
  97057. autoClear: boolean;
  97058. /**
  97059. * Defines whether or not to autoclear the depth buffer.
  97060. */
  97061. depth: boolean;
  97062. /**
  97063. * Defines whether or not to autoclear the stencil buffer.
  97064. */
  97065. stencil: boolean;
  97066. }
  97067. /**
  97068. * This class is used by the onRenderingGroupObservable
  97069. */
  97070. export class RenderingGroupInfo {
  97071. /**
  97072. * The Scene that being rendered
  97073. */
  97074. scene: Scene;
  97075. /**
  97076. * The camera currently used for the rendering pass
  97077. */
  97078. camera: Nullable<Camera>;
  97079. /**
  97080. * The ID of the renderingGroup being processed
  97081. */
  97082. renderingGroupId: number;
  97083. }
  97084. /**
  97085. * This is the manager responsible of all the rendering for meshes sprites and particles.
  97086. * It is enable to manage the different groups as well as the different necessary sort functions.
  97087. * This should not be used directly aside of the few static configurations
  97088. */
  97089. export class RenderingManager {
  97090. /**
  97091. * The max id used for rendering groups (not included)
  97092. */
  97093. static MAX_RENDERINGGROUPS: number;
  97094. /**
  97095. * The min id used for rendering groups (included)
  97096. */
  97097. static MIN_RENDERINGGROUPS: number;
  97098. /**
  97099. * Used to globally prevent autoclearing scenes.
  97100. */
  97101. static AUTOCLEAR: boolean;
  97102. /**
  97103. * @hidden
  97104. */
  97105. _useSceneAutoClearSetup: boolean;
  97106. private _scene;
  97107. private _renderingGroups;
  97108. private _depthStencilBufferAlreadyCleaned;
  97109. private _autoClearDepthStencil;
  97110. private _customOpaqueSortCompareFn;
  97111. private _customAlphaTestSortCompareFn;
  97112. private _customTransparentSortCompareFn;
  97113. private _renderingGroupInfo;
  97114. /**
  97115. * Instantiates a new rendering group for a particular scene
  97116. * @param scene Defines the scene the groups belongs to
  97117. */
  97118. constructor(scene: Scene);
  97119. private _clearDepthStencilBuffer;
  97120. /**
  97121. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  97122. * @hidden
  97123. */
  97124. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  97125. /**
  97126. * Resets the different information of the group to prepare a new frame
  97127. * @hidden
  97128. */
  97129. reset(): void;
  97130. /**
  97131. * Dispose and release the group and its associated resources.
  97132. * @hidden
  97133. */
  97134. dispose(): void;
  97135. /**
  97136. * Clear the info related to rendering groups preventing retention points during dispose.
  97137. */
  97138. freeRenderingGroups(): void;
  97139. private _prepareRenderingGroup;
  97140. /**
  97141. * Add a sprite manager to the rendering manager in order to render it this frame.
  97142. * @param spriteManager Define the sprite manager to render
  97143. */
  97144. dispatchSprites(spriteManager: ISpriteManager): void;
  97145. /**
  97146. * Add a particle system to the rendering manager in order to render it this frame.
  97147. * @param particleSystem Define the particle system to render
  97148. */
  97149. dispatchParticles(particleSystem: IParticleSystem): void;
  97150. /**
  97151. * Add a submesh to the manager in order to render it this frame
  97152. * @param subMesh The submesh to dispatch
  97153. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97154. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97155. */
  97156. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97157. /**
  97158. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  97159. * This allowed control for front to back rendering or reversly depending of the special needs.
  97160. *
  97161. * @param renderingGroupId The rendering group id corresponding to its index
  97162. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  97163. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  97164. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  97165. */
  97166. 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;
  97167. /**
  97168. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  97169. *
  97170. * @param renderingGroupId The rendering group id corresponding to its index
  97171. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  97172. * @param depth Automatically clears depth between groups if true and autoClear is true.
  97173. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  97174. */
  97175. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  97176. /**
  97177. * Gets the current auto clear configuration for one rendering group of the rendering
  97178. * manager.
  97179. * @param index the rendering group index to get the information for
  97180. * @returns The auto clear setup for the requested rendering group
  97181. */
  97182. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  97183. }
  97184. }
  97185. declare module BABYLON {
  97186. /**
  97187. * Defines the options associated with the creation of a custom shader for a shadow generator.
  97188. */
  97189. export interface ICustomShaderOptions {
  97190. /**
  97191. * Gets or sets the custom shader name to use
  97192. */
  97193. shaderName: string;
  97194. /**
  97195. * The list of attribute names used in the shader
  97196. */
  97197. attributes?: string[];
  97198. /**
  97199. * The list of unifrom names used in the shader
  97200. */
  97201. uniforms?: string[];
  97202. /**
  97203. * The list of sampler names used in the shader
  97204. */
  97205. samplers?: string[];
  97206. /**
  97207. * The list of defines used in the shader
  97208. */
  97209. defines?: string[];
  97210. }
  97211. /**
  97212. * Interface to implement to create a shadow generator compatible with BJS.
  97213. */
  97214. export interface IShadowGenerator {
  97215. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  97216. id: string;
  97217. /**
  97218. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  97219. * @returns The render target texture if present otherwise, null
  97220. */
  97221. getShadowMap(): Nullable<RenderTargetTexture>;
  97222. /**
  97223. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  97224. * @param subMesh The submesh we want to render in the shadow map
  97225. * @param useInstances Defines wether will draw in the map using instances
  97226. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  97227. * @returns true if ready otherwise, false
  97228. */
  97229. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  97230. /**
  97231. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  97232. * @param defines Defines of the material we want to update
  97233. * @param lightIndex Index of the light in the enabled light list of the material
  97234. */
  97235. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  97236. /**
  97237. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  97238. * defined in the generator but impacting the effect).
  97239. * It implies the unifroms available on the materials are the standard BJS ones.
  97240. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  97241. * @param effect The effect we are binfing the information for
  97242. */
  97243. bindShadowLight(lightIndex: string, effect: Effect): void;
  97244. /**
  97245. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  97246. * (eq to shadow prjection matrix * light transform matrix)
  97247. * @returns The transform matrix used to create the shadow map
  97248. */
  97249. getTransformMatrix(): Matrix;
  97250. /**
  97251. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  97252. * Cube and 2D textures for instance.
  97253. */
  97254. recreateShadowMap(): void;
  97255. /**
  97256. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97257. * @param onCompiled Callback triggered at the and of the effects compilation
  97258. * @param options Sets of optional options forcing the compilation with different modes
  97259. */
  97260. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  97261. useInstances: boolean;
  97262. }>): void;
  97263. /**
  97264. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97265. * @param options Sets of optional options forcing the compilation with different modes
  97266. * @returns A promise that resolves when the compilation completes
  97267. */
  97268. forceCompilationAsync(options?: Partial<{
  97269. useInstances: boolean;
  97270. }>): Promise<void>;
  97271. /**
  97272. * Serializes the shadow generator setup to a json object.
  97273. * @returns The serialized JSON object
  97274. */
  97275. serialize(): any;
  97276. /**
  97277. * Disposes the Shadow map and related Textures and effects.
  97278. */
  97279. dispose(): void;
  97280. }
  97281. /**
  97282. * Default implementation IShadowGenerator.
  97283. * This is the main object responsible of generating shadows in the framework.
  97284. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  97285. */
  97286. export class ShadowGenerator implements IShadowGenerator {
  97287. /**
  97288. * Name of the shadow generator class
  97289. */
  97290. static CLASSNAME: string;
  97291. /**
  97292. * Shadow generator mode None: no filtering applied.
  97293. */
  97294. static readonly FILTER_NONE: number;
  97295. /**
  97296. * Shadow generator mode ESM: Exponential Shadow Mapping.
  97297. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97298. */
  97299. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  97300. /**
  97301. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  97302. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  97303. */
  97304. static readonly FILTER_POISSONSAMPLING: number;
  97305. /**
  97306. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  97307. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97308. */
  97309. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  97310. /**
  97311. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  97312. * edge artifacts on steep falloff.
  97313. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97314. */
  97315. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  97316. /**
  97317. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  97318. * edge artifacts on steep falloff.
  97319. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97320. */
  97321. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  97322. /**
  97323. * Shadow generator mode PCF: Percentage Closer Filtering
  97324. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  97325. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  97326. */
  97327. static readonly FILTER_PCF: number;
  97328. /**
  97329. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  97330. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  97331. * Contact Hardening
  97332. */
  97333. static readonly FILTER_PCSS: number;
  97334. /**
  97335. * Reserved for PCF and PCSS
  97336. * Highest Quality.
  97337. *
  97338. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  97339. *
  97340. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  97341. */
  97342. static readonly QUALITY_HIGH: number;
  97343. /**
  97344. * Reserved for PCF and PCSS
  97345. * Good tradeoff for quality/perf cross devices
  97346. *
  97347. * Execute PCF on a 3*3 kernel.
  97348. *
  97349. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  97350. */
  97351. static readonly QUALITY_MEDIUM: number;
  97352. /**
  97353. * Reserved for PCF and PCSS
  97354. * The lowest quality but the fastest.
  97355. *
  97356. * Execute PCF on a 1*1 kernel.
  97357. *
  97358. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  97359. */
  97360. static readonly QUALITY_LOW: number;
  97361. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  97362. id: string;
  97363. /** Gets or sets the custom shader name to use */
  97364. customShaderOptions: ICustomShaderOptions;
  97365. /**
  97366. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  97367. */
  97368. onBeforeShadowMapRenderObservable: Observable<Effect>;
  97369. /**
  97370. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  97371. */
  97372. onAfterShadowMapRenderObservable: Observable<Effect>;
  97373. /**
  97374. * Observable triggered before a mesh is rendered in the shadow map.
  97375. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  97376. */
  97377. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  97378. /**
  97379. * Observable triggered after a mesh is rendered in the shadow map.
  97380. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  97381. */
  97382. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  97383. protected _bias: number;
  97384. /**
  97385. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  97386. */
  97387. get bias(): number;
  97388. /**
  97389. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  97390. */
  97391. set bias(bias: number);
  97392. protected _normalBias: number;
  97393. /**
  97394. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  97395. */
  97396. get normalBias(): number;
  97397. /**
  97398. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  97399. */
  97400. set normalBias(normalBias: number);
  97401. protected _blurBoxOffset: number;
  97402. /**
  97403. * Gets the blur box offset: offset applied during the blur pass.
  97404. * Only useful if useKernelBlur = false
  97405. */
  97406. get blurBoxOffset(): number;
  97407. /**
  97408. * Sets the blur box offset: offset applied during the blur pass.
  97409. * Only useful if useKernelBlur = false
  97410. */
  97411. set blurBoxOffset(value: number);
  97412. protected _blurScale: number;
  97413. /**
  97414. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  97415. * 2 means half of the size.
  97416. */
  97417. get blurScale(): number;
  97418. /**
  97419. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  97420. * 2 means half of the size.
  97421. */
  97422. set blurScale(value: number);
  97423. protected _blurKernel: number;
  97424. /**
  97425. * Gets the blur kernel: kernel size of the blur pass.
  97426. * Only useful if useKernelBlur = true
  97427. */
  97428. get blurKernel(): number;
  97429. /**
  97430. * Sets the blur kernel: kernel size of the blur pass.
  97431. * Only useful if useKernelBlur = true
  97432. */
  97433. set blurKernel(value: number);
  97434. protected _useKernelBlur: boolean;
  97435. /**
  97436. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  97437. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  97438. */
  97439. get useKernelBlur(): boolean;
  97440. /**
  97441. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  97442. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  97443. */
  97444. set useKernelBlur(value: boolean);
  97445. protected _depthScale: number;
  97446. /**
  97447. * Gets the depth scale used in ESM mode.
  97448. */
  97449. get depthScale(): number;
  97450. /**
  97451. * Sets the depth scale used in ESM mode.
  97452. * This can override the scale stored on the light.
  97453. */
  97454. set depthScale(value: number);
  97455. protected _validateFilter(filter: number): number;
  97456. protected _filter: number;
  97457. /**
  97458. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  97459. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  97460. */
  97461. get filter(): number;
  97462. /**
  97463. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  97464. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  97465. */
  97466. set filter(value: number);
  97467. /**
  97468. * Gets if the current filter is set to Poisson Sampling.
  97469. */
  97470. get usePoissonSampling(): boolean;
  97471. /**
  97472. * Sets the current filter to Poisson Sampling.
  97473. */
  97474. set usePoissonSampling(value: boolean);
  97475. /**
  97476. * Gets if the current filter is set to ESM.
  97477. */
  97478. get useExponentialShadowMap(): boolean;
  97479. /**
  97480. * Sets the current filter is to ESM.
  97481. */
  97482. set useExponentialShadowMap(value: boolean);
  97483. /**
  97484. * Gets if the current filter is set to filtered ESM.
  97485. */
  97486. get useBlurExponentialShadowMap(): boolean;
  97487. /**
  97488. * Gets if the current filter is set to filtered ESM.
  97489. */
  97490. set useBlurExponentialShadowMap(value: boolean);
  97491. /**
  97492. * Gets if the current filter is set to "close ESM" (using the inverse of the
  97493. * exponential to prevent steep falloff artifacts).
  97494. */
  97495. get useCloseExponentialShadowMap(): boolean;
  97496. /**
  97497. * Sets the current filter to "close ESM" (using the inverse of the
  97498. * exponential to prevent steep falloff artifacts).
  97499. */
  97500. set useCloseExponentialShadowMap(value: boolean);
  97501. /**
  97502. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  97503. * exponential to prevent steep falloff artifacts).
  97504. */
  97505. get useBlurCloseExponentialShadowMap(): boolean;
  97506. /**
  97507. * Sets the current filter to filtered "close ESM" (using the inverse of the
  97508. * exponential to prevent steep falloff artifacts).
  97509. */
  97510. set useBlurCloseExponentialShadowMap(value: boolean);
  97511. /**
  97512. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  97513. */
  97514. get usePercentageCloserFiltering(): boolean;
  97515. /**
  97516. * Sets the current filter to "PCF" (percentage closer filtering).
  97517. */
  97518. set usePercentageCloserFiltering(value: boolean);
  97519. protected _filteringQuality: number;
  97520. /**
  97521. * Gets the PCF or PCSS Quality.
  97522. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  97523. */
  97524. get filteringQuality(): number;
  97525. /**
  97526. * Sets the PCF or PCSS Quality.
  97527. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  97528. */
  97529. set filteringQuality(filteringQuality: number);
  97530. /**
  97531. * Gets if the current filter is set to "PCSS" (contact hardening).
  97532. */
  97533. get useContactHardeningShadow(): boolean;
  97534. /**
  97535. * Sets the current filter to "PCSS" (contact hardening).
  97536. */
  97537. set useContactHardeningShadow(value: boolean);
  97538. protected _contactHardeningLightSizeUVRatio: number;
  97539. /**
  97540. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  97541. * Using a ratio helps keeping shape stability independently of the map size.
  97542. *
  97543. * It does not account for the light projection as it was having too much
  97544. * instability during the light setup or during light position changes.
  97545. *
  97546. * Only valid if useContactHardeningShadow is true.
  97547. */
  97548. get contactHardeningLightSizeUVRatio(): number;
  97549. /**
  97550. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  97551. * Using a ratio helps keeping shape stability independently of the map size.
  97552. *
  97553. * It does not account for the light projection as it was having too much
  97554. * instability during the light setup or during light position changes.
  97555. *
  97556. * Only valid if useContactHardeningShadow is true.
  97557. */
  97558. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  97559. protected _darkness: number;
  97560. /** Gets or sets the actual darkness of a shadow */
  97561. get darkness(): number;
  97562. set darkness(value: number);
  97563. /**
  97564. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  97565. * 0 means strongest and 1 would means no shadow.
  97566. * @returns the darkness.
  97567. */
  97568. getDarkness(): number;
  97569. /**
  97570. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  97571. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  97572. * @returns the shadow generator allowing fluent coding.
  97573. */
  97574. setDarkness(darkness: number): ShadowGenerator;
  97575. protected _transparencyShadow: boolean;
  97576. /** Gets or sets the ability to have transparent shadow */
  97577. get transparencyShadow(): boolean;
  97578. set transparencyShadow(value: boolean);
  97579. /**
  97580. * Sets the ability to have transparent shadow (boolean).
  97581. * @param transparent True if transparent else False
  97582. * @returns the shadow generator allowing fluent coding
  97583. */
  97584. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  97585. /**
  97586. * Enables or disables shadows with varying strength based on the transparency
  97587. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  97588. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  97589. * mesh.visibility * alphaTexture.a
  97590. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  97591. */
  97592. enableSoftTransparentShadow: boolean;
  97593. protected _shadowMap: Nullable<RenderTargetTexture>;
  97594. protected _shadowMap2: Nullable<RenderTargetTexture>;
  97595. /**
  97596. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  97597. * @returns The render target texture if present otherwise, null
  97598. */
  97599. getShadowMap(): Nullable<RenderTargetTexture>;
  97600. /**
  97601. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  97602. * @returns The render target texture if the shadow map is present otherwise, null
  97603. */
  97604. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  97605. /**
  97606. * Gets the class name of that object
  97607. * @returns "ShadowGenerator"
  97608. */
  97609. getClassName(): string;
  97610. /**
  97611. * Helper function to add a mesh and its descendants to the list of shadow casters.
  97612. * @param mesh Mesh to add
  97613. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  97614. * @returns the Shadow Generator itself
  97615. */
  97616. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  97617. /**
  97618. * Helper function to remove a mesh and its descendants from the list of shadow casters
  97619. * @param mesh Mesh to remove
  97620. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  97621. * @returns the Shadow Generator itself
  97622. */
  97623. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  97624. /**
  97625. * Controls the extent to which the shadows fade out at the edge of the frustum
  97626. */
  97627. frustumEdgeFalloff: number;
  97628. protected _light: IShadowLight;
  97629. /**
  97630. * Returns the associated light object.
  97631. * @returns the light generating the shadow
  97632. */
  97633. getLight(): IShadowLight;
  97634. /**
  97635. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  97636. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  97637. * It might on the other hand introduce peter panning.
  97638. */
  97639. forceBackFacesOnly: boolean;
  97640. protected _scene: Scene;
  97641. protected _lightDirection: Vector3;
  97642. protected _effect: Effect;
  97643. protected _viewMatrix: Matrix;
  97644. protected _projectionMatrix: Matrix;
  97645. protected _transformMatrix: Matrix;
  97646. protected _cachedPosition: Vector3;
  97647. protected _cachedDirection: Vector3;
  97648. protected _cachedDefines: string;
  97649. protected _currentRenderID: number;
  97650. protected _boxBlurPostprocess: Nullable<PostProcess>;
  97651. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  97652. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  97653. protected _blurPostProcesses: PostProcess[];
  97654. protected _mapSize: number;
  97655. protected _currentFaceIndex: number;
  97656. protected _currentFaceIndexCache: number;
  97657. protected _textureType: number;
  97658. protected _defaultTextureMatrix: Matrix;
  97659. protected _storedUniqueId: Nullable<number>;
  97660. /** @hidden */
  97661. static _SceneComponentInitialization: (scene: Scene) => void;
  97662. /**
  97663. * Creates a ShadowGenerator object.
  97664. * A ShadowGenerator is the required tool to use the shadows.
  97665. * Each light casting shadows needs to use its own ShadowGenerator.
  97666. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  97667. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  97668. * @param light The light object generating the shadows.
  97669. * @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.
  97670. */
  97671. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  97672. protected _initializeGenerator(): void;
  97673. protected _createTargetRenderTexture(): void;
  97674. protected _initializeShadowMap(): void;
  97675. protected _initializeBlurRTTAndPostProcesses(): void;
  97676. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  97677. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  97678. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  97679. protected _applyFilterValues(): void;
  97680. /**
  97681. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97682. * @param onCompiled Callback triggered at the and of the effects compilation
  97683. * @param options Sets of optional options forcing the compilation with different modes
  97684. */
  97685. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  97686. useInstances: boolean;
  97687. }>): void;
  97688. /**
  97689. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97690. * @param options Sets of optional options forcing the compilation with different modes
  97691. * @returns A promise that resolves when the compilation completes
  97692. */
  97693. forceCompilationAsync(options?: Partial<{
  97694. useInstances: boolean;
  97695. }>): Promise<void>;
  97696. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  97697. private _prepareShadowDefines;
  97698. /**
  97699. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  97700. * @param subMesh The submesh we want to render in the shadow map
  97701. * @param useInstances Defines wether will draw in the map using instances
  97702. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  97703. * @returns true if ready otherwise, false
  97704. */
  97705. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  97706. /**
  97707. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  97708. * @param defines Defines of the material we want to update
  97709. * @param lightIndex Index of the light in the enabled light list of the material
  97710. */
  97711. prepareDefines(defines: any, lightIndex: number): void;
  97712. /**
  97713. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  97714. * defined in the generator but impacting the effect).
  97715. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  97716. * @param effect The effect we are binfing the information for
  97717. */
  97718. bindShadowLight(lightIndex: string, effect: Effect): void;
  97719. /**
  97720. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  97721. * (eq to shadow prjection matrix * light transform matrix)
  97722. * @returns The transform matrix used to create the shadow map
  97723. */
  97724. getTransformMatrix(): Matrix;
  97725. /**
  97726. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  97727. * Cube and 2D textures for instance.
  97728. */
  97729. recreateShadowMap(): void;
  97730. protected _disposeBlurPostProcesses(): void;
  97731. protected _disposeRTTandPostProcesses(): void;
  97732. /**
  97733. * Disposes the ShadowGenerator.
  97734. * Returns nothing.
  97735. */
  97736. dispose(): void;
  97737. /**
  97738. * Serializes the shadow generator setup to a json object.
  97739. * @returns The serialized JSON object
  97740. */
  97741. serialize(): any;
  97742. /**
  97743. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  97744. * @param parsedShadowGenerator The JSON object to parse
  97745. * @param scene The scene to create the shadow map for
  97746. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  97747. * @returns The parsed shadow generator
  97748. */
  97749. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  97750. }
  97751. }
  97752. declare module BABYLON {
  97753. /**
  97754. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  97755. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  97756. * 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.
  97757. */
  97758. export abstract class Light extends Node {
  97759. /**
  97760. * Falloff Default: light is falling off following the material specification:
  97761. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  97762. */
  97763. static readonly FALLOFF_DEFAULT: number;
  97764. /**
  97765. * Falloff Physical: light is falling off following the inverse squared distance law.
  97766. */
  97767. static readonly FALLOFF_PHYSICAL: number;
  97768. /**
  97769. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  97770. * to enhance interoperability with other engines.
  97771. */
  97772. static readonly FALLOFF_GLTF: number;
  97773. /**
  97774. * Falloff Standard: light is falling off like in the standard material
  97775. * to enhance interoperability with other materials.
  97776. */
  97777. static readonly FALLOFF_STANDARD: number;
  97778. /**
  97779. * If every light affecting the material is in this lightmapMode,
  97780. * material.lightmapTexture adds or multiplies
  97781. * (depends on material.useLightmapAsShadowmap)
  97782. * after every other light calculations.
  97783. */
  97784. static readonly LIGHTMAP_DEFAULT: number;
  97785. /**
  97786. * material.lightmapTexture as only diffuse lighting from this light
  97787. * adds only specular lighting from this light
  97788. * adds dynamic shadows
  97789. */
  97790. static readonly LIGHTMAP_SPECULAR: number;
  97791. /**
  97792. * material.lightmapTexture as only lighting
  97793. * no light calculation from this light
  97794. * only adds dynamic shadows from this light
  97795. */
  97796. static readonly LIGHTMAP_SHADOWSONLY: number;
  97797. /**
  97798. * Each light type uses the default quantity according to its type:
  97799. * point/spot lights use luminous intensity
  97800. * directional lights use illuminance
  97801. */
  97802. static readonly INTENSITYMODE_AUTOMATIC: number;
  97803. /**
  97804. * lumen (lm)
  97805. */
  97806. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  97807. /**
  97808. * candela (lm/sr)
  97809. */
  97810. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  97811. /**
  97812. * lux (lm/m^2)
  97813. */
  97814. static readonly INTENSITYMODE_ILLUMINANCE: number;
  97815. /**
  97816. * nit (cd/m^2)
  97817. */
  97818. static readonly INTENSITYMODE_LUMINANCE: number;
  97819. /**
  97820. * Light type const id of the point light.
  97821. */
  97822. static readonly LIGHTTYPEID_POINTLIGHT: number;
  97823. /**
  97824. * Light type const id of the directional light.
  97825. */
  97826. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  97827. /**
  97828. * Light type const id of the spot light.
  97829. */
  97830. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  97831. /**
  97832. * Light type const id of the hemispheric light.
  97833. */
  97834. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  97835. /**
  97836. * Diffuse gives the basic color to an object.
  97837. */
  97838. diffuse: Color3;
  97839. /**
  97840. * Specular produces a highlight color on an object.
  97841. * Note: This is note affecting PBR materials.
  97842. */
  97843. specular: Color3;
  97844. /**
  97845. * Defines the falloff type for this light. This lets overrriding how punctual light are
  97846. * falling off base on range or angle.
  97847. * This can be set to any values in Light.FALLOFF_x.
  97848. *
  97849. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  97850. * other types of materials.
  97851. */
  97852. falloffType: number;
  97853. /**
  97854. * Strength of the light.
  97855. * Note: By default it is define in the framework own unit.
  97856. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  97857. */
  97858. intensity: number;
  97859. private _range;
  97860. protected _inverseSquaredRange: number;
  97861. /**
  97862. * Defines how far from the source the light is impacting in scene units.
  97863. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  97864. */
  97865. get range(): number;
  97866. /**
  97867. * Defines how far from the source the light is impacting in scene units.
  97868. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  97869. */
  97870. set range(value: number);
  97871. /**
  97872. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  97873. * of light.
  97874. */
  97875. private _photometricScale;
  97876. private _intensityMode;
  97877. /**
  97878. * Gets the photometric scale used to interpret the intensity.
  97879. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  97880. */
  97881. get intensityMode(): number;
  97882. /**
  97883. * Sets the photometric scale used to interpret the intensity.
  97884. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  97885. */
  97886. set intensityMode(value: number);
  97887. private _radius;
  97888. /**
  97889. * Gets the light radius used by PBR Materials to simulate soft area lights.
  97890. */
  97891. get radius(): number;
  97892. /**
  97893. * sets the light radius used by PBR Materials to simulate soft area lights.
  97894. */
  97895. set radius(value: number);
  97896. private _renderPriority;
  97897. /**
  97898. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  97899. * exceeding the number allowed of the materials.
  97900. */
  97901. renderPriority: number;
  97902. private _shadowEnabled;
  97903. /**
  97904. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  97905. * the current shadow generator.
  97906. */
  97907. get shadowEnabled(): boolean;
  97908. /**
  97909. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  97910. * the current shadow generator.
  97911. */
  97912. set shadowEnabled(value: boolean);
  97913. private _includedOnlyMeshes;
  97914. /**
  97915. * Gets the only meshes impacted by this light.
  97916. */
  97917. get includedOnlyMeshes(): AbstractMesh[];
  97918. /**
  97919. * Sets the only meshes impacted by this light.
  97920. */
  97921. set includedOnlyMeshes(value: AbstractMesh[]);
  97922. private _excludedMeshes;
  97923. /**
  97924. * Gets the meshes not impacted by this light.
  97925. */
  97926. get excludedMeshes(): AbstractMesh[];
  97927. /**
  97928. * Sets the meshes not impacted by this light.
  97929. */
  97930. set excludedMeshes(value: AbstractMesh[]);
  97931. private _excludeWithLayerMask;
  97932. /**
  97933. * Gets the layer id use to find what meshes are not impacted by the light.
  97934. * Inactive if 0
  97935. */
  97936. get excludeWithLayerMask(): number;
  97937. /**
  97938. * Sets the layer id use to find what meshes are not impacted by the light.
  97939. * Inactive if 0
  97940. */
  97941. set excludeWithLayerMask(value: number);
  97942. private _includeOnlyWithLayerMask;
  97943. /**
  97944. * Gets the layer id use to find what meshes are impacted by the light.
  97945. * Inactive if 0
  97946. */
  97947. get includeOnlyWithLayerMask(): number;
  97948. /**
  97949. * Sets the layer id use to find what meshes are impacted by the light.
  97950. * Inactive if 0
  97951. */
  97952. set includeOnlyWithLayerMask(value: number);
  97953. private _lightmapMode;
  97954. /**
  97955. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  97956. */
  97957. get lightmapMode(): number;
  97958. /**
  97959. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  97960. */
  97961. set lightmapMode(value: number);
  97962. /**
  97963. * Shadow generator associted to the light.
  97964. * @hidden Internal use only.
  97965. */
  97966. _shadowGenerator: Nullable<IShadowGenerator>;
  97967. /**
  97968. * @hidden Internal use only.
  97969. */
  97970. _excludedMeshesIds: string[];
  97971. /**
  97972. * @hidden Internal use only.
  97973. */
  97974. _includedOnlyMeshesIds: string[];
  97975. /**
  97976. * The current light unifom buffer.
  97977. * @hidden Internal use only.
  97978. */
  97979. _uniformBuffer: UniformBuffer;
  97980. /** @hidden */
  97981. _renderId: number;
  97982. /**
  97983. * Creates a Light object in the scene.
  97984. * Documentation : https://doc.babylonjs.com/babylon101/lights
  97985. * @param name The firendly name of the light
  97986. * @param scene The scene the light belongs too
  97987. */
  97988. constructor(name: string, scene: Scene);
  97989. protected abstract _buildUniformLayout(): void;
  97990. /**
  97991. * Sets the passed Effect "effect" with the Light information.
  97992. * @param effect The effect to update
  97993. * @param lightIndex The index of the light in the effect to update
  97994. * @returns The light
  97995. */
  97996. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  97997. /**
  97998. * Sets the passed Effect "effect" with the Light textures.
  97999. * @param effect The effect to update
  98000. * @param lightIndex The index of the light in the effect to update
  98001. * @returns The light
  98002. */
  98003. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  98004. /**
  98005. * Binds the lights information from the scene to the effect for the given mesh.
  98006. * @param lightIndex Light index
  98007. * @param scene The scene where the light belongs to
  98008. * @param effect The effect we are binding the data to
  98009. * @param useSpecular Defines if specular is supported
  98010. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98011. */
  98012. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  98013. /**
  98014. * Sets the passed Effect "effect" with the Light information.
  98015. * @param effect The effect to update
  98016. * @param lightDataUniformName The uniform used to store light data (position or direction)
  98017. * @returns The light
  98018. */
  98019. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  98020. /**
  98021. * Returns the string "Light".
  98022. * @returns the class name
  98023. */
  98024. getClassName(): string;
  98025. /** @hidden */
  98026. readonly _isLight: boolean;
  98027. /**
  98028. * Converts the light information to a readable string for debug purpose.
  98029. * @param fullDetails Supports for multiple levels of logging within scene loading
  98030. * @returns the human readable light info
  98031. */
  98032. toString(fullDetails?: boolean): string;
  98033. /** @hidden */
  98034. protected _syncParentEnabledState(): void;
  98035. /**
  98036. * Set the enabled state of this node.
  98037. * @param value - the new enabled state
  98038. */
  98039. setEnabled(value: boolean): void;
  98040. /**
  98041. * Returns the Light associated shadow generator if any.
  98042. * @return the associated shadow generator.
  98043. */
  98044. getShadowGenerator(): Nullable<IShadowGenerator>;
  98045. /**
  98046. * Returns a Vector3, the absolute light position in the World.
  98047. * @returns the world space position of the light
  98048. */
  98049. getAbsolutePosition(): Vector3;
  98050. /**
  98051. * Specifies if the light will affect the passed mesh.
  98052. * @param mesh The mesh to test against the light
  98053. * @return true the mesh is affected otherwise, false.
  98054. */
  98055. canAffectMesh(mesh: AbstractMesh): boolean;
  98056. /**
  98057. * Sort function to order lights for rendering.
  98058. * @param a First Light object to compare to second.
  98059. * @param b Second Light object to compare first.
  98060. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  98061. */
  98062. static CompareLightsPriority(a: Light, b: Light): number;
  98063. /**
  98064. * Releases resources associated with this node.
  98065. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98066. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98067. */
  98068. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98069. /**
  98070. * Returns the light type ID (integer).
  98071. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  98072. */
  98073. getTypeID(): number;
  98074. /**
  98075. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  98076. * @returns the scaled intensity in intensity mode unit
  98077. */
  98078. getScaledIntensity(): number;
  98079. /**
  98080. * Returns a new Light object, named "name", from the current one.
  98081. * @param name The name of the cloned light
  98082. * @param newParent The parent of this light, if it has one
  98083. * @returns the new created light
  98084. */
  98085. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  98086. /**
  98087. * Serializes the current light into a Serialization object.
  98088. * @returns the serialized object.
  98089. */
  98090. serialize(): any;
  98091. /**
  98092. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  98093. * This new light is named "name" and added to the passed scene.
  98094. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  98095. * @param name The friendly name of the light
  98096. * @param scene The scene the new light will belong to
  98097. * @returns the constructor function
  98098. */
  98099. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  98100. /**
  98101. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  98102. * @param parsedLight The JSON representation of the light
  98103. * @param scene The scene to create the parsed light in
  98104. * @returns the created light after parsing
  98105. */
  98106. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  98107. private _hookArrayForExcluded;
  98108. private _hookArrayForIncludedOnly;
  98109. private _resyncMeshes;
  98110. /**
  98111. * Forces the meshes to update their light related information in their rendering used effects
  98112. * @hidden Internal Use Only
  98113. */
  98114. _markMeshesAsLightDirty(): void;
  98115. /**
  98116. * Recomputes the cached photometric scale if needed.
  98117. */
  98118. private _computePhotometricScale;
  98119. /**
  98120. * Returns the Photometric Scale according to the light type and intensity mode.
  98121. */
  98122. private _getPhotometricScale;
  98123. /**
  98124. * Reorder the light in the scene according to their defined priority.
  98125. * @hidden Internal Use Only
  98126. */
  98127. _reorderLightsInScene(): void;
  98128. /**
  98129. * Prepares the list of defines specific to the light type.
  98130. * @param defines the list of defines
  98131. * @param lightIndex defines the index of the light for the effect
  98132. */
  98133. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  98134. }
  98135. }
  98136. declare module BABYLON {
  98137. /**
  98138. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  98139. * This is the base of the follow, arc rotate cameras and Free camera
  98140. * @see https://doc.babylonjs.com/features/cameras
  98141. */
  98142. export class TargetCamera extends Camera {
  98143. private static _RigCamTransformMatrix;
  98144. private static _TargetTransformMatrix;
  98145. private static _TargetFocalPoint;
  98146. private _tmpUpVector;
  98147. private _tmpTargetVector;
  98148. /**
  98149. * Define the current direction the camera is moving to
  98150. */
  98151. cameraDirection: Vector3;
  98152. /**
  98153. * Define the current rotation the camera is rotating to
  98154. */
  98155. cameraRotation: Vector2;
  98156. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  98157. ignoreParentScaling: boolean;
  98158. /**
  98159. * When set, the up vector of the camera will be updated by the rotation of the camera
  98160. */
  98161. updateUpVectorFromRotation: boolean;
  98162. private _tmpQuaternion;
  98163. /**
  98164. * Define the current rotation of the camera
  98165. */
  98166. rotation: Vector3;
  98167. /**
  98168. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  98169. */
  98170. rotationQuaternion: Quaternion;
  98171. /**
  98172. * Define the current speed of the camera
  98173. */
  98174. speed: number;
  98175. /**
  98176. * Add constraint to the camera to prevent it to move freely in all directions and
  98177. * around all axis.
  98178. */
  98179. noRotationConstraint: boolean;
  98180. /**
  98181. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  98182. * panning
  98183. */
  98184. invertRotation: boolean;
  98185. /**
  98186. * Speed multiplier for inverse camera panning
  98187. */
  98188. inverseRotationSpeed: number;
  98189. /**
  98190. * Define the current target of the camera as an object or a position.
  98191. */
  98192. lockedTarget: any;
  98193. /** @hidden */
  98194. _currentTarget: Vector3;
  98195. /** @hidden */
  98196. _initialFocalDistance: number;
  98197. /** @hidden */
  98198. _viewMatrix: Matrix;
  98199. /** @hidden */
  98200. _camMatrix: Matrix;
  98201. /** @hidden */
  98202. _cameraTransformMatrix: Matrix;
  98203. /** @hidden */
  98204. _cameraRotationMatrix: Matrix;
  98205. /** @hidden */
  98206. _referencePoint: Vector3;
  98207. /** @hidden */
  98208. _transformedReferencePoint: Vector3;
  98209. /** @hidden */
  98210. _reset: () => void;
  98211. private _defaultUp;
  98212. /**
  98213. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  98214. * This is the base of the follow, arc rotate cameras and Free camera
  98215. * @see https://doc.babylonjs.com/features/cameras
  98216. * @param name Defines the name of the camera in the scene
  98217. * @param position Defines the start position of the camera in the scene
  98218. * @param scene Defines the scene the camera belongs to
  98219. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98220. */
  98221. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98222. /**
  98223. * Gets the position in front of the camera at a given distance.
  98224. * @param distance The distance from the camera we want the position to be
  98225. * @returns the position
  98226. */
  98227. getFrontPosition(distance: number): Vector3;
  98228. /** @hidden */
  98229. _getLockedTargetPosition(): Nullable<Vector3>;
  98230. private _storedPosition;
  98231. private _storedRotation;
  98232. private _storedRotationQuaternion;
  98233. /**
  98234. * Store current camera state of the camera (fov, position, rotation, etc..)
  98235. * @returns the camera
  98236. */
  98237. storeState(): Camera;
  98238. /**
  98239. * Restored camera state. You must call storeState() first
  98240. * @returns whether it was successful or not
  98241. * @hidden
  98242. */
  98243. _restoreStateValues(): boolean;
  98244. /** @hidden */
  98245. _initCache(): void;
  98246. /** @hidden */
  98247. _updateCache(ignoreParentClass?: boolean): void;
  98248. /** @hidden */
  98249. _isSynchronizedViewMatrix(): boolean;
  98250. /** @hidden */
  98251. _computeLocalCameraSpeed(): number;
  98252. /**
  98253. * Defines the target the camera should look at.
  98254. * @param target Defines the new target as a Vector or a mesh
  98255. */
  98256. setTarget(target: Vector3): void;
  98257. /**
  98258. * Defines the target point of the camera.
  98259. * The camera looks towards it form the radius distance.
  98260. */
  98261. get target(): Vector3;
  98262. set target(value: Vector3);
  98263. /**
  98264. * Return the current target position of the camera. This value is expressed in local space.
  98265. * @returns the target position
  98266. */
  98267. getTarget(): Vector3;
  98268. /** @hidden */
  98269. _decideIfNeedsToMove(): boolean;
  98270. /** @hidden */
  98271. _updatePosition(): void;
  98272. /** @hidden */
  98273. _checkInputs(): void;
  98274. protected _updateCameraRotationMatrix(): void;
  98275. /**
  98276. * 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)
  98277. * @returns the current camera
  98278. */
  98279. private _rotateUpVectorWithCameraRotationMatrix;
  98280. private _cachedRotationZ;
  98281. private _cachedQuaternionRotationZ;
  98282. /** @hidden */
  98283. _getViewMatrix(): Matrix;
  98284. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  98285. /**
  98286. * @hidden
  98287. */
  98288. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  98289. /**
  98290. * @hidden
  98291. */
  98292. _updateRigCameras(): void;
  98293. private _getRigCamPositionAndTarget;
  98294. /**
  98295. * Gets the current object class name.
  98296. * @return the class name
  98297. */
  98298. getClassName(): string;
  98299. }
  98300. }
  98301. declare module BABYLON {
  98302. /**
  98303. * Gather the list of keyboard event types as constants.
  98304. */
  98305. export class KeyboardEventTypes {
  98306. /**
  98307. * The keydown event is fired when a key becomes active (pressed).
  98308. */
  98309. static readonly KEYDOWN: number;
  98310. /**
  98311. * The keyup event is fired when a key has been released.
  98312. */
  98313. static readonly KEYUP: number;
  98314. }
  98315. /**
  98316. * This class is used to store keyboard related info for the onKeyboardObservable event.
  98317. */
  98318. export class KeyboardInfo {
  98319. /**
  98320. * Defines the type of event (KeyboardEventTypes)
  98321. */
  98322. type: number;
  98323. /**
  98324. * Defines the related dom event
  98325. */
  98326. event: KeyboardEvent;
  98327. /**
  98328. * Instantiates a new keyboard info.
  98329. * This class is used to store keyboard related info for the onKeyboardObservable event.
  98330. * @param type Defines the type of event (KeyboardEventTypes)
  98331. * @param event Defines the related dom event
  98332. */
  98333. constructor(
  98334. /**
  98335. * Defines the type of event (KeyboardEventTypes)
  98336. */
  98337. type: number,
  98338. /**
  98339. * Defines the related dom event
  98340. */
  98341. event: KeyboardEvent);
  98342. }
  98343. /**
  98344. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  98345. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  98346. */
  98347. export class KeyboardInfoPre extends KeyboardInfo {
  98348. /**
  98349. * Defines the type of event (KeyboardEventTypes)
  98350. */
  98351. type: number;
  98352. /**
  98353. * Defines the related dom event
  98354. */
  98355. event: KeyboardEvent;
  98356. /**
  98357. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  98358. */
  98359. skipOnPointerObservable: boolean;
  98360. /**
  98361. * Instantiates a new keyboard pre info.
  98362. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  98363. * @param type Defines the type of event (KeyboardEventTypes)
  98364. * @param event Defines the related dom event
  98365. */
  98366. constructor(
  98367. /**
  98368. * Defines the type of event (KeyboardEventTypes)
  98369. */
  98370. type: number,
  98371. /**
  98372. * Defines the related dom event
  98373. */
  98374. event: KeyboardEvent);
  98375. }
  98376. }
  98377. declare module BABYLON {
  98378. /**
  98379. * Manage the keyboard inputs to control the movement of a free camera.
  98380. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98381. */
  98382. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  98383. /**
  98384. * Defines the camera the input is attached to.
  98385. */
  98386. camera: FreeCamera;
  98387. /**
  98388. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  98389. */
  98390. keysUp: number[];
  98391. /**
  98392. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  98393. */
  98394. keysUpward: number[];
  98395. /**
  98396. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  98397. */
  98398. keysDown: number[];
  98399. /**
  98400. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  98401. */
  98402. keysDownward: number[];
  98403. /**
  98404. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  98405. */
  98406. keysLeft: number[];
  98407. /**
  98408. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  98409. */
  98410. keysRight: number[];
  98411. private _keys;
  98412. private _onCanvasBlurObserver;
  98413. private _onKeyboardObserver;
  98414. private _engine;
  98415. private _scene;
  98416. /**
  98417. * Attach the input controls to a specific dom element to get the input from.
  98418. * @param element Defines the element the controls should be listened from
  98419. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98420. */
  98421. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98422. /**
  98423. * Detach the current controls from the specified dom element.
  98424. * @param element Defines the element to stop listening the inputs from
  98425. */
  98426. detachControl(element: Nullable<HTMLElement>): void;
  98427. /**
  98428. * Update the current camera state depending on the inputs that have been used this frame.
  98429. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98430. */
  98431. checkInputs(): void;
  98432. /**
  98433. * Gets the class name of the current intput.
  98434. * @returns the class name
  98435. */
  98436. getClassName(): string;
  98437. /** @hidden */
  98438. _onLostFocus(): void;
  98439. /**
  98440. * Get the friendly name associated with the input class.
  98441. * @returns the input friendly name
  98442. */
  98443. getSimpleName(): string;
  98444. }
  98445. }
  98446. declare module BABYLON {
  98447. /**
  98448. * Gather the list of pointer event types as constants.
  98449. */
  98450. export class PointerEventTypes {
  98451. /**
  98452. * 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.
  98453. */
  98454. static readonly POINTERDOWN: number;
  98455. /**
  98456. * The pointerup event is fired when a pointer is no longer active.
  98457. */
  98458. static readonly POINTERUP: number;
  98459. /**
  98460. * The pointermove event is fired when a pointer changes coordinates.
  98461. */
  98462. static readonly POINTERMOVE: number;
  98463. /**
  98464. * The pointerwheel event is fired when a mouse wheel has been rotated.
  98465. */
  98466. static readonly POINTERWHEEL: number;
  98467. /**
  98468. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  98469. */
  98470. static readonly POINTERPICK: number;
  98471. /**
  98472. * The pointertap event is fired when a the object has been touched and released without drag.
  98473. */
  98474. static readonly POINTERTAP: number;
  98475. /**
  98476. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  98477. */
  98478. static readonly POINTERDOUBLETAP: number;
  98479. }
  98480. /**
  98481. * Base class of pointer info types.
  98482. */
  98483. export class PointerInfoBase {
  98484. /**
  98485. * Defines the type of event (PointerEventTypes)
  98486. */
  98487. type: number;
  98488. /**
  98489. * Defines the related dom event
  98490. */
  98491. event: PointerEvent | MouseWheelEvent;
  98492. /**
  98493. * Instantiates the base class of pointers info.
  98494. * @param type Defines the type of event (PointerEventTypes)
  98495. * @param event Defines the related dom event
  98496. */
  98497. constructor(
  98498. /**
  98499. * Defines the type of event (PointerEventTypes)
  98500. */
  98501. type: number,
  98502. /**
  98503. * Defines the related dom event
  98504. */
  98505. event: PointerEvent | MouseWheelEvent);
  98506. }
  98507. /**
  98508. * This class is used to store pointer related info for the onPrePointerObservable event.
  98509. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  98510. */
  98511. export class PointerInfoPre extends PointerInfoBase {
  98512. /**
  98513. * Ray from a pointer if availible (eg. 6dof controller)
  98514. */
  98515. ray: Nullable<Ray>;
  98516. /**
  98517. * Defines the local position of the pointer on the canvas.
  98518. */
  98519. localPosition: Vector2;
  98520. /**
  98521. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  98522. */
  98523. skipOnPointerObservable: boolean;
  98524. /**
  98525. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  98526. * @param type Defines the type of event (PointerEventTypes)
  98527. * @param event Defines the related dom event
  98528. * @param localX Defines the local x coordinates of the pointer when the event occured
  98529. * @param localY Defines the local y coordinates of the pointer when the event occured
  98530. */
  98531. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  98532. }
  98533. /**
  98534. * This type contains all the data related to a pointer event in Babylon.js.
  98535. * 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.
  98536. */
  98537. export class PointerInfo extends PointerInfoBase {
  98538. /**
  98539. * Defines the picking info associated to the info (if any)\
  98540. */
  98541. pickInfo: Nullable<PickingInfo>;
  98542. /**
  98543. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  98544. * @param type Defines the type of event (PointerEventTypes)
  98545. * @param event Defines the related dom event
  98546. * @param pickInfo Defines the picking info associated to the info (if any)\
  98547. */
  98548. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  98549. /**
  98550. * Defines the picking info associated to the info (if any)\
  98551. */
  98552. pickInfo: Nullable<PickingInfo>);
  98553. }
  98554. /**
  98555. * Data relating to a touch event on the screen.
  98556. */
  98557. export interface PointerTouch {
  98558. /**
  98559. * X coordinate of touch.
  98560. */
  98561. x: number;
  98562. /**
  98563. * Y coordinate of touch.
  98564. */
  98565. y: number;
  98566. /**
  98567. * Id of touch. Unique for each finger.
  98568. */
  98569. pointerId: number;
  98570. /**
  98571. * Event type passed from DOM.
  98572. */
  98573. type: any;
  98574. }
  98575. }
  98576. declare module BABYLON {
  98577. /**
  98578. * Manage the mouse inputs to control the movement of a free camera.
  98579. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98580. */
  98581. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  98582. /**
  98583. * Define if touch is enabled in the mouse input
  98584. */
  98585. touchEnabled: boolean;
  98586. /**
  98587. * Defines the camera the input is attached to.
  98588. */
  98589. camera: FreeCamera;
  98590. /**
  98591. * Defines the buttons associated with the input to handle camera move.
  98592. */
  98593. buttons: number[];
  98594. /**
  98595. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  98596. */
  98597. angularSensibility: number;
  98598. private _pointerInput;
  98599. private _onMouseMove;
  98600. private _observer;
  98601. private previousPosition;
  98602. /**
  98603. * Observable for when a pointer move event occurs containing the move offset
  98604. */
  98605. onPointerMovedObservable: Observable<{
  98606. offsetX: number;
  98607. offsetY: number;
  98608. }>;
  98609. /**
  98610. * @hidden
  98611. * If the camera should be rotated automatically based on pointer movement
  98612. */
  98613. _allowCameraRotation: boolean;
  98614. /**
  98615. * Manage the mouse inputs to control the movement of a free camera.
  98616. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98617. * @param touchEnabled Defines if touch is enabled or not
  98618. */
  98619. constructor(
  98620. /**
  98621. * Define if touch is enabled in the mouse input
  98622. */
  98623. touchEnabled?: boolean);
  98624. /**
  98625. * Attach the input controls to a specific dom element to get the input from.
  98626. * @param element Defines the element the controls should be listened from
  98627. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98628. */
  98629. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98630. /**
  98631. * Called on JS contextmenu event.
  98632. * Override this method to provide functionality.
  98633. */
  98634. protected onContextMenu(evt: PointerEvent): void;
  98635. /**
  98636. * Detach the current controls from the specified dom element.
  98637. * @param element Defines the element to stop listening the inputs from
  98638. */
  98639. detachControl(element: Nullable<HTMLElement>): void;
  98640. /**
  98641. * Gets the class name of the current intput.
  98642. * @returns the class name
  98643. */
  98644. getClassName(): string;
  98645. /**
  98646. * Get the friendly name associated with the input class.
  98647. * @returns the input friendly name
  98648. */
  98649. getSimpleName(): string;
  98650. }
  98651. }
  98652. declare module BABYLON {
  98653. /**
  98654. * Manage the touch inputs to control the movement of a free camera.
  98655. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98656. */
  98657. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  98658. /**
  98659. * Define if mouse events can be treated as touch events
  98660. */
  98661. allowMouse: boolean;
  98662. /**
  98663. * Defines the camera the input is attached to.
  98664. */
  98665. camera: FreeCamera;
  98666. /**
  98667. * Defines the touch sensibility for rotation.
  98668. * The higher the faster.
  98669. */
  98670. touchAngularSensibility: number;
  98671. /**
  98672. * Defines the touch sensibility for move.
  98673. * The higher the faster.
  98674. */
  98675. touchMoveSensibility: number;
  98676. private _offsetX;
  98677. private _offsetY;
  98678. private _pointerPressed;
  98679. private _pointerInput;
  98680. private _observer;
  98681. private _onLostFocus;
  98682. /**
  98683. * Manage the touch inputs to control the movement of a free camera.
  98684. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98685. * @param allowMouse Defines if mouse events can be treated as touch events
  98686. */
  98687. constructor(
  98688. /**
  98689. * Define if mouse events can be treated as touch events
  98690. */
  98691. allowMouse?: boolean);
  98692. /**
  98693. * Attach the input controls to a specific dom element to get the input from.
  98694. * @param element Defines the element the controls should be listened from
  98695. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98696. */
  98697. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98698. /**
  98699. * Detach the current controls from the specified dom element.
  98700. * @param element Defines the element to stop listening the inputs from
  98701. */
  98702. detachControl(element: Nullable<HTMLElement>): void;
  98703. /**
  98704. * Update the current camera state depending on the inputs that have been used this frame.
  98705. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98706. */
  98707. checkInputs(): void;
  98708. /**
  98709. * Gets the class name of the current intput.
  98710. * @returns the class name
  98711. */
  98712. getClassName(): string;
  98713. /**
  98714. * Get the friendly name associated with the input class.
  98715. * @returns the input friendly name
  98716. */
  98717. getSimpleName(): string;
  98718. }
  98719. }
  98720. declare module BABYLON {
  98721. /**
  98722. * Default Inputs manager for the FreeCamera.
  98723. * It groups all the default supported inputs for ease of use.
  98724. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98725. */
  98726. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  98727. /**
  98728. * @hidden
  98729. */
  98730. _mouseInput: Nullable<FreeCameraMouseInput>;
  98731. /**
  98732. * Instantiates a new FreeCameraInputsManager.
  98733. * @param camera Defines the camera the inputs belong to
  98734. */
  98735. constructor(camera: FreeCamera);
  98736. /**
  98737. * Add keyboard input support to the input manager.
  98738. * @returns the current input manager
  98739. */
  98740. addKeyboard(): FreeCameraInputsManager;
  98741. /**
  98742. * Add mouse input support to the input manager.
  98743. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  98744. * @returns the current input manager
  98745. */
  98746. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  98747. /**
  98748. * Removes the mouse input support from the manager
  98749. * @returns the current input manager
  98750. */
  98751. removeMouse(): FreeCameraInputsManager;
  98752. /**
  98753. * Add touch input support to the input manager.
  98754. * @returns the current input manager
  98755. */
  98756. addTouch(): FreeCameraInputsManager;
  98757. /**
  98758. * Remove all attached input methods from a camera
  98759. */
  98760. clear(): void;
  98761. }
  98762. }
  98763. declare module BABYLON {
  98764. /**
  98765. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  98766. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  98767. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  98768. */
  98769. export class FreeCamera extends TargetCamera {
  98770. /**
  98771. * Define the collision ellipsoid of the camera.
  98772. * This is helpful to simulate a camera body like the player body around the camera
  98773. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  98774. */
  98775. ellipsoid: Vector3;
  98776. /**
  98777. * Define an offset for the position of the ellipsoid around the camera.
  98778. * This can be helpful to determine the center of the body near the gravity center of the body
  98779. * instead of its head.
  98780. */
  98781. ellipsoidOffset: Vector3;
  98782. /**
  98783. * Enable or disable collisions of the camera with the rest of the scene objects.
  98784. */
  98785. checkCollisions: boolean;
  98786. /**
  98787. * Enable or disable gravity on the camera.
  98788. */
  98789. applyGravity: boolean;
  98790. /**
  98791. * Define the input manager associated to the camera.
  98792. */
  98793. inputs: FreeCameraInputsManager;
  98794. /**
  98795. * Gets the input sensibility for a mouse input. (default is 2000.0)
  98796. * Higher values reduce sensitivity.
  98797. */
  98798. get angularSensibility(): number;
  98799. /**
  98800. * Sets the input sensibility for a mouse input. (default is 2000.0)
  98801. * Higher values reduce sensitivity.
  98802. */
  98803. set angularSensibility(value: number);
  98804. /**
  98805. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  98806. */
  98807. get keysUp(): number[];
  98808. set keysUp(value: number[]);
  98809. /**
  98810. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  98811. */
  98812. get keysUpward(): number[];
  98813. set keysUpward(value: number[]);
  98814. /**
  98815. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  98816. */
  98817. get keysDown(): number[];
  98818. set keysDown(value: number[]);
  98819. /**
  98820. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  98821. */
  98822. get keysDownward(): number[];
  98823. set keysDownward(value: number[]);
  98824. /**
  98825. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  98826. */
  98827. get keysLeft(): number[];
  98828. set keysLeft(value: number[]);
  98829. /**
  98830. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  98831. */
  98832. get keysRight(): number[];
  98833. set keysRight(value: number[]);
  98834. /**
  98835. * Event raised when the camera collide with a mesh in the scene.
  98836. */
  98837. onCollide: (collidedMesh: AbstractMesh) => void;
  98838. private _collider;
  98839. private _needMoveForGravity;
  98840. private _oldPosition;
  98841. private _diffPosition;
  98842. private _newPosition;
  98843. /** @hidden */
  98844. _localDirection: Vector3;
  98845. /** @hidden */
  98846. _transformedDirection: Vector3;
  98847. /**
  98848. * Instantiates a Free Camera.
  98849. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  98850. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  98851. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  98852. * @param name Define the name of the camera in the scene
  98853. * @param position Define the start position of the camera in the scene
  98854. * @param scene Define the scene the camera belongs to
  98855. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98856. */
  98857. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98858. /**
  98859. * Attached controls to the current camera.
  98860. * @param element Defines the element the controls should be listened from
  98861. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98862. */
  98863. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98864. /**
  98865. * Detach the current controls from the camera.
  98866. * The camera will stop reacting to inputs.
  98867. * @param element Defines the element to stop listening the inputs from
  98868. */
  98869. detachControl(element: HTMLElement): void;
  98870. private _collisionMask;
  98871. /**
  98872. * Define a collision mask to limit the list of object the camera can collide with
  98873. */
  98874. get collisionMask(): number;
  98875. set collisionMask(mask: number);
  98876. /** @hidden */
  98877. _collideWithWorld(displacement: Vector3): void;
  98878. private _onCollisionPositionChange;
  98879. /** @hidden */
  98880. _checkInputs(): void;
  98881. /** @hidden */
  98882. _decideIfNeedsToMove(): boolean;
  98883. /** @hidden */
  98884. _updatePosition(): void;
  98885. /**
  98886. * Destroy the camera and release the current resources hold by it.
  98887. */
  98888. dispose(): void;
  98889. /**
  98890. * Gets the current object class name.
  98891. * @return the class name
  98892. */
  98893. getClassName(): string;
  98894. }
  98895. }
  98896. declare module BABYLON {
  98897. /**
  98898. * Represents a gamepad control stick position
  98899. */
  98900. export class StickValues {
  98901. /**
  98902. * The x component of the control stick
  98903. */
  98904. x: number;
  98905. /**
  98906. * The y component of the control stick
  98907. */
  98908. y: number;
  98909. /**
  98910. * Initializes the gamepad x and y control stick values
  98911. * @param x The x component of the gamepad control stick value
  98912. * @param y The y component of the gamepad control stick value
  98913. */
  98914. constructor(
  98915. /**
  98916. * The x component of the control stick
  98917. */
  98918. x: number,
  98919. /**
  98920. * The y component of the control stick
  98921. */
  98922. y: number);
  98923. }
  98924. /**
  98925. * An interface which manages callbacks for gamepad button changes
  98926. */
  98927. export interface GamepadButtonChanges {
  98928. /**
  98929. * Called when a gamepad has been changed
  98930. */
  98931. changed: boolean;
  98932. /**
  98933. * Called when a gamepad press event has been triggered
  98934. */
  98935. pressChanged: boolean;
  98936. /**
  98937. * Called when a touch event has been triggered
  98938. */
  98939. touchChanged: boolean;
  98940. /**
  98941. * Called when a value has changed
  98942. */
  98943. valueChanged: boolean;
  98944. }
  98945. /**
  98946. * Represents a gamepad
  98947. */
  98948. export class Gamepad {
  98949. /**
  98950. * The id of the gamepad
  98951. */
  98952. id: string;
  98953. /**
  98954. * The index of the gamepad
  98955. */
  98956. index: number;
  98957. /**
  98958. * The browser gamepad
  98959. */
  98960. browserGamepad: any;
  98961. /**
  98962. * Specifies what type of gamepad this represents
  98963. */
  98964. type: number;
  98965. private _leftStick;
  98966. private _rightStick;
  98967. /** @hidden */
  98968. _isConnected: boolean;
  98969. private _leftStickAxisX;
  98970. private _leftStickAxisY;
  98971. private _rightStickAxisX;
  98972. private _rightStickAxisY;
  98973. /**
  98974. * Triggered when the left control stick has been changed
  98975. */
  98976. private _onleftstickchanged;
  98977. /**
  98978. * Triggered when the right control stick has been changed
  98979. */
  98980. private _onrightstickchanged;
  98981. /**
  98982. * Represents a gamepad controller
  98983. */
  98984. static GAMEPAD: number;
  98985. /**
  98986. * Represents a generic controller
  98987. */
  98988. static GENERIC: number;
  98989. /**
  98990. * Represents an XBox controller
  98991. */
  98992. static XBOX: number;
  98993. /**
  98994. * Represents a pose-enabled controller
  98995. */
  98996. static POSE_ENABLED: number;
  98997. /**
  98998. * Represents an Dual Shock controller
  98999. */
  99000. static DUALSHOCK: number;
  99001. /**
  99002. * Specifies whether the left control stick should be Y-inverted
  99003. */
  99004. protected _invertLeftStickY: boolean;
  99005. /**
  99006. * Specifies if the gamepad has been connected
  99007. */
  99008. get isConnected(): boolean;
  99009. /**
  99010. * Initializes the gamepad
  99011. * @param id The id of the gamepad
  99012. * @param index The index of the gamepad
  99013. * @param browserGamepad The browser gamepad
  99014. * @param leftStickX The x component of the left joystick
  99015. * @param leftStickY The y component of the left joystick
  99016. * @param rightStickX The x component of the right joystick
  99017. * @param rightStickY The y component of the right joystick
  99018. */
  99019. constructor(
  99020. /**
  99021. * The id of the gamepad
  99022. */
  99023. id: string,
  99024. /**
  99025. * The index of the gamepad
  99026. */
  99027. index: number,
  99028. /**
  99029. * The browser gamepad
  99030. */
  99031. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  99032. /**
  99033. * Callback triggered when the left joystick has changed
  99034. * @param callback
  99035. */
  99036. onleftstickchanged(callback: (values: StickValues) => void): void;
  99037. /**
  99038. * Callback triggered when the right joystick has changed
  99039. * @param callback
  99040. */
  99041. onrightstickchanged(callback: (values: StickValues) => void): void;
  99042. /**
  99043. * Gets the left joystick
  99044. */
  99045. get leftStick(): StickValues;
  99046. /**
  99047. * Sets the left joystick values
  99048. */
  99049. set leftStick(newValues: StickValues);
  99050. /**
  99051. * Gets the right joystick
  99052. */
  99053. get rightStick(): StickValues;
  99054. /**
  99055. * Sets the right joystick value
  99056. */
  99057. set rightStick(newValues: StickValues);
  99058. /**
  99059. * Updates the gamepad joystick positions
  99060. */
  99061. update(): void;
  99062. /**
  99063. * Disposes the gamepad
  99064. */
  99065. dispose(): void;
  99066. }
  99067. /**
  99068. * Represents a generic gamepad
  99069. */
  99070. export class GenericPad extends Gamepad {
  99071. private _buttons;
  99072. private _onbuttondown;
  99073. private _onbuttonup;
  99074. /**
  99075. * Observable triggered when a button has been pressed
  99076. */
  99077. onButtonDownObservable: Observable<number>;
  99078. /**
  99079. * Observable triggered when a button has been released
  99080. */
  99081. onButtonUpObservable: Observable<number>;
  99082. /**
  99083. * Callback triggered when a button has been pressed
  99084. * @param callback Called when a button has been pressed
  99085. */
  99086. onbuttondown(callback: (buttonPressed: number) => void): void;
  99087. /**
  99088. * Callback triggered when a button has been released
  99089. * @param callback Called when a button has been released
  99090. */
  99091. onbuttonup(callback: (buttonReleased: number) => void): void;
  99092. /**
  99093. * Initializes the generic gamepad
  99094. * @param id The id of the generic gamepad
  99095. * @param index The index of the generic gamepad
  99096. * @param browserGamepad The browser gamepad
  99097. */
  99098. constructor(id: string, index: number, browserGamepad: any);
  99099. private _setButtonValue;
  99100. /**
  99101. * Updates the generic gamepad
  99102. */
  99103. update(): void;
  99104. /**
  99105. * Disposes the generic gamepad
  99106. */
  99107. dispose(): void;
  99108. }
  99109. }
  99110. declare module BABYLON {
  99111. /**
  99112. * Defines the types of pose enabled controllers that are supported
  99113. */
  99114. export enum PoseEnabledControllerType {
  99115. /**
  99116. * HTC Vive
  99117. */
  99118. VIVE = 0,
  99119. /**
  99120. * Oculus Rift
  99121. */
  99122. OCULUS = 1,
  99123. /**
  99124. * Windows mixed reality
  99125. */
  99126. WINDOWS = 2,
  99127. /**
  99128. * Samsung gear VR
  99129. */
  99130. GEAR_VR = 3,
  99131. /**
  99132. * Google Daydream
  99133. */
  99134. DAYDREAM = 4,
  99135. /**
  99136. * Generic
  99137. */
  99138. GENERIC = 5
  99139. }
  99140. /**
  99141. * Defines the MutableGamepadButton interface for the state of a gamepad button
  99142. */
  99143. export interface MutableGamepadButton {
  99144. /**
  99145. * Value of the button/trigger
  99146. */
  99147. value: number;
  99148. /**
  99149. * If the button/trigger is currently touched
  99150. */
  99151. touched: boolean;
  99152. /**
  99153. * If the button/trigger is currently pressed
  99154. */
  99155. pressed: boolean;
  99156. }
  99157. /**
  99158. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  99159. * @hidden
  99160. */
  99161. export interface ExtendedGamepadButton extends GamepadButton {
  99162. /**
  99163. * If the button/trigger is currently pressed
  99164. */
  99165. readonly pressed: boolean;
  99166. /**
  99167. * If the button/trigger is currently touched
  99168. */
  99169. readonly touched: boolean;
  99170. /**
  99171. * Value of the button/trigger
  99172. */
  99173. readonly value: number;
  99174. }
  99175. /** @hidden */
  99176. export interface _GamePadFactory {
  99177. /**
  99178. * Returns whether or not the current gamepad can be created for this type of controller.
  99179. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99180. * @returns true if it can be created, otherwise false
  99181. */
  99182. canCreate(gamepadInfo: any): boolean;
  99183. /**
  99184. * Creates a new instance of the Gamepad.
  99185. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99186. * @returns the new gamepad instance
  99187. */
  99188. create(gamepadInfo: any): Gamepad;
  99189. }
  99190. /**
  99191. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  99192. */
  99193. export class PoseEnabledControllerHelper {
  99194. /** @hidden */
  99195. static _ControllerFactories: _GamePadFactory[];
  99196. /** @hidden */
  99197. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  99198. /**
  99199. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  99200. * @param vrGamepad the gamepad to initialized
  99201. * @returns a vr controller of the type the gamepad identified as
  99202. */
  99203. static InitiateController(vrGamepad: any): Gamepad;
  99204. }
  99205. /**
  99206. * Defines the PoseEnabledController object that contains state of a vr capable controller
  99207. */
  99208. export class PoseEnabledController extends Gamepad implements PoseControlled {
  99209. /**
  99210. * If the controller is used in a webXR session
  99211. */
  99212. isXR: boolean;
  99213. private _deviceRoomPosition;
  99214. private _deviceRoomRotationQuaternion;
  99215. /**
  99216. * The device position in babylon space
  99217. */
  99218. devicePosition: Vector3;
  99219. /**
  99220. * The device rotation in babylon space
  99221. */
  99222. deviceRotationQuaternion: Quaternion;
  99223. /**
  99224. * The scale factor of the device in babylon space
  99225. */
  99226. deviceScaleFactor: number;
  99227. /**
  99228. * (Likely devicePosition should be used instead) The device position in its room space
  99229. */
  99230. position: Vector3;
  99231. /**
  99232. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  99233. */
  99234. rotationQuaternion: Quaternion;
  99235. /**
  99236. * The type of controller (Eg. Windows mixed reality)
  99237. */
  99238. controllerType: PoseEnabledControllerType;
  99239. protected _calculatedPosition: Vector3;
  99240. private _calculatedRotation;
  99241. /**
  99242. * The raw pose from the device
  99243. */
  99244. rawPose: DevicePose;
  99245. private _trackPosition;
  99246. private _maxRotationDistFromHeadset;
  99247. private _draggedRoomRotation;
  99248. /**
  99249. * @hidden
  99250. */
  99251. _disableTrackPosition(fixedPosition: Vector3): void;
  99252. /**
  99253. * Internal, the mesh attached to the controller
  99254. * @hidden
  99255. */
  99256. _mesh: Nullable<AbstractMesh>;
  99257. private _poseControlledCamera;
  99258. private _leftHandSystemQuaternion;
  99259. /**
  99260. * Internal, matrix used to convert room space to babylon space
  99261. * @hidden
  99262. */
  99263. _deviceToWorld: Matrix;
  99264. /**
  99265. * Node to be used when casting a ray from the controller
  99266. * @hidden
  99267. */
  99268. _pointingPoseNode: Nullable<TransformNode>;
  99269. /**
  99270. * Name of the child mesh that can be used to cast a ray from the controller
  99271. */
  99272. static readonly POINTING_POSE: string;
  99273. /**
  99274. * Creates a new PoseEnabledController from a gamepad
  99275. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  99276. */
  99277. constructor(browserGamepad: any);
  99278. private _workingMatrix;
  99279. /**
  99280. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  99281. */
  99282. update(): void;
  99283. /**
  99284. * Updates only the pose device and mesh without doing any button event checking
  99285. */
  99286. protected _updatePoseAndMesh(): void;
  99287. /**
  99288. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  99289. * @param poseData raw pose fromthe device
  99290. */
  99291. updateFromDevice(poseData: DevicePose): void;
  99292. /**
  99293. * @hidden
  99294. */
  99295. _meshAttachedObservable: Observable<AbstractMesh>;
  99296. /**
  99297. * Attaches a mesh to the controller
  99298. * @param mesh the mesh to be attached
  99299. */
  99300. attachToMesh(mesh: AbstractMesh): void;
  99301. /**
  99302. * Attaches the controllers mesh to a camera
  99303. * @param camera the camera the mesh should be attached to
  99304. */
  99305. attachToPoseControlledCamera(camera: TargetCamera): void;
  99306. /**
  99307. * Disposes of the controller
  99308. */
  99309. dispose(): void;
  99310. /**
  99311. * The mesh that is attached to the controller
  99312. */
  99313. get mesh(): Nullable<AbstractMesh>;
  99314. /**
  99315. * Gets the ray of the controller in the direction the controller is pointing
  99316. * @param length the length the resulting ray should be
  99317. * @returns a ray in the direction the controller is pointing
  99318. */
  99319. getForwardRay(length?: number): Ray;
  99320. }
  99321. }
  99322. declare module BABYLON {
  99323. /**
  99324. * Defines the WebVRController object that represents controllers tracked in 3D space
  99325. */
  99326. export abstract class WebVRController extends PoseEnabledController {
  99327. /**
  99328. * Internal, the default controller model for the controller
  99329. */
  99330. protected _defaultModel: Nullable<AbstractMesh>;
  99331. /**
  99332. * Fired when the trigger state has changed
  99333. */
  99334. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  99335. /**
  99336. * Fired when the main button state has changed
  99337. */
  99338. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99339. /**
  99340. * Fired when the secondary button state has changed
  99341. */
  99342. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99343. /**
  99344. * Fired when the pad state has changed
  99345. */
  99346. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  99347. /**
  99348. * Fired when controllers stick values have changed
  99349. */
  99350. onPadValuesChangedObservable: Observable<StickValues>;
  99351. /**
  99352. * Array of button availible on the controller
  99353. */
  99354. protected _buttons: Array<MutableGamepadButton>;
  99355. private _onButtonStateChange;
  99356. /**
  99357. * Fired when a controller button's state has changed
  99358. * @param callback the callback containing the button that was modified
  99359. */
  99360. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  99361. /**
  99362. * X and Y axis corresponding to the controllers joystick
  99363. */
  99364. pad: StickValues;
  99365. /**
  99366. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  99367. */
  99368. hand: string;
  99369. /**
  99370. * The default controller model for the controller
  99371. */
  99372. get defaultModel(): Nullable<AbstractMesh>;
  99373. /**
  99374. * Creates a new WebVRController from a gamepad
  99375. * @param vrGamepad the gamepad that the WebVRController should be created from
  99376. */
  99377. constructor(vrGamepad: any);
  99378. /**
  99379. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  99380. */
  99381. update(): void;
  99382. /**
  99383. * Function to be called when a button is modified
  99384. */
  99385. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99386. /**
  99387. * Loads a mesh and attaches it to the controller
  99388. * @param scene the scene the mesh should be added to
  99389. * @param meshLoaded callback for when the mesh has been loaded
  99390. */
  99391. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99392. private _setButtonValue;
  99393. private _changes;
  99394. private _checkChanges;
  99395. /**
  99396. * Disposes of th webVRCOntroller
  99397. */
  99398. dispose(): void;
  99399. }
  99400. }
  99401. declare module BABYLON {
  99402. /**
  99403. * The HemisphericLight simulates the ambient environment light,
  99404. * so the passed direction is the light reflection direction, not the incoming direction.
  99405. */
  99406. export class HemisphericLight extends Light {
  99407. /**
  99408. * The groundColor is the light in the opposite direction to the one specified during creation.
  99409. * 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.
  99410. */
  99411. groundColor: Color3;
  99412. /**
  99413. * The light reflection direction, not the incoming direction.
  99414. */
  99415. direction: Vector3;
  99416. /**
  99417. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  99418. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  99419. * The HemisphericLight can't cast shadows.
  99420. * Documentation : https://doc.babylonjs.com/babylon101/lights
  99421. * @param name The friendly name of the light
  99422. * @param direction The direction of the light reflection
  99423. * @param scene The scene the light belongs to
  99424. */
  99425. constructor(name: string, direction: Vector3, scene: Scene);
  99426. protected _buildUniformLayout(): void;
  99427. /**
  99428. * Returns the string "HemisphericLight".
  99429. * @return The class name
  99430. */
  99431. getClassName(): string;
  99432. /**
  99433. * Sets the HemisphericLight direction towards the passed target (Vector3).
  99434. * Returns the updated direction.
  99435. * @param target The target the direction should point to
  99436. * @return The computed direction
  99437. */
  99438. setDirectionToTarget(target: Vector3): Vector3;
  99439. /**
  99440. * Returns the shadow generator associated to the light.
  99441. * @returns Always null for hemispheric lights because it does not support shadows.
  99442. */
  99443. getShadowGenerator(): Nullable<IShadowGenerator>;
  99444. /**
  99445. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  99446. * @param effect The effect to update
  99447. * @param lightIndex The index of the light in the effect to update
  99448. * @returns The hemispheric light
  99449. */
  99450. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  99451. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  99452. /**
  99453. * Computes the world matrix of the node
  99454. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  99455. * @param useWasUpdatedFlag defines a reserved property
  99456. * @returns the world matrix
  99457. */
  99458. computeWorldMatrix(): Matrix;
  99459. /**
  99460. * Returns the integer 3.
  99461. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  99462. */
  99463. getTypeID(): number;
  99464. /**
  99465. * Prepares the list of defines specific to the light type.
  99466. * @param defines the list of defines
  99467. * @param lightIndex defines the index of the light for the effect
  99468. */
  99469. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  99470. }
  99471. }
  99472. declare module BABYLON {
  99473. /** @hidden */
  99474. export var vrMultiviewToSingleviewPixelShader: {
  99475. name: string;
  99476. shader: string;
  99477. };
  99478. }
  99479. declare module BABYLON {
  99480. /**
  99481. * Renders to multiple views with a single draw call
  99482. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  99483. */
  99484. export class MultiviewRenderTarget extends RenderTargetTexture {
  99485. /**
  99486. * Creates a multiview render target
  99487. * @param scene scene used with the render target
  99488. * @param size the size of the render target (used for each view)
  99489. */
  99490. constructor(scene: Scene, size?: number | {
  99491. width: number;
  99492. height: number;
  99493. } | {
  99494. ratio: number;
  99495. });
  99496. /**
  99497. * @hidden
  99498. * @param faceIndex the face index, if its a cube texture
  99499. */
  99500. _bindFrameBuffer(faceIndex?: number): void;
  99501. /**
  99502. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  99503. * @returns the view count
  99504. */
  99505. getViewCount(): number;
  99506. }
  99507. }
  99508. declare module BABYLON {
  99509. interface Engine {
  99510. /**
  99511. * Creates a new multiview render target
  99512. * @param width defines the width of the texture
  99513. * @param height defines the height of the texture
  99514. * @returns the created multiview texture
  99515. */
  99516. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  99517. /**
  99518. * Binds a multiview framebuffer to be drawn to
  99519. * @param multiviewTexture texture to bind
  99520. */
  99521. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  99522. }
  99523. interface Camera {
  99524. /**
  99525. * @hidden
  99526. * 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)
  99527. */
  99528. _useMultiviewToSingleView: boolean;
  99529. /**
  99530. * @hidden
  99531. * 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)
  99532. */
  99533. _multiviewTexture: Nullable<RenderTargetTexture>;
  99534. /**
  99535. * @hidden
  99536. * ensures the multiview texture of the camera exists and has the specified width/height
  99537. * @param width height to set on the multiview texture
  99538. * @param height width to set on the multiview texture
  99539. */
  99540. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  99541. }
  99542. interface Scene {
  99543. /** @hidden */
  99544. _transformMatrixR: Matrix;
  99545. /** @hidden */
  99546. _multiviewSceneUbo: Nullable<UniformBuffer>;
  99547. /** @hidden */
  99548. _createMultiviewUbo(): void;
  99549. /** @hidden */
  99550. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  99551. /** @hidden */
  99552. _renderMultiviewToSingleView(camera: Camera): void;
  99553. }
  99554. }
  99555. declare module BABYLON {
  99556. /**
  99557. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  99558. * This will not be used for webXR as it supports displaying texture arrays directly
  99559. */
  99560. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  99561. /**
  99562. * Gets a string identifying the name of the class
  99563. * @returns "VRMultiviewToSingleviewPostProcess" string
  99564. */
  99565. getClassName(): string;
  99566. /**
  99567. * Initializes a VRMultiviewToSingleview
  99568. * @param name name of the post process
  99569. * @param camera camera to be applied to
  99570. * @param scaleFactor scaling factor to the size of the output texture
  99571. */
  99572. constructor(name: string, camera: Camera, scaleFactor: number);
  99573. }
  99574. }
  99575. declare module BABYLON {
  99576. /**
  99577. * Interface used to define additional presentation attributes
  99578. */
  99579. export interface IVRPresentationAttributes {
  99580. /**
  99581. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  99582. */
  99583. highRefreshRate: boolean;
  99584. /**
  99585. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  99586. */
  99587. foveationLevel: number;
  99588. }
  99589. interface Engine {
  99590. /** @hidden */
  99591. _vrDisplay: any;
  99592. /** @hidden */
  99593. _vrSupported: boolean;
  99594. /** @hidden */
  99595. _oldSize: Size;
  99596. /** @hidden */
  99597. _oldHardwareScaleFactor: number;
  99598. /** @hidden */
  99599. _vrExclusivePointerMode: boolean;
  99600. /** @hidden */
  99601. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  99602. /** @hidden */
  99603. _onVRDisplayPointerRestricted: () => void;
  99604. /** @hidden */
  99605. _onVRDisplayPointerUnrestricted: () => void;
  99606. /** @hidden */
  99607. _onVrDisplayConnect: Nullable<(display: any) => void>;
  99608. /** @hidden */
  99609. _onVrDisplayDisconnect: Nullable<() => void>;
  99610. /** @hidden */
  99611. _onVrDisplayPresentChange: Nullable<() => void>;
  99612. /**
  99613. * Observable signaled when VR display mode changes
  99614. */
  99615. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  99616. /**
  99617. * Observable signaled when VR request present is complete
  99618. */
  99619. onVRRequestPresentComplete: Observable<boolean>;
  99620. /**
  99621. * Observable signaled when VR request present starts
  99622. */
  99623. onVRRequestPresentStart: Observable<Engine>;
  99624. /**
  99625. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  99626. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  99627. */
  99628. isInVRExclusivePointerMode: boolean;
  99629. /**
  99630. * Gets a boolean indicating if a webVR device was detected
  99631. * @returns true if a webVR device was detected
  99632. */
  99633. isVRDevicePresent(): boolean;
  99634. /**
  99635. * Gets the current webVR device
  99636. * @returns the current webVR device (or null)
  99637. */
  99638. getVRDevice(): any;
  99639. /**
  99640. * Initializes a webVR display and starts listening to display change events
  99641. * The onVRDisplayChangedObservable will be notified upon these changes
  99642. * @returns A promise containing a VRDisplay and if vr is supported
  99643. */
  99644. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  99645. /** @hidden */
  99646. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  99647. /**
  99648. * Gets or sets the presentation attributes used to configure VR rendering
  99649. */
  99650. vrPresentationAttributes?: IVRPresentationAttributes;
  99651. /**
  99652. * Call this function to switch to webVR mode
  99653. * Will do nothing if webVR is not supported or if there is no webVR device
  99654. * @param options the webvr options provided to the camera. mainly used for multiview
  99655. * @see https://doc.babylonjs.com/how_to/webvr_camera
  99656. */
  99657. enableVR(options: WebVROptions): void;
  99658. /** @hidden */
  99659. _onVRFullScreenTriggered(): void;
  99660. }
  99661. }
  99662. declare module BABYLON {
  99663. /**
  99664. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  99665. * IMPORTANT!! The data is right-hand data.
  99666. * @export
  99667. * @interface DevicePose
  99668. */
  99669. export interface DevicePose {
  99670. /**
  99671. * The position of the device, values in array are [x,y,z].
  99672. */
  99673. readonly position: Nullable<Float32Array>;
  99674. /**
  99675. * The linearVelocity of the device, values in array are [x,y,z].
  99676. */
  99677. readonly linearVelocity: Nullable<Float32Array>;
  99678. /**
  99679. * The linearAcceleration of the device, values in array are [x,y,z].
  99680. */
  99681. readonly linearAcceleration: Nullable<Float32Array>;
  99682. /**
  99683. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  99684. */
  99685. readonly orientation: Nullable<Float32Array>;
  99686. /**
  99687. * The angularVelocity of the device, values in array are [x,y,z].
  99688. */
  99689. readonly angularVelocity: Nullable<Float32Array>;
  99690. /**
  99691. * The angularAcceleration of the device, values in array are [x,y,z].
  99692. */
  99693. readonly angularAcceleration: Nullable<Float32Array>;
  99694. }
  99695. /**
  99696. * Interface representing a pose controlled object in Babylon.
  99697. * A pose controlled object has both regular pose values as well as pose values
  99698. * from an external device such as a VR head mounted display
  99699. */
  99700. export interface PoseControlled {
  99701. /**
  99702. * The position of the object in babylon space.
  99703. */
  99704. position: Vector3;
  99705. /**
  99706. * The rotation quaternion of the object in babylon space.
  99707. */
  99708. rotationQuaternion: Quaternion;
  99709. /**
  99710. * The position of the device in babylon space.
  99711. */
  99712. devicePosition?: Vector3;
  99713. /**
  99714. * The rotation quaternion of the device in babylon space.
  99715. */
  99716. deviceRotationQuaternion: Quaternion;
  99717. /**
  99718. * The raw pose coming from the device.
  99719. */
  99720. rawPose: Nullable<DevicePose>;
  99721. /**
  99722. * The scale of the device to be used when translating from device space to babylon space.
  99723. */
  99724. deviceScaleFactor: number;
  99725. /**
  99726. * Updates the poseControlled values based on the input device pose.
  99727. * @param poseData the pose data to update the object with
  99728. */
  99729. updateFromDevice(poseData: DevicePose): void;
  99730. }
  99731. /**
  99732. * Set of options to customize the webVRCamera
  99733. */
  99734. export interface WebVROptions {
  99735. /**
  99736. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  99737. */
  99738. trackPosition?: boolean;
  99739. /**
  99740. * Sets the scale of the vrDevice in babylon space. (default: 1)
  99741. */
  99742. positionScale?: number;
  99743. /**
  99744. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  99745. */
  99746. displayName?: string;
  99747. /**
  99748. * Should the native controller meshes be initialized. (default: true)
  99749. */
  99750. controllerMeshes?: boolean;
  99751. /**
  99752. * Creating a default HemiLight only on controllers. (default: true)
  99753. */
  99754. defaultLightingOnControllers?: boolean;
  99755. /**
  99756. * If you don't want to use the default VR button of the helper. (default: false)
  99757. */
  99758. useCustomVRButton?: boolean;
  99759. /**
  99760. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  99761. */
  99762. customVRButton?: HTMLButtonElement;
  99763. /**
  99764. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  99765. */
  99766. rayLength?: number;
  99767. /**
  99768. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  99769. */
  99770. defaultHeight?: number;
  99771. /**
  99772. * If multiview should be used if availible (default: false)
  99773. */
  99774. useMultiview?: boolean;
  99775. }
  99776. /**
  99777. * This represents a WebVR camera.
  99778. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  99779. * @example https://doc.babylonjs.com/how_to/webvr_camera
  99780. */
  99781. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  99782. private webVROptions;
  99783. /**
  99784. * @hidden
  99785. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  99786. */
  99787. _vrDevice: any;
  99788. /**
  99789. * The rawPose of the vrDevice.
  99790. */
  99791. rawPose: Nullable<DevicePose>;
  99792. private _onVREnabled;
  99793. private _specsVersion;
  99794. private _attached;
  99795. private _frameData;
  99796. protected _descendants: Array<Node>;
  99797. private _deviceRoomPosition;
  99798. /** @hidden */
  99799. _deviceRoomRotationQuaternion: Quaternion;
  99800. private _standingMatrix;
  99801. /**
  99802. * Represents device position in babylon space.
  99803. */
  99804. devicePosition: Vector3;
  99805. /**
  99806. * Represents device rotation in babylon space.
  99807. */
  99808. deviceRotationQuaternion: Quaternion;
  99809. /**
  99810. * The scale of the device to be used when translating from device space to babylon space.
  99811. */
  99812. deviceScaleFactor: number;
  99813. private _deviceToWorld;
  99814. private _worldToDevice;
  99815. /**
  99816. * References to the webVR controllers for the vrDevice.
  99817. */
  99818. controllers: Array<WebVRController>;
  99819. /**
  99820. * Emits an event when a controller is attached.
  99821. */
  99822. onControllersAttachedObservable: Observable<WebVRController[]>;
  99823. /**
  99824. * Emits an event when a controller's mesh has been loaded;
  99825. */
  99826. onControllerMeshLoadedObservable: Observable<WebVRController>;
  99827. /**
  99828. * Emits an event when the HMD's pose has been updated.
  99829. */
  99830. onPoseUpdatedFromDeviceObservable: Observable<any>;
  99831. private _poseSet;
  99832. /**
  99833. * If the rig cameras be used as parent instead of this camera.
  99834. */
  99835. rigParenting: boolean;
  99836. private _lightOnControllers;
  99837. private _defaultHeight?;
  99838. /**
  99839. * Instantiates a WebVRFreeCamera.
  99840. * @param name The name of the WebVRFreeCamera
  99841. * @param position The starting anchor position for the camera
  99842. * @param scene The scene the camera belongs to
  99843. * @param webVROptions a set of customizable options for the webVRCamera
  99844. */
  99845. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  99846. /**
  99847. * Gets the device distance from the ground in meters.
  99848. * @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.
  99849. */
  99850. deviceDistanceToRoomGround(): number;
  99851. /**
  99852. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  99853. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  99854. */
  99855. useStandingMatrix(callback?: (bool: boolean) => void): void;
  99856. /**
  99857. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  99858. * @returns A promise with a boolean set to if the standing matrix is supported.
  99859. */
  99860. useStandingMatrixAsync(): Promise<boolean>;
  99861. /**
  99862. * Disposes the camera
  99863. */
  99864. dispose(): void;
  99865. /**
  99866. * Gets a vrController by name.
  99867. * @param name The name of the controller to retreive
  99868. * @returns the controller matching the name specified or null if not found
  99869. */
  99870. getControllerByName(name: string): Nullable<WebVRController>;
  99871. private _leftController;
  99872. /**
  99873. * The controller corresponding to the users left hand.
  99874. */
  99875. get leftController(): Nullable<WebVRController>;
  99876. private _rightController;
  99877. /**
  99878. * The controller corresponding to the users right hand.
  99879. */
  99880. get rightController(): Nullable<WebVRController>;
  99881. /**
  99882. * Casts a ray forward from the vrCamera's gaze.
  99883. * @param length Length of the ray (default: 100)
  99884. * @returns the ray corresponding to the gaze
  99885. */
  99886. getForwardRay(length?: number): Ray;
  99887. /**
  99888. * @hidden
  99889. * Updates the camera based on device's frame data
  99890. */
  99891. _checkInputs(): void;
  99892. /**
  99893. * Updates the poseControlled values based on the input device pose.
  99894. * @param poseData Pose coming from the device
  99895. */
  99896. updateFromDevice(poseData: DevicePose): void;
  99897. private _htmlElementAttached;
  99898. private _detachIfAttached;
  99899. /**
  99900. * WebVR's attach control will start broadcasting frames to the device.
  99901. * Note that in certain browsers (chrome for example) this function must be called
  99902. * within a user-interaction callback. Example:
  99903. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  99904. *
  99905. * @param element html element to attach the vrDevice to
  99906. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  99907. */
  99908. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99909. /**
  99910. * Detaches the camera from the html element and disables VR
  99911. *
  99912. * @param element html element to detach from
  99913. */
  99914. detachControl(element: HTMLElement): void;
  99915. /**
  99916. * @returns the name of this class
  99917. */
  99918. getClassName(): string;
  99919. /**
  99920. * Calls resetPose on the vrDisplay
  99921. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  99922. */
  99923. resetToCurrentRotation(): void;
  99924. /**
  99925. * @hidden
  99926. * Updates the rig cameras (left and right eye)
  99927. */
  99928. _updateRigCameras(): void;
  99929. private _workingVector;
  99930. private _oneVector;
  99931. private _workingMatrix;
  99932. private updateCacheCalled;
  99933. private _correctPositionIfNotTrackPosition;
  99934. /**
  99935. * @hidden
  99936. * Updates the cached values of the camera
  99937. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  99938. */
  99939. _updateCache(ignoreParentClass?: boolean): void;
  99940. /**
  99941. * @hidden
  99942. * Get current device position in babylon world
  99943. */
  99944. _computeDevicePosition(): void;
  99945. /**
  99946. * Updates the current device position and rotation in the babylon world
  99947. */
  99948. update(): void;
  99949. /**
  99950. * @hidden
  99951. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  99952. * @returns an identity matrix
  99953. */
  99954. _getViewMatrix(): Matrix;
  99955. private _tmpMatrix;
  99956. /**
  99957. * This function is called by the two RIG cameras.
  99958. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  99959. * @hidden
  99960. */
  99961. _getWebVRViewMatrix(): Matrix;
  99962. /** @hidden */
  99963. _getWebVRProjectionMatrix(): Matrix;
  99964. private _onGamepadConnectedObserver;
  99965. private _onGamepadDisconnectedObserver;
  99966. private _updateCacheWhenTrackingDisabledObserver;
  99967. /**
  99968. * Initializes the controllers and their meshes
  99969. */
  99970. initControllers(): void;
  99971. }
  99972. }
  99973. declare module BABYLON {
  99974. /**
  99975. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  99976. *
  99977. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  99978. *
  99979. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  99980. */
  99981. export class MaterialHelper {
  99982. /**
  99983. * Bind the current view position to an effect.
  99984. * @param effect The effect to be bound
  99985. * @param scene The scene the eyes position is used from
  99986. * @param variableName name of the shader variable that will hold the eye position
  99987. */
  99988. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  99989. /**
  99990. * Helps preparing the defines values about the UVs in used in the effect.
  99991. * UVs are shared as much as we can accross channels in the shaders.
  99992. * @param texture The texture we are preparing the UVs for
  99993. * @param defines The defines to update
  99994. * @param key The channel key "diffuse", "specular"... used in the shader
  99995. */
  99996. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  99997. /**
  99998. * Binds a texture matrix value to its corrsponding uniform
  99999. * @param texture The texture to bind the matrix for
  100000. * @param uniformBuffer The uniform buffer receivin the data
  100001. * @param key The channel key "diffuse", "specular"... used in the shader
  100002. */
  100003. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  100004. /**
  100005. * Gets the current status of the fog (should it be enabled?)
  100006. * @param mesh defines the mesh to evaluate for fog support
  100007. * @param scene defines the hosting scene
  100008. * @returns true if fog must be enabled
  100009. */
  100010. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  100011. /**
  100012. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  100013. * @param mesh defines the current mesh
  100014. * @param scene defines the current scene
  100015. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  100016. * @param pointsCloud defines if point cloud rendering has to be turned on
  100017. * @param fogEnabled defines if fog has to be turned on
  100018. * @param alphaTest defines if alpha testing has to be turned on
  100019. * @param defines defines the current list of defines
  100020. */
  100021. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  100022. /**
  100023. * Helper used to prepare the list of defines associated with frame values for shader compilation
  100024. * @param scene defines the current scene
  100025. * @param engine defines the current engine
  100026. * @param defines specifies the list of active defines
  100027. * @param useInstances defines if instances have to be turned on
  100028. * @param useClipPlane defines if clip plane have to be turned on
  100029. * @param useInstances defines if instances have to be turned on
  100030. * @param useThinInstances defines if thin instances have to be turned on
  100031. */
  100032. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  100033. /**
  100034. * Prepares the defines for bones
  100035. * @param mesh The mesh containing the geometry data we will draw
  100036. * @param defines The defines to update
  100037. */
  100038. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  100039. /**
  100040. * Prepares the defines for morph targets
  100041. * @param mesh The mesh containing the geometry data we will draw
  100042. * @param defines The defines to update
  100043. */
  100044. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  100045. /**
  100046. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  100047. * @param mesh The mesh containing the geometry data we will draw
  100048. * @param defines The defines to update
  100049. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  100050. * @param useBones Precise whether bones should be used or not (override mesh info)
  100051. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  100052. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  100053. * @returns false if defines are considered not dirty and have not been checked
  100054. */
  100055. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  100056. /**
  100057. * Prepares the defines related to multiview
  100058. * @param scene The scene we are intending to draw
  100059. * @param defines The defines to update
  100060. */
  100061. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  100062. /**
  100063. * Prepares the defines related to the prepass
  100064. * @param scene The scene we are intending to draw
  100065. * @param defines The defines to update
  100066. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  100067. */
  100068. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  100069. /**
  100070. * Prepares the defines related to the light information passed in parameter
  100071. * @param scene The scene we are intending to draw
  100072. * @param mesh The mesh the effect is compiling for
  100073. * @param light The light the effect is compiling for
  100074. * @param lightIndex The index of the light
  100075. * @param defines The defines to update
  100076. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  100077. * @param state Defines the current state regarding what is needed (normals, etc...)
  100078. */
  100079. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  100080. needNormals: boolean;
  100081. needRebuild: boolean;
  100082. shadowEnabled: boolean;
  100083. specularEnabled: boolean;
  100084. lightmapMode: boolean;
  100085. }): void;
  100086. /**
  100087. * Prepares the defines related to the light information passed in parameter
  100088. * @param scene The scene we are intending to draw
  100089. * @param mesh The mesh the effect is compiling for
  100090. * @param defines The defines to update
  100091. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  100092. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  100093. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  100094. * @returns true if normals will be required for the rest of the effect
  100095. */
  100096. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  100097. /**
  100098. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  100099. * @param lightIndex defines the light index
  100100. * @param uniformsList The uniform list
  100101. * @param samplersList The sampler list
  100102. * @param projectedLightTexture defines if projected texture must be used
  100103. * @param uniformBuffersList defines an optional list of uniform buffers
  100104. */
  100105. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  100106. /**
  100107. * Prepares the uniforms and samplers list to be used in the effect
  100108. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  100109. * @param samplersList The sampler list
  100110. * @param defines The defines helping in the list generation
  100111. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  100112. */
  100113. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  100114. /**
  100115. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  100116. * @param defines The defines to update while falling back
  100117. * @param fallbacks The authorized effect fallbacks
  100118. * @param maxSimultaneousLights The maximum number of lights allowed
  100119. * @param rank the current rank of the Effect
  100120. * @returns The newly affected rank
  100121. */
  100122. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  100123. private static _TmpMorphInfluencers;
  100124. /**
  100125. * Prepares the list of attributes required for morph targets according to the effect defines.
  100126. * @param attribs The current list of supported attribs
  100127. * @param mesh The mesh to prepare the morph targets attributes for
  100128. * @param influencers The number of influencers
  100129. */
  100130. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  100131. /**
  100132. * Prepares the list of attributes required for morph targets according to the effect defines.
  100133. * @param attribs The current list of supported attribs
  100134. * @param mesh The mesh to prepare the morph targets attributes for
  100135. * @param defines The current Defines of the effect
  100136. */
  100137. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  100138. /**
  100139. * Prepares the list of attributes required for bones according to the effect defines.
  100140. * @param attribs The current list of supported attribs
  100141. * @param mesh The mesh to prepare the bones attributes for
  100142. * @param defines The current Defines of the effect
  100143. * @param fallbacks The current efffect fallback strategy
  100144. */
  100145. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  100146. /**
  100147. * Check and prepare the list of attributes required for instances according to the effect defines.
  100148. * @param attribs The current list of supported attribs
  100149. * @param defines The current MaterialDefines of the effect
  100150. */
  100151. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  100152. /**
  100153. * Add the list of attributes required for instances to the attribs array.
  100154. * @param attribs The current list of supported attribs
  100155. */
  100156. static PushAttributesForInstances(attribs: string[]): void;
  100157. /**
  100158. * Binds the light information to the effect.
  100159. * @param light The light containing the generator
  100160. * @param effect The effect we are binding the data to
  100161. * @param lightIndex The light index in the effect used to render
  100162. */
  100163. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  100164. /**
  100165. * Binds the lights information from the scene to the effect for the given mesh.
  100166. * @param light Light to bind
  100167. * @param lightIndex Light index
  100168. * @param scene The scene where the light belongs to
  100169. * @param effect The effect we are binding the data to
  100170. * @param useSpecular Defines if specular is supported
  100171. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100172. */
  100173. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  100174. /**
  100175. * Binds the lights information from the scene to the effect for the given mesh.
  100176. * @param scene The scene the lights belongs to
  100177. * @param mesh The mesh we are binding the information to render
  100178. * @param effect The effect we are binding the data to
  100179. * @param defines The generated defines for the effect
  100180. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  100181. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100182. */
  100183. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  100184. private static _tempFogColor;
  100185. /**
  100186. * Binds the fog information from the scene to the effect for the given mesh.
  100187. * @param scene The scene the lights belongs to
  100188. * @param mesh The mesh we are binding the information to render
  100189. * @param effect The effect we are binding the data to
  100190. * @param linearSpace Defines if the fog effect is applied in linear space
  100191. */
  100192. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  100193. /**
  100194. * Binds the bones information from the mesh to the effect.
  100195. * @param mesh The mesh we are binding the information to render
  100196. * @param effect The effect we are binding the data to
  100197. */
  100198. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  100199. /**
  100200. * Binds the morph targets information from the mesh to the effect.
  100201. * @param abstractMesh The mesh we are binding the information to render
  100202. * @param effect The effect we are binding the data to
  100203. */
  100204. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  100205. /**
  100206. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  100207. * @param defines The generated defines used in the effect
  100208. * @param effect The effect we are binding the data to
  100209. * @param scene The scene we are willing to render with logarithmic scale for
  100210. */
  100211. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  100212. /**
  100213. * Binds the clip plane information from the scene to the effect.
  100214. * @param scene The scene the clip plane information are extracted from
  100215. * @param effect The effect we are binding the data to
  100216. */
  100217. static BindClipPlane(effect: Effect, scene: Scene): void;
  100218. }
  100219. }
  100220. declare module BABYLON {
  100221. /**
  100222. * Block used to expose an input value
  100223. */
  100224. export class InputBlock extends NodeMaterialBlock {
  100225. private _mode;
  100226. private _associatedVariableName;
  100227. private _storedValue;
  100228. private _valueCallback;
  100229. private _type;
  100230. private _animationType;
  100231. /** Gets or set a value used to limit the range of float values */
  100232. min: number;
  100233. /** Gets or set a value used to limit the range of float values */
  100234. max: number;
  100235. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  100236. isBoolean: boolean;
  100237. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  100238. matrixMode: number;
  100239. /** @hidden */
  100240. _systemValue: Nullable<NodeMaterialSystemValues>;
  100241. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  100242. isConstant: boolean;
  100243. /** Gets or sets the group to use to display this block in the Inspector */
  100244. groupInInspector: string;
  100245. /** Gets an observable raised when the value is changed */
  100246. onValueChangedObservable: Observable<InputBlock>;
  100247. /**
  100248. * Gets or sets the connection point type (default is float)
  100249. */
  100250. get type(): NodeMaterialBlockConnectionPointTypes;
  100251. /**
  100252. * Creates a new InputBlock
  100253. * @param name defines the block name
  100254. * @param target defines the target of that block (Vertex by default)
  100255. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  100256. */
  100257. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  100258. /**
  100259. * Validates if a name is a reserve word.
  100260. * @param newName the new name to be given to the node.
  100261. * @returns false if the name is a reserve word, else true.
  100262. */
  100263. validateBlockName(newName: string): boolean;
  100264. /**
  100265. * Gets the output component
  100266. */
  100267. get output(): NodeMaterialConnectionPoint;
  100268. /**
  100269. * Set the source of this connection point to a vertex attribute
  100270. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  100271. * @returns the current connection point
  100272. */
  100273. setAsAttribute(attributeName?: string): InputBlock;
  100274. /**
  100275. * Set the source of this connection point to a system value
  100276. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  100277. * @returns the current connection point
  100278. */
  100279. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  100280. /**
  100281. * Gets or sets the value of that point.
  100282. * Please note that this value will be ignored if valueCallback is defined
  100283. */
  100284. get value(): any;
  100285. set value(value: any);
  100286. /**
  100287. * Gets or sets a callback used to get the value of that point.
  100288. * Please note that setting this value will force the connection point to ignore the value property
  100289. */
  100290. get valueCallback(): () => any;
  100291. set valueCallback(value: () => any);
  100292. /**
  100293. * Gets or sets the associated variable name in the shader
  100294. */
  100295. get associatedVariableName(): string;
  100296. set associatedVariableName(value: string);
  100297. /** Gets or sets the type of animation applied to the input */
  100298. get animationType(): AnimatedInputBlockTypes;
  100299. set animationType(value: AnimatedInputBlockTypes);
  100300. /**
  100301. * Gets a boolean indicating that this connection point not defined yet
  100302. */
  100303. get isUndefined(): boolean;
  100304. /**
  100305. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  100306. * In this case the connection point name must be the name of the uniform to use.
  100307. * Can only be set on inputs
  100308. */
  100309. get isUniform(): boolean;
  100310. set isUniform(value: boolean);
  100311. /**
  100312. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  100313. * In this case the connection point name must be the name of the attribute to use
  100314. * Can only be set on inputs
  100315. */
  100316. get isAttribute(): boolean;
  100317. set isAttribute(value: boolean);
  100318. /**
  100319. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  100320. * Can only be set on exit points
  100321. */
  100322. get isVarying(): boolean;
  100323. set isVarying(value: boolean);
  100324. /**
  100325. * Gets a boolean indicating that the current connection point is a system value
  100326. */
  100327. get isSystemValue(): boolean;
  100328. /**
  100329. * Gets or sets the current well known value or null if not defined as a system value
  100330. */
  100331. get systemValue(): Nullable<NodeMaterialSystemValues>;
  100332. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  100333. /**
  100334. * Gets the current class name
  100335. * @returns the class name
  100336. */
  100337. getClassName(): string;
  100338. /**
  100339. * Animate the input if animationType !== None
  100340. * @param scene defines the rendering scene
  100341. */
  100342. animate(scene: Scene): void;
  100343. private _emitDefine;
  100344. initialize(state: NodeMaterialBuildState): void;
  100345. /**
  100346. * Set the input block to its default value (based on its type)
  100347. */
  100348. setDefaultValue(): void;
  100349. private _emitConstant;
  100350. /** @hidden */
  100351. get _noContextSwitch(): boolean;
  100352. private _emit;
  100353. /** @hidden */
  100354. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  100355. /** @hidden */
  100356. _transmit(effect: Effect, scene: Scene): void;
  100357. protected _buildBlock(state: NodeMaterialBuildState): void;
  100358. protected _dumpPropertiesCode(): string;
  100359. dispose(): void;
  100360. serialize(): any;
  100361. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100362. }
  100363. }
  100364. declare module BABYLON {
  100365. /**
  100366. * Enum used to define the compatibility state between two connection points
  100367. */
  100368. export enum NodeMaterialConnectionPointCompatibilityStates {
  100369. /** Points are compatibles */
  100370. Compatible = 0,
  100371. /** Points are incompatible because of their types */
  100372. TypeIncompatible = 1,
  100373. /** Points are incompatible because of their targets (vertex vs fragment) */
  100374. TargetIncompatible = 2
  100375. }
  100376. /**
  100377. * Defines the direction of a connection point
  100378. */
  100379. export enum NodeMaterialConnectionPointDirection {
  100380. /** Input */
  100381. Input = 0,
  100382. /** Output */
  100383. Output = 1
  100384. }
  100385. /**
  100386. * Defines a connection point for a block
  100387. */
  100388. export class NodeMaterialConnectionPoint {
  100389. /** @hidden */
  100390. _ownerBlock: NodeMaterialBlock;
  100391. /** @hidden */
  100392. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  100393. private _endpoints;
  100394. private _associatedVariableName;
  100395. private _direction;
  100396. /** @hidden */
  100397. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  100398. /** @hidden */
  100399. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  100400. private _type;
  100401. /** @hidden */
  100402. _enforceAssociatedVariableName: boolean;
  100403. /** Gets the direction of the point */
  100404. get direction(): NodeMaterialConnectionPointDirection;
  100405. /** Indicates that this connection point needs dual validation before being connected to another point */
  100406. needDualDirectionValidation: boolean;
  100407. /**
  100408. * Gets or sets the additional types supported by this connection point
  100409. */
  100410. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  100411. /**
  100412. * Gets or sets the additional types excluded by this connection point
  100413. */
  100414. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  100415. /**
  100416. * Observable triggered when this point is connected
  100417. */
  100418. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  100419. /**
  100420. * Gets or sets the associated variable name in the shader
  100421. */
  100422. get associatedVariableName(): string;
  100423. set associatedVariableName(value: string);
  100424. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  100425. get innerType(): NodeMaterialBlockConnectionPointTypes;
  100426. /**
  100427. * Gets or sets the connection point type (default is float)
  100428. */
  100429. get type(): NodeMaterialBlockConnectionPointTypes;
  100430. set type(value: NodeMaterialBlockConnectionPointTypes);
  100431. /**
  100432. * Gets or sets the connection point name
  100433. */
  100434. name: string;
  100435. /**
  100436. * Gets or sets the connection point name
  100437. */
  100438. displayName: string;
  100439. /**
  100440. * Gets or sets a boolean indicating that this connection point can be omitted
  100441. */
  100442. isOptional: boolean;
  100443. /**
  100444. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  100445. */
  100446. isExposedOnFrame: boolean;
  100447. /**
  100448. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  100449. */
  100450. define: string;
  100451. /** @hidden */
  100452. _prioritizeVertex: boolean;
  100453. private _target;
  100454. /** Gets or sets the target of that connection point */
  100455. get target(): NodeMaterialBlockTargets;
  100456. set target(value: NodeMaterialBlockTargets);
  100457. /**
  100458. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  100459. */
  100460. get isConnected(): boolean;
  100461. /**
  100462. * Gets a boolean indicating that the current point is connected to an input block
  100463. */
  100464. get isConnectedToInputBlock(): boolean;
  100465. /**
  100466. * Gets a the connected input block (if any)
  100467. */
  100468. get connectInputBlock(): Nullable<InputBlock>;
  100469. /** Get the other side of the connection (if any) */
  100470. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  100471. /** Get the block that owns this connection point */
  100472. get ownerBlock(): NodeMaterialBlock;
  100473. /** Get the block connected on the other side of this connection (if any) */
  100474. get sourceBlock(): Nullable<NodeMaterialBlock>;
  100475. /** Get the block connected on the endpoints of this connection (if any) */
  100476. get connectedBlocks(): Array<NodeMaterialBlock>;
  100477. /** Gets the list of connected endpoints */
  100478. get endpoints(): NodeMaterialConnectionPoint[];
  100479. /** Gets a boolean indicating if that output point is connected to at least one input */
  100480. get hasEndpoints(): boolean;
  100481. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  100482. get isConnectedInVertexShader(): boolean;
  100483. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  100484. get isConnectedInFragmentShader(): boolean;
  100485. /**
  100486. * Creates a block suitable to be used as an input for this input point.
  100487. * If null is returned, a block based on the point type will be created.
  100488. * @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
  100489. */
  100490. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  100491. /**
  100492. * Creates a new connection point
  100493. * @param name defines the connection point name
  100494. * @param ownerBlock defines the block hosting this connection point
  100495. * @param direction defines the direction of the connection point
  100496. */
  100497. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  100498. /**
  100499. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  100500. * @returns the class name
  100501. */
  100502. getClassName(): string;
  100503. /**
  100504. * Gets a boolean indicating if the current point can be connected to another point
  100505. * @param connectionPoint defines the other connection point
  100506. * @returns a boolean
  100507. */
  100508. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  100509. /**
  100510. * Gets a number indicating if the current point can be connected to another point
  100511. * @param connectionPoint defines the other connection point
  100512. * @returns a number defining the compatibility state
  100513. */
  100514. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  100515. /**
  100516. * Connect this point to another connection point
  100517. * @param connectionPoint defines the other connection point
  100518. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  100519. * @returns the current connection point
  100520. */
  100521. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  100522. /**
  100523. * Disconnect this point from one of his endpoint
  100524. * @param endpoint defines the other connection point
  100525. * @returns the current connection point
  100526. */
  100527. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  100528. /**
  100529. * Serializes this point in a JSON representation
  100530. * @param isInput defines if the connection point is an input (default is true)
  100531. * @returns the serialized point object
  100532. */
  100533. serialize(isInput?: boolean): any;
  100534. /**
  100535. * Release resources
  100536. */
  100537. dispose(): void;
  100538. }
  100539. }
  100540. declare module BABYLON {
  100541. /**
  100542. * Enum used to define the material modes
  100543. */
  100544. export enum NodeMaterialModes {
  100545. /** Regular material */
  100546. Material = 0,
  100547. /** For post process */
  100548. PostProcess = 1,
  100549. /** For particle system */
  100550. Particle = 2
  100551. }
  100552. }
  100553. declare module BABYLON {
  100554. /**
  100555. * Block used to read a texture from a sampler
  100556. */
  100557. export class TextureBlock extends NodeMaterialBlock {
  100558. private _defineName;
  100559. private _linearDefineName;
  100560. private _gammaDefineName;
  100561. private _tempTextureRead;
  100562. private _samplerName;
  100563. private _transformedUVName;
  100564. private _textureTransformName;
  100565. private _textureInfoName;
  100566. private _mainUVName;
  100567. private _mainUVDefineName;
  100568. private _fragmentOnly;
  100569. /**
  100570. * Gets or sets the texture associated with the node
  100571. */
  100572. texture: Nullable<Texture>;
  100573. /**
  100574. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  100575. */
  100576. convertToGammaSpace: boolean;
  100577. /**
  100578. * Gets or sets a boolean indicating if content needs to be converted to linear space
  100579. */
  100580. convertToLinearSpace: boolean;
  100581. /**
  100582. * Create a new TextureBlock
  100583. * @param name defines the block name
  100584. */
  100585. constructor(name: string, fragmentOnly?: boolean);
  100586. /**
  100587. * Gets the current class name
  100588. * @returns the class name
  100589. */
  100590. getClassName(): string;
  100591. /**
  100592. * Gets the uv input component
  100593. */
  100594. get uv(): NodeMaterialConnectionPoint;
  100595. /**
  100596. * Gets the rgba output component
  100597. */
  100598. get rgba(): NodeMaterialConnectionPoint;
  100599. /**
  100600. * Gets the rgb output component
  100601. */
  100602. get rgb(): NodeMaterialConnectionPoint;
  100603. /**
  100604. * Gets the r output component
  100605. */
  100606. get r(): NodeMaterialConnectionPoint;
  100607. /**
  100608. * Gets the g output component
  100609. */
  100610. get g(): NodeMaterialConnectionPoint;
  100611. /**
  100612. * Gets the b output component
  100613. */
  100614. get b(): NodeMaterialConnectionPoint;
  100615. /**
  100616. * Gets the a output component
  100617. */
  100618. get a(): NodeMaterialConnectionPoint;
  100619. get target(): NodeMaterialBlockTargets;
  100620. autoConfigure(material: NodeMaterial): void;
  100621. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  100622. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100623. isReady(): boolean;
  100624. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  100625. private get _isMixed();
  100626. private _injectVertexCode;
  100627. private _writeTextureRead;
  100628. private _writeOutput;
  100629. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100630. protected _dumpPropertiesCode(): string;
  100631. serialize(): any;
  100632. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100633. }
  100634. }
  100635. declare module BABYLON {
  100636. /** @hidden */
  100637. export var reflectionFunction: {
  100638. name: string;
  100639. shader: string;
  100640. };
  100641. }
  100642. declare module BABYLON {
  100643. /**
  100644. * Base block used to read a reflection texture from a sampler
  100645. */
  100646. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  100647. /** @hidden */
  100648. _define3DName: string;
  100649. /** @hidden */
  100650. _defineCubicName: string;
  100651. /** @hidden */
  100652. _defineExplicitName: string;
  100653. /** @hidden */
  100654. _defineProjectionName: string;
  100655. /** @hidden */
  100656. _defineLocalCubicName: string;
  100657. /** @hidden */
  100658. _defineSphericalName: string;
  100659. /** @hidden */
  100660. _definePlanarName: string;
  100661. /** @hidden */
  100662. _defineEquirectangularName: string;
  100663. /** @hidden */
  100664. _defineMirroredEquirectangularFixedName: string;
  100665. /** @hidden */
  100666. _defineEquirectangularFixedName: string;
  100667. /** @hidden */
  100668. _defineSkyboxName: string;
  100669. /** @hidden */
  100670. _defineOppositeZ: string;
  100671. /** @hidden */
  100672. _cubeSamplerName: string;
  100673. /** @hidden */
  100674. _2DSamplerName: string;
  100675. protected _positionUVWName: string;
  100676. protected _directionWName: string;
  100677. protected _reflectionVectorName: string;
  100678. /** @hidden */
  100679. _reflectionCoordsName: string;
  100680. /** @hidden */
  100681. _reflectionMatrixName: string;
  100682. protected _reflectionColorName: string;
  100683. /**
  100684. * Gets or sets the texture associated with the node
  100685. */
  100686. texture: Nullable<BaseTexture>;
  100687. /**
  100688. * Create a new ReflectionTextureBaseBlock
  100689. * @param name defines the block name
  100690. */
  100691. constructor(name: string);
  100692. /**
  100693. * Gets the current class name
  100694. * @returns the class name
  100695. */
  100696. getClassName(): string;
  100697. /**
  100698. * Gets the world position input component
  100699. */
  100700. abstract get position(): NodeMaterialConnectionPoint;
  100701. /**
  100702. * Gets the world position input component
  100703. */
  100704. abstract get worldPosition(): NodeMaterialConnectionPoint;
  100705. /**
  100706. * Gets the world normal input component
  100707. */
  100708. abstract get worldNormal(): NodeMaterialConnectionPoint;
  100709. /**
  100710. * Gets the world input component
  100711. */
  100712. abstract get world(): NodeMaterialConnectionPoint;
  100713. /**
  100714. * Gets the camera (or eye) position component
  100715. */
  100716. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  100717. /**
  100718. * Gets the view input component
  100719. */
  100720. abstract get view(): NodeMaterialConnectionPoint;
  100721. protected _getTexture(): Nullable<BaseTexture>;
  100722. autoConfigure(material: NodeMaterial): void;
  100723. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100724. isReady(): boolean;
  100725. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  100726. /**
  100727. * Gets the code to inject in the vertex shader
  100728. * @param state current state of the node material building
  100729. * @returns the shader code
  100730. */
  100731. handleVertexSide(state: NodeMaterialBuildState): string;
  100732. /**
  100733. * Handles the inits for the fragment code path
  100734. * @param state node material build state
  100735. */
  100736. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  100737. /**
  100738. * Generates the reflection coords code for the fragment code path
  100739. * @param worldNormalVarName name of the world normal variable
  100740. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  100741. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  100742. * @returns the shader code
  100743. */
  100744. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  100745. /**
  100746. * Generates the reflection color code for the fragment code path
  100747. * @param lodVarName name of the lod variable
  100748. * @param swizzleLookupTexture swizzle to use for the final color variable
  100749. * @returns the shader code
  100750. */
  100751. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  100752. /**
  100753. * Generates the code corresponding to the connected output points
  100754. * @param state node material build state
  100755. * @param varName name of the variable to output
  100756. * @returns the shader code
  100757. */
  100758. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  100759. protected _buildBlock(state: NodeMaterialBuildState): this;
  100760. protected _dumpPropertiesCode(): string;
  100761. serialize(): any;
  100762. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100763. }
  100764. }
  100765. declare module BABYLON {
  100766. /**
  100767. * Defines a connection point to be used for points with a custom object type
  100768. */
  100769. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  100770. private _blockType;
  100771. private _blockName;
  100772. private _nameForCheking?;
  100773. /**
  100774. * Creates a new connection point
  100775. * @param name defines the connection point name
  100776. * @param ownerBlock defines the block hosting this connection point
  100777. * @param direction defines the direction of the connection point
  100778. */
  100779. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  100780. /**
  100781. * Gets a number indicating if the current point can be connected to another point
  100782. * @param connectionPoint defines the other connection point
  100783. * @returns a number defining the compatibility state
  100784. */
  100785. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  100786. /**
  100787. * Creates a block suitable to be used as an input for this input point.
  100788. * If null is returned, a block based on the point type will be created.
  100789. * @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
  100790. */
  100791. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  100792. }
  100793. }
  100794. declare module BABYLON {
  100795. /**
  100796. * Enum defining the type of properties that can be edited in the property pages in the NME
  100797. */
  100798. export enum PropertyTypeForEdition {
  100799. /** property is a boolean */
  100800. Boolean = 0,
  100801. /** property is a float */
  100802. Float = 1,
  100803. /** property is a Vector2 */
  100804. Vector2 = 2,
  100805. /** property is a list of values */
  100806. List = 3
  100807. }
  100808. /**
  100809. * Interface that defines an option in a variable of type list
  100810. */
  100811. export interface IEditablePropertyListOption {
  100812. /** label of the option */
  100813. "label": string;
  100814. /** value of the option */
  100815. "value": number;
  100816. }
  100817. /**
  100818. * Interface that defines the options available for an editable property
  100819. */
  100820. export interface IEditablePropertyOption {
  100821. /** min value */
  100822. "min"?: number;
  100823. /** max value */
  100824. "max"?: number;
  100825. /** notifiers: indicates which actions to take when the property is changed */
  100826. "notifiers"?: {
  100827. /** the material should be rebuilt */
  100828. "rebuild"?: boolean;
  100829. /** the preview should be updated */
  100830. "update"?: boolean;
  100831. };
  100832. /** list of the options for a variable of type list */
  100833. "options"?: IEditablePropertyListOption[];
  100834. }
  100835. /**
  100836. * Interface that describes an editable property
  100837. */
  100838. export interface IPropertyDescriptionForEdition {
  100839. /** name of the property */
  100840. "propertyName": string;
  100841. /** display name of the property */
  100842. "displayName": string;
  100843. /** type of the property */
  100844. "type": PropertyTypeForEdition;
  100845. /** group of the property - all properties with the same group value will be displayed in a specific section */
  100846. "groupName": string;
  100847. /** options for the property */
  100848. "options": IEditablePropertyOption;
  100849. }
  100850. /**
  100851. * Decorator that flags a property in a node material block as being editable
  100852. */
  100853. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  100854. }
  100855. declare module BABYLON {
  100856. /**
  100857. * Block used to implement the refraction part of the sub surface module of the PBR material
  100858. */
  100859. export class RefractionBlock extends NodeMaterialBlock {
  100860. /** @hidden */
  100861. _define3DName: string;
  100862. /** @hidden */
  100863. _refractionMatrixName: string;
  100864. /** @hidden */
  100865. _defineLODRefractionAlpha: string;
  100866. /** @hidden */
  100867. _defineLinearSpecularRefraction: string;
  100868. /** @hidden */
  100869. _defineOppositeZ: string;
  100870. /** @hidden */
  100871. _cubeSamplerName: string;
  100872. /** @hidden */
  100873. _2DSamplerName: string;
  100874. /** @hidden */
  100875. _vRefractionMicrosurfaceInfosName: string;
  100876. /** @hidden */
  100877. _vRefractionInfosName: string;
  100878. private _scene;
  100879. /**
  100880. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  100881. * Materials half opaque for instance using refraction could benefit from this control.
  100882. */
  100883. linkRefractionWithTransparency: boolean;
  100884. /**
  100885. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  100886. */
  100887. invertRefractionY: boolean;
  100888. /**
  100889. * Gets or sets the texture associated with the node
  100890. */
  100891. texture: Nullable<BaseTexture>;
  100892. /**
  100893. * Create a new RefractionBlock
  100894. * @param name defines the block name
  100895. */
  100896. constructor(name: string);
  100897. /**
  100898. * Gets the current class name
  100899. * @returns the class name
  100900. */
  100901. getClassName(): string;
  100902. /**
  100903. * Gets the intensity input component
  100904. */
  100905. get intensity(): NodeMaterialConnectionPoint;
  100906. /**
  100907. * Gets the index of refraction input component
  100908. */
  100909. get indexOfRefraction(): NodeMaterialConnectionPoint;
  100910. /**
  100911. * Gets the tint at distance input component
  100912. */
  100913. get tintAtDistance(): NodeMaterialConnectionPoint;
  100914. /**
  100915. * Gets the view input component
  100916. */
  100917. get view(): NodeMaterialConnectionPoint;
  100918. /**
  100919. * Gets the refraction object output component
  100920. */
  100921. get refraction(): NodeMaterialConnectionPoint;
  100922. /**
  100923. * Returns true if the block has a texture
  100924. */
  100925. get hasTexture(): boolean;
  100926. protected _getTexture(): Nullable<BaseTexture>;
  100927. autoConfigure(material: NodeMaterial): void;
  100928. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  100929. isReady(): boolean;
  100930. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  100931. /**
  100932. * Gets the main code of the block (fragment side)
  100933. * @param state current state of the node material building
  100934. * @returns the shader code
  100935. */
  100936. getCode(state: NodeMaterialBuildState): string;
  100937. protected _buildBlock(state: NodeMaterialBuildState): this;
  100938. protected _dumpPropertiesCode(): string;
  100939. serialize(): any;
  100940. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100941. }
  100942. }
  100943. declare module BABYLON {
  100944. /**
  100945. * Base block used as input for post process
  100946. */
  100947. export class CurrentScreenBlock extends NodeMaterialBlock {
  100948. private _samplerName;
  100949. private _linearDefineName;
  100950. private _gammaDefineName;
  100951. private _mainUVName;
  100952. private _tempTextureRead;
  100953. /**
  100954. * Gets or sets the texture associated with the node
  100955. */
  100956. texture: Nullable<BaseTexture>;
  100957. /**
  100958. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  100959. */
  100960. convertToGammaSpace: boolean;
  100961. /**
  100962. * Gets or sets a boolean indicating if content needs to be converted to linear space
  100963. */
  100964. convertToLinearSpace: boolean;
  100965. /**
  100966. * Create a new CurrentScreenBlock
  100967. * @param name defines the block name
  100968. */
  100969. constructor(name: string);
  100970. /**
  100971. * Gets the current class name
  100972. * @returns the class name
  100973. */
  100974. getClassName(): string;
  100975. /**
  100976. * Gets the uv input component
  100977. */
  100978. get uv(): NodeMaterialConnectionPoint;
  100979. /**
  100980. * Gets the rgba output component
  100981. */
  100982. get rgba(): NodeMaterialConnectionPoint;
  100983. /**
  100984. * Gets the rgb output component
  100985. */
  100986. get rgb(): NodeMaterialConnectionPoint;
  100987. /**
  100988. * Gets the r output component
  100989. */
  100990. get r(): NodeMaterialConnectionPoint;
  100991. /**
  100992. * Gets the g output component
  100993. */
  100994. get g(): NodeMaterialConnectionPoint;
  100995. /**
  100996. * Gets the b output component
  100997. */
  100998. get b(): NodeMaterialConnectionPoint;
  100999. /**
  101000. * Gets the a output component
  101001. */
  101002. get a(): NodeMaterialConnectionPoint;
  101003. /**
  101004. * Initialize the block and prepare the context for build
  101005. * @param state defines the state that will be used for the build
  101006. */
  101007. initialize(state: NodeMaterialBuildState): void;
  101008. get target(): NodeMaterialBlockTargets;
  101009. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101010. isReady(): boolean;
  101011. private _injectVertexCode;
  101012. private _writeTextureRead;
  101013. private _writeOutput;
  101014. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101015. serialize(): any;
  101016. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101017. }
  101018. }
  101019. declare module BABYLON {
  101020. /**
  101021. * Base block used for the particle texture
  101022. */
  101023. export class ParticleTextureBlock extends NodeMaterialBlock {
  101024. private _samplerName;
  101025. private _linearDefineName;
  101026. private _gammaDefineName;
  101027. private _tempTextureRead;
  101028. /**
  101029. * Gets or sets the texture associated with the node
  101030. */
  101031. texture: Nullable<BaseTexture>;
  101032. /**
  101033. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101034. */
  101035. convertToGammaSpace: boolean;
  101036. /**
  101037. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101038. */
  101039. convertToLinearSpace: boolean;
  101040. /**
  101041. * Create a new ParticleTextureBlock
  101042. * @param name defines the block name
  101043. */
  101044. constructor(name: string);
  101045. /**
  101046. * Gets the current class name
  101047. * @returns the class name
  101048. */
  101049. getClassName(): string;
  101050. /**
  101051. * Gets the uv input component
  101052. */
  101053. get uv(): NodeMaterialConnectionPoint;
  101054. /**
  101055. * Gets the rgba output component
  101056. */
  101057. get rgba(): NodeMaterialConnectionPoint;
  101058. /**
  101059. * Gets the rgb output component
  101060. */
  101061. get rgb(): NodeMaterialConnectionPoint;
  101062. /**
  101063. * Gets the r output component
  101064. */
  101065. get r(): NodeMaterialConnectionPoint;
  101066. /**
  101067. * Gets the g output component
  101068. */
  101069. get g(): NodeMaterialConnectionPoint;
  101070. /**
  101071. * Gets the b output component
  101072. */
  101073. get b(): NodeMaterialConnectionPoint;
  101074. /**
  101075. * Gets the a output component
  101076. */
  101077. get a(): NodeMaterialConnectionPoint;
  101078. /**
  101079. * Initialize the block and prepare the context for build
  101080. * @param state defines the state that will be used for the build
  101081. */
  101082. initialize(state: NodeMaterialBuildState): void;
  101083. autoConfigure(material: NodeMaterial): void;
  101084. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101085. isReady(): boolean;
  101086. private _writeOutput;
  101087. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101088. serialize(): any;
  101089. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101090. }
  101091. }
  101092. declare module BABYLON {
  101093. /**
  101094. * Class used to store shared data between 2 NodeMaterialBuildState
  101095. */
  101096. export class NodeMaterialBuildStateSharedData {
  101097. /**
  101098. * Gets the list of emitted varyings
  101099. */
  101100. temps: string[];
  101101. /**
  101102. * Gets the list of emitted varyings
  101103. */
  101104. varyings: string[];
  101105. /**
  101106. * Gets the varying declaration string
  101107. */
  101108. varyingDeclaration: string;
  101109. /**
  101110. * Input blocks
  101111. */
  101112. inputBlocks: InputBlock[];
  101113. /**
  101114. * Input blocks
  101115. */
  101116. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  101117. /**
  101118. * Bindable blocks (Blocks that need to set data to the effect)
  101119. */
  101120. bindableBlocks: NodeMaterialBlock[];
  101121. /**
  101122. * List of blocks that can provide a compilation fallback
  101123. */
  101124. blocksWithFallbacks: NodeMaterialBlock[];
  101125. /**
  101126. * List of blocks that can provide a define update
  101127. */
  101128. blocksWithDefines: NodeMaterialBlock[];
  101129. /**
  101130. * List of blocks that can provide a repeatable content
  101131. */
  101132. repeatableContentBlocks: NodeMaterialBlock[];
  101133. /**
  101134. * List of blocks that can provide a dynamic list of uniforms
  101135. */
  101136. dynamicUniformBlocks: NodeMaterialBlock[];
  101137. /**
  101138. * List of blocks that can block the isReady function for the material
  101139. */
  101140. blockingBlocks: NodeMaterialBlock[];
  101141. /**
  101142. * Gets the list of animated inputs
  101143. */
  101144. animatedInputs: InputBlock[];
  101145. /**
  101146. * Build Id used to avoid multiple recompilations
  101147. */
  101148. buildId: number;
  101149. /** List of emitted variables */
  101150. variableNames: {
  101151. [key: string]: number;
  101152. };
  101153. /** List of emitted defines */
  101154. defineNames: {
  101155. [key: string]: number;
  101156. };
  101157. /** Should emit comments? */
  101158. emitComments: boolean;
  101159. /** Emit build activity */
  101160. verbose: boolean;
  101161. /** Gets or sets the hosting scene */
  101162. scene: Scene;
  101163. /**
  101164. * Gets the compilation hints emitted at compilation time
  101165. */
  101166. hints: {
  101167. needWorldViewMatrix: boolean;
  101168. needWorldViewProjectionMatrix: boolean;
  101169. needAlphaBlending: boolean;
  101170. needAlphaTesting: boolean;
  101171. };
  101172. /**
  101173. * List of compilation checks
  101174. */
  101175. checks: {
  101176. emitVertex: boolean;
  101177. emitFragment: boolean;
  101178. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  101179. };
  101180. /**
  101181. * Is vertex program allowed to be empty?
  101182. */
  101183. allowEmptyVertexProgram: boolean;
  101184. /** Creates a new shared data */
  101185. constructor();
  101186. /**
  101187. * Emits console errors and exceptions if there is a failing check
  101188. */
  101189. emitErrors(): void;
  101190. }
  101191. }
  101192. declare module BABYLON {
  101193. /**
  101194. * Class used to store node based material build state
  101195. */
  101196. export class NodeMaterialBuildState {
  101197. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  101198. supportUniformBuffers: boolean;
  101199. /**
  101200. * Gets the list of emitted attributes
  101201. */
  101202. attributes: string[];
  101203. /**
  101204. * Gets the list of emitted uniforms
  101205. */
  101206. uniforms: string[];
  101207. /**
  101208. * Gets the list of emitted constants
  101209. */
  101210. constants: string[];
  101211. /**
  101212. * Gets the list of emitted samplers
  101213. */
  101214. samplers: string[];
  101215. /**
  101216. * Gets the list of emitted functions
  101217. */
  101218. functions: {
  101219. [key: string]: string;
  101220. };
  101221. /**
  101222. * Gets the list of emitted extensions
  101223. */
  101224. extensions: {
  101225. [key: string]: string;
  101226. };
  101227. /**
  101228. * Gets the target of the compilation state
  101229. */
  101230. target: NodeMaterialBlockTargets;
  101231. /**
  101232. * Gets the list of emitted counters
  101233. */
  101234. counters: {
  101235. [key: string]: number;
  101236. };
  101237. /**
  101238. * Shared data between multiple NodeMaterialBuildState instances
  101239. */
  101240. sharedData: NodeMaterialBuildStateSharedData;
  101241. /** @hidden */
  101242. _vertexState: NodeMaterialBuildState;
  101243. /** @hidden */
  101244. _attributeDeclaration: string;
  101245. /** @hidden */
  101246. _uniformDeclaration: string;
  101247. /** @hidden */
  101248. _constantDeclaration: string;
  101249. /** @hidden */
  101250. _samplerDeclaration: string;
  101251. /** @hidden */
  101252. _varyingTransfer: string;
  101253. /** @hidden */
  101254. _injectAtEnd: string;
  101255. private _repeatableContentAnchorIndex;
  101256. /** @hidden */
  101257. _builtCompilationString: string;
  101258. /**
  101259. * Gets the emitted compilation strings
  101260. */
  101261. compilationString: string;
  101262. /**
  101263. * Finalize the compilation strings
  101264. * @param state defines the current compilation state
  101265. */
  101266. finalize(state: NodeMaterialBuildState): void;
  101267. /** @hidden */
  101268. get _repeatableContentAnchor(): string;
  101269. /** @hidden */
  101270. _getFreeVariableName(prefix: string): string;
  101271. /** @hidden */
  101272. _getFreeDefineName(prefix: string): string;
  101273. /** @hidden */
  101274. _excludeVariableName(name: string): void;
  101275. /** @hidden */
  101276. _emit2DSampler(name: string): void;
  101277. /** @hidden */
  101278. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  101279. /** @hidden */
  101280. _emitExtension(name: string, extension: string, define?: string): void;
  101281. /** @hidden */
  101282. _emitFunction(name: string, code: string, comments: string): void;
  101283. /** @hidden */
  101284. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  101285. replaceStrings?: {
  101286. search: RegExp;
  101287. replace: string;
  101288. }[];
  101289. repeatKey?: string;
  101290. }): string;
  101291. /** @hidden */
  101292. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  101293. repeatKey?: string;
  101294. removeAttributes?: boolean;
  101295. removeUniforms?: boolean;
  101296. removeVaryings?: boolean;
  101297. removeIfDef?: boolean;
  101298. replaceStrings?: {
  101299. search: RegExp;
  101300. replace: string;
  101301. }[];
  101302. }, storeKey?: string): void;
  101303. /** @hidden */
  101304. _registerTempVariable(name: string): boolean;
  101305. /** @hidden */
  101306. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  101307. /** @hidden */
  101308. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  101309. /** @hidden */
  101310. _emitFloat(value: number): string;
  101311. }
  101312. }
  101313. declare module BABYLON {
  101314. /**
  101315. * Helper class used to generate session unique ID
  101316. */
  101317. export class UniqueIdGenerator {
  101318. private static _UniqueIdCounter;
  101319. /**
  101320. * Gets an unique (relatively to the current scene) Id
  101321. */
  101322. static get UniqueId(): number;
  101323. }
  101324. }
  101325. declare module BABYLON {
  101326. /**
  101327. * Defines a block that can be used inside a node based material
  101328. */
  101329. export class NodeMaterialBlock {
  101330. private _buildId;
  101331. private _buildTarget;
  101332. private _target;
  101333. private _isFinalMerger;
  101334. private _isInput;
  101335. private _name;
  101336. protected _isUnique: boolean;
  101337. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  101338. inputsAreExclusive: boolean;
  101339. /** @hidden */
  101340. _codeVariableName: string;
  101341. /** @hidden */
  101342. _inputs: NodeMaterialConnectionPoint[];
  101343. /** @hidden */
  101344. _outputs: NodeMaterialConnectionPoint[];
  101345. /** @hidden */
  101346. _preparationId: number;
  101347. /**
  101348. * Gets the name of the block
  101349. */
  101350. get name(): string;
  101351. /**
  101352. * Sets the name of the block. Will check if the name is valid.
  101353. */
  101354. set name(newName: string);
  101355. /**
  101356. * Gets or sets the unique id of the node
  101357. */
  101358. uniqueId: number;
  101359. /**
  101360. * Gets or sets the comments associated with this block
  101361. */
  101362. comments: string;
  101363. /**
  101364. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  101365. */
  101366. get isUnique(): boolean;
  101367. /**
  101368. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  101369. */
  101370. get isFinalMerger(): boolean;
  101371. /**
  101372. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  101373. */
  101374. get isInput(): boolean;
  101375. /**
  101376. * Gets or sets the build Id
  101377. */
  101378. get buildId(): number;
  101379. set buildId(value: number);
  101380. /**
  101381. * Gets or sets the target of the block
  101382. */
  101383. get target(): NodeMaterialBlockTargets;
  101384. set target(value: NodeMaterialBlockTargets);
  101385. /**
  101386. * Gets the list of input points
  101387. */
  101388. get inputs(): NodeMaterialConnectionPoint[];
  101389. /** Gets the list of output points */
  101390. get outputs(): NodeMaterialConnectionPoint[];
  101391. /**
  101392. * Find an input by its name
  101393. * @param name defines the name of the input to look for
  101394. * @returns the input or null if not found
  101395. */
  101396. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  101397. /**
  101398. * Find an output by its name
  101399. * @param name defines the name of the outputto look for
  101400. * @returns the output or null if not found
  101401. */
  101402. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  101403. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  101404. visibleInInspector: boolean;
  101405. /**
  101406. * Creates a new NodeMaterialBlock
  101407. * @param name defines the block name
  101408. * @param target defines the target of that block (Vertex by default)
  101409. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  101410. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  101411. */
  101412. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  101413. /**
  101414. * Initialize the block and prepare the context for build
  101415. * @param state defines the state that will be used for the build
  101416. */
  101417. initialize(state: NodeMaterialBuildState): void;
  101418. /**
  101419. * Bind data to effect. Will only be called for blocks with isBindable === true
  101420. * @param effect defines the effect to bind data to
  101421. * @param nodeMaterial defines the hosting NodeMaterial
  101422. * @param mesh defines the mesh that will be rendered
  101423. * @param subMesh defines the submesh that will be rendered
  101424. */
  101425. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  101426. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  101427. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  101428. protected _writeFloat(value: number): string;
  101429. /**
  101430. * Gets the current class name e.g. "NodeMaterialBlock"
  101431. * @returns the class name
  101432. */
  101433. getClassName(): string;
  101434. /**
  101435. * Register a new input. Must be called inside a block constructor
  101436. * @param name defines the connection point name
  101437. * @param type defines the connection point type
  101438. * @param isOptional defines a boolean indicating that this input can be omitted
  101439. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  101440. * @param point an already created connection point. If not provided, create a new one
  101441. * @returns the current block
  101442. */
  101443. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  101444. /**
  101445. * Register a new output. Must be called inside a block constructor
  101446. * @param name defines the connection point name
  101447. * @param type defines the connection point type
  101448. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  101449. * @param point an already created connection point. If not provided, create a new one
  101450. * @returns the current block
  101451. */
  101452. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  101453. /**
  101454. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  101455. * @param forOutput defines an optional connection point to check compatibility with
  101456. * @returns the first available input or null
  101457. */
  101458. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  101459. /**
  101460. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  101461. * @param forBlock defines an optional block to check compatibility with
  101462. * @returns the first available input or null
  101463. */
  101464. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  101465. /**
  101466. * Gets the sibling of the given output
  101467. * @param current defines the current output
  101468. * @returns the next output in the list or null
  101469. */
  101470. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  101471. /**
  101472. * Connect current block with another block
  101473. * @param other defines the block to connect with
  101474. * @param options define the various options to help pick the right connections
  101475. * @returns the current block
  101476. */
  101477. connectTo(other: NodeMaterialBlock, options?: {
  101478. input?: string;
  101479. output?: string;
  101480. outputSwizzle?: string;
  101481. }): this | undefined;
  101482. protected _buildBlock(state: NodeMaterialBuildState): void;
  101483. /**
  101484. * Add uniforms, samplers and uniform buffers at compilation time
  101485. * @param state defines the state to update
  101486. * @param nodeMaterial defines the node material requesting the update
  101487. * @param defines defines the material defines to update
  101488. * @param uniformBuffers defines the list of uniform buffer names
  101489. */
  101490. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  101491. /**
  101492. * Add potential fallbacks if shader compilation fails
  101493. * @param mesh defines the mesh to be rendered
  101494. * @param fallbacks defines the current prioritized list of fallbacks
  101495. */
  101496. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  101497. /**
  101498. * Initialize defines for shader compilation
  101499. * @param mesh defines the mesh to be rendered
  101500. * @param nodeMaterial defines the node material requesting the update
  101501. * @param defines defines the material defines to update
  101502. * @param useInstances specifies that instances should be used
  101503. */
  101504. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  101505. /**
  101506. * Update defines for shader compilation
  101507. * @param mesh defines the mesh to be rendered
  101508. * @param nodeMaterial defines the node material requesting the update
  101509. * @param defines defines the material defines to update
  101510. * @param useInstances specifies that instances should be used
  101511. * @param subMesh defines which submesh to render
  101512. */
  101513. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  101514. /**
  101515. * Lets the block try to connect some inputs automatically
  101516. * @param material defines the hosting NodeMaterial
  101517. */
  101518. autoConfigure(material: NodeMaterial): void;
  101519. /**
  101520. * Function called when a block is declared as repeatable content generator
  101521. * @param vertexShaderState defines the current compilation state for the vertex shader
  101522. * @param fragmentShaderState defines the current compilation state for the fragment shader
  101523. * @param mesh defines the mesh to be rendered
  101524. * @param defines defines the material defines to update
  101525. */
  101526. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  101527. /**
  101528. * Checks if the block is ready
  101529. * @param mesh defines the mesh to be rendered
  101530. * @param nodeMaterial defines the node material requesting the update
  101531. * @param defines defines the material defines to update
  101532. * @param useInstances specifies that instances should be used
  101533. * @returns true if the block is ready
  101534. */
  101535. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  101536. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  101537. private _processBuild;
  101538. /**
  101539. * Validates the new name for the block node.
  101540. * @param newName the new name to be given to the node.
  101541. * @returns false if the name is a reserve word, else true.
  101542. */
  101543. validateBlockName(newName: string): boolean;
  101544. /**
  101545. * Compile the current node and generate the shader code
  101546. * @param state defines the current compilation state (uniforms, samplers, current string)
  101547. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  101548. * @returns true if already built
  101549. */
  101550. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  101551. protected _inputRename(name: string): string;
  101552. protected _outputRename(name: string): string;
  101553. protected _dumpPropertiesCode(): string;
  101554. /** @hidden */
  101555. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  101556. /** @hidden */
  101557. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  101558. /**
  101559. * Clone the current block to a new identical block
  101560. * @param scene defines the hosting scene
  101561. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101562. * @returns a copy of the current block
  101563. */
  101564. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  101565. /**
  101566. * Serializes this block in a JSON representation
  101567. * @returns the serialized block object
  101568. */
  101569. serialize(): any;
  101570. /** @hidden */
  101571. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101572. private _deserializePortDisplayNamesAndExposedOnFrame;
  101573. /**
  101574. * Release resources
  101575. */
  101576. dispose(): void;
  101577. }
  101578. }
  101579. declare module BABYLON {
  101580. /**
  101581. * Base class of materials working in push mode in babylon JS
  101582. * @hidden
  101583. */
  101584. export class PushMaterial extends Material {
  101585. protected _activeEffect: Effect;
  101586. protected _normalMatrix: Matrix;
  101587. constructor(name: string, scene: Scene);
  101588. getEffect(): Effect;
  101589. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101590. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  101591. /**
  101592. * Binds the given world matrix to the active effect
  101593. *
  101594. * @param world the matrix to bind
  101595. */
  101596. bindOnlyWorldMatrix(world: Matrix): void;
  101597. /**
  101598. * Binds the given normal matrix to the active effect
  101599. *
  101600. * @param normalMatrix the matrix to bind
  101601. */
  101602. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  101603. bind(world: Matrix, mesh?: Mesh): void;
  101604. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  101605. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  101606. }
  101607. }
  101608. declare module BABYLON {
  101609. /**
  101610. * Root class for all node material optimizers
  101611. */
  101612. export class NodeMaterialOptimizer {
  101613. /**
  101614. * Function used to optimize a NodeMaterial graph
  101615. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  101616. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  101617. */
  101618. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  101619. }
  101620. }
  101621. declare module BABYLON {
  101622. /**
  101623. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  101624. */
  101625. export class TransformBlock extends NodeMaterialBlock {
  101626. /**
  101627. * Defines the value to use to complement W value to transform it to a Vector4
  101628. */
  101629. complementW: number;
  101630. /**
  101631. * Defines the value to use to complement z value to transform it to a Vector4
  101632. */
  101633. complementZ: number;
  101634. /**
  101635. * Creates a new TransformBlock
  101636. * @param name defines the block name
  101637. */
  101638. constructor(name: string);
  101639. /**
  101640. * Gets the current class name
  101641. * @returns the class name
  101642. */
  101643. getClassName(): string;
  101644. /**
  101645. * Gets the vector input
  101646. */
  101647. get vector(): NodeMaterialConnectionPoint;
  101648. /**
  101649. * Gets the output component
  101650. */
  101651. get output(): NodeMaterialConnectionPoint;
  101652. /**
  101653. * Gets the xyz output component
  101654. */
  101655. get xyz(): NodeMaterialConnectionPoint;
  101656. /**
  101657. * Gets the matrix transform input
  101658. */
  101659. get transform(): NodeMaterialConnectionPoint;
  101660. protected _buildBlock(state: NodeMaterialBuildState): this;
  101661. /**
  101662. * Update defines for shader compilation
  101663. * @param mesh defines the mesh to be rendered
  101664. * @param nodeMaterial defines the node material requesting the update
  101665. * @param defines defines the material defines to update
  101666. * @param useInstances specifies that instances should be used
  101667. * @param subMesh defines which submesh to render
  101668. */
  101669. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  101670. serialize(): any;
  101671. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101672. protected _dumpPropertiesCode(): string;
  101673. }
  101674. }
  101675. declare module BABYLON {
  101676. /**
  101677. * Block used to output the vertex position
  101678. */
  101679. export class VertexOutputBlock extends NodeMaterialBlock {
  101680. /**
  101681. * Creates a new VertexOutputBlock
  101682. * @param name defines the block name
  101683. */
  101684. constructor(name: string);
  101685. /**
  101686. * Gets the current class name
  101687. * @returns the class name
  101688. */
  101689. getClassName(): string;
  101690. /**
  101691. * Gets the vector input component
  101692. */
  101693. get vector(): NodeMaterialConnectionPoint;
  101694. protected _buildBlock(state: NodeMaterialBuildState): this;
  101695. }
  101696. }
  101697. declare module BABYLON {
  101698. /**
  101699. * Block used to output the final color
  101700. */
  101701. export class FragmentOutputBlock extends NodeMaterialBlock {
  101702. /**
  101703. * Create a new FragmentOutputBlock
  101704. * @param name defines the block name
  101705. */
  101706. constructor(name: string);
  101707. /**
  101708. * Gets the current class name
  101709. * @returns the class name
  101710. */
  101711. getClassName(): string;
  101712. /**
  101713. * Gets the rgba input component
  101714. */
  101715. get rgba(): NodeMaterialConnectionPoint;
  101716. /**
  101717. * Gets the rgb input component
  101718. */
  101719. get rgb(): NodeMaterialConnectionPoint;
  101720. /**
  101721. * Gets the a input component
  101722. */
  101723. get a(): NodeMaterialConnectionPoint;
  101724. protected _buildBlock(state: NodeMaterialBuildState): this;
  101725. }
  101726. }
  101727. declare module BABYLON {
  101728. /**
  101729. * Block used for the particle ramp gradient section
  101730. */
  101731. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  101732. /**
  101733. * Create a new ParticleRampGradientBlock
  101734. * @param name defines the block name
  101735. */
  101736. constructor(name: string);
  101737. /**
  101738. * Gets the current class name
  101739. * @returns the class name
  101740. */
  101741. getClassName(): string;
  101742. /**
  101743. * Gets the color input component
  101744. */
  101745. get color(): NodeMaterialConnectionPoint;
  101746. /**
  101747. * Gets the rampColor output component
  101748. */
  101749. get rampColor(): NodeMaterialConnectionPoint;
  101750. /**
  101751. * Initialize the block and prepare the context for build
  101752. * @param state defines the state that will be used for the build
  101753. */
  101754. initialize(state: NodeMaterialBuildState): void;
  101755. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101756. }
  101757. }
  101758. declare module BABYLON {
  101759. /**
  101760. * Block used for the particle blend multiply section
  101761. */
  101762. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  101763. /**
  101764. * Create a new ParticleBlendMultiplyBlock
  101765. * @param name defines the block name
  101766. */
  101767. constructor(name: string);
  101768. /**
  101769. * Gets the current class name
  101770. * @returns the class name
  101771. */
  101772. getClassName(): string;
  101773. /**
  101774. * Gets the color input component
  101775. */
  101776. get color(): NodeMaterialConnectionPoint;
  101777. /**
  101778. * Gets the alphaTexture input component
  101779. */
  101780. get alphaTexture(): NodeMaterialConnectionPoint;
  101781. /**
  101782. * Gets the alphaColor input component
  101783. */
  101784. get alphaColor(): NodeMaterialConnectionPoint;
  101785. /**
  101786. * Gets the blendColor output component
  101787. */
  101788. get blendColor(): NodeMaterialConnectionPoint;
  101789. /**
  101790. * Initialize the block and prepare the context for build
  101791. * @param state defines the state that will be used for the build
  101792. */
  101793. initialize(state: NodeMaterialBuildState): void;
  101794. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101795. }
  101796. }
  101797. declare module BABYLON {
  101798. /**
  101799. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  101800. */
  101801. export class VectorMergerBlock extends NodeMaterialBlock {
  101802. /**
  101803. * Create a new VectorMergerBlock
  101804. * @param name defines the block name
  101805. */
  101806. constructor(name: string);
  101807. /**
  101808. * Gets the current class name
  101809. * @returns the class name
  101810. */
  101811. getClassName(): string;
  101812. /**
  101813. * Gets the xyz component (input)
  101814. */
  101815. get xyzIn(): NodeMaterialConnectionPoint;
  101816. /**
  101817. * Gets the xy component (input)
  101818. */
  101819. get xyIn(): NodeMaterialConnectionPoint;
  101820. /**
  101821. * Gets the x component (input)
  101822. */
  101823. get x(): NodeMaterialConnectionPoint;
  101824. /**
  101825. * Gets the y component (input)
  101826. */
  101827. get y(): NodeMaterialConnectionPoint;
  101828. /**
  101829. * Gets the z component (input)
  101830. */
  101831. get z(): NodeMaterialConnectionPoint;
  101832. /**
  101833. * Gets the w component (input)
  101834. */
  101835. get w(): NodeMaterialConnectionPoint;
  101836. /**
  101837. * Gets the xyzw component (output)
  101838. */
  101839. get xyzw(): NodeMaterialConnectionPoint;
  101840. /**
  101841. * Gets the xyz component (output)
  101842. */
  101843. get xyzOut(): NodeMaterialConnectionPoint;
  101844. /**
  101845. * Gets the xy component (output)
  101846. */
  101847. get xyOut(): NodeMaterialConnectionPoint;
  101848. /**
  101849. * Gets the xy component (output)
  101850. * @deprecated Please use xyOut instead.
  101851. */
  101852. get xy(): NodeMaterialConnectionPoint;
  101853. /**
  101854. * Gets the xyz component (output)
  101855. * @deprecated Please use xyzOut instead.
  101856. */
  101857. get xyz(): NodeMaterialConnectionPoint;
  101858. protected _buildBlock(state: NodeMaterialBuildState): this;
  101859. }
  101860. }
  101861. declare module BABYLON {
  101862. /**
  101863. * Block used to remap a float from a range to a new one
  101864. */
  101865. export class RemapBlock extends NodeMaterialBlock {
  101866. /**
  101867. * Gets or sets the source range
  101868. */
  101869. sourceRange: Vector2;
  101870. /**
  101871. * Gets or sets the target range
  101872. */
  101873. targetRange: Vector2;
  101874. /**
  101875. * Creates a new RemapBlock
  101876. * @param name defines the block name
  101877. */
  101878. constructor(name: string);
  101879. /**
  101880. * Gets the current class name
  101881. * @returns the class name
  101882. */
  101883. getClassName(): string;
  101884. /**
  101885. * Gets the input component
  101886. */
  101887. get input(): NodeMaterialConnectionPoint;
  101888. /**
  101889. * Gets the source min input component
  101890. */
  101891. get sourceMin(): NodeMaterialConnectionPoint;
  101892. /**
  101893. * Gets the source max input component
  101894. */
  101895. get sourceMax(): NodeMaterialConnectionPoint;
  101896. /**
  101897. * Gets the target min input component
  101898. */
  101899. get targetMin(): NodeMaterialConnectionPoint;
  101900. /**
  101901. * Gets the target max input component
  101902. */
  101903. get targetMax(): NodeMaterialConnectionPoint;
  101904. /**
  101905. * Gets the output component
  101906. */
  101907. get output(): NodeMaterialConnectionPoint;
  101908. protected _buildBlock(state: NodeMaterialBuildState): this;
  101909. protected _dumpPropertiesCode(): string;
  101910. serialize(): any;
  101911. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101912. }
  101913. }
  101914. declare module BABYLON {
  101915. /**
  101916. * Block used to multiply 2 values
  101917. */
  101918. export class MultiplyBlock extends NodeMaterialBlock {
  101919. /**
  101920. * Creates a new MultiplyBlock
  101921. * @param name defines the block name
  101922. */
  101923. constructor(name: string);
  101924. /**
  101925. * Gets the current class name
  101926. * @returns the class name
  101927. */
  101928. getClassName(): string;
  101929. /**
  101930. * Gets the left operand input component
  101931. */
  101932. get left(): NodeMaterialConnectionPoint;
  101933. /**
  101934. * Gets the right operand input component
  101935. */
  101936. get right(): NodeMaterialConnectionPoint;
  101937. /**
  101938. * Gets the output component
  101939. */
  101940. get output(): NodeMaterialConnectionPoint;
  101941. protected _buildBlock(state: NodeMaterialBuildState): this;
  101942. }
  101943. }
  101944. declare module BABYLON {
  101945. /**
  101946. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  101947. */
  101948. export class ColorSplitterBlock extends NodeMaterialBlock {
  101949. /**
  101950. * Create a new ColorSplitterBlock
  101951. * @param name defines the block name
  101952. */
  101953. constructor(name: string);
  101954. /**
  101955. * Gets the current class name
  101956. * @returns the class name
  101957. */
  101958. getClassName(): string;
  101959. /**
  101960. * Gets the rgba component (input)
  101961. */
  101962. get rgba(): NodeMaterialConnectionPoint;
  101963. /**
  101964. * Gets the rgb component (input)
  101965. */
  101966. get rgbIn(): NodeMaterialConnectionPoint;
  101967. /**
  101968. * Gets the rgb component (output)
  101969. */
  101970. get rgbOut(): NodeMaterialConnectionPoint;
  101971. /**
  101972. * Gets the r component (output)
  101973. */
  101974. get r(): NodeMaterialConnectionPoint;
  101975. /**
  101976. * Gets the g component (output)
  101977. */
  101978. get g(): NodeMaterialConnectionPoint;
  101979. /**
  101980. * Gets the b component (output)
  101981. */
  101982. get b(): NodeMaterialConnectionPoint;
  101983. /**
  101984. * Gets the a component (output)
  101985. */
  101986. get a(): NodeMaterialConnectionPoint;
  101987. protected _inputRename(name: string): string;
  101988. protected _outputRename(name: string): string;
  101989. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101990. }
  101991. }
  101992. declare module BABYLON {
  101993. /**
  101994. * Interface used to configure the node material editor
  101995. */
  101996. export interface INodeMaterialEditorOptions {
  101997. /** Define the URl to load node editor script */
  101998. editorURL?: string;
  101999. }
  102000. /** @hidden */
  102001. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102002. NORMAL: boolean;
  102003. TANGENT: boolean;
  102004. UV1: boolean;
  102005. /** BONES */
  102006. NUM_BONE_INFLUENCERS: number;
  102007. BonesPerMesh: number;
  102008. BONETEXTURE: boolean;
  102009. /** MORPH TARGETS */
  102010. MORPHTARGETS: boolean;
  102011. MORPHTARGETS_NORMAL: boolean;
  102012. MORPHTARGETS_TANGENT: boolean;
  102013. MORPHTARGETS_UV: boolean;
  102014. NUM_MORPH_INFLUENCERS: number;
  102015. /** IMAGE PROCESSING */
  102016. IMAGEPROCESSING: boolean;
  102017. VIGNETTE: boolean;
  102018. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102019. VIGNETTEBLENDMODEOPAQUE: boolean;
  102020. TONEMAPPING: boolean;
  102021. TONEMAPPING_ACES: boolean;
  102022. CONTRAST: boolean;
  102023. EXPOSURE: boolean;
  102024. COLORCURVES: boolean;
  102025. COLORGRADING: boolean;
  102026. COLORGRADING3D: boolean;
  102027. SAMPLER3DGREENDEPTH: boolean;
  102028. SAMPLER3DBGRMAP: boolean;
  102029. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102030. /** MISC. */
  102031. BUMPDIRECTUV: number;
  102032. constructor();
  102033. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  102034. }
  102035. /**
  102036. * Class used to configure NodeMaterial
  102037. */
  102038. export interface INodeMaterialOptions {
  102039. /**
  102040. * Defines if blocks should emit comments
  102041. */
  102042. emitComments: boolean;
  102043. }
  102044. /**
  102045. * Class used to create a node based material built by assembling shader blocks
  102046. */
  102047. export class NodeMaterial extends PushMaterial {
  102048. private static _BuildIdGenerator;
  102049. private _options;
  102050. private _vertexCompilationState;
  102051. private _fragmentCompilationState;
  102052. private _sharedData;
  102053. private _buildId;
  102054. private _buildWasSuccessful;
  102055. private _cachedWorldViewMatrix;
  102056. private _cachedWorldViewProjectionMatrix;
  102057. private _optimizers;
  102058. private _animationFrame;
  102059. /** Define the Url to load node editor script */
  102060. static EditorURL: string;
  102061. /** Define the Url to load snippets */
  102062. static SnippetUrl: string;
  102063. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  102064. static IgnoreTexturesAtLoadTime: boolean;
  102065. private BJSNODEMATERIALEDITOR;
  102066. /** Get the inspector from bundle or global */
  102067. private _getGlobalNodeMaterialEditor;
  102068. /**
  102069. * Snippet ID if the material was created from the snippet server
  102070. */
  102071. snippetId: string;
  102072. /**
  102073. * Gets or sets data used by visual editor
  102074. * @see https://nme.babylonjs.com
  102075. */
  102076. editorData: any;
  102077. /**
  102078. * 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)
  102079. */
  102080. ignoreAlpha: boolean;
  102081. /**
  102082. * Defines the maximum number of lights that can be used in the material
  102083. */
  102084. maxSimultaneousLights: number;
  102085. /**
  102086. * Observable raised when the material is built
  102087. */
  102088. onBuildObservable: Observable<NodeMaterial>;
  102089. /**
  102090. * Gets or sets the root nodes of the material vertex shader
  102091. */
  102092. _vertexOutputNodes: NodeMaterialBlock[];
  102093. /**
  102094. * Gets or sets the root nodes of the material fragment (pixel) shader
  102095. */
  102096. _fragmentOutputNodes: NodeMaterialBlock[];
  102097. /** Gets or sets options to control the node material overall behavior */
  102098. get options(): INodeMaterialOptions;
  102099. set options(options: INodeMaterialOptions);
  102100. /**
  102101. * Default configuration related to image processing available in the standard Material.
  102102. */
  102103. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102104. /**
  102105. * Gets the image processing configuration used either in this material.
  102106. */
  102107. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  102108. /**
  102109. * Sets the Default image processing configuration used either in the this material.
  102110. *
  102111. * If sets to null, the scene one is in use.
  102112. */
  102113. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  102114. /**
  102115. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  102116. */
  102117. attachedBlocks: NodeMaterialBlock[];
  102118. /**
  102119. * Specifies the mode of the node material
  102120. * @hidden
  102121. */
  102122. _mode: NodeMaterialModes;
  102123. /**
  102124. * Gets the mode property
  102125. */
  102126. get mode(): NodeMaterialModes;
  102127. /**
  102128. * Create a new node based material
  102129. * @param name defines the material name
  102130. * @param scene defines the hosting scene
  102131. * @param options defines creation option
  102132. */
  102133. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  102134. /**
  102135. * Gets the current class name of the material e.g. "NodeMaterial"
  102136. * @returns the class name
  102137. */
  102138. getClassName(): string;
  102139. /**
  102140. * Keep track of the image processing observer to allow dispose and replace.
  102141. */
  102142. private _imageProcessingObserver;
  102143. /**
  102144. * Attaches a new image processing configuration to the Standard Material.
  102145. * @param configuration
  102146. */
  102147. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102148. /**
  102149. * Get a block by its name
  102150. * @param name defines the name of the block to retrieve
  102151. * @returns the required block or null if not found
  102152. */
  102153. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  102154. /**
  102155. * Get a block by its name
  102156. * @param predicate defines the predicate used to find the good candidate
  102157. * @returns the required block or null if not found
  102158. */
  102159. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  102160. /**
  102161. * Get an input block by its name
  102162. * @param predicate defines the predicate used to find the good candidate
  102163. * @returns the required input block or null if not found
  102164. */
  102165. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  102166. /**
  102167. * Gets the list of input blocks attached to this material
  102168. * @returns an array of InputBlocks
  102169. */
  102170. getInputBlocks(): InputBlock[];
  102171. /**
  102172. * Adds a new optimizer to the list of optimizers
  102173. * @param optimizer defines the optimizers to add
  102174. * @returns the current material
  102175. */
  102176. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102177. /**
  102178. * Remove an optimizer from the list of optimizers
  102179. * @param optimizer defines the optimizers to remove
  102180. * @returns the current material
  102181. */
  102182. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102183. /**
  102184. * Add a new block to the list of output nodes
  102185. * @param node defines the node to add
  102186. * @returns the current material
  102187. */
  102188. addOutputNode(node: NodeMaterialBlock): this;
  102189. /**
  102190. * Remove a block from the list of root nodes
  102191. * @param node defines the node to remove
  102192. * @returns the current material
  102193. */
  102194. removeOutputNode(node: NodeMaterialBlock): this;
  102195. private _addVertexOutputNode;
  102196. private _removeVertexOutputNode;
  102197. private _addFragmentOutputNode;
  102198. private _removeFragmentOutputNode;
  102199. /**
  102200. * Specifies if the material will require alpha blending
  102201. * @returns a boolean specifying if alpha blending is needed
  102202. */
  102203. needAlphaBlending(): boolean;
  102204. /**
  102205. * Specifies if this material should be rendered in alpha test mode
  102206. * @returns a boolean specifying if an alpha test is needed.
  102207. */
  102208. needAlphaTesting(): boolean;
  102209. private _initializeBlock;
  102210. private _resetDualBlocks;
  102211. /**
  102212. * Remove a block from the current node material
  102213. * @param block defines the block to remove
  102214. */
  102215. removeBlock(block: NodeMaterialBlock): void;
  102216. /**
  102217. * Build the material and generates the inner effect
  102218. * @param verbose defines if the build should log activity
  102219. */
  102220. build(verbose?: boolean): void;
  102221. /**
  102222. * Runs an otpimization phase to try to improve the shader code
  102223. */
  102224. optimize(): void;
  102225. private _prepareDefinesForAttributes;
  102226. /**
  102227. * Create a post process from the material
  102228. * @param camera The camera to apply the render pass to.
  102229. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102230. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102231. * @param engine The engine which the post process will be applied. (default: current engine)
  102232. * @param reusable If the post process can be reused on the same frame. (default: false)
  102233. * @param textureType Type of textures used when performing the post process. (default: 0)
  102234. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  102235. * @returns the post process created
  102236. */
  102237. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  102238. /**
  102239. * Create the post process effect from the material
  102240. * @param postProcess The post process to create the effect for
  102241. */
  102242. createEffectForPostProcess(postProcess: PostProcess): void;
  102243. private _createEffectOrPostProcess;
  102244. private _createEffectForParticles;
  102245. /**
  102246. * Create the effect to be used as the custom effect for a particle system
  102247. * @param particleSystem Particle system to create the effect for
  102248. * @param onCompiled defines a function to call when the effect creation is successful
  102249. * @param onError defines a function to call when the effect creation has failed
  102250. */
  102251. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102252. private _processDefines;
  102253. /**
  102254. * Get if the submesh is ready to be used and all its information available.
  102255. * Child classes can use it to update shaders
  102256. * @param mesh defines the mesh to check
  102257. * @param subMesh defines which submesh to check
  102258. * @param useInstances specifies that instances should be used
  102259. * @returns a boolean indicating that the submesh is ready or not
  102260. */
  102261. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102262. /**
  102263. * Get a string representing the shaders built by the current node graph
  102264. */
  102265. get compiledShaders(): string;
  102266. /**
  102267. * Binds the world matrix to the material
  102268. * @param world defines the world transformation matrix
  102269. */
  102270. bindOnlyWorldMatrix(world: Matrix): void;
  102271. /**
  102272. * Binds the submesh to this material by preparing the effect and shader to draw
  102273. * @param world defines the world transformation matrix
  102274. * @param mesh defines the mesh containing the submesh
  102275. * @param subMesh defines the submesh to bind the material to
  102276. */
  102277. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102278. /**
  102279. * Gets the active textures from the material
  102280. * @returns an array of textures
  102281. */
  102282. getActiveTextures(): BaseTexture[];
  102283. /**
  102284. * Gets the list of texture blocks
  102285. * @returns an array of texture blocks
  102286. */
  102287. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  102288. /**
  102289. * Specifies if the material uses a texture
  102290. * @param texture defines the texture to check against the material
  102291. * @returns a boolean specifying if the material uses the texture
  102292. */
  102293. hasTexture(texture: BaseTexture): boolean;
  102294. /**
  102295. * Disposes the material
  102296. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102297. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102298. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  102299. */
  102300. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  102301. /** Creates the node editor window. */
  102302. private _createNodeEditor;
  102303. /**
  102304. * Launch the node material editor
  102305. * @param config Define the configuration of the editor
  102306. * @return a promise fulfilled when the node editor is visible
  102307. */
  102308. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  102309. /**
  102310. * Clear the current material
  102311. */
  102312. clear(): void;
  102313. /**
  102314. * Clear the current material and set it to a default state
  102315. */
  102316. setToDefault(): void;
  102317. /**
  102318. * Clear the current material and set it to a default state for post process
  102319. */
  102320. setToDefaultPostProcess(): void;
  102321. /**
  102322. * Clear the current material and set it to a default state for particle
  102323. */
  102324. setToDefaultParticle(): void;
  102325. /**
  102326. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  102327. * @param url defines the url to load from
  102328. * @returns a promise that will fullfil when the material is fully loaded
  102329. */
  102330. loadAsync(url: string): Promise<void>;
  102331. private _gatherBlocks;
  102332. /**
  102333. * Generate a string containing the code declaration required to create an equivalent of this material
  102334. * @returns a string
  102335. */
  102336. generateCode(): string;
  102337. /**
  102338. * Serializes this material in a JSON representation
  102339. * @returns the serialized material object
  102340. */
  102341. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  102342. private _restoreConnections;
  102343. /**
  102344. * Clear the current graph and load a new one from a serialization object
  102345. * @param source defines the JSON representation of the material
  102346. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102347. * @param merge defines whether or not the source must be merged or replace the current content
  102348. */
  102349. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  102350. /**
  102351. * Makes a duplicate of the current material.
  102352. * @param name - name to use for the new material.
  102353. */
  102354. clone(name: string): NodeMaterial;
  102355. /**
  102356. * Creates a node material from parsed material data
  102357. * @param source defines the JSON representation of the material
  102358. * @param scene defines the hosting scene
  102359. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102360. * @returns a new node material
  102361. */
  102362. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  102363. /**
  102364. * Creates a node material from a snippet saved in a remote file
  102365. * @param name defines the name of the material to create
  102366. * @param url defines the url to load from
  102367. * @param scene defines the hosting scene
  102368. * @returns a promise that will resolve to the new node material
  102369. */
  102370. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  102371. /**
  102372. * Creates a node material from a snippet saved by the node material editor
  102373. * @param snippetId defines the snippet to load
  102374. * @param scene defines the hosting scene
  102375. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102376. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  102377. * @returns a promise that will resolve to the new node material
  102378. */
  102379. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  102380. /**
  102381. * Creates a new node material set to default basic configuration
  102382. * @param name defines the name of the material
  102383. * @param scene defines the hosting scene
  102384. * @returns a new NodeMaterial
  102385. */
  102386. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  102387. }
  102388. }
  102389. declare module BABYLON {
  102390. /**
  102391. * Size options for a post process
  102392. */
  102393. export type PostProcessOptions = {
  102394. width: number;
  102395. height: number;
  102396. };
  102397. /**
  102398. * PostProcess can be used to apply a shader to a texture after it has been rendered
  102399. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  102400. */
  102401. export class PostProcess {
  102402. /**
  102403. * Gets or sets the unique id of the post process
  102404. */
  102405. uniqueId: number;
  102406. /** Name of the PostProcess. */
  102407. name: string;
  102408. /**
  102409. * Width of the texture to apply the post process on
  102410. */
  102411. width: number;
  102412. /**
  102413. * Height of the texture to apply the post process on
  102414. */
  102415. height: number;
  102416. /**
  102417. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  102418. */
  102419. nodeMaterialSource: Nullable<NodeMaterial>;
  102420. /**
  102421. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  102422. * @hidden
  102423. */
  102424. _outputTexture: Nullable<InternalTexture>;
  102425. /**
  102426. * Sampling mode used by the shader
  102427. * See https://doc.babylonjs.com/classes/3.1/texture
  102428. */
  102429. renderTargetSamplingMode: number;
  102430. /**
  102431. * Clear color to use when screen clearing
  102432. */
  102433. clearColor: Color4;
  102434. /**
  102435. * If the buffer needs to be cleared before applying the post process. (default: true)
  102436. * Should be set to false if shader will overwrite all previous pixels.
  102437. */
  102438. autoClear: boolean;
  102439. /**
  102440. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  102441. */
  102442. alphaMode: number;
  102443. /**
  102444. * Sets the setAlphaBlendConstants of the babylon engine
  102445. */
  102446. alphaConstants: Color4;
  102447. /**
  102448. * Animations to be used for the post processing
  102449. */
  102450. animations: Animation[];
  102451. /**
  102452. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  102453. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  102454. */
  102455. enablePixelPerfectMode: boolean;
  102456. /**
  102457. * Force the postprocess to be applied without taking in account viewport
  102458. */
  102459. forceFullscreenViewport: boolean;
  102460. /**
  102461. * List of inspectable custom properties (used by the Inspector)
  102462. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102463. */
  102464. inspectableCustomProperties: IInspectable[];
  102465. /**
  102466. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  102467. *
  102468. * | Value | Type | Description |
  102469. * | ----- | ----------------------------------- | ----------- |
  102470. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  102471. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  102472. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  102473. *
  102474. */
  102475. scaleMode: number;
  102476. /**
  102477. * Force textures to be a power of two (default: false)
  102478. */
  102479. alwaysForcePOT: boolean;
  102480. private _samples;
  102481. /**
  102482. * Number of sample textures (default: 1)
  102483. */
  102484. get samples(): number;
  102485. set samples(n: number);
  102486. /**
  102487. * Modify the scale of the post process to be the same as the viewport (default: false)
  102488. */
  102489. adaptScaleToCurrentViewport: boolean;
  102490. private _camera;
  102491. protected _scene: Scene;
  102492. private _engine;
  102493. private _options;
  102494. private _reusable;
  102495. private _textureType;
  102496. private _textureFormat;
  102497. /**
  102498. * Smart array of input and output textures for the post process.
  102499. * @hidden
  102500. */
  102501. _textures: SmartArray<InternalTexture>;
  102502. /**
  102503. * The index in _textures that corresponds to the output texture.
  102504. * @hidden
  102505. */
  102506. _currentRenderTextureInd: number;
  102507. private _effect;
  102508. private _samplers;
  102509. private _fragmentUrl;
  102510. private _vertexUrl;
  102511. private _parameters;
  102512. private _scaleRatio;
  102513. protected _indexParameters: any;
  102514. private _shareOutputWithPostProcess;
  102515. private _texelSize;
  102516. private _forcedOutputTexture;
  102517. /**
  102518. * Returns the fragment url or shader name used in the post process.
  102519. * @returns the fragment url or name in the shader store.
  102520. */
  102521. getEffectName(): string;
  102522. /**
  102523. * An event triggered when the postprocess is activated.
  102524. */
  102525. onActivateObservable: Observable<Camera>;
  102526. private _onActivateObserver;
  102527. /**
  102528. * A function that is added to the onActivateObservable
  102529. */
  102530. set onActivate(callback: Nullable<(camera: Camera) => void>);
  102531. /**
  102532. * An event triggered when the postprocess changes its size.
  102533. */
  102534. onSizeChangedObservable: Observable<PostProcess>;
  102535. private _onSizeChangedObserver;
  102536. /**
  102537. * A function that is added to the onSizeChangedObservable
  102538. */
  102539. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  102540. /**
  102541. * An event triggered when the postprocess applies its effect.
  102542. */
  102543. onApplyObservable: Observable<Effect>;
  102544. private _onApplyObserver;
  102545. /**
  102546. * A function that is added to the onApplyObservable
  102547. */
  102548. set onApply(callback: (effect: Effect) => void);
  102549. /**
  102550. * An event triggered before rendering the postprocess
  102551. */
  102552. onBeforeRenderObservable: Observable<Effect>;
  102553. private _onBeforeRenderObserver;
  102554. /**
  102555. * A function that is added to the onBeforeRenderObservable
  102556. */
  102557. set onBeforeRender(callback: (effect: Effect) => void);
  102558. /**
  102559. * An event triggered after rendering the postprocess
  102560. */
  102561. onAfterRenderObservable: Observable<Effect>;
  102562. private _onAfterRenderObserver;
  102563. /**
  102564. * A function that is added to the onAfterRenderObservable
  102565. */
  102566. set onAfterRender(callback: (efect: Effect) => void);
  102567. /**
  102568. * 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
  102569. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  102570. */
  102571. get inputTexture(): InternalTexture;
  102572. set inputTexture(value: InternalTexture);
  102573. /**
  102574. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  102575. * the only way to unset it is to use this function to restore its internal state
  102576. */
  102577. restoreDefaultInputTexture(): void;
  102578. /**
  102579. * Gets the camera which post process is applied to.
  102580. * @returns The camera the post process is applied to.
  102581. */
  102582. getCamera(): Camera;
  102583. /**
  102584. * Gets the texel size of the postprocess.
  102585. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  102586. */
  102587. get texelSize(): Vector2;
  102588. /**
  102589. * Creates a new instance PostProcess
  102590. * @param name The name of the PostProcess.
  102591. * @param fragmentUrl The url of the fragment shader to be used.
  102592. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  102593. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  102594. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102595. * @param camera The camera to apply the render pass to.
  102596. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102597. * @param engine The engine which the post process will be applied. (default: current engine)
  102598. * @param reusable If the post process can be reused on the same frame. (default: false)
  102599. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  102600. * @param textureType Type of textures used when performing the post process. (default: 0)
  102601. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  102602. * @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
  102603. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  102604. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  102605. */
  102606. 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);
  102607. /**
  102608. * Gets a string identifying the name of the class
  102609. * @returns "PostProcess" string
  102610. */
  102611. getClassName(): string;
  102612. /**
  102613. * Gets the engine which this post process belongs to.
  102614. * @returns The engine the post process was enabled with.
  102615. */
  102616. getEngine(): Engine;
  102617. /**
  102618. * The effect that is created when initializing the post process.
  102619. * @returns The created effect corresponding the the postprocess.
  102620. */
  102621. getEffect(): Effect;
  102622. /**
  102623. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  102624. * @param postProcess The post process to share the output with.
  102625. * @returns This post process.
  102626. */
  102627. shareOutputWith(postProcess: PostProcess): PostProcess;
  102628. /**
  102629. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  102630. * This should be called if the post process that shares output with this post process is disabled/disposed.
  102631. */
  102632. useOwnOutput(): void;
  102633. /**
  102634. * Updates the effect with the current post process compile time values and recompiles the shader.
  102635. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  102636. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  102637. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  102638. * @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
  102639. * @param onCompiled Called when the shader has been compiled.
  102640. * @param onError Called if there is an error when compiling a shader.
  102641. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  102642. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  102643. */
  102644. 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;
  102645. /**
  102646. * The post process is reusable if it can be used multiple times within one frame.
  102647. * @returns If the post process is reusable
  102648. */
  102649. isReusable(): boolean;
  102650. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  102651. markTextureDirty(): void;
  102652. /**
  102653. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  102654. * 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.
  102655. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  102656. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  102657. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  102658. * @returns The target texture that was bound to be written to.
  102659. */
  102660. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  102661. /**
  102662. * If the post process is supported.
  102663. */
  102664. get isSupported(): boolean;
  102665. /**
  102666. * The aspect ratio of the output texture.
  102667. */
  102668. get aspectRatio(): number;
  102669. /**
  102670. * Get a value indicating if the post-process is ready to be used
  102671. * @returns true if the post-process is ready (shader is compiled)
  102672. */
  102673. isReady(): boolean;
  102674. /**
  102675. * Binds all textures and uniforms to the shader, this will be run on every pass.
  102676. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  102677. */
  102678. apply(): Nullable<Effect>;
  102679. private _disposeTextures;
  102680. /**
  102681. * Disposes the post process.
  102682. * @param camera The camera to dispose the post process on.
  102683. */
  102684. dispose(camera?: Camera): void;
  102685. /**
  102686. * Serializes the particle system to a JSON object
  102687. * @returns the JSON object
  102688. */
  102689. serialize(): any;
  102690. /**
  102691. * Creates a material from parsed material data
  102692. * @param parsedPostProcess defines parsed post process data
  102693. * @param scene defines the hosting scene
  102694. * @param rootUrl defines the root URL to use to load textures
  102695. * @returns a new post process
  102696. */
  102697. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  102698. }
  102699. }
  102700. declare module BABYLON {
  102701. /** @hidden */
  102702. export var kernelBlurVaryingDeclaration: {
  102703. name: string;
  102704. shader: string;
  102705. };
  102706. }
  102707. declare module BABYLON {
  102708. /** @hidden */
  102709. export var kernelBlurFragment: {
  102710. name: string;
  102711. shader: string;
  102712. };
  102713. }
  102714. declare module BABYLON {
  102715. /** @hidden */
  102716. export var kernelBlurFragment2: {
  102717. name: string;
  102718. shader: string;
  102719. };
  102720. }
  102721. declare module BABYLON {
  102722. /** @hidden */
  102723. export var kernelBlurPixelShader: {
  102724. name: string;
  102725. shader: string;
  102726. };
  102727. }
  102728. declare module BABYLON {
  102729. /** @hidden */
  102730. export var kernelBlurVertex: {
  102731. name: string;
  102732. shader: string;
  102733. };
  102734. }
  102735. declare module BABYLON {
  102736. /** @hidden */
  102737. export var kernelBlurVertexShader: {
  102738. name: string;
  102739. shader: string;
  102740. };
  102741. }
  102742. declare module BABYLON {
  102743. /**
  102744. * The Blur Post Process which blurs an image based on a kernel and direction.
  102745. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  102746. */
  102747. export class BlurPostProcess extends PostProcess {
  102748. private blockCompilation;
  102749. protected _kernel: number;
  102750. protected _idealKernel: number;
  102751. protected _packedFloat: boolean;
  102752. private _staticDefines;
  102753. /** The direction in which to blur the image. */
  102754. direction: Vector2;
  102755. /**
  102756. * Sets the length in pixels of the blur sample region
  102757. */
  102758. set kernel(v: number);
  102759. /**
  102760. * Gets the length in pixels of the blur sample region
  102761. */
  102762. get kernel(): number;
  102763. /**
  102764. * Sets wether or not the blur needs to unpack/repack floats
  102765. */
  102766. set packedFloat(v: boolean);
  102767. /**
  102768. * Gets wether or not the blur is unpacking/repacking floats
  102769. */
  102770. get packedFloat(): boolean;
  102771. /**
  102772. * Gets a string identifying the name of the class
  102773. * @returns "BlurPostProcess" string
  102774. */
  102775. getClassName(): string;
  102776. /**
  102777. * Creates a new instance BlurPostProcess
  102778. * @param name The name of the effect.
  102779. * @param direction The direction in which to blur the image.
  102780. * @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.
  102781. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102782. * @param camera The camera to apply the render pass to.
  102783. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102784. * @param engine The engine which the post process will be applied. (default: current engine)
  102785. * @param reusable If the post process can be reused on the same frame. (default: false)
  102786. * @param textureType Type of textures used when performing the post process. (default: 0)
  102787. * @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)
  102788. */
  102789. 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);
  102790. /**
  102791. * Updates the effect with the current post process compile time values and recompiles the shader.
  102792. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  102793. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  102794. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  102795. * @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
  102796. * @param onCompiled Called when the shader has been compiled.
  102797. * @param onError Called if there is an error when compiling a shader.
  102798. */
  102799. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102800. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102801. /**
  102802. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  102803. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  102804. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  102805. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  102806. * The gaps between physical kernels are compensated for in the weighting of the samples
  102807. * @param idealKernel Ideal blur kernel.
  102808. * @return Nearest best kernel.
  102809. */
  102810. protected _nearestBestKernel(idealKernel: number): number;
  102811. /**
  102812. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  102813. * @param x The point on the Gaussian distribution to sample.
  102814. * @return the value of the Gaussian function at x.
  102815. */
  102816. protected _gaussianWeight(x: number): number;
  102817. /**
  102818. * Generates a string that can be used as a floating point number in GLSL.
  102819. * @param x Value to print.
  102820. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  102821. * @return GLSL float string.
  102822. */
  102823. protected _glslFloat(x: number, decimalFigures?: number): string;
  102824. /** @hidden */
  102825. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  102826. }
  102827. }
  102828. declare module BABYLON {
  102829. /**
  102830. * Mirror texture can be used to simulate the view from a mirror in a scene.
  102831. * It will dynamically be rendered every frame to adapt to the camera point of view.
  102832. * You can then easily use it as a reflectionTexture on a flat surface.
  102833. * In case the surface is not a plane, please consider relying on reflection probes.
  102834. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  102835. */
  102836. export class MirrorTexture extends RenderTargetTexture {
  102837. private scene;
  102838. /**
  102839. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  102840. * 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.
  102841. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  102842. */
  102843. mirrorPlane: Plane;
  102844. /**
  102845. * Define the blur ratio used to blur the reflection if needed.
  102846. */
  102847. set blurRatio(value: number);
  102848. get blurRatio(): number;
  102849. /**
  102850. * Define the adaptive blur kernel used to blur the reflection if needed.
  102851. * This will autocompute the closest best match for the `blurKernel`
  102852. */
  102853. set adaptiveBlurKernel(value: number);
  102854. /**
  102855. * Define the blur kernel used to blur the reflection if needed.
  102856. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  102857. */
  102858. set blurKernel(value: number);
  102859. /**
  102860. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  102861. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  102862. */
  102863. set blurKernelX(value: number);
  102864. get blurKernelX(): number;
  102865. /**
  102866. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  102867. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  102868. */
  102869. set blurKernelY(value: number);
  102870. get blurKernelY(): number;
  102871. private _autoComputeBlurKernel;
  102872. protected _onRatioRescale(): void;
  102873. private _updateGammaSpace;
  102874. private _imageProcessingConfigChangeObserver;
  102875. private _transformMatrix;
  102876. private _mirrorMatrix;
  102877. private _savedViewMatrix;
  102878. private _blurX;
  102879. private _blurY;
  102880. private _adaptiveBlurKernel;
  102881. private _blurKernelX;
  102882. private _blurKernelY;
  102883. private _blurRatio;
  102884. /**
  102885. * Instantiates a Mirror Texture.
  102886. * Mirror texture can be used to simulate the view from a mirror in a scene.
  102887. * It will dynamically be rendered every frame to adapt to the camera point of view.
  102888. * You can then easily use it as a reflectionTexture on a flat surface.
  102889. * In case the surface is not a plane, please consider relying on reflection probes.
  102890. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  102891. * @param name
  102892. * @param size
  102893. * @param scene
  102894. * @param generateMipMaps
  102895. * @param type
  102896. * @param samplingMode
  102897. * @param generateDepthBuffer
  102898. */
  102899. constructor(name: string, size: number | {
  102900. width: number;
  102901. height: number;
  102902. } | {
  102903. ratio: number;
  102904. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  102905. private _preparePostProcesses;
  102906. /**
  102907. * Clone the mirror texture.
  102908. * @returns the cloned texture
  102909. */
  102910. clone(): MirrorTexture;
  102911. /**
  102912. * Serialize the texture to a JSON representation you could use in Parse later on
  102913. * @returns the serialized JSON representation
  102914. */
  102915. serialize(): any;
  102916. /**
  102917. * Dispose the texture and release its associated resources.
  102918. */
  102919. dispose(): void;
  102920. }
  102921. }
  102922. declare module BABYLON {
  102923. /**
  102924. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  102925. * @see https://doc.babylonjs.com/babylon101/materials#texture
  102926. */
  102927. export class Texture extends BaseTexture {
  102928. /**
  102929. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  102930. */
  102931. static SerializeBuffers: boolean;
  102932. /** @hidden */
  102933. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  102934. /** @hidden */
  102935. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  102936. /** @hidden */
  102937. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  102938. /** nearest is mag = nearest and min = nearest and mip = linear */
  102939. static readonly NEAREST_SAMPLINGMODE: number;
  102940. /** nearest is mag = nearest and min = nearest and mip = linear */
  102941. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  102942. /** Bilinear is mag = linear and min = linear and mip = nearest */
  102943. static readonly BILINEAR_SAMPLINGMODE: number;
  102944. /** Bilinear is mag = linear and min = linear and mip = nearest */
  102945. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  102946. /** Trilinear is mag = linear and min = linear and mip = linear */
  102947. static readonly TRILINEAR_SAMPLINGMODE: number;
  102948. /** Trilinear is mag = linear and min = linear and mip = linear */
  102949. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  102950. /** mag = nearest and min = nearest and mip = nearest */
  102951. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  102952. /** mag = nearest and min = linear and mip = nearest */
  102953. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  102954. /** mag = nearest and min = linear and mip = linear */
  102955. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  102956. /** mag = nearest and min = linear and mip = none */
  102957. static readonly NEAREST_LINEAR: number;
  102958. /** mag = nearest and min = nearest and mip = none */
  102959. static readonly NEAREST_NEAREST: number;
  102960. /** mag = linear and min = nearest and mip = nearest */
  102961. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  102962. /** mag = linear and min = nearest and mip = linear */
  102963. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  102964. /** mag = linear and min = linear and mip = none */
  102965. static readonly LINEAR_LINEAR: number;
  102966. /** mag = linear and min = nearest and mip = none */
  102967. static readonly LINEAR_NEAREST: number;
  102968. /** Explicit coordinates mode */
  102969. static readonly EXPLICIT_MODE: number;
  102970. /** Spherical coordinates mode */
  102971. static readonly SPHERICAL_MODE: number;
  102972. /** Planar coordinates mode */
  102973. static readonly PLANAR_MODE: number;
  102974. /** Cubic coordinates mode */
  102975. static readonly CUBIC_MODE: number;
  102976. /** Projection coordinates mode */
  102977. static readonly PROJECTION_MODE: number;
  102978. /** Inverse Cubic coordinates mode */
  102979. static readonly SKYBOX_MODE: number;
  102980. /** Inverse Cubic coordinates mode */
  102981. static readonly INVCUBIC_MODE: number;
  102982. /** Equirectangular coordinates mode */
  102983. static readonly EQUIRECTANGULAR_MODE: number;
  102984. /** Equirectangular Fixed coordinates mode */
  102985. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  102986. /** Equirectangular Fixed Mirrored coordinates mode */
  102987. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  102988. /** Texture is not repeating outside of 0..1 UVs */
  102989. static readonly CLAMP_ADDRESSMODE: number;
  102990. /** Texture is repeating outside of 0..1 UVs */
  102991. static readonly WRAP_ADDRESSMODE: number;
  102992. /** Texture is repeating and mirrored */
  102993. static readonly MIRROR_ADDRESSMODE: number;
  102994. /**
  102995. * 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
  102996. */
  102997. static UseSerializedUrlIfAny: boolean;
  102998. /**
  102999. * Define the url of the texture.
  103000. */
  103001. url: Nullable<string>;
  103002. /**
  103003. * Define an offset on the texture to offset the u coordinates of the UVs
  103004. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  103005. */
  103006. uOffset: number;
  103007. /**
  103008. * Define an offset on the texture to offset the v coordinates of the UVs
  103009. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  103010. */
  103011. vOffset: number;
  103012. /**
  103013. * Define an offset on the texture to scale the u coordinates of the UVs
  103014. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  103015. */
  103016. uScale: number;
  103017. /**
  103018. * Define an offset on the texture to scale the v coordinates of the UVs
  103019. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  103020. */
  103021. vScale: number;
  103022. /**
  103023. * Define an offset on the texture to rotate around the u coordinates of the UVs
  103024. * @see https://doc.babylonjs.com/how_to/more_materials
  103025. */
  103026. uAng: number;
  103027. /**
  103028. * Define an offset on the texture to rotate around the v coordinates of the UVs
  103029. * @see https://doc.babylonjs.com/how_to/more_materials
  103030. */
  103031. vAng: number;
  103032. /**
  103033. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  103034. * @see https://doc.babylonjs.com/how_to/more_materials
  103035. */
  103036. wAng: number;
  103037. /**
  103038. * Defines the center of rotation (U)
  103039. */
  103040. uRotationCenter: number;
  103041. /**
  103042. * Defines the center of rotation (V)
  103043. */
  103044. vRotationCenter: number;
  103045. /**
  103046. * Defines the center of rotation (W)
  103047. */
  103048. wRotationCenter: number;
  103049. /**
  103050. * Are mip maps generated for this texture or not.
  103051. */
  103052. get noMipmap(): boolean;
  103053. /**
  103054. * List of inspectable custom properties (used by the Inspector)
  103055. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103056. */
  103057. inspectableCustomProperties: Nullable<IInspectable[]>;
  103058. private _noMipmap;
  103059. /** @hidden */
  103060. _invertY: boolean;
  103061. private _rowGenerationMatrix;
  103062. private _cachedTextureMatrix;
  103063. private _projectionModeMatrix;
  103064. private _t0;
  103065. private _t1;
  103066. private _t2;
  103067. private _cachedUOffset;
  103068. private _cachedVOffset;
  103069. private _cachedUScale;
  103070. private _cachedVScale;
  103071. private _cachedUAng;
  103072. private _cachedVAng;
  103073. private _cachedWAng;
  103074. private _cachedProjectionMatrixId;
  103075. private _cachedCoordinatesMode;
  103076. /** @hidden */
  103077. protected _initialSamplingMode: number;
  103078. /** @hidden */
  103079. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  103080. private _deleteBuffer;
  103081. protected _format: Nullable<number>;
  103082. private _delayedOnLoad;
  103083. private _delayedOnError;
  103084. private _mimeType?;
  103085. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  103086. get mimeType(): string | undefined;
  103087. /**
  103088. * Observable triggered once the texture has been loaded.
  103089. */
  103090. onLoadObservable: Observable<Texture>;
  103091. protected _isBlocking: boolean;
  103092. /**
  103093. * Is the texture preventing material to render while loading.
  103094. * If false, a default texture will be used instead of the loading one during the preparation step.
  103095. */
  103096. set isBlocking(value: boolean);
  103097. get isBlocking(): boolean;
  103098. /**
  103099. * Get the current sampling mode associated with the texture.
  103100. */
  103101. get samplingMode(): number;
  103102. /**
  103103. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  103104. */
  103105. get invertY(): boolean;
  103106. /**
  103107. * Instantiates a new texture.
  103108. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  103109. * @see https://doc.babylonjs.com/babylon101/materials#texture
  103110. * @param url defines the url of the picture to load as a texture
  103111. * @param sceneOrEngine defines the scene or engine the texture will belong to
  103112. * @param noMipmap defines if the texture will require mip maps or not
  103113. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  103114. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103115. * @param onLoad defines a callback triggered when the texture has been loaded
  103116. * @param onError defines a callback triggered when an error occurred during the loading session
  103117. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  103118. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  103119. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103120. * @param mimeType defines an optional mime type information
  103121. */
  103122. 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);
  103123. /**
  103124. * Update the url (and optional buffer) of this texture if url was null during construction.
  103125. * @param url the url of the texture
  103126. * @param buffer the buffer of the texture (defaults to null)
  103127. * @param onLoad callback called when the texture is loaded (defaults to null)
  103128. */
  103129. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  103130. /**
  103131. * Finish the loading sequence of a texture flagged as delayed load.
  103132. * @hidden
  103133. */
  103134. delayLoad(): void;
  103135. private _prepareRowForTextureGeneration;
  103136. /**
  103137. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  103138. * @returns the transform matrix of the texture.
  103139. */
  103140. getTextureMatrix(uBase?: number): Matrix;
  103141. /**
  103142. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  103143. * @returns The reflection texture transform
  103144. */
  103145. getReflectionTextureMatrix(): Matrix;
  103146. /**
  103147. * Clones the texture.
  103148. * @returns the cloned texture
  103149. */
  103150. clone(): Texture;
  103151. /**
  103152. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  103153. * @returns The JSON representation of the texture
  103154. */
  103155. serialize(): any;
  103156. /**
  103157. * Get the current class name of the texture useful for serialization or dynamic coding.
  103158. * @returns "Texture"
  103159. */
  103160. getClassName(): string;
  103161. /**
  103162. * Dispose the texture and release its associated resources.
  103163. */
  103164. dispose(): void;
  103165. /**
  103166. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  103167. * @param parsedTexture Define the JSON representation of the texture
  103168. * @param scene Define the scene the parsed texture should be instantiated in
  103169. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  103170. * @returns The parsed texture if successful
  103171. */
  103172. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  103173. /**
  103174. * Creates a texture from its base 64 representation.
  103175. * @param data Define the base64 payload without the data: prefix
  103176. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  103177. * @param scene Define the scene the texture should belong to
  103178. * @param noMipmap Forces the texture to not create mip map information if true
  103179. * @param invertY define if the texture needs to be inverted on the y axis during loading
  103180. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103181. * @param onLoad define a callback triggered when the texture has been loaded
  103182. * @param onError define a callback triggered when an error occurred during the loading session
  103183. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103184. * @returns the created texture
  103185. */
  103186. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  103187. /**
  103188. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  103189. * @param data Define the base64 payload without the data: prefix
  103190. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  103191. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  103192. * @param scene Define the scene the texture should belong to
  103193. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  103194. * @param noMipmap Forces the texture to not create mip map information if true
  103195. * @param invertY define if the texture needs to be inverted on the y axis during loading
  103196. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103197. * @param onLoad define a callback triggered when the texture has been loaded
  103198. * @param onError define a callback triggered when an error occurred during the loading session
  103199. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103200. * @returns the created texture
  103201. */
  103202. 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;
  103203. }
  103204. }
  103205. declare module BABYLON {
  103206. /**
  103207. * PostProcessManager is used to manage one or more post processes or post process pipelines
  103208. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  103209. */
  103210. export class PostProcessManager {
  103211. private _scene;
  103212. private _indexBuffer;
  103213. private _vertexBuffers;
  103214. /**
  103215. * Creates a new instance PostProcess
  103216. * @param scene The scene that the post process is associated with.
  103217. */
  103218. constructor(scene: Scene);
  103219. private _prepareBuffers;
  103220. private _buildIndexBuffer;
  103221. /**
  103222. * Rebuilds the vertex buffers of the manager.
  103223. * @hidden
  103224. */
  103225. _rebuild(): void;
  103226. /**
  103227. * Prepares a frame to be run through a post process.
  103228. * @param sourceTexture The input texture to the post procesess. (default: null)
  103229. * @param postProcesses An array of post processes to be run. (default: null)
  103230. * @returns True if the post processes were able to be run.
  103231. * @hidden
  103232. */
  103233. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  103234. /**
  103235. * Manually render a set of post processes to a texture.
  103236. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  103237. * @param postProcesses An array of post processes to be run.
  103238. * @param targetTexture The target texture to render to.
  103239. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  103240. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  103241. * @param lodLevel defines which lod of the texture to render to
  103242. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  103243. */
  103244. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  103245. /**
  103246. * Finalize the result of the output of the postprocesses.
  103247. * @param doNotPresent If true the result will not be displayed to the screen.
  103248. * @param targetTexture The target texture to render to.
  103249. * @param faceIndex The index of the face to bind the target texture to.
  103250. * @param postProcesses The array of post processes to render.
  103251. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  103252. * @hidden
  103253. */
  103254. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  103255. /**
  103256. * Disposes of the post process manager.
  103257. */
  103258. dispose(): void;
  103259. }
  103260. }
  103261. declare module BABYLON {
  103262. /**
  103263. * This Helps creating a texture that will be created from a camera in your scene.
  103264. * It is basically a dynamic texture that could be used to create special effects for instance.
  103265. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  103266. */
  103267. export class RenderTargetTexture extends Texture {
  103268. /**
  103269. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  103270. */
  103271. static readonly REFRESHRATE_RENDER_ONCE: number;
  103272. /**
  103273. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  103274. */
  103275. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  103276. /**
  103277. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  103278. * the central point of your effect and can save a lot of performances.
  103279. */
  103280. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  103281. /**
  103282. * Use this predicate to dynamically define the list of mesh you want to render.
  103283. * If set, the renderList property will be overwritten.
  103284. */
  103285. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  103286. private _renderList;
  103287. /**
  103288. * Use this list to define the list of mesh you want to render.
  103289. */
  103290. get renderList(): Nullable<Array<AbstractMesh>>;
  103291. set renderList(value: Nullable<Array<AbstractMesh>>);
  103292. /**
  103293. * Use this function to overload the renderList array at rendering time.
  103294. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  103295. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  103296. * the cube (if the RTT is a cube, else layerOrFace=0).
  103297. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  103298. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  103299. * hold dummy elements!
  103300. */
  103301. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  103302. private _hookArray;
  103303. /**
  103304. * Define if particles should be rendered in your texture.
  103305. */
  103306. renderParticles: boolean;
  103307. /**
  103308. * Define if sprites should be rendered in your texture.
  103309. */
  103310. renderSprites: boolean;
  103311. /**
  103312. * Define the camera used to render the texture.
  103313. */
  103314. activeCamera: Nullable<Camera>;
  103315. /**
  103316. * Override the mesh isReady function with your own one.
  103317. */
  103318. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  103319. /**
  103320. * Override the render function of the texture with your own one.
  103321. */
  103322. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  103323. /**
  103324. * Define if camera post processes should be use while rendering the texture.
  103325. */
  103326. useCameraPostProcesses: boolean;
  103327. /**
  103328. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  103329. */
  103330. ignoreCameraViewport: boolean;
  103331. private _postProcessManager;
  103332. private _postProcesses;
  103333. private _resizeObserver;
  103334. /**
  103335. * An event triggered when the texture is unbind.
  103336. */
  103337. onBeforeBindObservable: Observable<RenderTargetTexture>;
  103338. /**
  103339. * An event triggered when the texture is unbind.
  103340. */
  103341. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  103342. private _onAfterUnbindObserver;
  103343. /**
  103344. * Set a after unbind callback in the texture.
  103345. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  103346. */
  103347. set onAfterUnbind(callback: () => void);
  103348. /**
  103349. * An event triggered before rendering the texture
  103350. */
  103351. onBeforeRenderObservable: Observable<number>;
  103352. private _onBeforeRenderObserver;
  103353. /**
  103354. * Set a before render callback in the texture.
  103355. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  103356. */
  103357. set onBeforeRender(callback: (faceIndex: number) => void);
  103358. /**
  103359. * An event triggered after rendering the texture
  103360. */
  103361. onAfterRenderObservable: Observable<number>;
  103362. private _onAfterRenderObserver;
  103363. /**
  103364. * Set a after render callback in the texture.
  103365. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  103366. */
  103367. set onAfterRender(callback: (faceIndex: number) => void);
  103368. /**
  103369. * An event triggered after the texture clear
  103370. */
  103371. onClearObservable: Observable<Engine>;
  103372. private _onClearObserver;
  103373. /**
  103374. * Set a clear callback in the texture.
  103375. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  103376. */
  103377. set onClear(callback: (Engine: Engine) => void);
  103378. /**
  103379. * An event triggered when the texture is resized.
  103380. */
  103381. onResizeObservable: Observable<RenderTargetTexture>;
  103382. /**
  103383. * Define the clear color of the Render Target if it should be different from the scene.
  103384. */
  103385. clearColor: Color4;
  103386. protected _size: number | {
  103387. width: number;
  103388. height: number;
  103389. layers?: number;
  103390. };
  103391. protected _initialSizeParameter: number | {
  103392. width: number;
  103393. height: number;
  103394. } | {
  103395. ratio: number;
  103396. };
  103397. protected _sizeRatio: Nullable<number>;
  103398. /** @hidden */
  103399. _generateMipMaps: boolean;
  103400. protected _renderingManager: RenderingManager;
  103401. /** @hidden */
  103402. _waitingRenderList?: string[];
  103403. protected _doNotChangeAspectRatio: boolean;
  103404. protected _currentRefreshId: number;
  103405. protected _refreshRate: number;
  103406. protected _textureMatrix: Matrix;
  103407. protected _samples: number;
  103408. protected _renderTargetOptions: RenderTargetCreationOptions;
  103409. /**
  103410. * Gets render target creation options that were used.
  103411. */
  103412. get renderTargetOptions(): RenderTargetCreationOptions;
  103413. protected _onRatioRescale(): void;
  103414. /**
  103415. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  103416. * It must define where the camera used to render the texture is set
  103417. */
  103418. boundingBoxPosition: Vector3;
  103419. private _boundingBoxSize;
  103420. /**
  103421. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  103422. * When defined, the cubemap will switch to local mode
  103423. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  103424. * @example https://www.babylonjs-playground.com/#RNASML
  103425. */
  103426. set boundingBoxSize(value: Vector3);
  103427. get boundingBoxSize(): Vector3;
  103428. /**
  103429. * In case the RTT has been created with a depth texture, get the associated
  103430. * depth texture.
  103431. * Otherwise, return null.
  103432. */
  103433. get depthStencilTexture(): Nullable<InternalTexture>;
  103434. /**
  103435. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  103436. * or used a shadow, depth texture...
  103437. * @param name The friendly name of the texture
  103438. * @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)
  103439. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  103440. * @param generateMipMaps True if mip maps need to be generated after render.
  103441. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  103442. * @param type The type of the buffer in the RTT (int, half float, float...)
  103443. * @param isCube True if a cube texture needs to be created
  103444. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  103445. * @param generateDepthBuffer True to generate a depth buffer
  103446. * @param generateStencilBuffer True to generate a stencil buffer
  103447. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  103448. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  103449. * @param delayAllocation if the texture allocation should be delayed (default: false)
  103450. */
  103451. constructor(name: string, size: number | {
  103452. width: number;
  103453. height: number;
  103454. layers?: number;
  103455. } | {
  103456. ratio: number;
  103457. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  103458. /**
  103459. * Creates a depth stencil texture.
  103460. * This is only available in WebGL 2 or with the depth texture extension available.
  103461. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  103462. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  103463. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  103464. */
  103465. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  103466. private _processSizeParameter;
  103467. /**
  103468. * Define the number of samples to use in case of MSAA.
  103469. * It defaults to one meaning no MSAA has been enabled.
  103470. */
  103471. get samples(): number;
  103472. set samples(value: number);
  103473. /**
  103474. * Resets the refresh counter of the texture and start bak from scratch.
  103475. * Could be useful to regenerate the texture if it is setup to render only once.
  103476. */
  103477. resetRefreshCounter(): void;
  103478. /**
  103479. * Define the refresh rate of the texture or the rendering frequency.
  103480. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  103481. */
  103482. get refreshRate(): number;
  103483. set refreshRate(value: number);
  103484. /**
  103485. * Adds a post process to the render target rendering passes.
  103486. * @param postProcess define the post process to add
  103487. */
  103488. addPostProcess(postProcess: PostProcess): void;
  103489. /**
  103490. * Clear all the post processes attached to the render target
  103491. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  103492. */
  103493. clearPostProcesses(dispose?: boolean): void;
  103494. /**
  103495. * Remove one of the post process from the list of attached post processes to the texture
  103496. * @param postProcess define the post process to remove from the list
  103497. */
  103498. removePostProcess(postProcess: PostProcess): void;
  103499. /** @hidden */
  103500. _shouldRender(): boolean;
  103501. /**
  103502. * Gets the actual render size of the texture.
  103503. * @returns the width of the render size
  103504. */
  103505. getRenderSize(): number;
  103506. /**
  103507. * Gets the actual render width of the texture.
  103508. * @returns the width of the render size
  103509. */
  103510. getRenderWidth(): number;
  103511. /**
  103512. * Gets the actual render height of the texture.
  103513. * @returns the height of the render size
  103514. */
  103515. getRenderHeight(): number;
  103516. /**
  103517. * Gets the actual number of layers of the texture.
  103518. * @returns the number of layers
  103519. */
  103520. getRenderLayers(): number;
  103521. /**
  103522. * Get if the texture can be rescaled or not.
  103523. */
  103524. get canRescale(): boolean;
  103525. /**
  103526. * Resize the texture using a ratio.
  103527. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  103528. */
  103529. scale(ratio: number): void;
  103530. /**
  103531. * Get the texture reflection matrix used to rotate/transform the reflection.
  103532. * @returns the reflection matrix
  103533. */
  103534. getReflectionTextureMatrix(): Matrix;
  103535. /**
  103536. * Resize the texture to a new desired size.
  103537. * Be carrefull as it will recreate all the data in the new texture.
  103538. * @param size Define the new size. It can be:
  103539. * - a number for squared texture,
  103540. * - an object containing { width: number, height: number }
  103541. * - or an object containing a ratio { ratio: number }
  103542. */
  103543. resize(size: number | {
  103544. width: number;
  103545. height: number;
  103546. } | {
  103547. ratio: number;
  103548. }): void;
  103549. private _defaultRenderListPrepared;
  103550. /**
  103551. * Renders all the objects from the render list into the texture.
  103552. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  103553. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  103554. */
  103555. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  103556. private _bestReflectionRenderTargetDimension;
  103557. private _prepareRenderingManager;
  103558. /**
  103559. * @hidden
  103560. * @param faceIndex face index to bind to if this is a cubetexture
  103561. * @param layer defines the index of the texture to bind in the array
  103562. */
  103563. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  103564. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103565. private renderToTarget;
  103566. /**
  103567. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  103568. * This allowed control for front to back rendering or reversly depending of the special needs.
  103569. *
  103570. * @param renderingGroupId The rendering group id corresponding to its index
  103571. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  103572. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  103573. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  103574. */
  103575. 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;
  103576. /**
  103577. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  103578. *
  103579. * @param renderingGroupId The rendering group id corresponding to its index
  103580. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  103581. */
  103582. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  103583. /**
  103584. * Clones the texture.
  103585. * @returns the cloned texture
  103586. */
  103587. clone(): RenderTargetTexture;
  103588. /**
  103589. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  103590. * @returns The JSON representation of the texture
  103591. */
  103592. serialize(): any;
  103593. /**
  103594. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  103595. */
  103596. disposeFramebufferObjects(): void;
  103597. /**
  103598. * Dispose the texture and release its associated resources.
  103599. */
  103600. dispose(): void;
  103601. /** @hidden */
  103602. _rebuild(): void;
  103603. /**
  103604. * Clear the info related to rendering groups preventing retention point in material dispose.
  103605. */
  103606. freeRenderingGroups(): void;
  103607. /**
  103608. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  103609. * @returns the view count
  103610. */
  103611. getViewCount(): number;
  103612. }
  103613. }
  103614. declare module BABYLON {
  103615. /**
  103616. * Class used to manipulate GUIDs
  103617. */
  103618. export class GUID {
  103619. /**
  103620. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  103621. * Be aware Math.random() could cause collisions, but:
  103622. * "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"
  103623. * @returns a pseudo random id
  103624. */
  103625. static RandomId(): string;
  103626. }
  103627. }
  103628. declare module BABYLON {
  103629. /**
  103630. * Options to be used when creating a shadow depth material
  103631. */
  103632. export interface IIOptionShadowDepthMaterial {
  103633. /** Variables in the vertex shader code that need to have their names remapped.
  103634. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  103635. * "var_name" should be either: worldPos or vNormalW
  103636. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  103637. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  103638. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  103639. */
  103640. remappedVariables?: string[];
  103641. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  103642. standalone?: boolean;
  103643. }
  103644. /**
  103645. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  103646. */
  103647. export class ShadowDepthWrapper {
  103648. private _scene;
  103649. private _options?;
  103650. private _baseMaterial;
  103651. private _onEffectCreatedObserver;
  103652. private _subMeshToEffect;
  103653. private _subMeshToDepthEffect;
  103654. private _meshes;
  103655. /** @hidden */
  103656. _matriceNames: any;
  103657. /** Gets the standalone status of the wrapper */
  103658. get standalone(): boolean;
  103659. /** Gets the base material the wrapper is built upon */
  103660. get baseMaterial(): Material;
  103661. /**
  103662. * Instantiate a new shadow depth wrapper.
  103663. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  103664. * generate the shadow depth map. For more information, please refer to the documentation:
  103665. * https://doc.babylonjs.com/babylon101/shadows
  103666. * @param baseMaterial Material to wrap
  103667. * @param scene Define the scene the material belongs to
  103668. * @param options Options used to create the wrapper
  103669. */
  103670. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  103671. /**
  103672. * Gets the effect to use to generate the depth map
  103673. * @param subMesh subMesh to get the effect for
  103674. * @param shadowGenerator shadow generator to get the effect for
  103675. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  103676. */
  103677. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  103678. /**
  103679. * Specifies that the submesh is ready to be used for depth rendering
  103680. * @param subMesh submesh to check
  103681. * @param defines the list of defines to take into account when checking the effect
  103682. * @param shadowGenerator combined with subMesh, it defines the effect to check
  103683. * @param useInstances specifies that instances should be used
  103684. * @returns a boolean indicating that the submesh is ready or not
  103685. */
  103686. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  103687. /**
  103688. * Disposes the resources
  103689. */
  103690. dispose(): void;
  103691. private _makeEffect;
  103692. }
  103693. }
  103694. declare module BABYLON {
  103695. interface ThinEngine {
  103696. /**
  103697. * Unbind a list of render target textures from the webGL context
  103698. * This is used only when drawBuffer extension or webGL2 are active
  103699. * @param textures defines the render target textures to unbind
  103700. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  103701. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  103702. */
  103703. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  103704. /**
  103705. * Create a multi render target texture
  103706. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  103707. * @param size defines the size of the texture
  103708. * @param options defines the creation options
  103709. * @returns the cube texture as an InternalTexture
  103710. */
  103711. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  103712. /**
  103713. * Update the sample count for a given multiple render target texture
  103714. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  103715. * @param textures defines the textures to update
  103716. * @param samples defines the sample count to set
  103717. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  103718. */
  103719. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  103720. /**
  103721. * Select a subsets of attachments to draw to.
  103722. * @param attachments gl attachments
  103723. */
  103724. bindAttachments(attachments: number[]): void;
  103725. }
  103726. }
  103727. declare module BABYLON {
  103728. /**
  103729. * Creation options of the multi render target texture.
  103730. */
  103731. export interface IMultiRenderTargetOptions {
  103732. /**
  103733. * Define if the texture needs to create mip maps after render.
  103734. */
  103735. generateMipMaps?: boolean;
  103736. /**
  103737. * Define the types of all the draw buffers we want to create
  103738. */
  103739. types?: number[];
  103740. /**
  103741. * Define the sampling modes of all the draw buffers we want to create
  103742. */
  103743. samplingModes?: number[];
  103744. /**
  103745. * Define if a depth buffer is required
  103746. */
  103747. generateDepthBuffer?: boolean;
  103748. /**
  103749. * Define if a stencil buffer is required
  103750. */
  103751. generateStencilBuffer?: boolean;
  103752. /**
  103753. * Define if a depth texture is required instead of a depth buffer
  103754. */
  103755. generateDepthTexture?: boolean;
  103756. /**
  103757. * Define the number of desired draw buffers
  103758. */
  103759. textureCount?: number;
  103760. /**
  103761. * Define if aspect ratio should be adapted to the texture or stay the scene one
  103762. */
  103763. doNotChangeAspectRatio?: boolean;
  103764. /**
  103765. * Define the default type of the buffers we are creating
  103766. */
  103767. defaultType?: number;
  103768. }
  103769. /**
  103770. * A multi render target, like a render target provides the ability to render to a texture.
  103771. * Unlike the render target, it can render to several draw buffers in one draw.
  103772. * This is specially interesting in deferred rendering or for any effects requiring more than
  103773. * just one color from a single pass.
  103774. */
  103775. export class MultiRenderTarget extends RenderTargetTexture {
  103776. private _internalTextures;
  103777. private _textures;
  103778. private _multiRenderTargetOptions;
  103779. private _count;
  103780. /**
  103781. * Get if draw buffers are currently supported by the used hardware and browser.
  103782. */
  103783. get isSupported(): boolean;
  103784. /**
  103785. * Get the list of textures generated by the multi render target.
  103786. */
  103787. get textures(): Texture[];
  103788. /**
  103789. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  103790. */
  103791. get count(): number;
  103792. /**
  103793. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  103794. */
  103795. get depthTexture(): Texture;
  103796. /**
  103797. * Set the wrapping mode on U of all the textures we are rendering to.
  103798. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103799. */
  103800. set wrapU(wrap: number);
  103801. /**
  103802. * Set the wrapping mode on V of all the textures we are rendering to.
  103803. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103804. */
  103805. set wrapV(wrap: number);
  103806. /**
  103807. * Instantiate a new multi render target texture.
  103808. * A multi render target, like a render target provides the ability to render to a texture.
  103809. * Unlike the render target, it can render to several draw buffers in one draw.
  103810. * This is specially interesting in deferred rendering or for any effects requiring more than
  103811. * just one color from a single pass.
  103812. * @param name Define the name of the texture
  103813. * @param size Define the size of the buffers to render to
  103814. * @param count Define the number of target we are rendering into
  103815. * @param scene Define the scene the texture belongs to
  103816. * @param options Define the options used to create the multi render target
  103817. */
  103818. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  103819. /** @hidden */
  103820. _rebuild(): void;
  103821. private _createInternalTextures;
  103822. private _createTextures;
  103823. /**
  103824. * Define the number of samples used if MSAA is enabled.
  103825. */
  103826. get samples(): number;
  103827. set samples(value: number);
  103828. /**
  103829. * Resize all the textures in the multi render target.
  103830. * Be carrefull as it will recreate all the data in the new texture.
  103831. * @param size Define the new size
  103832. */
  103833. resize(size: any): void;
  103834. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103835. /**
  103836. * Dispose the render targets and their associated resources
  103837. */
  103838. dispose(): void;
  103839. /**
  103840. * Release all the underlying texture used as draw buffers.
  103841. */
  103842. releaseInternalTextures(): void;
  103843. }
  103844. }
  103845. declare module BABYLON {
  103846. /** @hidden */
  103847. export var imageProcessingPixelShader: {
  103848. name: string;
  103849. shader: string;
  103850. };
  103851. }
  103852. declare module BABYLON {
  103853. /**
  103854. * ImageProcessingPostProcess
  103855. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  103856. */
  103857. export class ImageProcessingPostProcess extends PostProcess {
  103858. /**
  103859. * Default configuration related to image processing available in the PBR Material.
  103860. */
  103861. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103862. /**
  103863. * Gets the image processing configuration used either in this material.
  103864. */
  103865. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103866. /**
  103867. * Sets the Default image processing configuration used either in the this material.
  103868. *
  103869. * If sets to null, the scene one is in use.
  103870. */
  103871. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103872. /**
  103873. * Keep track of the image processing observer to allow dispose and replace.
  103874. */
  103875. private _imageProcessingObserver;
  103876. /**
  103877. * Attaches a new image processing configuration to the PBR Material.
  103878. * @param configuration
  103879. */
  103880. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  103881. /**
  103882. * If the post process is supported.
  103883. */
  103884. get isSupported(): boolean;
  103885. /**
  103886. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103887. */
  103888. get colorCurves(): Nullable<ColorCurves>;
  103889. /**
  103890. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103891. */
  103892. set colorCurves(value: Nullable<ColorCurves>);
  103893. /**
  103894. * Gets wether the color curves effect is enabled.
  103895. */
  103896. get colorCurvesEnabled(): boolean;
  103897. /**
  103898. * Sets wether the color curves effect is enabled.
  103899. */
  103900. set colorCurvesEnabled(value: boolean);
  103901. /**
  103902. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103903. */
  103904. get colorGradingTexture(): Nullable<BaseTexture>;
  103905. /**
  103906. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103907. */
  103908. set colorGradingTexture(value: Nullable<BaseTexture>);
  103909. /**
  103910. * Gets wether the color grading effect is enabled.
  103911. */
  103912. get colorGradingEnabled(): boolean;
  103913. /**
  103914. * Gets wether the color grading effect is enabled.
  103915. */
  103916. set colorGradingEnabled(value: boolean);
  103917. /**
  103918. * Gets exposure used in the effect.
  103919. */
  103920. get exposure(): number;
  103921. /**
  103922. * Sets exposure used in the effect.
  103923. */
  103924. set exposure(value: number);
  103925. /**
  103926. * Gets wether tonemapping is enabled or not.
  103927. */
  103928. get toneMappingEnabled(): boolean;
  103929. /**
  103930. * Sets wether tonemapping is enabled or not
  103931. */
  103932. set toneMappingEnabled(value: boolean);
  103933. /**
  103934. * Gets the type of tone mapping effect.
  103935. */
  103936. get toneMappingType(): number;
  103937. /**
  103938. * Sets the type of tone mapping effect.
  103939. */
  103940. set toneMappingType(value: number);
  103941. /**
  103942. * Gets contrast used in the effect.
  103943. */
  103944. get contrast(): number;
  103945. /**
  103946. * Sets contrast used in the effect.
  103947. */
  103948. set contrast(value: number);
  103949. /**
  103950. * Gets Vignette stretch size.
  103951. */
  103952. get vignetteStretch(): number;
  103953. /**
  103954. * Sets Vignette stretch size.
  103955. */
  103956. set vignetteStretch(value: number);
  103957. /**
  103958. * Gets Vignette centre X Offset.
  103959. */
  103960. get vignetteCentreX(): number;
  103961. /**
  103962. * Sets Vignette centre X Offset.
  103963. */
  103964. set vignetteCentreX(value: number);
  103965. /**
  103966. * Gets Vignette centre Y Offset.
  103967. */
  103968. get vignetteCentreY(): number;
  103969. /**
  103970. * Sets Vignette centre Y Offset.
  103971. */
  103972. set vignetteCentreY(value: number);
  103973. /**
  103974. * Gets Vignette weight or intensity of the vignette effect.
  103975. */
  103976. get vignetteWeight(): number;
  103977. /**
  103978. * Sets Vignette weight or intensity of the vignette effect.
  103979. */
  103980. set vignetteWeight(value: number);
  103981. /**
  103982. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103983. * if vignetteEnabled is set to true.
  103984. */
  103985. get vignetteColor(): Color4;
  103986. /**
  103987. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103988. * if vignetteEnabled is set to true.
  103989. */
  103990. set vignetteColor(value: Color4);
  103991. /**
  103992. * Gets Camera field of view used by the Vignette effect.
  103993. */
  103994. get vignetteCameraFov(): number;
  103995. /**
  103996. * Sets Camera field of view used by the Vignette effect.
  103997. */
  103998. set vignetteCameraFov(value: number);
  103999. /**
  104000. * Gets the vignette blend mode allowing different kind of effect.
  104001. */
  104002. get vignetteBlendMode(): number;
  104003. /**
  104004. * Sets the vignette blend mode allowing different kind of effect.
  104005. */
  104006. set vignetteBlendMode(value: number);
  104007. /**
  104008. * Gets wether the vignette effect is enabled.
  104009. */
  104010. get vignetteEnabled(): boolean;
  104011. /**
  104012. * Sets wether the vignette effect is enabled.
  104013. */
  104014. set vignetteEnabled(value: boolean);
  104015. private _fromLinearSpace;
  104016. /**
  104017. * Gets wether the input of the processing is in Gamma or Linear Space.
  104018. */
  104019. get fromLinearSpace(): boolean;
  104020. /**
  104021. * Sets wether the input of the processing is in Gamma or Linear Space.
  104022. */
  104023. set fromLinearSpace(value: boolean);
  104024. /**
  104025. * Defines cache preventing GC.
  104026. */
  104027. private _defines;
  104028. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  104029. /**
  104030. * "ImageProcessingPostProcess"
  104031. * @returns "ImageProcessingPostProcess"
  104032. */
  104033. getClassName(): string;
  104034. /**
  104035. * @hidden
  104036. */
  104037. _updateParameters(): void;
  104038. dispose(camera?: Camera): void;
  104039. }
  104040. }
  104041. declare module BABYLON {
  104042. /** @hidden */
  104043. export var fibonacci: {
  104044. name: string;
  104045. shader: string;
  104046. };
  104047. }
  104048. declare module BABYLON {
  104049. /** @hidden */
  104050. export var subSurfaceScatteringFunctions: {
  104051. name: string;
  104052. shader: string;
  104053. };
  104054. }
  104055. declare module BABYLON {
  104056. /** @hidden */
  104057. export var diffusionProfile: {
  104058. name: string;
  104059. shader: string;
  104060. };
  104061. }
  104062. declare module BABYLON {
  104063. /** @hidden */
  104064. export var subSurfaceScatteringPixelShader: {
  104065. name: string;
  104066. shader: string;
  104067. };
  104068. }
  104069. declare module BABYLON {
  104070. /**
  104071. * Sub surface scattering post process
  104072. */
  104073. export class SubSurfaceScatteringPostProcess extends PostProcess {
  104074. /**
  104075. * Gets a string identifying the name of the class
  104076. * @returns "SubSurfaceScatteringPostProcess" string
  104077. */
  104078. getClassName(): string;
  104079. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  104080. }
  104081. }
  104082. declare module BABYLON {
  104083. /**
  104084. * Interface for defining prepass effects in the prepass post-process pipeline
  104085. */
  104086. export interface PrePassEffectConfiguration {
  104087. /**
  104088. * Post process to attach for this effect
  104089. */
  104090. postProcess: PostProcess;
  104091. /**
  104092. * Is the effect enabled
  104093. */
  104094. enabled: boolean;
  104095. /**
  104096. * Disposes the effect configuration
  104097. */
  104098. dispose(): void;
  104099. /**
  104100. * Disposes the effect configuration
  104101. */
  104102. createPostProcess: () => PostProcess;
  104103. }
  104104. }
  104105. declare module BABYLON {
  104106. /**
  104107. * Contains all parameters needed for the prepass to perform
  104108. * screen space subsurface scattering
  104109. */
  104110. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  104111. private _ssDiffusionS;
  104112. private _ssFilterRadii;
  104113. private _ssDiffusionD;
  104114. /**
  104115. * Post process to attach for screen space subsurface scattering
  104116. */
  104117. postProcess: SubSurfaceScatteringPostProcess;
  104118. /**
  104119. * Diffusion profile color for subsurface scattering
  104120. */
  104121. get ssDiffusionS(): number[];
  104122. /**
  104123. * Diffusion profile max color channel value for subsurface scattering
  104124. */
  104125. get ssDiffusionD(): number[];
  104126. /**
  104127. * Diffusion profile filter radius for subsurface scattering
  104128. */
  104129. get ssFilterRadii(): number[];
  104130. /**
  104131. * Is subsurface enabled
  104132. */
  104133. enabled: boolean;
  104134. /**
  104135. * Diffusion profile colors for subsurface scattering
  104136. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  104137. * See ...
  104138. * Note that you can only store up to 5 of them
  104139. */
  104140. ssDiffusionProfileColors: Color3[];
  104141. /**
  104142. * Defines the ratio real world => scene units.
  104143. * Used for subsurface scattering
  104144. */
  104145. metersPerUnit: number;
  104146. private _scene;
  104147. /**
  104148. * Builds a subsurface configuration object
  104149. * @param scene The scene
  104150. */
  104151. constructor(scene: Scene);
  104152. /**
  104153. * Adds a new diffusion profile.
  104154. * Useful for more realistic subsurface scattering on diverse materials.
  104155. * @param color The color of the diffusion profile. Should be the average color of the material.
  104156. * @return The index of the diffusion profile for the material subsurface configuration
  104157. */
  104158. addDiffusionProfile(color: Color3): number;
  104159. /**
  104160. * Creates the sss post process
  104161. * @return The created post process
  104162. */
  104163. createPostProcess(): SubSurfaceScatteringPostProcess;
  104164. /**
  104165. * Deletes all diffusion profiles.
  104166. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  104167. */
  104168. clearAllDiffusionProfiles(): void;
  104169. /**
  104170. * Disposes this object
  104171. */
  104172. dispose(): void;
  104173. /**
  104174. * @hidden
  104175. * https://zero-radiance.github.io/post/sampling-diffusion/
  104176. *
  104177. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  104178. * ------------------------------------------------------------------------------------
  104179. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  104180. * PDF[r, phi, s] = r * R[r, phi, s]
  104181. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  104182. * ------------------------------------------------------------------------------------
  104183. * We importance sample the color channel with the widest scattering distance.
  104184. */
  104185. getDiffusionProfileParameters(color: Color3): number;
  104186. /**
  104187. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  104188. * 'u' is the random number (the value of the CDF): [0, 1).
  104189. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  104190. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  104191. */
  104192. private _sampleBurleyDiffusionProfile;
  104193. }
  104194. }
  104195. declare module BABYLON {
  104196. /**
  104197. * Renders a pre pass of the scene
  104198. * This means every mesh in the scene will be rendered to a render target texture
  104199. * And then this texture will be composited to the rendering canvas with post processes
  104200. * It is necessary for effects like subsurface scattering or deferred shading
  104201. */
  104202. export class PrePassRenderer {
  104203. /** @hidden */
  104204. static _SceneComponentInitialization: (scene: Scene) => void;
  104205. private _scene;
  104206. private _engine;
  104207. private _isDirty;
  104208. /**
  104209. * Number of textures in the multi render target texture where the scene is directly rendered
  104210. */
  104211. readonly mrtCount: number;
  104212. /**
  104213. * The render target where the scene is directly rendered
  104214. */
  104215. prePassRT: MultiRenderTarget;
  104216. private _mrtTypes;
  104217. private _multiRenderAttachments;
  104218. private _defaultAttachments;
  104219. private _clearAttachments;
  104220. private _postProcesses;
  104221. private readonly _clearColor;
  104222. /**
  104223. * Image processing post process for composition
  104224. */
  104225. imageProcessingPostProcess: ImageProcessingPostProcess;
  104226. /**
  104227. * Configuration for sub surface scattering post process
  104228. */
  104229. subSurfaceConfiguration: SubSurfaceConfiguration;
  104230. /**
  104231. * Should materials render their geometry on the MRT
  104232. */
  104233. materialsShouldRenderGeometry: boolean;
  104234. /**
  104235. * Should materials render the irradiance information on the MRT
  104236. */
  104237. materialsShouldRenderIrradiance: boolean;
  104238. private _enabled;
  104239. /**
  104240. * Indicates if the prepass is enabled
  104241. */
  104242. get enabled(): boolean;
  104243. /**
  104244. * How many samples are used for MSAA of the scene render target
  104245. */
  104246. get samples(): number;
  104247. set samples(n: number);
  104248. /**
  104249. * Instanciates a prepass renderer
  104250. * @param scene The scene
  104251. */
  104252. constructor(scene: Scene);
  104253. private _initializeAttachments;
  104254. private _createCompositionEffect;
  104255. /**
  104256. * Indicates if rendering a prepass is supported
  104257. */
  104258. get isSupported(): boolean;
  104259. /**
  104260. * Sets the proper output textures to draw in the engine.
  104261. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  104262. */
  104263. bindAttachmentsForEffect(effect: Effect): void;
  104264. /**
  104265. * @hidden
  104266. */
  104267. _beforeCameraDraw(): void;
  104268. /**
  104269. * @hidden
  104270. */
  104271. _afterCameraDraw(): void;
  104272. private _checkRTSize;
  104273. private _bindFrameBuffer;
  104274. /**
  104275. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  104276. */
  104277. clear(): void;
  104278. private _setState;
  104279. private _enable;
  104280. private _disable;
  104281. private _resetPostProcessChain;
  104282. private _bindPostProcessChain;
  104283. /**
  104284. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  104285. */
  104286. markAsDirty(): void;
  104287. private _update;
  104288. /**
  104289. * Disposes the prepass renderer.
  104290. */
  104291. dispose(): void;
  104292. }
  104293. }
  104294. declare module BABYLON {
  104295. /**
  104296. * Options for compiling materials.
  104297. */
  104298. export interface IMaterialCompilationOptions {
  104299. /**
  104300. * Defines whether clip planes are enabled.
  104301. */
  104302. clipPlane: boolean;
  104303. /**
  104304. * Defines whether instances are enabled.
  104305. */
  104306. useInstances: boolean;
  104307. }
  104308. /**
  104309. * Options passed when calling customShaderNameResolve
  104310. */
  104311. export interface ICustomShaderNameResolveOptions {
  104312. /**
  104313. * 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
  104314. */
  104315. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  104316. }
  104317. /**
  104318. * Base class for the main features of a material in Babylon.js
  104319. */
  104320. export class Material implements IAnimatable {
  104321. /**
  104322. * Returns the triangle fill mode
  104323. */
  104324. static readonly TriangleFillMode: number;
  104325. /**
  104326. * Returns the wireframe mode
  104327. */
  104328. static readonly WireFrameFillMode: number;
  104329. /**
  104330. * Returns the point fill mode
  104331. */
  104332. static readonly PointFillMode: number;
  104333. /**
  104334. * Returns the point list draw mode
  104335. */
  104336. static readonly PointListDrawMode: number;
  104337. /**
  104338. * Returns the line list draw mode
  104339. */
  104340. static readonly LineListDrawMode: number;
  104341. /**
  104342. * Returns the line loop draw mode
  104343. */
  104344. static readonly LineLoopDrawMode: number;
  104345. /**
  104346. * Returns the line strip draw mode
  104347. */
  104348. static readonly LineStripDrawMode: number;
  104349. /**
  104350. * Returns the triangle strip draw mode
  104351. */
  104352. static readonly TriangleStripDrawMode: number;
  104353. /**
  104354. * Returns the triangle fan draw mode
  104355. */
  104356. static readonly TriangleFanDrawMode: number;
  104357. /**
  104358. * Stores the clock-wise side orientation
  104359. */
  104360. static readonly ClockWiseSideOrientation: number;
  104361. /**
  104362. * Stores the counter clock-wise side orientation
  104363. */
  104364. static readonly CounterClockWiseSideOrientation: number;
  104365. /**
  104366. * The dirty texture flag value
  104367. */
  104368. static readonly TextureDirtyFlag: number;
  104369. /**
  104370. * The dirty light flag value
  104371. */
  104372. static readonly LightDirtyFlag: number;
  104373. /**
  104374. * The dirty fresnel flag value
  104375. */
  104376. static readonly FresnelDirtyFlag: number;
  104377. /**
  104378. * The dirty attribute flag value
  104379. */
  104380. static readonly AttributesDirtyFlag: number;
  104381. /**
  104382. * The dirty misc flag value
  104383. */
  104384. static readonly MiscDirtyFlag: number;
  104385. /**
  104386. * The all dirty flag value
  104387. */
  104388. static readonly AllDirtyFlag: number;
  104389. /**
  104390. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104391. */
  104392. static readonly MATERIAL_OPAQUE: number;
  104393. /**
  104394. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104395. */
  104396. static readonly MATERIAL_ALPHATEST: number;
  104397. /**
  104398. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104399. */
  104400. static readonly MATERIAL_ALPHABLEND: number;
  104401. /**
  104402. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104403. * They are also discarded below the alpha cutoff threshold to improve performances.
  104404. */
  104405. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  104406. /**
  104407. * The Whiteout method is used to blend normals.
  104408. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  104409. */
  104410. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  104411. /**
  104412. * The Reoriented Normal Mapping method is used to blend normals.
  104413. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  104414. */
  104415. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  104416. /**
  104417. * Custom callback helping to override the default shader used in the material.
  104418. */
  104419. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  104420. /**
  104421. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  104422. */
  104423. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  104424. /**
  104425. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  104426. * This means that the material can keep using a previous shader while a new one is being compiled.
  104427. * This is mostly used when shader parallel compilation is supported (true by default)
  104428. */
  104429. allowShaderHotSwapping: boolean;
  104430. /**
  104431. * The ID of the material
  104432. */
  104433. id: string;
  104434. /**
  104435. * Gets or sets the unique id of the material
  104436. */
  104437. uniqueId: number;
  104438. /**
  104439. * The name of the material
  104440. */
  104441. name: string;
  104442. /**
  104443. * Gets or sets user defined metadata
  104444. */
  104445. metadata: any;
  104446. /**
  104447. * For internal use only. Please do not use.
  104448. */
  104449. reservedDataStore: any;
  104450. /**
  104451. * Specifies if the ready state should be checked on each call
  104452. */
  104453. checkReadyOnEveryCall: boolean;
  104454. /**
  104455. * Specifies if the ready state should be checked once
  104456. */
  104457. checkReadyOnlyOnce: boolean;
  104458. /**
  104459. * The state of the material
  104460. */
  104461. state: string;
  104462. /**
  104463. * If the material can be rendered to several textures with MRT extension
  104464. */
  104465. get canRenderToMRT(): boolean;
  104466. /**
  104467. * The alpha value of the material
  104468. */
  104469. protected _alpha: number;
  104470. /**
  104471. * List of inspectable custom properties (used by the Inspector)
  104472. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  104473. */
  104474. inspectableCustomProperties: IInspectable[];
  104475. /**
  104476. * Sets the alpha value of the material
  104477. */
  104478. set alpha(value: number);
  104479. /**
  104480. * Gets the alpha value of the material
  104481. */
  104482. get alpha(): number;
  104483. /**
  104484. * Specifies if back face culling is enabled
  104485. */
  104486. protected _backFaceCulling: boolean;
  104487. /**
  104488. * Sets the back-face culling state
  104489. */
  104490. set backFaceCulling(value: boolean);
  104491. /**
  104492. * Gets the back-face culling state
  104493. */
  104494. get backFaceCulling(): boolean;
  104495. /**
  104496. * Stores the value for side orientation
  104497. */
  104498. sideOrientation: number;
  104499. /**
  104500. * Callback triggered when the material is compiled
  104501. */
  104502. onCompiled: Nullable<(effect: Effect) => void>;
  104503. /**
  104504. * Callback triggered when an error occurs
  104505. */
  104506. onError: Nullable<(effect: Effect, errors: string) => void>;
  104507. /**
  104508. * Callback triggered to get the render target textures
  104509. */
  104510. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  104511. /**
  104512. * Gets a boolean indicating that current material needs to register RTT
  104513. */
  104514. get hasRenderTargetTextures(): boolean;
  104515. /**
  104516. * Specifies if the material should be serialized
  104517. */
  104518. doNotSerialize: boolean;
  104519. /**
  104520. * @hidden
  104521. */
  104522. _storeEffectOnSubMeshes: boolean;
  104523. /**
  104524. * Stores the animations for the material
  104525. */
  104526. animations: Nullable<Array<Animation>>;
  104527. /**
  104528. * An event triggered when the material is disposed
  104529. */
  104530. onDisposeObservable: Observable<Material>;
  104531. /**
  104532. * An observer which watches for dispose events
  104533. */
  104534. private _onDisposeObserver;
  104535. private _onUnBindObservable;
  104536. /**
  104537. * Called during a dispose event
  104538. */
  104539. set onDispose(callback: () => void);
  104540. private _onBindObservable;
  104541. /**
  104542. * An event triggered when the material is bound
  104543. */
  104544. get onBindObservable(): Observable<AbstractMesh>;
  104545. /**
  104546. * An observer which watches for bind events
  104547. */
  104548. private _onBindObserver;
  104549. /**
  104550. * Called during a bind event
  104551. */
  104552. set onBind(callback: (Mesh: AbstractMesh) => void);
  104553. /**
  104554. * An event triggered when the material is unbound
  104555. */
  104556. get onUnBindObservable(): Observable<Material>;
  104557. protected _onEffectCreatedObservable: Nullable<Observable<{
  104558. effect: Effect;
  104559. subMesh: Nullable<SubMesh>;
  104560. }>>;
  104561. /**
  104562. * An event triggered when the effect is (re)created
  104563. */
  104564. get onEffectCreatedObservable(): Observable<{
  104565. effect: Effect;
  104566. subMesh: Nullable<SubMesh>;
  104567. }>;
  104568. /**
  104569. * Stores the value of the alpha mode
  104570. */
  104571. private _alphaMode;
  104572. /**
  104573. * Sets the value of the alpha mode.
  104574. *
  104575. * | Value | Type | Description |
  104576. * | --- | --- | --- |
  104577. * | 0 | ALPHA_DISABLE | |
  104578. * | 1 | ALPHA_ADD | |
  104579. * | 2 | ALPHA_COMBINE | |
  104580. * | 3 | ALPHA_SUBTRACT | |
  104581. * | 4 | ALPHA_MULTIPLY | |
  104582. * | 5 | ALPHA_MAXIMIZED | |
  104583. * | 6 | ALPHA_ONEONE | |
  104584. * | 7 | ALPHA_PREMULTIPLIED | |
  104585. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  104586. * | 9 | ALPHA_INTERPOLATE | |
  104587. * | 10 | ALPHA_SCREENMODE | |
  104588. *
  104589. */
  104590. set alphaMode(value: number);
  104591. /**
  104592. * Gets the value of the alpha mode
  104593. */
  104594. get alphaMode(): number;
  104595. /**
  104596. * Stores the state of the need depth pre-pass value
  104597. */
  104598. private _needDepthPrePass;
  104599. /**
  104600. * Sets the need depth pre-pass value
  104601. */
  104602. set needDepthPrePass(value: boolean);
  104603. /**
  104604. * Gets the depth pre-pass value
  104605. */
  104606. get needDepthPrePass(): boolean;
  104607. /**
  104608. * Specifies if depth writing should be disabled
  104609. */
  104610. disableDepthWrite: boolean;
  104611. /**
  104612. * Specifies if color writing should be disabled
  104613. */
  104614. disableColorWrite: boolean;
  104615. /**
  104616. * Specifies if depth writing should be forced
  104617. */
  104618. forceDepthWrite: boolean;
  104619. /**
  104620. * Specifies the depth function that should be used. 0 means the default engine function
  104621. */
  104622. depthFunction: number;
  104623. /**
  104624. * Specifies if there should be a separate pass for culling
  104625. */
  104626. separateCullingPass: boolean;
  104627. /**
  104628. * Stores the state specifing if fog should be enabled
  104629. */
  104630. private _fogEnabled;
  104631. /**
  104632. * Sets the state for enabling fog
  104633. */
  104634. set fogEnabled(value: boolean);
  104635. /**
  104636. * Gets the value of the fog enabled state
  104637. */
  104638. get fogEnabled(): boolean;
  104639. /**
  104640. * Stores the size of points
  104641. */
  104642. pointSize: number;
  104643. /**
  104644. * Stores the z offset value
  104645. */
  104646. zOffset: number;
  104647. get wireframe(): boolean;
  104648. /**
  104649. * Sets the state of wireframe mode
  104650. */
  104651. set wireframe(value: boolean);
  104652. /**
  104653. * Gets the value specifying if point clouds are enabled
  104654. */
  104655. get pointsCloud(): boolean;
  104656. /**
  104657. * Sets the state of point cloud mode
  104658. */
  104659. set pointsCloud(value: boolean);
  104660. /**
  104661. * Gets the material fill mode
  104662. */
  104663. get fillMode(): number;
  104664. /**
  104665. * Sets the material fill mode
  104666. */
  104667. set fillMode(value: number);
  104668. /**
  104669. * @hidden
  104670. * Stores the effects for the material
  104671. */
  104672. _effect: Nullable<Effect>;
  104673. /**
  104674. * Specifies if uniform buffers should be used
  104675. */
  104676. private _useUBO;
  104677. /**
  104678. * Stores a reference to the scene
  104679. */
  104680. private _scene;
  104681. /**
  104682. * Stores the fill mode state
  104683. */
  104684. private _fillMode;
  104685. /**
  104686. * Specifies if the depth write state should be cached
  104687. */
  104688. private _cachedDepthWriteState;
  104689. /**
  104690. * Specifies if the color write state should be cached
  104691. */
  104692. private _cachedColorWriteState;
  104693. /**
  104694. * Specifies if the depth function state should be cached
  104695. */
  104696. private _cachedDepthFunctionState;
  104697. /**
  104698. * Stores the uniform buffer
  104699. */
  104700. protected _uniformBuffer: UniformBuffer;
  104701. /** @hidden */
  104702. _indexInSceneMaterialArray: number;
  104703. /** @hidden */
  104704. meshMap: Nullable<{
  104705. [id: string]: AbstractMesh | undefined;
  104706. }>;
  104707. /**
  104708. * Creates a material instance
  104709. * @param name defines the name of the material
  104710. * @param scene defines the scene to reference
  104711. * @param doNotAdd specifies if the material should be added to the scene
  104712. */
  104713. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  104714. /**
  104715. * Returns a string representation of the current material
  104716. * @param fullDetails defines a boolean indicating which levels of logging is desired
  104717. * @returns a string with material information
  104718. */
  104719. toString(fullDetails?: boolean): string;
  104720. /**
  104721. * Gets the class name of the material
  104722. * @returns a string with the class name of the material
  104723. */
  104724. getClassName(): string;
  104725. /**
  104726. * Specifies if updates for the material been locked
  104727. */
  104728. get isFrozen(): boolean;
  104729. /**
  104730. * Locks updates for the material
  104731. */
  104732. freeze(): void;
  104733. /**
  104734. * Unlocks updates for the material
  104735. */
  104736. unfreeze(): void;
  104737. /**
  104738. * Specifies if the material is ready to be used
  104739. * @param mesh defines the mesh to check
  104740. * @param useInstances specifies if instances should be used
  104741. * @returns a boolean indicating if the material is ready to be used
  104742. */
  104743. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  104744. /**
  104745. * Specifies that the submesh is ready to be used
  104746. * @param mesh defines the mesh to check
  104747. * @param subMesh defines which submesh to check
  104748. * @param useInstances specifies that instances should be used
  104749. * @returns a boolean indicating that the submesh is ready or not
  104750. */
  104751. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104752. /**
  104753. * Returns the material effect
  104754. * @returns the effect associated with the material
  104755. */
  104756. getEffect(): Nullable<Effect>;
  104757. /**
  104758. * Returns the current scene
  104759. * @returns a Scene
  104760. */
  104761. getScene(): Scene;
  104762. /**
  104763. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  104764. */
  104765. protected _forceAlphaTest: boolean;
  104766. /**
  104767. * The transparency mode of the material.
  104768. */
  104769. protected _transparencyMode: Nullable<number>;
  104770. /**
  104771. * Gets the current transparency mode.
  104772. */
  104773. get transparencyMode(): Nullable<number>;
  104774. /**
  104775. * Sets the transparency mode of the material.
  104776. *
  104777. * | Value | Type | Description |
  104778. * | ----- | ----------------------------------- | ----------- |
  104779. * | 0 | OPAQUE | |
  104780. * | 1 | ALPHATEST | |
  104781. * | 2 | ALPHABLEND | |
  104782. * | 3 | ALPHATESTANDBLEND | |
  104783. *
  104784. */
  104785. set transparencyMode(value: Nullable<number>);
  104786. /**
  104787. * Returns true if alpha blending should be disabled.
  104788. */
  104789. protected get _disableAlphaBlending(): boolean;
  104790. /**
  104791. * Specifies whether or not this material should be rendered in alpha blend mode.
  104792. * @returns a boolean specifying if alpha blending is needed
  104793. */
  104794. needAlphaBlending(): boolean;
  104795. /**
  104796. * Specifies if the mesh will require alpha blending
  104797. * @param mesh defines the mesh to check
  104798. * @returns a boolean specifying if alpha blending is needed for the mesh
  104799. */
  104800. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  104801. /**
  104802. * Specifies whether or not this material should be rendered in alpha test mode.
  104803. * @returns a boolean specifying if an alpha test is needed.
  104804. */
  104805. needAlphaTesting(): boolean;
  104806. /**
  104807. * Specifies if material alpha testing should be turned on for the mesh
  104808. * @param mesh defines the mesh to check
  104809. */
  104810. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  104811. /**
  104812. * Gets the texture used for the alpha test
  104813. * @returns the texture to use for alpha testing
  104814. */
  104815. getAlphaTestTexture(): Nullable<BaseTexture>;
  104816. /**
  104817. * Marks the material to indicate that it needs to be re-calculated
  104818. */
  104819. markDirty(): void;
  104820. /** @hidden */
  104821. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  104822. /**
  104823. * Binds the material to the mesh
  104824. * @param world defines the world transformation matrix
  104825. * @param mesh defines the mesh to bind the material to
  104826. */
  104827. bind(world: Matrix, mesh?: Mesh): void;
  104828. /**
  104829. * Binds the submesh to the material
  104830. * @param world defines the world transformation matrix
  104831. * @param mesh defines the mesh containing the submesh
  104832. * @param subMesh defines the submesh to bind the material to
  104833. */
  104834. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104835. /**
  104836. * Binds the world matrix to the material
  104837. * @param world defines the world transformation matrix
  104838. */
  104839. bindOnlyWorldMatrix(world: Matrix): void;
  104840. /**
  104841. * Binds the scene's uniform buffer to the effect.
  104842. * @param effect defines the effect to bind to the scene uniform buffer
  104843. * @param sceneUbo defines the uniform buffer storing scene data
  104844. */
  104845. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  104846. /**
  104847. * Binds the view matrix to the effect
  104848. * @param effect defines the effect to bind the view matrix to
  104849. */
  104850. bindView(effect: Effect): void;
  104851. /**
  104852. * Binds the view projection matrix to the effect
  104853. * @param effect defines the effect to bind the view projection matrix to
  104854. */
  104855. bindViewProjection(effect: Effect): void;
  104856. /**
  104857. * Processes to execute after binding the material to a mesh
  104858. * @param mesh defines the rendered mesh
  104859. */
  104860. protected _afterBind(mesh?: Mesh): void;
  104861. /**
  104862. * Unbinds the material from the mesh
  104863. */
  104864. unbind(): void;
  104865. /**
  104866. * Gets the active textures from the material
  104867. * @returns an array of textures
  104868. */
  104869. getActiveTextures(): BaseTexture[];
  104870. /**
  104871. * Specifies if the material uses a texture
  104872. * @param texture defines the texture to check against the material
  104873. * @returns a boolean specifying if the material uses the texture
  104874. */
  104875. hasTexture(texture: BaseTexture): boolean;
  104876. /**
  104877. * Makes a duplicate of the material, and gives it a new name
  104878. * @param name defines the new name for the duplicated material
  104879. * @returns the cloned material
  104880. */
  104881. clone(name: string): Nullable<Material>;
  104882. /**
  104883. * Gets the meshes bound to the material
  104884. * @returns an array of meshes bound to the material
  104885. */
  104886. getBindedMeshes(): AbstractMesh[];
  104887. /**
  104888. * Force shader compilation
  104889. * @param mesh defines the mesh associated with this material
  104890. * @param onCompiled defines a function to execute once the material is compiled
  104891. * @param options defines the options to configure the compilation
  104892. * @param onError defines a function to execute if the material fails compiling
  104893. */
  104894. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  104895. /**
  104896. * Force shader compilation
  104897. * @param mesh defines the mesh that will use this material
  104898. * @param options defines additional options for compiling the shaders
  104899. * @returns a promise that resolves when the compilation completes
  104900. */
  104901. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  104902. private static readonly _AllDirtyCallBack;
  104903. private static readonly _ImageProcessingDirtyCallBack;
  104904. private static readonly _TextureDirtyCallBack;
  104905. private static readonly _FresnelDirtyCallBack;
  104906. private static readonly _MiscDirtyCallBack;
  104907. private static readonly _LightsDirtyCallBack;
  104908. private static readonly _AttributeDirtyCallBack;
  104909. private static _FresnelAndMiscDirtyCallBack;
  104910. private static _TextureAndMiscDirtyCallBack;
  104911. private static readonly _DirtyCallbackArray;
  104912. private static readonly _RunDirtyCallBacks;
  104913. /**
  104914. * Marks a define in the material to indicate that it needs to be re-computed
  104915. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  104916. */
  104917. markAsDirty(flag: number): void;
  104918. /**
  104919. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  104920. * @param func defines a function which checks material defines against the submeshes
  104921. */
  104922. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  104923. /**
  104924. * Indicates that the scene should check if the rendering now needs a prepass
  104925. */
  104926. protected _markScenePrePassDirty(): void;
  104927. /**
  104928. * Indicates that we need to re-calculated for all submeshes
  104929. */
  104930. protected _markAllSubMeshesAsAllDirty(): void;
  104931. /**
  104932. * Indicates that image processing needs to be re-calculated for all submeshes
  104933. */
  104934. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  104935. /**
  104936. * Indicates that textures need to be re-calculated for all submeshes
  104937. */
  104938. protected _markAllSubMeshesAsTexturesDirty(): void;
  104939. /**
  104940. * Indicates that fresnel needs to be re-calculated for all submeshes
  104941. */
  104942. protected _markAllSubMeshesAsFresnelDirty(): void;
  104943. /**
  104944. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  104945. */
  104946. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  104947. /**
  104948. * Indicates that lights need to be re-calculated for all submeshes
  104949. */
  104950. protected _markAllSubMeshesAsLightsDirty(): void;
  104951. /**
  104952. * Indicates that attributes need to be re-calculated for all submeshes
  104953. */
  104954. protected _markAllSubMeshesAsAttributesDirty(): void;
  104955. /**
  104956. * Indicates that misc needs to be re-calculated for all submeshes
  104957. */
  104958. protected _markAllSubMeshesAsMiscDirty(): void;
  104959. /**
  104960. * Indicates that textures and misc need to be re-calculated for all submeshes
  104961. */
  104962. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  104963. /**
  104964. * Sets the required values to the prepass renderer.
  104965. * @param prePassRenderer defines the prepass renderer to setup.
  104966. * @returns true if the pre pass is needed.
  104967. */
  104968. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  104969. /**
  104970. * Disposes the material
  104971. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  104972. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  104973. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  104974. */
  104975. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  104976. /** @hidden */
  104977. private releaseVertexArrayObject;
  104978. /**
  104979. * Serializes this material
  104980. * @returns the serialized material object
  104981. */
  104982. serialize(): any;
  104983. /**
  104984. * Creates a material from parsed material data
  104985. * @param parsedMaterial defines parsed material data
  104986. * @param scene defines the hosting scene
  104987. * @param rootUrl defines the root URL to use to load textures
  104988. * @returns a new material
  104989. */
  104990. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  104991. }
  104992. }
  104993. declare module BABYLON {
  104994. /**
  104995. * A multi-material is used to apply different materials to different parts of the same object without the need of
  104996. * separate meshes. This can be use to improve performances.
  104997. * @see https://doc.babylonjs.com/how_to/multi_materials
  104998. */
  104999. export class MultiMaterial extends Material {
  105000. private _subMaterials;
  105001. /**
  105002. * Gets or Sets the list of Materials used within the multi material.
  105003. * They need to be ordered according to the submeshes order in the associated mesh
  105004. */
  105005. get subMaterials(): Nullable<Material>[];
  105006. set subMaterials(value: Nullable<Material>[]);
  105007. /**
  105008. * Function used to align with Node.getChildren()
  105009. * @returns the list of Materials used within the multi material
  105010. */
  105011. getChildren(): Nullable<Material>[];
  105012. /**
  105013. * Instantiates a new Multi Material
  105014. * A multi-material is used to apply different materials to different parts of the same object without the need of
  105015. * separate meshes. This can be use to improve performances.
  105016. * @see https://doc.babylonjs.com/how_to/multi_materials
  105017. * @param name Define the name in the scene
  105018. * @param scene Define the scene the material belongs to
  105019. */
  105020. constructor(name: string, scene: Scene);
  105021. private _hookArray;
  105022. /**
  105023. * Get one of the submaterial by its index in the submaterials array
  105024. * @param index The index to look the sub material at
  105025. * @returns The Material if the index has been defined
  105026. */
  105027. getSubMaterial(index: number): Nullable<Material>;
  105028. /**
  105029. * Get the list of active textures for the whole sub materials list.
  105030. * @returns All the textures that will be used during the rendering
  105031. */
  105032. getActiveTextures(): BaseTexture[];
  105033. /**
  105034. * Gets the current class name of the material e.g. "MultiMaterial"
  105035. * Mainly use in serialization.
  105036. * @returns the class name
  105037. */
  105038. getClassName(): string;
  105039. /**
  105040. * Checks if the material is ready to render the requested sub mesh
  105041. * @param mesh Define the mesh the submesh belongs to
  105042. * @param subMesh Define the sub mesh to look readyness for
  105043. * @param useInstances Define whether or not the material is used with instances
  105044. * @returns true if ready, otherwise false
  105045. */
  105046. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105047. /**
  105048. * Clones the current material and its related sub materials
  105049. * @param name Define the name of the newly cloned material
  105050. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  105051. * @returns the cloned material
  105052. */
  105053. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  105054. /**
  105055. * Serializes the materials into a JSON representation.
  105056. * @returns the JSON representation
  105057. */
  105058. serialize(): any;
  105059. /**
  105060. * Dispose the material and release its associated resources
  105061. * @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)
  105062. * @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)
  105063. * @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)
  105064. */
  105065. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  105066. /**
  105067. * Creates a MultiMaterial from parsed MultiMaterial data.
  105068. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  105069. * @param scene defines the hosting scene
  105070. * @returns a new MultiMaterial
  105071. */
  105072. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  105073. }
  105074. }
  105075. declare module BABYLON {
  105076. /**
  105077. * Defines a subdivision inside a mesh
  105078. */
  105079. export class SubMesh implements ICullable {
  105080. /** the material index to use */
  105081. materialIndex: number;
  105082. /** vertex index start */
  105083. verticesStart: number;
  105084. /** vertices count */
  105085. verticesCount: number;
  105086. /** index start */
  105087. indexStart: number;
  105088. /** indices count */
  105089. indexCount: number;
  105090. /** @hidden */
  105091. _materialDefines: Nullable<MaterialDefines>;
  105092. /** @hidden */
  105093. _materialEffect: Nullable<Effect>;
  105094. /** @hidden */
  105095. _effectOverride: Nullable<Effect>;
  105096. /**
  105097. * Gets material defines used by the effect associated to the sub mesh
  105098. */
  105099. get materialDefines(): Nullable<MaterialDefines>;
  105100. /**
  105101. * Sets material defines used by the effect associated to the sub mesh
  105102. */
  105103. set materialDefines(defines: Nullable<MaterialDefines>);
  105104. /**
  105105. * Gets associated effect
  105106. */
  105107. get effect(): Nullable<Effect>;
  105108. /**
  105109. * Sets associated effect (effect used to render this submesh)
  105110. * @param effect defines the effect to associate with
  105111. * @param defines defines the set of defines used to compile this effect
  105112. */
  105113. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  105114. /** @hidden */
  105115. _linesIndexCount: number;
  105116. private _mesh;
  105117. private _renderingMesh;
  105118. private _boundingInfo;
  105119. private _linesIndexBuffer;
  105120. /** @hidden */
  105121. _lastColliderWorldVertices: Nullable<Vector3[]>;
  105122. /** @hidden */
  105123. _trianglePlanes: Plane[];
  105124. /** @hidden */
  105125. _lastColliderTransformMatrix: Nullable<Matrix>;
  105126. /** @hidden */
  105127. _renderId: number;
  105128. /** @hidden */
  105129. _alphaIndex: number;
  105130. /** @hidden */
  105131. _distanceToCamera: number;
  105132. /** @hidden */
  105133. _id: number;
  105134. private _currentMaterial;
  105135. /**
  105136. * Add a new submesh to a mesh
  105137. * @param materialIndex defines the material index to use
  105138. * @param verticesStart defines vertex index start
  105139. * @param verticesCount defines vertices count
  105140. * @param indexStart defines index start
  105141. * @param indexCount defines indices count
  105142. * @param mesh defines the parent mesh
  105143. * @param renderingMesh defines an optional rendering mesh
  105144. * @param createBoundingBox defines if bounding box should be created for this submesh
  105145. * @returns the new submesh
  105146. */
  105147. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  105148. /**
  105149. * Creates a new submesh
  105150. * @param materialIndex defines the material index to use
  105151. * @param verticesStart defines vertex index start
  105152. * @param verticesCount defines vertices count
  105153. * @param indexStart defines index start
  105154. * @param indexCount defines indices count
  105155. * @param mesh defines the parent mesh
  105156. * @param renderingMesh defines an optional rendering mesh
  105157. * @param createBoundingBox defines if bounding box should be created for this submesh
  105158. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  105159. */
  105160. constructor(
  105161. /** the material index to use */
  105162. materialIndex: number,
  105163. /** vertex index start */
  105164. verticesStart: number,
  105165. /** vertices count */
  105166. verticesCount: number,
  105167. /** index start */
  105168. indexStart: number,
  105169. /** indices count */
  105170. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  105171. /**
  105172. * Returns true if this submesh covers the entire parent mesh
  105173. * @ignorenaming
  105174. */
  105175. get IsGlobal(): boolean;
  105176. /**
  105177. * Returns the submesh BoudingInfo object
  105178. * @returns current bounding info (or mesh's one if the submesh is global)
  105179. */
  105180. getBoundingInfo(): BoundingInfo;
  105181. /**
  105182. * Sets the submesh BoundingInfo
  105183. * @param boundingInfo defines the new bounding info to use
  105184. * @returns the SubMesh
  105185. */
  105186. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  105187. /**
  105188. * Returns the mesh of the current submesh
  105189. * @return the parent mesh
  105190. */
  105191. getMesh(): AbstractMesh;
  105192. /**
  105193. * Returns the rendering mesh of the submesh
  105194. * @returns the rendering mesh (could be different from parent mesh)
  105195. */
  105196. getRenderingMesh(): Mesh;
  105197. /**
  105198. * Returns the replacement mesh of the submesh
  105199. * @returns the replacement mesh (could be different from parent mesh)
  105200. */
  105201. getReplacementMesh(): Nullable<AbstractMesh>;
  105202. /**
  105203. * Returns the effective mesh of the submesh
  105204. * @returns the effective mesh (could be different from parent mesh)
  105205. */
  105206. getEffectiveMesh(): AbstractMesh;
  105207. /**
  105208. * Returns the submesh material
  105209. * @returns null or the current material
  105210. */
  105211. getMaterial(): Nullable<Material>;
  105212. private _IsMultiMaterial;
  105213. /**
  105214. * Sets a new updated BoundingInfo object to the submesh
  105215. * @param data defines an optional position array to use to determine the bounding info
  105216. * @returns the SubMesh
  105217. */
  105218. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  105219. /** @hidden */
  105220. _checkCollision(collider: Collider): boolean;
  105221. /**
  105222. * Updates the submesh BoundingInfo
  105223. * @param world defines the world matrix to use to update the bounding info
  105224. * @returns the submesh
  105225. */
  105226. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  105227. /**
  105228. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  105229. * @param frustumPlanes defines the frustum planes
  105230. * @returns true if the submesh is intersecting with the frustum
  105231. */
  105232. isInFrustum(frustumPlanes: Plane[]): boolean;
  105233. /**
  105234. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  105235. * @param frustumPlanes defines the frustum planes
  105236. * @returns true if the submesh is inside the frustum
  105237. */
  105238. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  105239. /**
  105240. * Renders the submesh
  105241. * @param enableAlphaMode defines if alpha needs to be used
  105242. * @returns the submesh
  105243. */
  105244. render(enableAlphaMode: boolean): SubMesh;
  105245. /**
  105246. * @hidden
  105247. */
  105248. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  105249. /**
  105250. * Checks if the submesh intersects with a ray
  105251. * @param ray defines the ray to test
  105252. * @returns true is the passed ray intersects the submesh bounding box
  105253. */
  105254. canIntersects(ray: Ray): boolean;
  105255. /**
  105256. * Intersects current submesh with a ray
  105257. * @param ray defines the ray to test
  105258. * @param positions defines mesh's positions array
  105259. * @param indices defines mesh's indices array
  105260. * @param fastCheck defines if the first intersection will be used (and not the closest)
  105261. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105262. * @returns intersection info or null if no intersection
  105263. */
  105264. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  105265. /** @hidden */
  105266. private _intersectLines;
  105267. /** @hidden */
  105268. private _intersectUnIndexedLines;
  105269. /** @hidden */
  105270. private _intersectTriangles;
  105271. /** @hidden */
  105272. private _intersectUnIndexedTriangles;
  105273. /** @hidden */
  105274. _rebuild(): void;
  105275. /**
  105276. * Creates a new submesh from the passed mesh
  105277. * @param newMesh defines the new hosting mesh
  105278. * @param newRenderingMesh defines an optional rendering mesh
  105279. * @returns the new submesh
  105280. */
  105281. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  105282. /**
  105283. * Release associated resources
  105284. */
  105285. dispose(): void;
  105286. /**
  105287. * Gets the class name
  105288. * @returns the string "SubMesh".
  105289. */
  105290. getClassName(): string;
  105291. /**
  105292. * Creates a new submesh from indices data
  105293. * @param materialIndex the index of the main mesh material
  105294. * @param startIndex the index where to start the copy in the mesh indices array
  105295. * @param indexCount the number of indices to copy then from the startIndex
  105296. * @param mesh the main mesh to create the submesh from
  105297. * @param renderingMesh the optional rendering mesh
  105298. * @returns a new submesh
  105299. */
  105300. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  105301. }
  105302. }
  105303. declare module BABYLON {
  105304. /**
  105305. * Class used to represent data loading progression
  105306. */
  105307. export class SceneLoaderFlags {
  105308. private static _ForceFullSceneLoadingForIncremental;
  105309. private static _ShowLoadingScreen;
  105310. private static _CleanBoneMatrixWeights;
  105311. private static _loggingLevel;
  105312. /**
  105313. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105314. */
  105315. static get ForceFullSceneLoadingForIncremental(): boolean;
  105316. static set ForceFullSceneLoadingForIncremental(value: boolean);
  105317. /**
  105318. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105319. */
  105320. static get ShowLoadingScreen(): boolean;
  105321. static set ShowLoadingScreen(value: boolean);
  105322. /**
  105323. * Defines the current logging level (while loading the scene)
  105324. * @ignorenaming
  105325. */
  105326. static get loggingLevel(): number;
  105327. static set loggingLevel(value: number);
  105328. /**
  105329. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105330. */
  105331. static get CleanBoneMatrixWeights(): boolean;
  105332. static set CleanBoneMatrixWeights(value: boolean);
  105333. }
  105334. }
  105335. declare module BABYLON {
  105336. /**
  105337. * Class used to store geometry data (vertex buffers + index buffer)
  105338. */
  105339. export class Geometry implements IGetSetVerticesData {
  105340. /**
  105341. * Gets or sets the ID of the geometry
  105342. */
  105343. id: string;
  105344. /**
  105345. * Gets or sets the unique ID of the geometry
  105346. */
  105347. uniqueId: number;
  105348. /**
  105349. * Gets the delay loading state of the geometry (none by default which means not delayed)
  105350. */
  105351. delayLoadState: number;
  105352. /**
  105353. * Gets the file containing the data to load when running in delay load state
  105354. */
  105355. delayLoadingFile: Nullable<string>;
  105356. /**
  105357. * Callback called when the geometry is updated
  105358. */
  105359. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  105360. private _scene;
  105361. private _engine;
  105362. private _meshes;
  105363. private _totalVertices;
  105364. /** @hidden */
  105365. _indices: IndicesArray;
  105366. /** @hidden */
  105367. _vertexBuffers: {
  105368. [key: string]: VertexBuffer;
  105369. };
  105370. private _isDisposed;
  105371. private _extend;
  105372. private _boundingBias;
  105373. /** @hidden */
  105374. _delayInfo: Array<string>;
  105375. private _indexBuffer;
  105376. private _indexBufferIsUpdatable;
  105377. /** @hidden */
  105378. _boundingInfo: Nullable<BoundingInfo>;
  105379. /** @hidden */
  105380. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  105381. /** @hidden */
  105382. _softwareSkinningFrameId: number;
  105383. private _vertexArrayObjects;
  105384. private _updatable;
  105385. /** @hidden */
  105386. _positions: Nullable<Vector3[]>;
  105387. /**
  105388. * 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
  105389. */
  105390. get boundingBias(): Vector2;
  105391. /**
  105392. * 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
  105393. */
  105394. set boundingBias(value: Vector2);
  105395. /**
  105396. * Static function used to attach a new empty geometry to a mesh
  105397. * @param mesh defines the mesh to attach the geometry to
  105398. * @returns the new Geometry
  105399. */
  105400. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  105401. /** Get the list of meshes using this geometry */
  105402. get meshes(): Mesh[];
  105403. /**
  105404. * 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
  105405. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  105406. */
  105407. useBoundingInfoFromGeometry: boolean;
  105408. /**
  105409. * Creates a new geometry
  105410. * @param id defines the unique ID
  105411. * @param scene defines the hosting scene
  105412. * @param vertexData defines the VertexData used to get geometry data
  105413. * @param updatable defines if geometry must be updatable (false by default)
  105414. * @param mesh defines the mesh that will be associated with the geometry
  105415. */
  105416. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  105417. /**
  105418. * Gets the current extend of the geometry
  105419. */
  105420. get extend(): {
  105421. minimum: Vector3;
  105422. maximum: Vector3;
  105423. };
  105424. /**
  105425. * Gets the hosting scene
  105426. * @returns the hosting Scene
  105427. */
  105428. getScene(): Scene;
  105429. /**
  105430. * Gets the hosting engine
  105431. * @returns the hosting Engine
  105432. */
  105433. getEngine(): Engine;
  105434. /**
  105435. * Defines if the geometry is ready to use
  105436. * @returns true if the geometry is ready to be used
  105437. */
  105438. isReady(): boolean;
  105439. /**
  105440. * Gets a value indicating that the geometry should not be serialized
  105441. */
  105442. get doNotSerialize(): boolean;
  105443. /** @hidden */
  105444. _rebuild(): void;
  105445. /**
  105446. * Affects all geometry data in one call
  105447. * @param vertexData defines the geometry data
  105448. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  105449. */
  105450. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  105451. /**
  105452. * Set specific vertex data
  105453. * @param kind defines the data kind (Position, normal, etc...)
  105454. * @param data defines the vertex data to use
  105455. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  105456. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  105457. */
  105458. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  105459. /**
  105460. * Removes a specific vertex data
  105461. * @param kind defines the data kind (Position, normal, etc...)
  105462. */
  105463. removeVerticesData(kind: string): void;
  105464. /**
  105465. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  105466. * @param buffer defines the vertex buffer to use
  105467. * @param totalVertices defines the total number of vertices for position kind (could be null)
  105468. */
  105469. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  105470. /**
  105471. * Update a specific vertex buffer
  105472. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  105473. * It will do nothing if the buffer is not updatable
  105474. * @param kind defines the data kind (Position, normal, etc...)
  105475. * @param data defines the data to use
  105476. * @param offset defines the offset in the target buffer where to store the data
  105477. * @param useBytes set to true if the offset is in bytes
  105478. */
  105479. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  105480. /**
  105481. * Update a specific vertex buffer
  105482. * This function will create a new buffer if the current one is not updatable
  105483. * @param kind defines the data kind (Position, normal, etc...)
  105484. * @param data defines the data to use
  105485. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  105486. */
  105487. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  105488. private _updateBoundingInfo;
  105489. /** @hidden */
  105490. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  105491. /**
  105492. * Gets total number of vertices
  105493. * @returns the total number of vertices
  105494. */
  105495. getTotalVertices(): number;
  105496. /**
  105497. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  105498. * @param kind defines the data kind (Position, normal, etc...)
  105499. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  105500. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105501. * @returns a float array containing vertex data
  105502. */
  105503. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  105504. /**
  105505. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  105506. * @param kind defines the data kind (Position, normal, etc...)
  105507. * @returns true if the vertex buffer with the specified kind is updatable
  105508. */
  105509. isVertexBufferUpdatable(kind: string): boolean;
  105510. /**
  105511. * Gets a specific vertex buffer
  105512. * @param kind defines the data kind (Position, normal, etc...)
  105513. * @returns a VertexBuffer
  105514. */
  105515. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  105516. /**
  105517. * Returns all vertex buffers
  105518. * @return an object holding all vertex buffers indexed by kind
  105519. */
  105520. getVertexBuffers(): Nullable<{
  105521. [key: string]: VertexBuffer;
  105522. }>;
  105523. /**
  105524. * Gets a boolean indicating if specific vertex buffer is present
  105525. * @param kind defines the data kind (Position, normal, etc...)
  105526. * @returns true if data is present
  105527. */
  105528. isVerticesDataPresent(kind: string): boolean;
  105529. /**
  105530. * Gets a list of all attached data kinds (Position, normal, etc...)
  105531. * @returns a list of string containing all kinds
  105532. */
  105533. getVerticesDataKinds(): string[];
  105534. /**
  105535. * Update index buffer
  105536. * @param indices defines the indices to store in the index buffer
  105537. * @param offset defines the offset in the target buffer where to store the data
  105538. * @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)
  105539. */
  105540. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  105541. /**
  105542. * Creates a new index buffer
  105543. * @param indices defines the indices to store in the index buffer
  105544. * @param totalVertices defines the total number of vertices (could be null)
  105545. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  105546. */
  105547. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  105548. /**
  105549. * Return the total number of indices
  105550. * @returns the total number of indices
  105551. */
  105552. getTotalIndices(): number;
  105553. /**
  105554. * Gets the index buffer array
  105555. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  105556. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105557. * @returns the index buffer array
  105558. */
  105559. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  105560. /**
  105561. * Gets the index buffer
  105562. * @return the index buffer
  105563. */
  105564. getIndexBuffer(): Nullable<DataBuffer>;
  105565. /** @hidden */
  105566. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  105567. /**
  105568. * Release the associated resources for a specific mesh
  105569. * @param mesh defines the source mesh
  105570. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  105571. */
  105572. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  105573. /**
  105574. * Apply current geometry to a given mesh
  105575. * @param mesh defines the mesh to apply geometry to
  105576. */
  105577. applyToMesh(mesh: Mesh): void;
  105578. private _updateExtend;
  105579. private _applyToMesh;
  105580. private notifyUpdate;
  105581. /**
  105582. * Load the geometry if it was flagged as delay loaded
  105583. * @param scene defines the hosting scene
  105584. * @param onLoaded defines a callback called when the geometry is loaded
  105585. */
  105586. load(scene: Scene, onLoaded?: () => void): void;
  105587. private _queueLoad;
  105588. /**
  105589. * Invert the geometry to move from a right handed system to a left handed one.
  105590. */
  105591. toLeftHanded(): void;
  105592. /** @hidden */
  105593. _resetPointsArrayCache(): void;
  105594. /** @hidden */
  105595. _generatePointsArray(): boolean;
  105596. /**
  105597. * Gets a value indicating if the geometry is disposed
  105598. * @returns true if the geometry was disposed
  105599. */
  105600. isDisposed(): boolean;
  105601. private _disposeVertexArrayObjects;
  105602. /**
  105603. * Free all associated resources
  105604. */
  105605. dispose(): void;
  105606. /**
  105607. * Clone the current geometry into a new geometry
  105608. * @param id defines the unique ID of the new geometry
  105609. * @returns a new geometry object
  105610. */
  105611. copy(id: string): Geometry;
  105612. /**
  105613. * Serialize the current geometry info (and not the vertices data) into a JSON object
  105614. * @return a JSON representation of the current geometry data (without the vertices data)
  105615. */
  105616. serialize(): any;
  105617. private toNumberArray;
  105618. /**
  105619. * Serialize all vertices data into a JSON oject
  105620. * @returns a JSON representation of the current geometry data
  105621. */
  105622. serializeVerticeData(): any;
  105623. /**
  105624. * Extracts a clone of a mesh geometry
  105625. * @param mesh defines the source mesh
  105626. * @param id defines the unique ID of the new geometry object
  105627. * @returns the new geometry object
  105628. */
  105629. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  105630. /**
  105631. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  105632. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  105633. * Be aware Math.random() could cause collisions, but:
  105634. * "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"
  105635. * @returns a string containing a new GUID
  105636. */
  105637. static RandomId(): string;
  105638. /** @hidden */
  105639. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  105640. private static _CleanMatricesWeights;
  105641. /**
  105642. * Create a new geometry from persisted data (Using .babylon file format)
  105643. * @param parsedVertexData defines the persisted data
  105644. * @param scene defines the hosting scene
  105645. * @param rootUrl defines the root url to use to load assets (like delayed data)
  105646. * @returns the new geometry object
  105647. */
  105648. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  105649. }
  105650. }
  105651. declare module BABYLON {
  105652. /**
  105653. * Define an interface for all classes that will get and set the data on vertices
  105654. */
  105655. export interface IGetSetVerticesData {
  105656. /**
  105657. * Gets a boolean indicating if specific vertex data is present
  105658. * @param kind defines the vertex data kind to use
  105659. * @returns true is data kind is present
  105660. */
  105661. isVerticesDataPresent(kind: string): boolean;
  105662. /**
  105663. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  105664. * @param kind defines the data kind (Position, normal, etc...)
  105665. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  105666. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105667. * @returns a float array containing vertex data
  105668. */
  105669. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  105670. /**
  105671. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  105672. * @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.
  105673. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105674. * @returns the indices array or an empty array if the mesh has no geometry
  105675. */
  105676. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  105677. /**
  105678. * Set specific vertex data
  105679. * @param kind defines the data kind (Position, normal, etc...)
  105680. * @param data defines the vertex data to use
  105681. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  105682. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  105683. */
  105684. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  105685. /**
  105686. * Update a specific associated vertex buffer
  105687. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105688. * - VertexBuffer.PositionKind
  105689. * - VertexBuffer.UVKind
  105690. * - VertexBuffer.UV2Kind
  105691. * - VertexBuffer.UV3Kind
  105692. * - VertexBuffer.UV4Kind
  105693. * - VertexBuffer.UV5Kind
  105694. * - VertexBuffer.UV6Kind
  105695. * - VertexBuffer.ColorKind
  105696. * - VertexBuffer.MatricesIndicesKind
  105697. * - VertexBuffer.MatricesIndicesExtraKind
  105698. * - VertexBuffer.MatricesWeightsKind
  105699. * - VertexBuffer.MatricesWeightsExtraKind
  105700. * @param data defines the data source
  105701. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  105702. * @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)
  105703. */
  105704. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  105705. /**
  105706. * Creates a new index buffer
  105707. * @param indices defines the indices to store in the index buffer
  105708. * @param totalVertices defines the total number of vertices (could be null)
  105709. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  105710. */
  105711. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  105712. }
  105713. /**
  105714. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  105715. */
  105716. export class VertexData {
  105717. /**
  105718. * Mesh side orientation : usually the external or front surface
  105719. */
  105720. static readonly FRONTSIDE: number;
  105721. /**
  105722. * Mesh side orientation : usually the internal or back surface
  105723. */
  105724. static readonly BACKSIDE: number;
  105725. /**
  105726. * Mesh side orientation : both internal and external or front and back surfaces
  105727. */
  105728. static readonly DOUBLESIDE: number;
  105729. /**
  105730. * Mesh side orientation : by default, `FRONTSIDE`
  105731. */
  105732. static readonly DEFAULTSIDE: number;
  105733. /**
  105734. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  105735. */
  105736. positions: Nullable<FloatArray>;
  105737. /**
  105738. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  105739. */
  105740. normals: Nullable<FloatArray>;
  105741. /**
  105742. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  105743. */
  105744. tangents: Nullable<FloatArray>;
  105745. /**
  105746. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105747. */
  105748. uvs: Nullable<FloatArray>;
  105749. /**
  105750. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105751. */
  105752. uvs2: Nullable<FloatArray>;
  105753. /**
  105754. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105755. */
  105756. uvs3: Nullable<FloatArray>;
  105757. /**
  105758. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105759. */
  105760. uvs4: Nullable<FloatArray>;
  105761. /**
  105762. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105763. */
  105764. uvs5: Nullable<FloatArray>;
  105765. /**
  105766. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  105767. */
  105768. uvs6: Nullable<FloatArray>;
  105769. /**
  105770. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  105771. */
  105772. colors: Nullable<FloatArray>;
  105773. /**
  105774. * 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).
  105775. */
  105776. matricesIndices: Nullable<FloatArray>;
  105777. /**
  105778. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  105779. */
  105780. matricesWeights: Nullable<FloatArray>;
  105781. /**
  105782. * An array extending the number of possible indices
  105783. */
  105784. matricesIndicesExtra: Nullable<FloatArray>;
  105785. /**
  105786. * An array extending the number of possible weights when the number of indices is extended
  105787. */
  105788. matricesWeightsExtra: Nullable<FloatArray>;
  105789. /**
  105790. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  105791. */
  105792. indices: Nullable<IndicesArray>;
  105793. /**
  105794. * Uses the passed data array to set the set the values for the specified kind of data
  105795. * @param data a linear array of floating numbers
  105796. * @param kind the type of data that is being set, eg positions, colors etc
  105797. */
  105798. set(data: FloatArray, kind: string): void;
  105799. /**
  105800. * Associates the vertexData to the passed Mesh.
  105801. * Sets it as updatable or not (default `false`)
  105802. * @param mesh the mesh the vertexData is applied to
  105803. * @param updatable when used and having the value true allows new data to update the vertexData
  105804. * @returns the VertexData
  105805. */
  105806. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  105807. /**
  105808. * Associates the vertexData to the passed Geometry.
  105809. * Sets it as updatable or not (default `false`)
  105810. * @param geometry the geometry the vertexData is applied to
  105811. * @param updatable when used and having the value true allows new data to update the vertexData
  105812. * @returns VertexData
  105813. */
  105814. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  105815. /**
  105816. * Updates the associated mesh
  105817. * @param mesh the mesh to be updated
  105818. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  105819. * @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
  105820. * @returns VertexData
  105821. */
  105822. updateMesh(mesh: Mesh): VertexData;
  105823. /**
  105824. * Updates the associated geometry
  105825. * @param geometry the geometry to be updated
  105826. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  105827. * @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
  105828. * @returns VertexData.
  105829. */
  105830. updateGeometry(geometry: Geometry): VertexData;
  105831. private _applyTo;
  105832. private _update;
  105833. /**
  105834. * Transforms each position and each normal of the vertexData according to the passed Matrix
  105835. * @param matrix the transforming matrix
  105836. * @returns the VertexData
  105837. */
  105838. transform(matrix: Matrix): VertexData;
  105839. /**
  105840. * Merges the passed VertexData into the current one
  105841. * @param other the VertexData to be merged into the current one
  105842. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  105843. * @returns the modified VertexData
  105844. */
  105845. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  105846. private _mergeElement;
  105847. private _validate;
  105848. /**
  105849. * Serializes the VertexData
  105850. * @returns a serialized object
  105851. */
  105852. serialize(): any;
  105853. /**
  105854. * Extracts the vertexData from a mesh
  105855. * @param mesh the mesh from which to extract the VertexData
  105856. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  105857. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  105858. * @returns the object VertexData associated to the passed mesh
  105859. */
  105860. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  105861. /**
  105862. * Extracts the vertexData from the geometry
  105863. * @param geometry the geometry from which to extract the VertexData
  105864. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  105865. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  105866. * @returns the object VertexData associated to the passed mesh
  105867. */
  105868. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  105869. private static _ExtractFrom;
  105870. /**
  105871. * Creates the VertexData for a Ribbon
  105872. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  105873. * * pathArray array of paths, each of which an array of successive Vector3
  105874. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  105875. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  105876. * * 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
  105877. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105878. * * 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)
  105879. * * 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)
  105880. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  105881. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  105882. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  105883. * @returns the VertexData of the ribbon
  105884. */
  105885. static CreateRibbon(options: {
  105886. pathArray: Vector3[][];
  105887. closeArray?: boolean;
  105888. closePath?: boolean;
  105889. offset?: number;
  105890. sideOrientation?: number;
  105891. frontUVs?: Vector4;
  105892. backUVs?: Vector4;
  105893. invertUV?: boolean;
  105894. uvs?: Vector2[];
  105895. colors?: Color4[];
  105896. }): VertexData;
  105897. /**
  105898. * Creates the VertexData for a box
  105899. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105900. * * size sets the width, height and depth of the box to the value of size, optional default 1
  105901. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  105902. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  105903. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  105904. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  105905. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  105906. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105907. * * 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)
  105908. * * 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)
  105909. * @returns the VertexData of the box
  105910. */
  105911. static CreateBox(options: {
  105912. size?: number;
  105913. width?: number;
  105914. height?: number;
  105915. depth?: number;
  105916. faceUV?: Vector4[];
  105917. faceColors?: Color4[];
  105918. sideOrientation?: number;
  105919. frontUVs?: Vector4;
  105920. backUVs?: Vector4;
  105921. }): VertexData;
  105922. /**
  105923. * Creates the VertexData for a tiled box
  105924. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105925. * * faceTiles sets the pattern, tile size and number of tiles for a face
  105926. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  105927. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  105928. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105929. * @returns the VertexData of the box
  105930. */
  105931. static CreateTiledBox(options: {
  105932. pattern?: number;
  105933. width?: number;
  105934. height?: number;
  105935. depth?: number;
  105936. tileSize?: number;
  105937. tileWidth?: number;
  105938. tileHeight?: number;
  105939. alignHorizontal?: number;
  105940. alignVertical?: number;
  105941. faceUV?: Vector4[];
  105942. faceColors?: Color4[];
  105943. sideOrientation?: number;
  105944. }): VertexData;
  105945. /**
  105946. * Creates the VertexData for a tiled plane
  105947. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105948. * * pattern a limited pattern arrangement depending on the number
  105949. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  105950. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  105951. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  105952. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105953. * * 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)
  105954. * * 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)
  105955. * @returns the VertexData of the tiled plane
  105956. */
  105957. static CreateTiledPlane(options: {
  105958. pattern?: number;
  105959. tileSize?: number;
  105960. tileWidth?: number;
  105961. tileHeight?: number;
  105962. size?: number;
  105963. width?: number;
  105964. height?: number;
  105965. alignHorizontal?: number;
  105966. alignVertical?: number;
  105967. sideOrientation?: number;
  105968. frontUVs?: Vector4;
  105969. backUVs?: Vector4;
  105970. }): VertexData;
  105971. /**
  105972. * Creates the VertexData for an ellipsoid, defaults to a sphere
  105973. * @param options an object used to set the following optional parameters for the box, required but can be empty
  105974. * * segments sets the number of horizontal strips optional, default 32
  105975. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  105976. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  105977. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  105978. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  105979. * * 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
  105980. * * 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
  105981. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105982. * * 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)
  105983. * * 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)
  105984. * @returns the VertexData of the ellipsoid
  105985. */
  105986. static CreateSphere(options: {
  105987. segments?: number;
  105988. diameter?: number;
  105989. diameterX?: number;
  105990. diameterY?: number;
  105991. diameterZ?: number;
  105992. arc?: number;
  105993. slice?: number;
  105994. sideOrientation?: number;
  105995. frontUVs?: Vector4;
  105996. backUVs?: Vector4;
  105997. }): VertexData;
  105998. /**
  105999. * Creates the VertexData for a cylinder, cone or prism
  106000. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106001. * * height sets the height (y direction) of the cylinder, optional, default 2
  106002. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  106003. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  106004. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  106005. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  106006. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  106007. * * 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
  106008. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106009. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106010. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  106011. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  106012. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106013. * * 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)
  106014. * * 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)
  106015. * @returns the VertexData of the cylinder, cone or prism
  106016. */
  106017. static CreateCylinder(options: {
  106018. height?: number;
  106019. diameterTop?: number;
  106020. diameterBottom?: number;
  106021. diameter?: number;
  106022. tessellation?: number;
  106023. subdivisions?: number;
  106024. arc?: number;
  106025. faceColors?: Color4[];
  106026. faceUV?: Vector4[];
  106027. hasRings?: boolean;
  106028. enclose?: boolean;
  106029. sideOrientation?: number;
  106030. frontUVs?: Vector4;
  106031. backUVs?: Vector4;
  106032. }): VertexData;
  106033. /**
  106034. * Creates the VertexData for a torus
  106035. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106036. * * diameter the diameter of the torus, optional default 1
  106037. * * thickness the diameter of the tube forming the torus, optional default 0.5
  106038. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  106039. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106040. * * 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)
  106041. * * 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)
  106042. * @returns the VertexData of the torus
  106043. */
  106044. static CreateTorus(options: {
  106045. diameter?: number;
  106046. thickness?: number;
  106047. tessellation?: number;
  106048. sideOrientation?: number;
  106049. frontUVs?: Vector4;
  106050. backUVs?: Vector4;
  106051. }): VertexData;
  106052. /**
  106053. * Creates the VertexData of the LineSystem
  106054. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  106055. * - lines an array of lines, each line being an array of successive Vector3
  106056. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  106057. * @returns the VertexData of the LineSystem
  106058. */
  106059. static CreateLineSystem(options: {
  106060. lines: Vector3[][];
  106061. colors?: Nullable<Color4[][]>;
  106062. }): VertexData;
  106063. /**
  106064. * Create the VertexData for a DashedLines
  106065. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  106066. * - points an array successive Vector3
  106067. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  106068. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  106069. * - dashNb the intended total number of dashes, optional, default 200
  106070. * @returns the VertexData for the DashedLines
  106071. */
  106072. static CreateDashedLines(options: {
  106073. points: Vector3[];
  106074. dashSize?: number;
  106075. gapSize?: number;
  106076. dashNb?: number;
  106077. }): VertexData;
  106078. /**
  106079. * Creates the VertexData for a Ground
  106080. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  106081. * - width the width (x direction) of the ground, optional, default 1
  106082. * - height the height (z direction) of the ground, optional, default 1
  106083. * - subdivisions the number of subdivisions per side, optional, default 1
  106084. * @returns the VertexData of the Ground
  106085. */
  106086. static CreateGround(options: {
  106087. width?: number;
  106088. height?: number;
  106089. subdivisions?: number;
  106090. subdivisionsX?: number;
  106091. subdivisionsY?: number;
  106092. }): VertexData;
  106093. /**
  106094. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  106095. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  106096. * * xmin the ground minimum X coordinate, optional, default -1
  106097. * * zmin the ground minimum Z coordinate, optional, default -1
  106098. * * xmax the ground maximum X coordinate, optional, default 1
  106099. * * zmax the ground maximum Z coordinate, optional, default 1
  106100. * * 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}
  106101. * * 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}
  106102. * @returns the VertexData of the TiledGround
  106103. */
  106104. static CreateTiledGround(options: {
  106105. xmin: number;
  106106. zmin: number;
  106107. xmax: number;
  106108. zmax: number;
  106109. subdivisions?: {
  106110. w: number;
  106111. h: number;
  106112. };
  106113. precision?: {
  106114. w: number;
  106115. h: number;
  106116. };
  106117. }): VertexData;
  106118. /**
  106119. * Creates the VertexData of the Ground designed from a heightmap
  106120. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  106121. * * width the width (x direction) of the ground
  106122. * * height the height (z direction) of the ground
  106123. * * subdivisions the number of subdivisions per side
  106124. * * minHeight the minimum altitude on the ground, optional, default 0
  106125. * * maxHeight the maximum altitude on the ground, optional default 1
  106126. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  106127. * * buffer the array holding the image color data
  106128. * * bufferWidth the width of image
  106129. * * bufferHeight the height of image
  106130. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  106131. * @returns the VertexData of the Ground designed from a heightmap
  106132. */
  106133. static CreateGroundFromHeightMap(options: {
  106134. width: number;
  106135. height: number;
  106136. subdivisions: number;
  106137. minHeight: number;
  106138. maxHeight: number;
  106139. colorFilter: Color3;
  106140. buffer: Uint8Array;
  106141. bufferWidth: number;
  106142. bufferHeight: number;
  106143. alphaFilter: number;
  106144. }): VertexData;
  106145. /**
  106146. * Creates the VertexData for a Plane
  106147. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  106148. * * size sets the width and height of the plane to the value of size, optional default 1
  106149. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  106150. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  106151. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106152. * * 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)
  106153. * * 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)
  106154. * @returns the VertexData of the box
  106155. */
  106156. static CreatePlane(options: {
  106157. size?: number;
  106158. width?: number;
  106159. height?: number;
  106160. sideOrientation?: number;
  106161. frontUVs?: Vector4;
  106162. backUVs?: Vector4;
  106163. }): VertexData;
  106164. /**
  106165. * Creates the VertexData of the Disc or regular Polygon
  106166. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  106167. * * radius the radius of the disc, optional default 0.5
  106168. * * tessellation the number of polygon sides, optional, default 64
  106169. * * 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
  106170. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106171. * * 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)
  106172. * * 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)
  106173. * @returns the VertexData of the box
  106174. */
  106175. static CreateDisc(options: {
  106176. radius?: number;
  106177. tessellation?: number;
  106178. arc?: number;
  106179. sideOrientation?: number;
  106180. frontUVs?: Vector4;
  106181. backUVs?: Vector4;
  106182. }): VertexData;
  106183. /**
  106184. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  106185. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  106186. * @param polygon a mesh built from polygonTriangulation.build()
  106187. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106188. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106189. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106190. * @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)
  106191. * @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)
  106192. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  106193. * @returns the VertexData of the Polygon
  106194. */
  106195. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  106196. /**
  106197. * Creates the VertexData of the IcoSphere
  106198. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  106199. * * radius the radius of the IcoSphere, optional default 1
  106200. * * radiusX allows stretching in the x direction, optional, default radius
  106201. * * radiusY allows stretching in the y direction, optional, default radius
  106202. * * radiusZ allows stretching in the z direction, optional, default radius
  106203. * * flat when true creates a flat shaded mesh, optional, default true
  106204. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  106205. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106206. * * 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)
  106207. * * 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)
  106208. * @returns the VertexData of the IcoSphere
  106209. */
  106210. static CreateIcoSphere(options: {
  106211. radius?: number;
  106212. radiusX?: number;
  106213. radiusY?: number;
  106214. radiusZ?: number;
  106215. flat?: boolean;
  106216. subdivisions?: number;
  106217. sideOrientation?: number;
  106218. frontUVs?: Vector4;
  106219. backUVs?: Vector4;
  106220. }): VertexData;
  106221. /**
  106222. * Creates the VertexData for a Polyhedron
  106223. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  106224. * * type provided types are:
  106225. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  106226. * * 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)
  106227. * * size the size of the IcoSphere, optional default 1
  106228. * * sizeX allows stretching in the x direction, optional, default size
  106229. * * sizeY allows stretching in the y direction, optional, default size
  106230. * * sizeZ allows stretching in the z direction, optional, default size
  106231. * * 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
  106232. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106233. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106234. * * flat when true creates a flat shaded mesh, optional, default true
  106235. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  106236. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106237. * * 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)
  106238. * * 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)
  106239. * @returns the VertexData of the Polyhedron
  106240. */
  106241. static CreatePolyhedron(options: {
  106242. type?: number;
  106243. size?: number;
  106244. sizeX?: number;
  106245. sizeY?: number;
  106246. sizeZ?: number;
  106247. custom?: any;
  106248. faceUV?: Vector4[];
  106249. faceColors?: Color4[];
  106250. flat?: boolean;
  106251. sideOrientation?: number;
  106252. frontUVs?: Vector4;
  106253. backUVs?: Vector4;
  106254. }): VertexData;
  106255. /**
  106256. * Creates the VertexData for a TorusKnot
  106257. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  106258. * * radius the radius of the torus knot, optional, default 2
  106259. * * tube the thickness of the tube, optional, default 0.5
  106260. * * radialSegments the number of sides on each tube segments, optional, default 32
  106261. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  106262. * * p the number of windings around the z axis, optional, default 2
  106263. * * q the number of windings around the x axis, optional, default 3
  106264. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106265. * * 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)
  106266. * * 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)
  106267. * @returns the VertexData of the Torus Knot
  106268. */
  106269. static CreateTorusKnot(options: {
  106270. radius?: number;
  106271. tube?: number;
  106272. radialSegments?: number;
  106273. tubularSegments?: number;
  106274. p?: number;
  106275. q?: number;
  106276. sideOrientation?: number;
  106277. frontUVs?: Vector4;
  106278. backUVs?: Vector4;
  106279. }): VertexData;
  106280. /**
  106281. * Compute normals for given positions and indices
  106282. * @param positions an array of vertex positions, [...., x, y, z, ......]
  106283. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  106284. * @param normals an array of vertex normals, [...., x, y, z, ......]
  106285. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  106286. * * facetNormals : optional array of facet normals (vector3)
  106287. * * facetPositions : optional array of facet positions (vector3)
  106288. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  106289. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  106290. * * bInfo : optional bounding info, required for facetPartitioning computation
  106291. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  106292. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  106293. * * useRightHandedSystem: optional boolean to for right handed system computation
  106294. * * depthSort : optional boolean to enable the facet depth sort computation
  106295. * * distanceTo : optional Vector3 to compute the facet depth from this location
  106296. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  106297. */
  106298. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  106299. facetNormals?: any;
  106300. facetPositions?: any;
  106301. facetPartitioning?: any;
  106302. ratio?: number;
  106303. bInfo?: any;
  106304. bbSize?: Vector3;
  106305. subDiv?: any;
  106306. useRightHandedSystem?: boolean;
  106307. depthSort?: boolean;
  106308. distanceTo?: Vector3;
  106309. depthSortedFacets?: any;
  106310. }): void;
  106311. /** @hidden */
  106312. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  106313. /**
  106314. * Applies VertexData created from the imported parameters to the geometry
  106315. * @param parsedVertexData the parsed data from an imported file
  106316. * @param geometry the geometry to apply the VertexData to
  106317. */
  106318. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  106319. }
  106320. }
  106321. declare module BABYLON {
  106322. /**
  106323. * Defines a target to use with MorphTargetManager
  106324. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  106325. */
  106326. export class MorphTarget implements IAnimatable {
  106327. /** defines the name of the target */
  106328. name: string;
  106329. /**
  106330. * Gets or sets the list of animations
  106331. */
  106332. animations: Animation[];
  106333. private _scene;
  106334. private _positions;
  106335. private _normals;
  106336. private _tangents;
  106337. private _uvs;
  106338. private _influence;
  106339. private _uniqueId;
  106340. /**
  106341. * Observable raised when the influence changes
  106342. */
  106343. onInfluenceChanged: Observable<boolean>;
  106344. /** @hidden */
  106345. _onDataLayoutChanged: Observable<void>;
  106346. /**
  106347. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  106348. */
  106349. get influence(): number;
  106350. set influence(influence: number);
  106351. /**
  106352. * Gets or sets the id of the morph Target
  106353. */
  106354. id: string;
  106355. private _animationPropertiesOverride;
  106356. /**
  106357. * Gets or sets the animation properties override
  106358. */
  106359. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  106360. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  106361. /**
  106362. * Creates a new MorphTarget
  106363. * @param name defines the name of the target
  106364. * @param influence defines the influence to use
  106365. * @param scene defines the scene the morphtarget belongs to
  106366. */
  106367. constructor(
  106368. /** defines the name of the target */
  106369. name: string, influence?: number, scene?: Nullable<Scene>);
  106370. /**
  106371. * Gets the unique ID of this manager
  106372. */
  106373. get uniqueId(): number;
  106374. /**
  106375. * Gets a boolean defining if the target contains position data
  106376. */
  106377. get hasPositions(): boolean;
  106378. /**
  106379. * Gets a boolean defining if the target contains normal data
  106380. */
  106381. get hasNormals(): boolean;
  106382. /**
  106383. * Gets a boolean defining if the target contains tangent data
  106384. */
  106385. get hasTangents(): boolean;
  106386. /**
  106387. * Gets a boolean defining if the target contains texture coordinates data
  106388. */
  106389. get hasUVs(): boolean;
  106390. /**
  106391. * Affects position data to this target
  106392. * @param data defines the position data to use
  106393. */
  106394. setPositions(data: Nullable<FloatArray>): void;
  106395. /**
  106396. * Gets the position data stored in this target
  106397. * @returns a FloatArray containing the position data (or null if not present)
  106398. */
  106399. getPositions(): Nullable<FloatArray>;
  106400. /**
  106401. * Affects normal data to this target
  106402. * @param data defines the normal data to use
  106403. */
  106404. setNormals(data: Nullable<FloatArray>): void;
  106405. /**
  106406. * Gets the normal data stored in this target
  106407. * @returns a FloatArray containing the normal data (or null if not present)
  106408. */
  106409. getNormals(): Nullable<FloatArray>;
  106410. /**
  106411. * Affects tangent data to this target
  106412. * @param data defines the tangent data to use
  106413. */
  106414. setTangents(data: Nullable<FloatArray>): void;
  106415. /**
  106416. * Gets the tangent data stored in this target
  106417. * @returns a FloatArray containing the tangent data (or null if not present)
  106418. */
  106419. getTangents(): Nullable<FloatArray>;
  106420. /**
  106421. * Affects texture coordinates data to this target
  106422. * @param data defines the texture coordinates data to use
  106423. */
  106424. setUVs(data: Nullable<FloatArray>): void;
  106425. /**
  106426. * Gets the texture coordinates data stored in this target
  106427. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  106428. */
  106429. getUVs(): Nullable<FloatArray>;
  106430. /**
  106431. * Clone the current target
  106432. * @returns a new MorphTarget
  106433. */
  106434. clone(): MorphTarget;
  106435. /**
  106436. * Serializes the current target into a Serialization object
  106437. * @returns the serialized object
  106438. */
  106439. serialize(): any;
  106440. /**
  106441. * Returns the string "MorphTarget"
  106442. * @returns "MorphTarget"
  106443. */
  106444. getClassName(): string;
  106445. /**
  106446. * Creates a new target from serialized data
  106447. * @param serializationObject defines the serialized data to use
  106448. * @returns a new MorphTarget
  106449. */
  106450. static Parse(serializationObject: any): MorphTarget;
  106451. /**
  106452. * Creates a MorphTarget from mesh data
  106453. * @param mesh defines the source mesh
  106454. * @param name defines the name to use for the new target
  106455. * @param influence defines the influence to attach to the target
  106456. * @returns a new MorphTarget
  106457. */
  106458. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  106459. }
  106460. }
  106461. declare module BABYLON {
  106462. /**
  106463. * This class is used to deform meshes using morphing between different targets
  106464. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  106465. */
  106466. export class MorphTargetManager {
  106467. private _targets;
  106468. private _targetInfluenceChangedObservers;
  106469. private _targetDataLayoutChangedObservers;
  106470. private _activeTargets;
  106471. private _scene;
  106472. private _influences;
  106473. private _supportsNormals;
  106474. private _supportsTangents;
  106475. private _supportsUVs;
  106476. private _vertexCount;
  106477. private _uniqueId;
  106478. private _tempInfluences;
  106479. /**
  106480. * Gets or sets a boolean indicating if normals must be morphed
  106481. */
  106482. enableNormalMorphing: boolean;
  106483. /**
  106484. * Gets or sets a boolean indicating if tangents must be morphed
  106485. */
  106486. enableTangentMorphing: boolean;
  106487. /**
  106488. * Gets or sets a boolean indicating if UV must be morphed
  106489. */
  106490. enableUVMorphing: boolean;
  106491. /**
  106492. * Creates a new MorphTargetManager
  106493. * @param scene defines the current scene
  106494. */
  106495. constructor(scene?: Nullable<Scene>);
  106496. /**
  106497. * Gets the unique ID of this manager
  106498. */
  106499. get uniqueId(): number;
  106500. /**
  106501. * Gets the number of vertices handled by this manager
  106502. */
  106503. get vertexCount(): number;
  106504. /**
  106505. * Gets a boolean indicating if this manager supports morphing of normals
  106506. */
  106507. get supportsNormals(): boolean;
  106508. /**
  106509. * Gets a boolean indicating if this manager supports morphing of tangents
  106510. */
  106511. get supportsTangents(): boolean;
  106512. /**
  106513. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  106514. */
  106515. get supportsUVs(): boolean;
  106516. /**
  106517. * Gets the number of targets stored in this manager
  106518. */
  106519. get numTargets(): number;
  106520. /**
  106521. * Gets the number of influencers (ie. the number of targets with influences > 0)
  106522. */
  106523. get numInfluencers(): number;
  106524. /**
  106525. * Gets the list of influences (one per target)
  106526. */
  106527. get influences(): Float32Array;
  106528. /**
  106529. * Gets the active target at specified index. An active target is a target with an influence > 0
  106530. * @param index defines the index to check
  106531. * @returns the requested target
  106532. */
  106533. getActiveTarget(index: number): MorphTarget;
  106534. /**
  106535. * Gets the target at specified index
  106536. * @param index defines the index to check
  106537. * @returns the requested target
  106538. */
  106539. getTarget(index: number): MorphTarget;
  106540. /**
  106541. * Add a new target to this manager
  106542. * @param target defines the target to add
  106543. */
  106544. addTarget(target: MorphTarget): void;
  106545. /**
  106546. * Removes a target from the manager
  106547. * @param target defines the target to remove
  106548. */
  106549. removeTarget(target: MorphTarget): void;
  106550. /**
  106551. * Clone the current manager
  106552. * @returns a new MorphTargetManager
  106553. */
  106554. clone(): MorphTargetManager;
  106555. /**
  106556. * Serializes the current manager into a Serialization object
  106557. * @returns the serialized object
  106558. */
  106559. serialize(): any;
  106560. private _syncActiveTargets;
  106561. /**
  106562. * Syncrhonize the targets with all the meshes using this morph target manager
  106563. */
  106564. synchronize(): void;
  106565. /**
  106566. * Creates a new MorphTargetManager from serialized data
  106567. * @param serializationObject defines the serialized data
  106568. * @param scene defines the hosting scene
  106569. * @returns the new MorphTargetManager
  106570. */
  106571. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  106572. }
  106573. }
  106574. declare module BABYLON {
  106575. /**
  106576. * Class used to represent a specific level of detail of a mesh
  106577. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  106578. */
  106579. export class MeshLODLevel {
  106580. /** Defines the distance where this level should start being displayed */
  106581. distance: number;
  106582. /** Defines the mesh to use to render this level */
  106583. mesh: Nullable<Mesh>;
  106584. /**
  106585. * Creates a new LOD level
  106586. * @param distance defines the distance where this level should star being displayed
  106587. * @param mesh defines the mesh to use to render this level
  106588. */
  106589. constructor(
  106590. /** Defines the distance where this level should start being displayed */
  106591. distance: number,
  106592. /** Defines the mesh to use to render this level */
  106593. mesh: Nullable<Mesh>);
  106594. }
  106595. }
  106596. declare module BABYLON {
  106597. /**
  106598. * Helper class used to generate a canvas to manipulate images
  106599. */
  106600. export class CanvasGenerator {
  106601. /**
  106602. * Create a new canvas (or offscreen canvas depending on the context)
  106603. * @param width defines the expected width
  106604. * @param height defines the expected height
  106605. * @return a new canvas or offscreen canvas
  106606. */
  106607. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  106608. }
  106609. }
  106610. declare module BABYLON {
  106611. /**
  106612. * Mesh representing the gorund
  106613. */
  106614. export class GroundMesh extends Mesh {
  106615. /** If octree should be generated */
  106616. generateOctree: boolean;
  106617. private _heightQuads;
  106618. /** @hidden */
  106619. _subdivisionsX: number;
  106620. /** @hidden */
  106621. _subdivisionsY: number;
  106622. /** @hidden */
  106623. _width: number;
  106624. /** @hidden */
  106625. _height: number;
  106626. /** @hidden */
  106627. _minX: number;
  106628. /** @hidden */
  106629. _maxX: number;
  106630. /** @hidden */
  106631. _minZ: number;
  106632. /** @hidden */
  106633. _maxZ: number;
  106634. constructor(name: string, scene: Scene);
  106635. /**
  106636. * "GroundMesh"
  106637. * @returns "GroundMesh"
  106638. */
  106639. getClassName(): string;
  106640. /**
  106641. * The minimum of x and y subdivisions
  106642. */
  106643. get subdivisions(): number;
  106644. /**
  106645. * X subdivisions
  106646. */
  106647. get subdivisionsX(): number;
  106648. /**
  106649. * Y subdivisions
  106650. */
  106651. get subdivisionsY(): number;
  106652. /**
  106653. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  106654. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  106655. * @param chunksCount the number of subdivisions for x and y
  106656. * @param octreeBlocksSize (Default: 32)
  106657. */
  106658. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  106659. /**
  106660. * Returns a height (y) value in the Worl system :
  106661. * the ground altitude at the coordinates (x, z) expressed in the World system.
  106662. * @param x x coordinate
  106663. * @param z z coordinate
  106664. * @returns the ground y position if (x, z) are outside the ground surface.
  106665. */
  106666. getHeightAtCoordinates(x: number, z: number): number;
  106667. /**
  106668. * Returns a normalized vector (Vector3) orthogonal to the ground
  106669. * at the ground coordinates (x, z) expressed in the World system.
  106670. * @param x x coordinate
  106671. * @param z z coordinate
  106672. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  106673. */
  106674. getNormalAtCoordinates(x: number, z: number): Vector3;
  106675. /**
  106676. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  106677. * at the ground coordinates (x, z) expressed in the World system.
  106678. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  106679. * @param x x coordinate
  106680. * @param z z coordinate
  106681. * @param ref vector to store the result
  106682. * @returns the GroundMesh.
  106683. */
  106684. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  106685. /**
  106686. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  106687. * if the ground has been updated.
  106688. * This can be used in the render loop.
  106689. * @returns the GroundMesh.
  106690. */
  106691. updateCoordinateHeights(): GroundMesh;
  106692. private _getFacetAt;
  106693. private _initHeightQuads;
  106694. private _computeHeightQuads;
  106695. /**
  106696. * Serializes this ground mesh
  106697. * @param serializationObject object to write serialization to
  106698. */
  106699. serialize(serializationObject: any): void;
  106700. /**
  106701. * Parses a serialized ground mesh
  106702. * @param parsedMesh the serialized mesh
  106703. * @param scene the scene to create the ground mesh in
  106704. * @returns the created ground mesh
  106705. */
  106706. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  106707. }
  106708. }
  106709. declare module BABYLON {
  106710. /**
  106711. * Interface for Physics-Joint data
  106712. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106713. */
  106714. export interface PhysicsJointData {
  106715. /**
  106716. * The main pivot of the joint
  106717. */
  106718. mainPivot?: Vector3;
  106719. /**
  106720. * The connected pivot of the joint
  106721. */
  106722. connectedPivot?: Vector3;
  106723. /**
  106724. * The main axis of the joint
  106725. */
  106726. mainAxis?: Vector3;
  106727. /**
  106728. * The connected axis of the joint
  106729. */
  106730. connectedAxis?: Vector3;
  106731. /**
  106732. * The collision of the joint
  106733. */
  106734. collision?: boolean;
  106735. /**
  106736. * Native Oimo/Cannon/Energy data
  106737. */
  106738. nativeParams?: any;
  106739. }
  106740. /**
  106741. * This is a holder class for the physics joint created by the physics plugin
  106742. * It holds a set of functions to control the underlying joint
  106743. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106744. */
  106745. export class PhysicsJoint {
  106746. /**
  106747. * The type of the physics joint
  106748. */
  106749. type: number;
  106750. /**
  106751. * The data for the physics joint
  106752. */
  106753. jointData: PhysicsJointData;
  106754. private _physicsJoint;
  106755. protected _physicsPlugin: IPhysicsEnginePlugin;
  106756. /**
  106757. * Initializes the physics joint
  106758. * @param type The type of the physics joint
  106759. * @param jointData The data for the physics joint
  106760. */
  106761. constructor(
  106762. /**
  106763. * The type of the physics joint
  106764. */
  106765. type: number,
  106766. /**
  106767. * The data for the physics joint
  106768. */
  106769. jointData: PhysicsJointData);
  106770. /**
  106771. * Gets the physics joint
  106772. */
  106773. get physicsJoint(): any;
  106774. /**
  106775. * Sets the physics joint
  106776. */
  106777. set physicsJoint(newJoint: any);
  106778. /**
  106779. * Sets the physics plugin
  106780. */
  106781. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  106782. /**
  106783. * Execute a function that is physics-plugin specific.
  106784. * @param {Function} func the function that will be executed.
  106785. * It accepts two parameters: the physics world and the physics joint
  106786. */
  106787. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  106788. /**
  106789. * Distance-Joint type
  106790. */
  106791. static DistanceJoint: number;
  106792. /**
  106793. * Hinge-Joint type
  106794. */
  106795. static HingeJoint: number;
  106796. /**
  106797. * Ball-and-Socket joint type
  106798. */
  106799. static BallAndSocketJoint: number;
  106800. /**
  106801. * Wheel-Joint type
  106802. */
  106803. static WheelJoint: number;
  106804. /**
  106805. * Slider-Joint type
  106806. */
  106807. static SliderJoint: number;
  106808. /**
  106809. * Prismatic-Joint type
  106810. */
  106811. static PrismaticJoint: number;
  106812. /**
  106813. * Universal-Joint type
  106814. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  106815. */
  106816. static UniversalJoint: number;
  106817. /**
  106818. * Hinge-Joint 2 type
  106819. */
  106820. static Hinge2Joint: number;
  106821. /**
  106822. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  106823. */
  106824. static PointToPointJoint: number;
  106825. /**
  106826. * Spring-Joint type
  106827. */
  106828. static SpringJoint: number;
  106829. /**
  106830. * Lock-Joint type
  106831. */
  106832. static LockJoint: number;
  106833. }
  106834. /**
  106835. * A class representing a physics distance joint
  106836. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106837. */
  106838. export class DistanceJoint extends PhysicsJoint {
  106839. /**
  106840. *
  106841. * @param jointData The data for the Distance-Joint
  106842. */
  106843. constructor(jointData: DistanceJointData);
  106844. /**
  106845. * Update the predefined distance.
  106846. * @param maxDistance The maximum preferred distance
  106847. * @param minDistance The minimum preferred distance
  106848. */
  106849. updateDistance(maxDistance: number, minDistance?: number): void;
  106850. }
  106851. /**
  106852. * Represents a Motor-Enabled Joint
  106853. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106854. */
  106855. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  106856. /**
  106857. * Initializes the Motor-Enabled Joint
  106858. * @param type The type of the joint
  106859. * @param jointData The physica joint data for the joint
  106860. */
  106861. constructor(type: number, jointData: PhysicsJointData);
  106862. /**
  106863. * Set the motor values.
  106864. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106865. * @param force the force to apply
  106866. * @param maxForce max force for this motor.
  106867. */
  106868. setMotor(force?: number, maxForce?: number): void;
  106869. /**
  106870. * Set the motor's limits.
  106871. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106872. * @param upperLimit The upper limit of the motor
  106873. * @param lowerLimit The lower limit of the motor
  106874. */
  106875. setLimit(upperLimit: number, lowerLimit?: number): void;
  106876. }
  106877. /**
  106878. * This class represents a single physics Hinge-Joint
  106879. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106880. */
  106881. export class HingeJoint extends MotorEnabledJoint {
  106882. /**
  106883. * Initializes the Hinge-Joint
  106884. * @param jointData The joint data for the Hinge-Joint
  106885. */
  106886. constructor(jointData: PhysicsJointData);
  106887. /**
  106888. * Set the motor values.
  106889. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106890. * @param {number} force the force to apply
  106891. * @param {number} maxForce max force for this motor.
  106892. */
  106893. setMotor(force?: number, maxForce?: number): void;
  106894. /**
  106895. * Set the motor's limits.
  106896. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106897. * @param upperLimit The upper limit of the motor
  106898. * @param lowerLimit The lower limit of the motor
  106899. */
  106900. setLimit(upperLimit: number, lowerLimit?: number): void;
  106901. }
  106902. /**
  106903. * This class represents a dual hinge physics joint (same as wheel joint)
  106904. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106905. */
  106906. export class Hinge2Joint extends MotorEnabledJoint {
  106907. /**
  106908. * Initializes the Hinge2-Joint
  106909. * @param jointData The joint data for the Hinge2-Joint
  106910. */
  106911. constructor(jointData: PhysicsJointData);
  106912. /**
  106913. * Set the motor values.
  106914. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106915. * @param {number} targetSpeed the speed the motor is to reach
  106916. * @param {number} maxForce max force for this motor.
  106917. * @param {motorIndex} the motor's index, 0 or 1.
  106918. */
  106919. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  106920. /**
  106921. * Set the motor limits.
  106922. * Attention, this function is plugin specific. Engines won't react 100% the same.
  106923. * @param {number} upperLimit the upper limit
  106924. * @param {number} lowerLimit lower limit
  106925. * @param {motorIndex} the motor's index, 0 or 1.
  106926. */
  106927. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  106928. }
  106929. /**
  106930. * Interface for a motor enabled joint
  106931. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106932. */
  106933. export interface IMotorEnabledJoint {
  106934. /**
  106935. * Physics joint
  106936. */
  106937. physicsJoint: any;
  106938. /**
  106939. * Sets the motor of the motor-enabled joint
  106940. * @param force The force of the motor
  106941. * @param maxForce The maximum force of the motor
  106942. * @param motorIndex The index of the motor
  106943. */
  106944. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  106945. /**
  106946. * Sets the limit of the motor
  106947. * @param upperLimit The upper limit of the motor
  106948. * @param lowerLimit The lower limit of the motor
  106949. * @param motorIndex The index of the motor
  106950. */
  106951. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  106952. }
  106953. /**
  106954. * Joint data for a Distance-Joint
  106955. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106956. */
  106957. export interface DistanceJointData extends PhysicsJointData {
  106958. /**
  106959. * Max distance the 2 joint objects can be apart
  106960. */
  106961. maxDistance: number;
  106962. }
  106963. /**
  106964. * Joint data from a spring joint
  106965. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106966. */
  106967. export interface SpringJointData extends PhysicsJointData {
  106968. /**
  106969. * Length of the spring
  106970. */
  106971. length: number;
  106972. /**
  106973. * Stiffness of the spring
  106974. */
  106975. stiffness: number;
  106976. /**
  106977. * Damping of the spring
  106978. */
  106979. damping: number;
  106980. /** this callback will be called when applying the force to the impostors. */
  106981. forceApplicationCallback: () => void;
  106982. }
  106983. }
  106984. declare module BABYLON {
  106985. /**
  106986. * Holds the data for the raycast result
  106987. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  106988. */
  106989. export class PhysicsRaycastResult {
  106990. private _hasHit;
  106991. private _hitDistance;
  106992. private _hitNormalWorld;
  106993. private _hitPointWorld;
  106994. private _rayFromWorld;
  106995. private _rayToWorld;
  106996. /**
  106997. * Gets if there was a hit
  106998. */
  106999. get hasHit(): boolean;
  107000. /**
  107001. * Gets the distance from the hit
  107002. */
  107003. get hitDistance(): number;
  107004. /**
  107005. * Gets the hit normal/direction in the world
  107006. */
  107007. get hitNormalWorld(): Vector3;
  107008. /**
  107009. * Gets the hit point in the world
  107010. */
  107011. get hitPointWorld(): Vector3;
  107012. /**
  107013. * Gets the ray "start point" of the ray in the world
  107014. */
  107015. get rayFromWorld(): Vector3;
  107016. /**
  107017. * Gets the ray "end point" of the ray in the world
  107018. */
  107019. get rayToWorld(): Vector3;
  107020. /**
  107021. * Sets the hit data (normal & point in world space)
  107022. * @param hitNormalWorld defines the normal in world space
  107023. * @param hitPointWorld defines the point in world space
  107024. */
  107025. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  107026. /**
  107027. * Sets the distance from the start point to the hit point
  107028. * @param distance
  107029. */
  107030. setHitDistance(distance: number): void;
  107031. /**
  107032. * Calculates the distance manually
  107033. */
  107034. calculateHitDistance(): void;
  107035. /**
  107036. * Resets all the values to default
  107037. * @param from The from point on world space
  107038. * @param to The to point on world space
  107039. */
  107040. reset(from?: Vector3, to?: Vector3): void;
  107041. }
  107042. /**
  107043. * Interface for the size containing width and height
  107044. */
  107045. interface IXYZ {
  107046. /**
  107047. * X
  107048. */
  107049. x: number;
  107050. /**
  107051. * Y
  107052. */
  107053. y: number;
  107054. /**
  107055. * Z
  107056. */
  107057. z: number;
  107058. }
  107059. }
  107060. declare module BABYLON {
  107061. /**
  107062. * Interface used to describe a physics joint
  107063. */
  107064. export interface PhysicsImpostorJoint {
  107065. /** Defines the main impostor to which the joint is linked */
  107066. mainImpostor: PhysicsImpostor;
  107067. /** Defines the impostor that is connected to the main impostor using this joint */
  107068. connectedImpostor: PhysicsImpostor;
  107069. /** Defines the joint itself */
  107070. joint: PhysicsJoint;
  107071. }
  107072. /** @hidden */
  107073. export interface IPhysicsEnginePlugin {
  107074. world: any;
  107075. name: string;
  107076. setGravity(gravity: Vector3): void;
  107077. setTimeStep(timeStep: number): void;
  107078. getTimeStep(): number;
  107079. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107080. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107081. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107082. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107083. removePhysicsBody(impostor: PhysicsImpostor): void;
  107084. generateJoint(joint: PhysicsImpostorJoint): void;
  107085. removeJoint(joint: PhysicsImpostorJoint): void;
  107086. isSupported(): boolean;
  107087. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107088. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107089. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  107090. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  107091. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107092. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107093. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107094. getBodyMass(impostor: PhysicsImpostor): number;
  107095. getBodyFriction(impostor: PhysicsImpostor): number;
  107096. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107097. getBodyRestitution(impostor: PhysicsImpostor): number;
  107098. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107099. getBodyPressure?(impostor: PhysicsImpostor): number;
  107100. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  107101. getBodyStiffness?(impostor: PhysicsImpostor): number;
  107102. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  107103. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  107104. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  107105. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  107106. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  107107. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  107108. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  107109. sleepBody(impostor: PhysicsImpostor): void;
  107110. wakeUpBody(impostor: PhysicsImpostor): void;
  107111. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107112. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107113. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  107114. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107115. getRadius(impostor: PhysicsImpostor): number;
  107116. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107117. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107118. dispose(): void;
  107119. }
  107120. /**
  107121. * Interface used to define a physics engine
  107122. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107123. */
  107124. export interface IPhysicsEngine {
  107125. /**
  107126. * Gets the gravity vector used by the simulation
  107127. */
  107128. gravity: Vector3;
  107129. /**
  107130. * Sets the gravity vector used by the simulation
  107131. * @param gravity defines the gravity vector to use
  107132. */
  107133. setGravity(gravity: Vector3): void;
  107134. /**
  107135. * Set the time step of the physics engine.
  107136. * Default is 1/60.
  107137. * To slow it down, enter 1/600 for example.
  107138. * To speed it up, 1/30
  107139. * @param newTimeStep the new timestep to apply to this world.
  107140. */
  107141. setTimeStep(newTimeStep: number): void;
  107142. /**
  107143. * Get the time step of the physics engine.
  107144. * @returns the current time step
  107145. */
  107146. getTimeStep(): number;
  107147. /**
  107148. * Set the sub time step of the physics engine.
  107149. * Default is 0 meaning there is no sub steps
  107150. * To increase physics resolution precision, set a small value (like 1 ms)
  107151. * @param subTimeStep defines the new sub timestep used for physics resolution.
  107152. */
  107153. setSubTimeStep(subTimeStep: number): void;
  107154. /**
  107155. * Get the sub time step of the physics engine.
  107156. * @returns the current sub time step
  107157. */
  107158. getSubTimeStep(): number;
  107159. /**
  107160. * Release all resources
  107161. */
  107162. dispose(): void;
  107163. /**
  107164. * Gets the name of the current physics plugin
  107165. * @returns the name of the plugin
  107166. */
  107167. getPhysicsPluginName(): string;
  107168. /**
  107169. * Adding a new impostor for the impostor tracking.
  107170. * This will be done by the impostor itself.
  107171. * @param impostor the impostor to add
  107172. */
  107173. addImpostor(impostor: PhysicsImpostor): void;
  107174. /**
  107175. * Remove an impostor from the engine.
  107176. * This impostor and its mesh will not longer be updated by the physics engine.
  107177. * @param impostor the impostor to remove
  107178. */
  107179. removeImpostor(impostor: PhysicsImpostor): void;
  107180. /**
  107181. * Add a joint to the physics engine
  107182. * @param mainImpostor defines the main impostor to which the joint is added.
  107183. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  107184. * @param joint defines the joint that will connect both impostors.
  107185. */
  107186. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107187. /**
  107188. * Removes a joint from the simulation
  107189. * @param mainImpostor defines the impostor used with the joint
  107190. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  107191. * @param joint defines the joint to remove
  107192. */
  107193. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107194. /**
  107195. * Gets the current plugin used to run the simulation
  107196. * @returns current plugin
  107197. */
  107198. getPhysicsPlugin(): IPhysicsEnginePlugin;
  107199. /**
  107200. * Gets the list of physic impostors
  107201. * @returns an array of PhysicsImpostor
  107202. */
  107203. getImpostors(): Array<PhysicsImpostor>;
  107204. /**
  107205. * Gets the impostor for a physics enabled object
  107206. * @param object defines the object impersonated by the impostor
  107207. * @returns the PhysicsImpostor or null if not found
  107208. */
  107209. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107210. /**
  107211. * Gets the impostor for a physics body object
  107212. * @param body defines physics body used by the impostor
  107213. * @returns the PhysicsImpostor or null if not found
  107214. */
  107215. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  107216. /**
  107217. * Does a raycast in the physics world
  107218. * @param from when should the ray start?
  107219. * @param to when should the ray end?
  107220. * @returns PhysicsRaycastResult
  107221. */
  107222. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107223. /**
  107224. * Called by the scene. No need to call it.
  107225. * @param delta defines the timespam between frames
  107226. */
  107227. _step(delta: number): void;
  107228. }
  107229. }
  107230. declare module BABYLON {
  107231. /**
  107232. * The interface for the physics imposter parameters
  107233. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107234. */
  107235. export interface PhysicsImpostorParameters {
  107236. /**
  107237. * The mass of the physics imposter
  107238. */
  107239. mass: number;
  107240. /**
  107241. * The friction of the physics imposter
  107242. */
  107243. friction?: number;
  107244. /**
  107245. * The coefficient of restitution of the physics imposter
  107246. */
  107247. restitution?: number;
  107248. /**
  107249. * The native options of the physics imposter
  107250. */
  107251. nativeOptions?: any;
  107252. /**
  107253. * Specifies if the parent should be ignored
  107254. */
  107255. ignoreParent?: boolean;
  107256. /**
  107257. * Specifies if bi-directional transformations should be disabled
  107258. */
  107259. disableBidirectionalTransformation?: boolean;
  107260. /**
  107261. * The pressure inside the physics imposter, soft object only
  107262. */
  107263. pressure?: number;
  107264. /**
  107265. * The stiffness the physics imposter, soft object only
  107266. */
  107267. stiffness?: number;
  107268. /**
  107269. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  107270. */
  107271. velocityIterations?: number;
  107272. /**
  107273. * The number of iterations used in maintaining consistent vertex positions, soft object only
  107274. */
  107275. positionIterations?: number;
  107276. /**
  107277. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  107278. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  107279. * Add to fix multiple points
  107280. */
  107281. fixedPoints?: number;
  107282. /**
  107283. * The collision margin around a soft object
  107284. */
  107285. margin?: number;
  107286. /**
  107287. * The collision margin around a soft object
  107288. */
  107289. damping?: number;
  107290. /**
  107291. * The path for a rope based on an extrusion
  107292. */
  107293. path?: any;
  107294. /**
  107295. * The shape of an extrusion used for a rope based on an extrusion
  107296. */
  107297. shape?: any;
  107298. }
  107299. /**
  107300. * Interface for a physics-enabled object
  107301. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107302. */
  107303. export interface IPhysicsEnabledObject {
  107304. /**
  107305. * The position of the physics-enabled object
  107306. */
  107307. position: Vector3;
  107308. /**
  107309. * The rotation of the physics-enabled object
  107310. */
  107311. rotationQuaternion: Nullable<Quaternion>;
  107312. /**
  107313. * The scale of the physics-enabled object
  107314. */
  107315. scaling: Vector3;
  107316. /**
  107317. * The rotation of the physics-enabled object
  107318. */
  107319. rotation?: Vector3;
  107320. /**
  107321. * The parent of the physics-enabled object
  107322. */
  107323. parent?: any;
  107324. /**
  107325. * The bounding info of the physics-enabled object
  107326. * @returns The bounding info of the physics-enabled object
  107327. */
  107328. getBoundingInfo(): BoundingInfo;
  107329. /**
  107330. * Computes the world matrix
  107331. * @param force Specifies if the world matrix should be computed by force
  107332. * @returns A world matrix
  107333. */
  107334. computeWorldMatrix(force: boolean): Matrix;
  107335. /**
  107336. * Gets the world matrix
  107337. * @returns A world matrix
  107338. */
  107339. getWorldMatrix?(): Matrix;
  107340. /**
  107341. * Gets the child meshes
  107342. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  107343. * @returns An array of abstract meshes
  107344. */
  107345. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  107346. /**
  107347. * Gets the vertex data
  107348. * @param kind The type of vertex data
  107349. * @returns A nullable array of numbers, or a float32 array
  107350. */
  107351. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  107352. /**
  107353. * Gets the indices from the mesh
  107354. * @returns A nullable array of index arrays
  107355. */
  107356. getIndices?(): Nullable<IndicesArray>;
  107357. /**
  107358. * Gets the scene from the mesh
  107359. * @returns the indices array or null
  107360. */
  107361. getScene?(): Scene;
  107362. /**
  107363. * Gets the absolute position from the mesh
  107364. * @returns the absolute position
  107365. */
  107366. getAbsolutePosition(): Vector3;
  107367. /**
  107368. * Gets the absolute pivot point from the mesh
  107369. * @returns the absolute pivot point
  107370. */
  107371. getAbsolutePivotPoint(): Vector3;
  107372. /**
  107373. * Rotates the mesh
  107374. * @param axis The axis of rotation
  107375. * @param amount The amount of rotation
  107376. * @param space The space of the rotation
  107377. * @returns The rotation transform node
  107378. */
  107379. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  107380. /**
  107381. * Translates the mesh
  107382. * @param axis The axis of translation
  107383. * @param distance The distance of translation
  107384. * @param space The space of the translation
  107385. * @returns The transform node
  107386. */
  107387. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  107388. /**
  107389. * Sets the absolute position of the mesh
  107390. * @param absolutePosition The absolute position of the mesh
  107391. * @returns The transform node
  107392. */
  107393. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  107394. /**
  107395. * Gets the class name of the mesh
  107396. * @returns The class name
  107397. */
  107398. getClassName(): string;
  107399. }
  107400. /**
  107401. * Represents a physics imposter
  107402. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107403. */
  107404. export class PhysicsImpostor {
  107405. /**
  107406. * The physics-enabled object used as the physics imposter
  107407. */
  107408. object: IPhysicsEnabledObject;
  107409. /**
  107410. * The type of the physics imposter
  107411. */
  107412. type: number;
  107413. private _options;
  107414. private _scene?;
  107415. /**
  107416. * The default object size of the imposter
  107417. */
  107418. static DEFAULT_OBJECT_SIZE: Vector3;
  107419. /**
  107420. * The identity quaternion of the imposter
  107421. */
  107422. static IDENTITY_QUATERNION: Quaternion;
  107423. /** @hidden */
  107424. _pluginData: any;
  107425. private _physicsEngine;
  107426. private _physicsBody;
  107427. private _bodyUpdateRequired;
  107428. private _onBeforePhysicsStepCallbacks;
  107429. private _onAfterPhysicsStepCallbacks;
  107430. /** @hidden */
  107431. _onPhysicsCollideCallbacks: Array<{
  107432. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  107433. otherImpostors: Array<PhysicsImpostor>;
  107434. }>;
  107435. private _deltaPosition;
  107436. private _deltaRotation;
  107437. private _deltaRotationConjugated;
  107438. /** @hidden */
  107439. _isFromLine: boolean;
  107440. private _parent;
  107441. private _isDisposed;
  107442. private static _tmpVecs;
  107443. private static _tmpQuat;
  107444. /**
  107445. * Specifies if the physics imposter is disposed
  107446. */
  107447. get isDisposed(): boolean;
  107448. /**
  107449. * Gets the mass of the physics imposter
  107450. */
  107451. get mass(): number;
  107452. set mass(value: number);
  107453. /**
  107454. * Gets the coefficient of friction
  107455. */
  107456. get friction(): number;
  107457. /**
  107458. * Sets the coefficient of friction
  107459. */
  107460. set friction(value: number);
  107461. /**
  107462. * Gets the coefficient of restitution
  107463. */
  107464. get restitution(): number;
  107465. /**
  107466. * Sets the coefficient of restitution
  107467. */
  107468. set restitution(value: number);
  107469. /**
  107470. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  107471. */
  107472. get pressure(): number;
  107473. /**
  107474. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  107475. */
  107476. set pressure(value: number);
  107477. /**
  107478. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  107479. */
  107480. get stiffness(): number;
  107481. /**
  107482. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  107483. */
  107484. set stiffness(value: number);
  107485. /**
  107486. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  107487. */
  107488. get velocityIterations(): number;
  107489. /**
  107490. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  107491. */
  107492. set velocityIterations(value: number);
  107493. /**
  107494. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  107495. */
  107496. get positionIterations(): number;
  107497. /**
  107498. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  107499. */
  107500. set positionIterations(value: number);
  107501. /**
  107502. * The unique id of the physics imposter
  107503. * set by the physics engine when adding this impostor to the array
  107504. */
  107505. uniqueId: number;
  107506. /**
  107507. * @hidden
  107508. */
  107509. soft: boolean;
  107510. /**
  107511. * @hidden
  107512. */
  107513. segments: number;
  107514. private _joints;
  107515. /**
  107516. * Initializes the physics imposter
  107517. * @param object The physics-enabled object used as the physics imposter
  107518. * @param type The type of the physics imposter
  107519. * @param _options The options for the physics imposter
  107520. * @param _scene The Babylon scene
  107521. */
  107522. constructor(
  107523. /**
  107524. * The physics-enabled object used as the physics imposter
  107525. */
  107526. object: IPhysicsEnabledObject,
  107527. /**
  107528. * The type of the physics imposter
  107529. */
  107530. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  107531. /**
  107532. * This function will completly initialize this impostor.
  107533. * It will create a new body - but only if this mesh has no parent.
  107534. * If it has, this impostor will not be used other than to define the impostor
  107535. * of the child mesh.
  107536. * @hidden
  107537. */
  107538. _init(): void;
  107539. private _getPhysicsParent;
  107540. /**
  107541. * Should a new body be generated.
  107542. * @returns boolean specifying if body initialization is required
  107543. */
  107544. isBodyInitRequired(): boolean;
  107545. /**
  107546. * Sets the updated scaling
  107547. * @param updated Specifies if the scaling is updated
  107548. */
  107549. setScalingUpdated(): void;
  107550. /**
  107551. * Force a regeneration of this or the parent's impostor's body.
  107552. * Use under cautious - This will remove all joints already implemented.
  107553. */
  107554. forceUpdate(): void;
  107555. /**
  107556. * Gets the body that holds this impostor. Either its own, or its parent.
  107557. */
  107558. get physicsBody(): any;
  107559. /**
  107560. * Get the parent of the physics imposter
  107561. * @returns Physics imposter or null
  107562. */
  107563. get parent(): Nullable<PhysicsImpostor>;
  107564. /**
  107565. * Sets the parent of the physics imposter
  107566. */
  107567. set parent(value: Nullable<PhysicsImpostor>);
  107568. /**
  107569. * Set the physics body. Used mainly by the physics engine/plugin
  107570. */
  107571. set physicsBody(physicsBody: any);
  107572. /**
  107573. * Resets the update flags
  107574. */
  107575. resetUpdateFlags(): void;
  107576. /**
  107577. * Gets the object extend size
  107578. * @returns the object extend size
  107579. */
  107580. getObjectExtendSize(): Vector3;
  107581. /**
  107582. * Gets the object center
  107583. * @returns The object center
  107584. */
  107585. getObjectCenter(): Vector3;
  107586. /**
  107587. * Get a specific parameter from the options parameters
  107588. * @param paramName The object parameter name
  107589. * @returns The object parameter
  107590. */
  107591. getParam(paramName: string): any;
  107592. /**
  107593. * Sets a specific parameter in the options given to the physics plugin
  107594. * @param paramName The parameter name
  107595. * @param value The value of the parameter
  107596. */
  107597. setParam(paramName: string, value: number): void;
  107598. /**
  107599. * Specifically change the body's mass option. Won't recreate the physics body object
  107600. * @param mass The mass of the physics imposter
  107601. */
  107602. setMass(mass: number): void;
  107603. /**
  107604. * Gets the linear velocity
  107605. * @returns linear velocity or null
  107606. */
  107607. getLinearVelocity(): Nullable<Vector3>;
  107608. /**
  107609. * Sets the linear velocity
  107610. * @param velocity linear velocity or null
  107611. */
  107612. setLinearVelocity(velocity: Nullable<Vector3>): void;
  107613. /**
  107614. * Gets the angular velocity
  107615. * @returns angular velocity or null
  107616. */
  107617. getAngularVelocity(): Nullable<Vector3>;
  107618. /**
  107619. * Sets the angular velocity
  107620. * @param velocity The velocity or null
  107621. */
  107622. setAngularVelocity(velocity: Nullable<Vector3>): void;
  107623. /**
  107624. * Execute a function with the physics plugin native code
  107625. * Provide a function the will have two variables - the world object and the physics body object
  107626. * @param func The function to execute with the physics plugin native code
  107627. */
  107628. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  107629. /**
  107630. * Register a function that will be executed before the physics world is stepping forward
  107631. * @param func The function to execute before the physics world is stepped forward
  107632. */
  107633. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107634. /**
  107635. * Unregister a function that will be executed before the physics world is stepping forward
  107636. * @param func The function to execute before the physics world is stepped forward
  107637. */
  107638. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107639. /**
  107640. * Register a function that will be executed after the physics step
  107641. * @param func The function to execute after physics step
  107642. */
  107643. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107644. /**
  107645. * Unregisters a function that will be executed after the physics step
  107646. * @param func The function to execute after physics step
  107647. */
  107648. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  107649. /**
  107650. * register a function that will be executed when this impostor collides against a different body
  107651. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  107652. * @param func Callback that is executed on collision
  107653. */
  107654. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  107655. /**
  107656. * Unregisters the physics imposter on contact
  107657. * @param collideAgainst The physics object to collide against
  107658. * @param func Callback to execute on collision
  107659. */
  107660. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  107661. private _tmpQuat;
  107662. private _tmpQuat2;
  107663. /**
  107664. * Get the parent rotation
  107665. * @returns The parent rotation
  107666. */
  107667. getParentsRotation(): Quaternion;
  107668. /**
  107669. * this function is executed by the physics engine.
  107670. */
  107671. beforeStep: () => void;
  107672. /**
  107673. * this function is executed by the physics engine
  107674. */
  107675. afterStep: () => void;
  107676. /**
  107677. * Legacy collision detection event support
  107678. */
  107679. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  107680. /**
  107681. * event and body object due to cannon's event-based architecture.
  107682. */
  107683. onCollide: (e: {
  107684. body: any;
  107685. }) => void;
  107686. /**
  107687. * Apply a force
  107688. * @param force The force to apply
  107689. * @param contactPoint The contact point for the force
  107690. * @returns The physics imposter
  107691. */
  107692. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  107693. /**
  107694. * Apply an impulse
  107695. * @param force The impulse force
  107696. * @param contactPoint The contact point for the impulse force
  107697. * @returns The physics imposter
  107698. */
  107699. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  107700. /**
  107701. * A help function to create a joint
  107702. * @param otherImpostor A physics imposter used to create a joint
  107703. * @param jointType The type of joint
  107704. * @param jointData The data for the joint
  107705. * @returns The physics imposter
  107706. */
  107707. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  107708. /**
  107709. * Add a joint to this impostor with a different impostor
  107710. * @param otherImpostor A physics imposter used to add a joint
  107711. * @param joint The joint to add
  107712. * @returns The physics imposter
  107713. */
  107714. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  107715. /**
  107716. * Add an anchor to a cloth impostor
  107717. * @param otherImpostor rigid impostor to anchor to
  107718. * @param width ratio across width from 0 to 1
  107719. * @param height ratio up height from 0 to 1
  107720. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  107721. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  107722. * @returns impostor the soft imposter
  107723. */
  107724. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  107725. /**
  107726. * Add a hook to a rope impostor
  107727. * @param otherImpostor rigid impostor to anchor to
  107728. * @param length ratio across rope from 0 to 1
  107729. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  107730. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  107731. * @returns impostor the rope imposter
  107732. */
  107733. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  107734. /**
  107735. * Will keep this body still, in a sleep mode.
  107736. * @returns the physics imposter
  107737. */
  107738. sleep(): PhysicsImpostor;
  107739. /**
  107740. * Wake the body up.
  107741. * @returns The physics imposter
  107742. */
  107743. wakeUp(): PhysicsImpostor;
  107744. /**
  107745. * Clones the physics imposter
  107746. * @param newObject The physics imposter clones to this physics-enabled object
  107747. * @returns A nullable physics imposter
  107748. */
  107749. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107750. /**
  107751. * Disposes the physics imposter
  107752. */
  107753. dispose(): void;
  107754. /**
  107755. * Sets the delta position
  107756. * @param position The delta position amount
  107757. */
  107758. setDeltaPosition(position: Vector3): void;
  107759. /**
  107760. * Sets the delta rotation
  107761. * @param rotation The delta rotation amount
  107762. */
  107763. setDeltaRotation(rotation: Quaternion): void;
  107764. /**
  107765. * Gets the box size of the physics imposter and stores the result in the input parameter
  107766. * @param result Stores the box size
  107767. * @returns The physics imposter
  107768. */
  107769. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  107770. /**
  107771. * Gets the radius of the physics imposter
  107772. * @returns Radius of the physics imposter
  107773. */
  107774. getRadius(): number;
  107775. /**
  107776. * Sync a bone with this impostor
  107777. * @param bone The bone to sync to the impostor.
  107778. * @param boneMesh The mesh that the bone is influencing.
  107779. * @param jointPivot The pivot of the joint / bone in local space.
  107780. * @param distToJoint Optional distance from the impostor to the joint.
  107781. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  107782. */
  107783. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  107784. /**
  107785. * Sync impostor to a bone
  107786. * @param bone The bone that the impostor will be synced to.
  107787. * @param boneMesh The mesh that the bone is influencing.
  107788. * @param jointPivot The pivot of the joint / bone in local space.
  107789. * @param distToJoint Optional distance from the impostor to the joint.
  107790. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  107791. * @param boneAxis Optional vector3 axis the bone is aligned with
  107792. */
  107793. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  107794. /**
  107795. * No-Imposter type
  107796. */
  107797. static NoImpostor: number;
  107798. /**
  107799. * Sphere-Imposter type
  107800. */
  107801. static SphereImpostor: number;
  107802. /**
  107803. * Box-Imposter type
  107804. */
  107805. static BoxImpostor: number;
  107806. /**
  107807. * Plane-Imposter type
  107808. */
  107809. static PlaneImpostor: number;
  107810. /**
  107811. * Mesh-imposter type
  107812. */
  107813. static MeshImpostor: number;
  107814. /**
  107815. * Capsule-Impostor type (Ammo.js plugin only)
  107816. */
  107817. static CapsuleImpostor: number;
  107818. /**
  107819. * Cylinder-Imposter type
  107820. */
  107821. static CylinderImpostor: number;
  107822. /**
  107823. * Particle-Imposter type
  107824. */
  107825. static ParticleImpostor: number;
  107826. /**
  107827. * Heightmap-Imposter type
  107828. */
  107829. static HeightmapImpostor: number;
  107830. /**
  107831. * ConvexHull-Impostor type (Ammo.js plugin only)
  107832. */
  107833. static ConvexHullImpostor: number;
  107834. /**
  107835. * Custom-Imposter type (Ammo.js plugin only)
  107836. */
  107837. static CustomImpostor: number;
  107838. /**
  107839. * Rope-Imposter type
  107840. */
  107841. static RopeImpostor: number;
  107842. /**
  107843. * Cloth-Imposter type
  107844. */
  107845. static ClothImpostor: number;
  107846. /**
  107847. * Softbody-Imposter type
  107848. */
  107849. static SoftbodyImpostor: number;
  107850. }
  107851. }
  107852. declare module BABYLON {
  107853. /**
  107854. * @hidden
  107855. **/
  107856. export class _CreationDataStorage {
  107857. closePath?: boolean;
  107858. closeArray?: boolean;
  107859. idx: number[];
  107860. dashSize: number;
  107861. gapSize: number;
  107862. path3D: Path3D;
  107863. pathArray: Vector3[][];
  107864. arc: number;
  107865. radius: number;
  107866. cap: number;
  107867. tessellation: number;
  107868. }
  107869. /**
  107870. * @hidden
  107871. **/
  107872. class _InstanceDataStorage {
  107873. visibleInstances: any;
  107874. batchCache: _InstancesBatch;
  107875. instancesBufferSize: number;
  107876. instancesBuffer: Nullable<Buffer>;
  107877. instancesData: Float32Array;
  107878. overridenInstanceCount: number;
  107879. isFrozen: boolean;
  107880. previousBatch: Nullable<_InstancesBatch>;
  107881. hardwareInstancedRendering: boolean;
  107882. sideOrientation: number;
  107883. manualUpdate: boolean;
  107884. }
  107885. /**
  107886. * @hidden
  107887. **/
  107888. export class _InstancesBatch {
  107889. mustReturn: boolean;
  107890. visibleInstances: Nullable<InstancedMesh[]>[];
  107891. renderSelf: boolean[];
  107892. hardwareInstancedRendering: boolean[];
  107893. }
  107894. /**
  107895. * @hidden
  107896. **/
  107897. class _ThinInstanceDataStorage {
  107898. instancesCount: number;
  107899. matrixBuffer: Nullable<Buffer>;
  107900. matrixBufferSize: number;
  107901. matrixData: Nullable<Float32Array>;
  107902. boundingVectors: Array<Vector3>;
  107903. worldMatrices: Nullable<Matrix[]>;
  107904. }
  107905. /**
  107906. * Class used to represent renderable models
  107907. */
  107908. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  107909. /**
  107910. * Mesh side orientation : usually the external or front surface
  107911. */
  107912. static readonly FRONTSIDE: number;
  107913. /**
  107914. * Mesh side orientation : usually the internal or back surface
  107915. */
  107916. static readonly BACKSIDE: number;
  107917. /**
  107918. * Mesh side orientation : both internal and external or front and back surfaces
  107919. */
  107920. static readonly DOUBLESIDE: number;
  107921. /**
  107922. * Mesh side orientation : by default, `FRONTSIDE`
  107923. */
  107924. static readonly DEFAULTSIDE: number;
  107925. /**
  107926. * Mesh cap setting : no cap
  107927. */
  107928. static readonly NO_CAP: number;
  107929. /**
  107930. * Mesh cap setting : one cap at the beginning of the mesh
  107931. */
  107932. static readonly CAP_START: number;
  107933. /**
  107934. * Mesh cap setting : one cap at the end of the mesh
  107935. */
  107936. static readonly CAP_END: number;
  107937. /**
  107938. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  107939. */
  107940. static readonly CAP_ALL: number;
  107941. /**
  107942. * Mesh pattern setting : no flip or rotate
  107943. */
  107944. static readonly NO_FLIP: number;
  107945. /**
  107946. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  107947. */
  107948. static readonly FLIP_TILE: number;
  107949. /**
  107950. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  107951. */
  107952. static readonly ROTATE_TILE: number;
  107953. /**
  107954. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  107955. */
  107956. static readonly FLIP_ROW: number;
  107957. /**
  107958. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  107959. */
  107960. static readonly ROTATE_ROW: number;
  107961. /**
  107962. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  107963. */
  107964. static readonly FLIP_N_ROTATE_TILE: number;
  107965. /**
  107966. * Mesh pattern setting : rotate pattern and rotate
  107967. */
  107968. static readonly FLIP_N_ROTATE_ROW: number;
  107969. /**
  107970. * Mesh tile positioning : part tiles same on left/right or top/bottom
  107971. */
  107972. static readonly CENTER: number;
  107973. /**
  107974. * Mesh tile positioning : part tiles on left
  107975. */
  107976. static readonly LEFT: number;
  107977. /**
  107978. * Mesh tile positioning : part tiles on right
  107979. */
  107980. static readonly RIGHT: number;
  107981. /**
  107982. * Mesh tile positioning : part tiles on top
  107983. */
  107984. static readonly TOP: number;
  107985. /**
  107986. * Mesh tile positioning : part tiles on bottom
  107987. */
  107988. static readonly BOTTOM: number;
  107989. /**
  107990. * Gets the default side orientation.
  107991. * @param orientation the orientation to value to attempt to get
  107992. * @returns the default orientation
  107993. * @hidden
  107994. */
  107995. static _GetDefaultSideOrientation(orientation?: number): number;
  107996. private _internalMeshDataInfo;
  107997. get computeBonesUsingShaders(): boolean;
  107998. set computeBonesUsingShaders(value: boolean);
  107999. /**
  108000. * An event triggered before rendering the mesh
  108001. */
  108002. get onBeforeRenderObservable(): Observable<Mesh>;
  108003. /**
  108004. * An event triggered before binding the mesh
  108005. */
  108006. get onBeforeBindObservable(): Observable<Mesh>;
  108007. /**
  108008. * An event triggered after rendering the mesh
  108009. */
  108010. get onAfterRenderObservable(): Observable<Mesh>;
  108011. /**
  108012. * An event triggered before drawing the mesh
  108013. */
  108014. get onBeforeDrawObservable(): Observable<Mesh>;
  108015. private _onBeforeDrawObserver;
  108016. /**
  108017. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  108018. */
  108019. set onBeforeDraw(callback: () => void);
  108020. get hasInstances(): boolean;
  108021. get hasThinInstances(): boolean;
  108022. /**
  108023. * Gets the delay loading state of the mesh (when delay loading is turned on)
  108024. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  108025. */
  108026. delayLoadState: number;
  108027. /**
  108028. * Gets the list of instances created from this mesh
  108029. * it is not supposed to be modified manually.
  108030. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  108031. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  108032. */
  108033. instances: InstancedMesh[];
  108034. /**
  108035. * Gets the file containing delay loading data for this mesh
  108036. */
  108037. delayLoadingFile: string;
  108038. /** @hidden */
  108039. _binaryInfo: any;
  108040. /**
  108041. * User defined function used to change how LOD level selection is done
  108042. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108043. */
  108044. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  108045. /**
  108046. * Gets or sets the morph target manager
  108047. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  108048. */
  108049. get morphTargetManager(): Nullable<MorphTargetManager>;
  108050. set morphTargetManager(value: Nullable<MorphTargetManager>);
  108051. /** @hidden */
  108052. _creationDataStorage: Nullable<_CreationDataStorage>;
  108053. /** @hidden */
  108054. _geometry: Nullable<Geometry>;
  108055. /** @hidden */
  108056. _delayInfo: Array<string>;
  108057. /** @hidden */
  108058. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  108059. /** @hidden */
  108060. _instanceDataStorage: _InstanceDataStorage;
  108061. /** @hidden */
  108062. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  108063. private _effectiveMaterial;
  108064. /** @hidden */
  108065. _shouldGenerateFlatShading: boolean;
  108066. /** @hidden */
  108067. _originalBuilderSideOrientation: number;
  108068. /**
  108069. * Use this property to change the original side orientation defined at construction time
  108070. */
  108071. overrideMaterialSideOrientation: Nullable<number>;
  108072. /**
  108073. * Gets the source mesh (the one used to clone this one from)
  108074. */
  108075. get source(): Nullable<Mesh>;
  108076. /**
  108077. * Gets the list of clones of this mesh
  108078. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  108079. * Note that useClonedMeshMap=true is the default setting
  108080. */
  108081. get cloneMeshMap(): Nullable<{
  108082. [id: string]: Mesh | undefined;
  108083. }>;
  108084. /**
  108085. * Gets or sets a boolean indicating that this mesh does not use index buffer
  108086. */
  108087. get isUnIndexed(): boolean;
  108088. set isUnIndexed(value: boolean);
  108089. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  108090. get worldMatrixInstancedBuffer(): Float32Array;
  108091. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  108092. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  108093. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  108094. /**
  108095. * @constructor
  108096. * @param name The value used by scene.getMeshByName() to do a lookup.
  108097. * @param scene The scene to add this mesh to.
  108098. * @param parent The parent of this mesh, if it has one
  108099. * @param source An optional Mesh from which geometry is shared, cloned.
  108100. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  108101. * When false, achieved by calling a clone(), also passing False.
  108102. * This will make creation of children, recursive.
  108103. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  108104. */
  108105. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  108106. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  108107. doNotInstantiate: boolean;
  108108. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  108109. /**
  108110. * Gets the class name
  108111. * @returns the string "Mesh".
  108112. */
  108113. getClassName(): string;
  108114. /** @hidden */
  108115. get _isMesh(): boolean;
  108116. /**
  108117. * Returns a description of this mesh
  108118. * @param fullDetails define if full details about this mesh must be used
  108119. * @returns a descriptive string representing this mesh
  108120. */
  108121. toString(fullDetails?: boolean): string;
  108122. /** @hidden */
  108123. _unBindEffect(): void;
  108124. /**
  108125. * Gets a boolean indicating if this mesh has LOD
  108126. */
  108127. get hasLODLevels(): boolean;
  108128. /**
  108129. * Gets the list of MeshLODLevel associated with the current mesh
  108130. * @returns an array of MeshLODLevel
  108131. */
  108132. getLODLevels(): MeshLODLevel[];
  108133. private _sortLODLevels;
  108134. /**
  108135. * Add a mesh as LOD level triggered at the given distance.
  108136. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108137. * @param distance The distance from the center of the object to show this level
  108138. * @param mesh The mesh to be added as LOD level (can be null)
  108139. * @return This mesh (for chaining)
  108140. */
  108141. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  108142. /**
  108143. * Returns the LOD level mesh at the passed distance or null if not found.
  108144. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108145. * @param distance The distance from the center of the object to show this level
  108146. * @returns a Mesh or `null`
  108147. */
  108148. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  108149. /**
  108150. * Remove a mesh from the LOD array
  108151. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108152. * @param mesh defines the mesh to be removed
  108153. * @return This mesh (for chaining)
  108154. */
  108155. removeLODLevel(mesh: Mesh): Mesh;
  108156. /**
  108157. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  108158. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108159. * @param camera defines the camera to use to compute distance
  108160. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  108161. * @return This mesh (for chaining)
  108162. */
  108163. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  108164. /**
  108165. * Gets the mesh internal Geometry object
  108166. */
  108167. get geometry(): Nullable<Geometry>;
  108168. /**
  108169. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  108170. * @returns the total number of vertices
  108171. */
  108172. getTotalVertices(): number;
  108173. /**
  108174. * Returns the content of an associated vertex buffer
  108175. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108176. * - VertexBuffer.PositionKind
  108177. * - VertexBuffer.UVKind
  108178. * - VertexBuffer.UV2Kind
  108179. * - VertexBuffer.UV3Kind
  108180. * - VertexBuffer.UV4Kind
  108181. * - VertexBuffer.UV5Kind
  108182. * - VertexBuffer.UV6Kind
  108183. * - VertexBuffer.ColorKind
  108184. * - VertexBuffer.MatricesIndicesKind
  108185. * - VertexBuffer.MatricesIndicesExtraKind
  108186. * - VertexBuffer.MatricesWeightsKind
  108187. * - VertexBuffer.MatricesWeightsExtraKind
  108188. * @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
  108189. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  108190. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  108191. */
  108192. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  108193. /**
  108194. * Returns the mesh VertexBuffer object from the requested `kind`
  108195. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108196. * - VertexBuffer.PositionKind
  108197. * - VertexBuffer.NormalKind
  108198. * - VertexBuffer.UVKind
  108199. * - VertexBuffer.UV2Kind
  108200. * - VertexBuffer.UV3Kind
  108201. * - VertexBuffer.UV4Kind
  108202. * - VertexBuffer.UV5Kind
  108203. * - VertexBuffer.UV6Kind
  108204. * - VertexBuffer.ColorKind
  108205. * - VertexBuffer.MatricesIndicesKind
  108206. * - VertexBuffer.MatricesIndicesExtraKind
  108207. * - VertexBuffer.MatricesWeightsKind
  108208. * - VertexBuffer.MatricesWeightsExtraKind
  108209. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  108210. */
  108211. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  108212. /**
  108213. * Tests if a specific vertex buffer is associated with this mesh
  108214. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  108215. * - VertexBuffer.PositionKind
  108216. * - VertexBuffer.NormalKind
  108217. * - VertexBuffer.UVKind
  108218. * - VertexBuffer.UV2Kind
  108219. * - VertexBuffer.UV3Kind
  108220. * - VertexBuffer.UV4Kind
  108221. * - VertexBuffer.UV5Kind
  108222. * - VertexBuffer.UV6Kind
  108223. * - VertexBuffer.ColorKind
  108224. * - VertexBuffer.MatricesIndicesKind
  108225. * - VertexBuffer.MatricesIndicesExtraKind
  108226. * - VertexBuffer.MatricesWeightsKind
  108227. * - VertexBuffer.MatricesWeightsExtraKind
  108228. * @returns a boolean
  108229. */
  108230. isVerticesDataPresent(kind: string): boolean;
  108231. /**
  108232. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  108233. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  108234. * - VertexBuffer.PositionKind
  108235. * - VertexBuffer.UVKind
  108236. * - VertexBuffer.UV2Kind
  108237. * - VertexBuffer.UV3Kind
  108238. * - VertexBuffer.UV4Kind
  108239. * - VertexBuffer.UV5Kind
  108240. * - VertexBuffer.UV6Kind
  108241. * - VertexBuffer.ColorKind
  108242. * - VertexBuffer.MatricesIndicesKind
  108243. * - VertexBuffer.MatricesIndicesExtraKind
  108244. * - VertexBuffer.MatricesWeightsKind
  108245. * - VertexBuffer.MatricesWeightsExtraKind
  108246. * @returns a boolean
  108247. */
  108248. isVertexBufferUpdatable(kind: string): boolean;
  108249. /**
  108250. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  108251. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108252. * - VertexBuffer.PositionKind
  108253. * - VertexBuffer.NormalKind
  108254. * - VertexBuffer.UVKind
  108255. * - VertexBuffer.UV2Kind
  108256. * - VertexBuffer.UV3Kind
  108257. * - VertexBuffer.UV4Kind
  108258. * - VertexBuffer.UV5Kind
  108259. * - VertexBuffer.UV6Kind
  108260. * - VertexBuffer.ColorKind
  108261. * - VertexBuffer.MatricesIndicesKind
  108262. * - VertexBuffer.MatricesIndicesExtraKind
  108263. * - VertexBuffer.MatricesWeightsKind
  108264. * - VertexBuffer.MatricesWeightsExtraKind
  108265. * @returns an array of strings
  108266. */
  108267. getVerticesDataKinds(): string[];
  108268. /**
  108269. * Returns a positive integer : the total number of indices in this mesh geometry.
  108270. * @returns the numner of indices or zero if the mesh has no geometry.
  108271. */
  108272. getTotalIndices(): number;
  108273. /**
  108274. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  108275. * @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.
  108276. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  108277. * @returns the indices array or an empty array if the mesh has no geometry
  108278. */
  108279. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  108280. get isBlocked(): boolean;
  108281. /**
  108282. * Determine if the current mesh is ready to be rendered
  108283. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  108284. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  108285. * @returns true if all associated assets are ready (material, textures, shaders)
  108286. */
  108287. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  108288. /**
  108289. * 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.
  108290. */
  108291. get areNormalsFrozen(): boolean;
  108292. /**
  108293. * 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.
  108294. * @returns the current mesh
  108295. */
  108296. freezeNormals(): Mesh;
  108297. /**
  108298. * 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
  108299. * @returns the current mesh
  108300. */
  108301. unfreezeNormals(): Mesh;
  108302. /**
  108303. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  108304. */
  108305. set overridenInstanceCount(count: number);
  108306. /** @hidden */
  108307. _preActivate(): Mesh;
  108308. /** @hidden */
  108309. _preActivateForIntermediateRendering(renderId: number): Mesh;
  108310. /** @hidden */
  108311. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  108312. protected _afterComputeWorldMatrix(): void;
  108313. /** @hidden */
  108314. _postActivate(): void;
  108315. /**
  108316. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  108317. * This means the mesh underlying bounding box and sphere are recomputed.
  108318. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  108319. * @returns the current mesh
  108320. */
  108321. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  108322. /** @hidden */
  108323. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  108324. /**
  108325. * This function will subdivide the mesh into multiple submeshes
  108326. * @param count defines the expected number of submeshes
  108327. */
  108328. subdivide(count: number): void;
  108329. /**
  108330. * Copy a FloatArray into a specific associated vertex buffer
  108331. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  108332. * - VertexBuffer.PositionKind
  108333. * - VertexBuffer.UVKind
  108334. * - VertexBuffer.UV2Kind
  108335. * - VertexBuffer.UV3Kind
  108336. * - VertexBuffer.UV4Kind
  108337. * - VertexBuffer.UV5Kind
  108338. * - VertexBuffer.UV6Kind
  108339. * - VertexBuffer.ColorKind
  108340. * - VertexBuffer.MatricesIndicesKind
  108341. * - VertexBuffer.MatricesIndicesExtraKind
  108342. * - VertexBuffer.MatricesWeightsKind
  108343. * - VertexBuffer.MatricesWeightsExtraKind
  108344. * @param data defines the data source
  108345. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  108346. * @param stride defines the data stride size (can be null)
  108347. * @returns the current mesh
  108348. */
  108349. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  108350. /**
  108351. * Delete a vertex buffer associated with this mesh
  108352. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  108353. * - VertexBuffer.PositionKind
  108354. * - VertexBuffer.UVKind
  108355. * - VertexBuffer.UV2Kind
  108356. * - VertexBuffer.UV3Kind
  108357. * - VertexBuffer.UV4Kind
  108358. * - VertexBuffer.UV5Kind
  108359. * - VertexBuffer.UV6Kind
  108360. * - VertexBuffer.ColorKind
  108361. * - VertexBuffer.MatricesIndicesKind
  108362. * - VertexBuffer.MatricesIndicesExtraKind
  108363. * - VertexBuffer.MatricesWeightsKind
  108364. * - VertexBuffer.MatricesWeightsExtraKind
  108365. */
  108366. removeVerticesData(kind: string): void;
  108367. /**
  108368. * Flags an associated vertex buffer as updatable
  108369. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  108370. * - VertexBuffer.PositionKind
  108371. * - VertexBuffer.UVKind
  108372. * - VertexBuffer.UV2Kind
  108373. * - VertexBuffer.UV3Kind
  108374. * - VertexBuffer.UV4Kind
  108375. * - VertexBuffer.UV5Kind
  108376. * - VertexBuffer.UV6Kind
  108377. * - VertexBuffer.ColorKind
  108378. * - VertexBuffer.MatricesIndicesKind
  108379. * - VertexBuffer.MatricesIndicesExtraKind
  108380. * - VertexBuffer.MatricesWeightsKind
  108381. * - VertexBuffer.MatricesWeightsExtraKind
  108382. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  108383. */
  108384. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  108385. /**
  108386. * Sets the mesh global Vertex Buffer
  108387. * @param buffer defines the buffer to use
  108388. * @returns the current mesh
  108389. */
  108390. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  108391. /**
  108392. * Update a specific associated vertex buffer
  108393. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  108394. * - VertexBuffer.PositionKind
  108395. * - VertexBuffer.UVKind
  108396. * - VertexBuffer.UV2Kind
  108397. * - VertexBuffer.UV3Kind
  108398. * - VertexBuffer.UV4Kind
  108399. * - VertexBuffer.UV5Kind
  108400. * - VertexBuffer.UV6Kind
  108401. * - VertexBuffer.ColorKind
  108402. * - VertexBuffer.MatricesIndicesKind
  108403. * - VertexBuffer.MatricesIndicesExtraKind
  108404. * - VertexBuffer.MatricesWeightsKind
  108405. * - VertexBuffer.MatricesWeightsExtraKind
  108406. * @param data defines the data source
  108407. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  108408. * @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)
  108409. * @returns the current mesh
  108410. */
  108411. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  108412. /**
  108413. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  108414. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  108415. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  108416. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  108417. * @returns the current mesh
  108418. */
  108419. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  108420. /**
  108421. * Creates a un-shared specific occurence of the geometry for the mesh.
  108422. * @returns the current mesh
  108423. */
  108424. makeGeometryUnique(): Mesh;
  108425. /**
  108426. * Set the index buffer of this mesh
  108427. * @param indices defines the source data
  108428. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  108429. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  108430. * @returns the current mesh
  108431. */
  108432. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  108433. /**
  108434. * Update the current index buffer
  108435. * @param indices defines the source data
  108436. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  108437. * @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)
  108438. * @returns the current mesh
  108439. */
  108440. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  108441. /**
  108442. * Invert the geometry to move from a right handed system to a left handed one.
  108443. * @returns the current mesh
  108444. */
  108445. toLeftHanded(): Mesh;
  108446. /** @hidden */
  108447. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  108448. /** @hidden */
  108449. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  108450. /**
  108451. * Registers for this mesh a javascript function called just before the rendering process
  108452. * @param func defines the function to call before rendering this mesh
  108453. * @returns the current mesh
  108454. */
  108455. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  108456. /**
  108457. * Disposes a previously registered javascript function called before the rendering
  108458. * @param func defines the function to remove
  108459. * @returns the current mesh
  108460. */
  108461. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  108462. /**
  108463. * Registers for this mesh a javascript function called just after the rendering is complete
  108464. * @param func defines the function to call after rendering this mesh
  108465. * @returns the current mesh
  108466. */
  108467. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  108468. /**
  108469. * Disposes a previously registered javascript function called after the rendering.
  108470. * @param func defines the function to remove
  108471. * @returns the current mesh
  108472. */
  108473. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  108474. /** @hidden */
  108475. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  108476. /** @hidden */
  108477. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  108478. /** @hidden */
  108479. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  108480. /** @hidden */
  108481. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  108482. /** @hidden */
  108483. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  108484. /** @hidden */
  108485. _rebuild(): void;
  108486. /** @hidden */
  108487. _freeze(): void;
  108488. /** @hidden */
  108489. _unFreeze(): void;
  108490. /**
  108491. * 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
  108492. * @param subMesh defines the subMesh to render
  108493. * @param enableAlphaMode defines if alpha mode can be changed
  108494. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  108495. * @returns the current mesh
  108496. */
  108497. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  108498. private _onBeforeDraw;
  108499. /**
  108500. * Renormalize the mesh and patch it up if there are no weights
  108501. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  108502. * However in the case of zero weights then we set just a single influence to 1.
  108503. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  108504. */
  108505. cleanMatrixWeights(): void;
  108506. private normalizeSkinFourWeights;
  108507. private normalizeSkinWeightsAndExtra;
  108508. /**
  108509. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  108510. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  108511. * the user know there was an issue with importing the mesh
  108512. * @returns a validation object with skinned, valid and report string
  108513. */
  108514. validateSkinning(): {
  108515. skinned: boolean;
  108516. valid: boolean;
  108517. report: string;
  108518. };
  108519. /** @hidden */
  108520. _checkDelayState(): Mesh;
  108521. private _queueLoad;
  108522. /**
  108523. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  108524. * A mesh is in the frustum if its bounding box intersects the frustum
  108525. * @param frustumPlanes defines the frustum to test
  108526. * @returns true if the mesh is in the frustum planes
  108527. */
  108528. isInFrustum(frustumPlanes: Plane[]): boolean;
  108529. /**
  108530. * Sets the mesh material by the material or multiMaterial `id` property
  108531. * @param id is a string identifying the material or the multiMaterial
  108532. * @returns the current mesh
  108533. */
  108534. setMaterialByID(id: string): Mesh;
  108535. /**
  108536. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  108537. * @returns an array of IAnimatable
  108538. */
  108539. getAnimatables(): IAnimatable[];
  108540. /**
  108541. * Modifies the mesh geometry according to the passed transformation matrix.
  108542. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  108543. * The mesh normals are modified using the same transformation.
  108544. * Note that, under the hood, this method sets a new VertexBuffer each call.
  108545. * @param transform defines the transform matrix to use
  108546. * @see https://doc.babylonjs.com/resources/baking_transformations
  108547. * @returns the current mesh
  108548. */
  108549. bakeTransformIntoVertices(transform: Matrix): Mesh;
  108550. /**
  108551. * Modifies the mesh geometry according to its own current World Matrix.
  108552. * The mesh World Matrix is then reset.
  108553. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  108554. * Note that, under the hood, this method sets a new VertexBuffer each call.
  108555. * @see https://doc.babylonjs.com/resources/baking_transformations
  108556. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  108557. * @returns the current mesh
  108558. */
  108559. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  108560. /** @hidden */
  108561. get _positions(): Nullable<Vector3[]>;
  108562. /** @hidden */
  108563. _resetPointsArrayCache(): Mesh;
  108564. /** @hidden */
  108565. _generatePointsArray(): boolean;
  108566. /**
  108567. * Returns a new Mesh object generated from the current mesh properties.
  108568. * This method must not get confused with createInstance()
  108569. * @param name is a string, the name given to the new mesh
  108570. * @param newParent can be any Node object (default `null`)
  108571. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  108572. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  108573. * @returns a new mesh
  108574. */
  108575. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  108576. /**
  108577. * Releases resources associated with this mesh.
  108578. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108579. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108580. */
  108581. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108582. /** @hidden */
  108583. _disposeInstanceSpecificData(): void;
  108584. /** @hidden */
  108585. _disposeThinInstanceSpecificData(): void;
  108586. /**
  108587. * Modifies the mesh geometry according to a displacement map.
  108588. * 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.
  108589. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  108590. * @param url is a string, the URL from the image file is to be downloaded.
  108591. * @param minHeight is the lower limit of the displacement.
  108592. * @param maxHeight is the upper limit of the displacement.
  108593. * @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.
  108594. * @param uvOffset is an optional vector2 used to offset UV.
  108595. * @param uvScale is an optional vector2 used to scale UV.
  108596. * @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.
  108597. * @returns the Mesh.
  108598. */
  108599. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  108600. /**
  108601. * Modifies the mesh geometry according to a displacementMap buffer.
  108602. * 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.
  108603. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  108604. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  108605. * @param heightMapWidth is the width of the buffer image.
  108606. * @param heightMapHeight is the height of the buffer image.
  108607. * @param minHeight is the lower limit of the displacement.
  108608. * @param maxHeight is the upper limit of the displacement.
  108609. * @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.
  108610. * @param uvOffset is an optional vector2 used to offset UV.
  108611. * @param uvScale is an optional vector2 used to scale UV.
  108612. * @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.
  108613. * @returns the Mesh.
  108614. */
  108615. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  108616. /**
  108617. * Modify the mesh to get a flat shading rendering.
  108618. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  108619. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  108620. * @returns current mesh
  108621. */
  108622. convertToFlatShadedMesh(): Mesh;
  108623. /**
  108624. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  108625. * In other words, more vertices, no more indices and a single bigger VBO.
  108626. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  108627. * @returns current mesh
  108628. */
  108629. convertToUnIndexedMesh(): Mesh;
  108630. /**
  108631. * Inverses facet orientations.
  108632. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  108633. * @param flipNormals will also inverts the normals
  108634. * @returns current mesh
  108635. */
  108636. flipFaces(flipNormals?: boolean): Mesh;
  108637. /**
  108638. * Increase the number of facets and hence vertices in a mesh
  108639. * Vertex normals are interpolated from existing vertex normals
  108640. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  108641. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  108642. */
  108643. increaseVertices(numberPerEdge: number): void;
  108644. /**
  108645. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  108646. * This will undo any application of covertToFlatShadedMesh
  108647. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  108648. */
  108649. forceSharedVertices(): void;
  108650. /** @hidden */
  108651. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  108652. /** @hidden */
  108653. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  108654. /**
  108655. * Creates a new InstancedMesh object from the mesh model.
  108656. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  108657. * @param name defines the name of the new instance
  108658. * @returns a new InstancedMesh
  108659. */
  108660. createInstance(name: string): InstancedMesh;
  108661. /**
  108662. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  108663. * After this call, all the mesh instances have the same submeshes than the current mesh.
  108664. * @returns the current mesh
  108665. */
  108666. synchronizeInstances(): Mesh;
  108667. /**
  108668. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  108669. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  108670. * This should be used together with the simplification to avoid disappearing triangles.
  108671. * @param successCallback an optional success callback to be called after the optimization finished.
  108672. * @returns the current mesh
  108673. */
  108674. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  108675. /**
  108676. * Serialize current mesh
  108677. * @param serializationObject defines the object which will receive the serialization data
  108678. */
  108679. serialize(serializationObject: any): void;
  108680. /** @hidden */
  108681. _syncGeometryWithMorphTargetManager(): void;
  108682. /** @hidden */
  108683. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  108684. /**
  108685. * Returns a new Mesh object parsed from the source provided.
  108686. * @param parsedMesh is the source
  108687. * @param scene defines the hosting scene
  108688. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  108689. * @returns a new Mesh
  108690. */
  108691. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  108692. /**
  108693. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  108694. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108695. * @param name defines the name of the mesh to create
  108696. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  108697. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  108698. * @param closePath creates a seam between the first and the last points of each path of the path array
  108699. * @param offset is taken in account only if the `pathArray` is containing a single path
  108700. * @param scene defines the hosting scene
  108701. * @param updatable defines if the mesh must be flagged as updatable
  108702. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108703. * @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)
  108704. * @returns a new Mesh
  108705. */
  108706. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  108707. /**
  108708. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  108709. * @param name defines the name of the mesh to create
  108710. * @param radius sets the radius size (float) of the polygon (default 0.5)
  108711. * @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
  108712. * @param scene defines the hosting scene
  108713. * @param updatable defines if the mesh must be flagged as updatable
  108714. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108715. * @returns a new Mesh
  108716. */
  108717. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  108718. /**
  108719. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  108720. * @param name defines the name of the mesh to create
  108721. * @param size sets the size (float) of each box side (default 1)
  108722. * @param scene defines the hosting scene
  108723. * @param updatable defines if the mesh must be flagged as updatable
  108724. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108725. * @returns a new Mesh
  108726. */
  108727. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  108728. /**
  108729. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  108730. * @param name defines the name of the mesh to create
  108731. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  108732. * @param diameter sets the diameter size (float) of the sphere (default 1)
  108733. * @param scene defines the hosting scene
  108734. * @param updatable defines if the mesh must be flagged as updatable
  108735. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108736. * @returns a new Mesh
  108737. */
  108738. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108739. /**
  108740. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  108741. * @param name defines the name of the mesh to create
  108742. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  108743. * @param diameter sets the diameter size (float) of the sphere (default 1)
  108744. * @param scene defines the hosting scene
  108745. * @returns a new Mesh
  108746. */
  108747. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  108748. /**
  108749. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  108750. * @param name defines the name of the mesh to create
  108751. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  108752. * @param diameterTop set the top cap diameter (floats, default 1)
  108753. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  108754. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  108755. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  108756. * @param scene defines the hosting scene
  108757. * @param updatable defines if the mesh must be flagged as updatable
  108758. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108759. * @returns a new Mesh
  108760. */
  108761. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  108762. /**
  108763. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  108764. * @param name defines the name of the mesh to create
  108765. * @param diameter sets the diameter size (float) of the torus (default 1)
  108766. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  108767. * @param tessellation sets the number of torus sides (postive integer, default 16)
  108768. * @param scene defines the hosting scene
  108769. * @param updatable defines if the mesh must be flagged as updatable
  108770. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108771. * @returns a new Mesh
  108772. */
  108773. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108774. /**
  108775. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  108776. * @param name defines the name of the mesh to create
  108777. * @param radius sets the global radius size (float) of the torus knot (default 2)
  108778. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  108779. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  108780. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  108781. * @param p the number of windings on X axis (positive integers, default 2)
  108782. * @param q the number of windings on Y axis (positive integers, default 3)
  108783. * @param scene defines the hosting scene
  108784. * @param updatable defines if the mesh must be flagged as updatable
  108785. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108786. * @returns a new Mesh
  108787. */
  108788. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108789. /**
  108790. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  108791. * @param name defines the name of the mesh to create
  108792. * @param points is an array successive Vector3
  108793. * @param scene defines the hosting scene
  108794. * @param updatable defines if the mesh must be flagged as updatable
  108795. * @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).
  108796. * @returns a new Mesh
  108797. */
  108798. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  108799. /**
  108800. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  108801. * @param name defines the name of the mesh to create
  108802. * @param points is an array successive Vector3
  108803. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  108804. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  108805. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  108806. * @param scene defines the hosting scene
  108807. * @param updatable defines if the mesh must be flagged as updatable
  108808. * @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)
  108809. * @returns a new Mesh
  108810. */
  108811. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  108812. /**
  108813. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  108814. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  108815. * 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.
  108816. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  108817. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  108818. * Remember you can only change the shape positions, not their number when updating a polygon.
  108819. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  108820. * @param name defines the name of the mesh to create
  108821. * @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
  108822. * @param scene defines the hosting scene
  108823. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  108824. * @param updatable defines if the mesh must be flagged as updatable
  108825. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108826. * @param earcutInjection can be used to inject your own earcut reference
  108827. * @returns a new Mesh
  108828. */
  108829. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  108830. /**
  108831. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  108832. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  108833. * @param name defines the name of the mesh to create
  108834. * @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
  108835. * @param depth defines the height of extrusion
  108836. * @param scene defines the hosting scene
  108837. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  108838. * @param updatable defines if the mesh must be flagged as updatable
  108839. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108840. * @param earcutInjection can be used to inject your own earcut reference
  108841. * @returns a new Mesh
  108842. */
  108843. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  108844. /**
  108845. * Creates an extruded shape mesh.
  108846. * 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
  108847. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108848. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108849. * @param name defines the name of the mesh to create
  108850. * @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
  108851. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  108852. * @param scale is the value to scale the shape
  108853. * @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
  108854. * @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
  108855. * @param scene defines the hosting scene
  108856. * @param updatable defines if the mesh must be flagged as updatable
  108857. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108858. * @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)
  108859. * @returns a new Mesh
  108860. */
  108861. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  108862. /**
  108863. * Creates an custom extruded shape mesh.
  108864. * The custom extrusion is a parametric shape.
  108865. * It has no predefined shape. Its final shape will depend on the input parameters.
  108866. * Please consider using the same method from the MeshBuilder class instead
  108867. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  108868. * @param name defines the name of the mesh to create
  108869. * @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
  108870. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  108871. * @param scaleFunction is a custom Javascript function called on each path point
  108872. * @param rotationFunction is a custom Javascript function called on each path point
  108873. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  108874. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  108875. * @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
  108876. * @param scene defines the hosting scene
  108877. * @param updatable defines if the mesh must be flagged as updatable
  108878. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108879. * @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)
  108880. * @returns a new Mesh
  108881. */
  108882. 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;
  108883. /**
  108884. * Creates lathe mesh.
  108885. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  108886. * Please consider using the same method from the MeshBuilder class instead
  108887. * @param name defines the name of the mesh to create
  108888. * @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
  108889. * @param radius is the radius value of the lathe
  108890. * @param tessellation is the side number of the lathe.
  108891. * @param scene defines the hosting scene
  108892. * @param updatable defines if the mesh must be flagged as updatable
  108893. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108894. * @returns a new Mesh
  108895. */
  108896. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108897. /**
  108898. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  108899. * @param name defines the name of the mesh to create
  108900. * @param size sets the size (float) of both sides of the plane at once (default 1)
  108901. * @param scene defines the hosting scene
  108902. * @param updatable defines if the mesh must be flagged as updatable
  108903. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108904. * @returns a new Mesh
  108905. */
  108906. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  108907. /**
  108908. * Creates a ground mesh.
  108909. * Please consider using the same method from the MeshBuilder class instead
  108910. * @param name defines the name of the mesh to create
  108911. * @param width set the width of the ground
  108912. * @param height set the height of the ground
  108913. * @param subdivisions sets the number of subdivisions per side
  108914. * @param scene defines the hosting scene
  108915. * @param updatable defines if the mesh must be flagged as updatable
  108916. * @returns a new Mesh
  108917. */
  108918. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  108919. /**
  108920. * Creates a tiled ground mesh.
  108921. * Please consider using the same method from the MeshBuilder class instead
  108922. * @param name defines the name of the mesh to create
  108923. * @param xmin set the ground minimum X coordinate
  108924. * @param zmin set the ground minimum Y coordinate
  108925. * @param xmax set the ground maximum X coordinate
  108926. * @param zmax set the ground maximum Z coordinate
  108927. * @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
  108928. * @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
  108929. * @param scene defines the hosting scene
  108930. * @param updatable defines if the mesh must be flagged as updatable
  108931. * @returns a new Mesh
  108932. */
  108933. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  108934. w: number;
  108935. h: number;
  108936. }, precision: {
  108937. w: number;
  108938. h: number;
  108939. }, scene: Scene, updatable?: boolean): Mesh;
  108940. /**
  108941. * Creates a ground mesh from a height map.
  108942. * Please consider using the same method from the MeshBuilder class instead
  108943. * @see https://doc.babylonjs.com/babylon101/height_map
  108944. * @param name defines the name of the mesh to create
  108945. * @param url sets the URL of the height map image resource
  108946. * @param width set the ground width size
  108947. * @param height set the ground height size
  108948. * @param subdivisions sets the number of subdivision per side
  108949. * @param minHeight is the minimum altitude on the ground
  108950. * @param maxHeight is the maximum altitude on the ground
  108951. * @param scene defines the hosting scene
  108952. * @param updatable defines if the mesh must be flagged as updatable
  108953. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  108954. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  108955. * @returns a new Mesh
  108956. */
  108957. 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;
  108958. /**
  108959. * Creates a tube mesh.
  108960. * The tube is a parametric shape.
  108961. * It has no predefined shape. Its final shape will depend on the input parameters.
  108962. * Please consider using the same method from the MeshBuilder class instead
  108963. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  108964. * @param name defines the name of the mesh to create
  108965. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  108966. * @param radius sets the tube radius size
  108967. * @param tessellation is the number of sides on the tubular surface
  108968. * @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
  108969. * @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
  108970. * @param scene defines the hosting scene
  108971. * @param updatable defines if the mesh must be flagged as updatable
  108972. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  108973. * @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)
  108974. * @returns a new Mesh
  108975. */
  108976. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  108977. (i: number, distance: number): number;
  108978. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  108979. /**
  108980. * Creates a polyhedron mesh.
  108981. * Please consider using the same method from the MeshBuilder class instead.
  108982. * * 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
  108983. * * The parameter `size` (positive float, default 1) sets the polygon size
  108984. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  108985. * * 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`
  108986. * * 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
  108987. * * 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)`)
  108988. * * 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
  108989. * * 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
  108990. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  108991. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108992. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108993. * @param name defines the name of the mesh to create
  108994. * @param options defines the options used to create the mesh
  108995. * @param scene defines the hosting scene
  108996. * @returns a new Mesh
  108997. */
  108998. static CreatePolyhedron(name: string, options: {
  108999. type?: number;
  109000. size?: number;
  109001. sizeX?: number;
  109002. sizeY?: number;
  109003. sizeZ?: number;
  109004. custom?: any;
  109005. faceUV?: Vector4[];
  109006. faceColors?: Color4[];
  109007. updatable?: boolean;
  109008. sideOrientation?: number;
  109009. }, scene: Scene): Mesh;
  109010. /**
  109011. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109012. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109013. * * 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`)
  109014. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109015. * * 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
  109016. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109017. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109019. * @param name defines the name of the mesh
  109020. * @param options defines the options used to create the mesh
  109021. * @param scene defines the hosting scene
  109022. * @returns a new Mesh
  109023. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109024. */
  109025. static CreateIcoSphere(name: string, options: {
  109026. radius?: number;
  109027. flat?: boolean;
  109028. subdivisions?: number;
  109029. sideOrientation?: number;
  109030. updatable?: boolean;
  109031. }, scene: Scene): Mesh;
  109032. /**
  109033. * Creates a decal mesh.
  109034. * Please consider using the same method from the MeshBuilder class instead.
  109035. * A decal is a mesh usually applied as a model onto the surface of another mesh
  109036. * @param name defines the name of the mesh
  109037. * @param sourceMesh defines the mesh receiving the decal
  109038. * @param position sets the position of the decal in world coordinates
  109039. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  109040. * @param size sets the decal scaling
  109041. * @param angle sets the angle to rotate the decal
  109042. * @returns a new Mesh
  109043. */
  109044. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  109045. /**
  109046. * Prepare internal position array for software CPU skinning
  109047. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  109048. */
  109049. setPositionsForCPUSkinning(): Float32Array;
  109050. /**
  109051. * Prepare internal normal array for software CPU skinning
  109052. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  109053. */
  109054. setNormalsForCPUSkinning(): Float32Array;
  109055. /**
  109056. * Updates the vertex buffer by applying transformation from the bones
  109057. * @param skeleton defines the skeleton to apply to current mesh
  109058. * @returns the current mesh
  109059. */
  109060. applySkeleton(skeleton: Skeleton): Mesh;
  109061. /**
  109062. * 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
  109063. * @param meshes defines the list of meshes to scan
  109064. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  109065. */
  109066. static MinMax(meshes: AbstractMesh[]): {
  109067. min: Vector3;
  109068. max: Vector3;
  109069. };
  109070. /**
  109071. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  109072. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  109073. * @returns a vector3
  109074. */
  109075. static Center(meshesOrMinMaxVector: {
  109076. min: Vector3;
  109077. max: Vector3;
  109078. } | AbstractMesh[]): Vector3;
  109079. /**
  109080. * Merge the array of meshes into a single mesh for performance reasons.
  109081. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  109082. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  109083. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  109084. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  109085. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  109086. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  109087. * @returns a new mesh
  109088. */
  109089. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  109090. /** @hidden */
  109091. addInstance(instance: InstancedMesh): void;
  109092. /** @hidden */
  109093. removeInstance(instance: InstancedMesh): void;
  109094. }
  109095. }
  109096. declare module BABYLON {
  109097. /**
  109098. * This is the base class of all the camera used in the application.
  109099. * @see https://doc.babylonjs.com/features/cameras
  109100. */
  109101. export class Camera extends Node {
  109102. /** @hidden */
  109103. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  109104. /**
  109105. * This is the default projection mode used by the cameras.
  109106. * It helps recreating a feeling of perspective and better appreciate depth.
  109107. * This is the best way to simulate real life cameras.
  109108. */
  109109. static readonly PERSPECTIVE_CAMERA: number;
  109110. /**
  109111. * This helps creating camera with an orthographic mode.
  109112. * 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.
  109113. */
  109114. static readonly ORTHOGRAPHIC_CAMERA: number;
  109115. /**
  109116. * This is the default FOV mode for perspective cameras.
  109117. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  109118. */
  109119. static readonly FOVMODE_VERTICAL_FIXED: number;
  109120. /**
  109121. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  109122. */
  109123. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  109124. /**
  109125. * This specifies ther is no need for a camera rig.
  109126. * Basically only one eye is rendered corresponding to the camera.
  109127. */
  109128. static readonly RIG_MODE_NONE: number;
  109129. /**
  109130. * Simulates a camera Rig with one blue eye and one red eye.
  109131. * This can be use with 3d blue and red glasses.
  109132. */
  109133. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  109134. /**
  109135. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  109136. */
  109137. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  109138. /**
  109139. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  109140. */
  109141. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  109142. /**
  109143. * Defines that both eyes of the camera will be rendered over under each other.
  109144. */
  109145. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  109146. /**
  109147. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  109148. */
  109149. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  109150. /**
  109151. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  109152. */
  109153. static readonly RIG_MODE_VR: number;
  109154. /**
  109155. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  109156. */
  109157. static readonly RIG_MODE_WEBVR: number;
  109158. /**
  109159. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  109160. */
  109161. static readonly RIG_MODE_CUSTOM: number;
  109162. /**
  109163. * Defines if by default attaching controls should prevent the default javascript event to continue.
  109164. */
  109165. static ForceAttachControlToAlwaysPreventDefault: boolean;
  109166. /**
  109167. * Define the input manager associated with the camera.
  109168. */
  109169. inputs: CameraInputsManager<Camera>;
  109170. /** @hidden */
  109171. _position: Vector3;
  109172. /**
  109173. * Define the current local position of the camera in the scene
  109174. */
  109175. get position(): Vector3;
  109176. set position(newPosition: Vector3);
  109177. protected _upVector: Vector3;
  109178. /**
  109179. * The vector the camera should consider as up.
  109180. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  109181. */
  109182. set upVector(vec: Vector3);
  109183. get upVector(): Vector3;
  109184. /**
  109185. * Define the current limit on the left side for an orthographic camera
  109186. * In scene unit
  109187. */
  109188. orthoLeft: Nullable<number>;
  109189. /**
  109190. * Define the current limit on the right side for an orthographic camera
  109191. * In scene unit
  109192. */
  109193. orthoRight: Nullable<number>;
  109194. /**
  109195. * Define the current limit on the bottom side for an orthographic camera
  109196. * In scene unit
  109197. */
  109198. orthoBottom: Nullable<number>;
  109199. /**
  109200. * Define the current limit on the top side for an orthographic camera
  109201. * In scene unit
  109202. */
  109203. orthoTop: Nullable<number>;
  109204. /**
  109205. * Field Of View is set in Radians. (default is 0.8)
  109206. */
  109207. fov: number;
  109208. /**
  109209. * Define the minimum distance the camera can see from.
  109210. * This is important to note that the depth buffer are not infinite and the closer it starts
  109211. * the more your scene might encounter depth fighting issue.
  109212. */
  109213. minZ: number;
  109214. /**
  109215. * Define the maximum distance the camera can see to.
  109216. * This is important to note that the depth buffer are not infinite and the further it end
  109217. * the more your scene might encounter depth fighting issue.
  109218. */
  109219. maxZ: number;
  109220. /**
  109221. * Define the default inertia of the camera.
  109222. * This helps giving a smooth feeling to the camera movement.
  109223. */
  109224. inertia: number;
  109225. /**
  109226. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  109227. */
  109228. mode: number;
  109229. /**
  109230. * Define whether the camera is intermediate.
  109231. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  109232. */
  109233. isIntermediate: boolean;
  109234. /**
  109235. * Define the viewport of the camera.
  109236. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  109237. */
  109238. viewport: Viewport;
  109239. /**
  109240. * Restricts the camera to viewing objects with the same layerMask.
  109241. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  109242. */
  109243. layerMask: number;
  109244. /**
  109245. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  109246. */
  109247. fovMode: number;
  109248. /**
  109249. * Rig mode of the camera.
  109250. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  109251. * This is normally controlled byt the camera themselves as internal use.
  109252. */
  109253. cameraRigMode: number;
  109254. /**
  109255. * Defines the distance between both "eyes" in case of a RIG
  109256. */
  109257. interaxialDistance: number;
  109258. /**
  109259. * Defines if stereoscopic rendering is done side by side or over under.
  109260. */
  109261. isStereoscopicSideBySide: boolean;
  109262. /**
  109263. * 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
  109264. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  109265. * else in the scene. (Eg. security camera)
  109266. *
  109267. * 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)
  109268. */
  109269. customRenderTargets: RenderTargetTexture[];
  109270. /**
  109271. * When set, the camera will render to this render target instead of the default canvas
  109272. *
  109273. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  109274. */
  109275. outputRenderTarget: Nullable<RenderTargetTexture>;
  109276. /**
  109277. * Observable triggered when the camera view matrix has changed.
  109278. */
  109279. onViewMatrixChangedObservable: Observable<Camera>;
  109280. /**
  109281. * Observable triggered when the camera Projection matrix has changed.
  109282. */
  109283. onProjectionMatrixChangedObservable: Observable<Camera>;
  109284. /**
  109285. * Observable triggered when the inputs have been processed.
  109286. */
  109287. onAfterCheckInputsObservable: Observable<Camera>;
  109288. /**
  109289. * Observable triggered when reset has been called and applied to the camera.
  109290. */
  109291. onRestoreStateObservable: Observable<Camera>;
  109292. /**
  109293. * Is this camera a part of a rig system?
  109294. */
  109295. isRigCamera: boolean;
  109296. /**
  109297. * If isRigCamera set to true this will be set with the parent camera.
  109298. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  109299. */
  109300. rigParent?: Camera;
  109301. /** @hidden */
  109302. _cameraRigParams: any;
  109303. /** @hidden */
  109304. _rigCameras: Camera[];
  109305. /** @hidden */
  109306. _rigPostProcess: Nullable<PostProcess>;
  109307. protected _webvrViewMatrix: Matrix;
  109308. /** @hidden */
  109309. _skipRendering: boolean;
  109310. /** @hidden */
  109311. _projectionMatrix: Matrix;
  109312. /** @hidden */
  109313. _postProcesses: Nullable<PostProcess>[];
  109314. /** @hidden */
  109315. _activeMeshes: SmartArray<AbstractMesh>;
  109316. protected _globalPosition: Vector3;
  109317. /** @hidden */
  109318. _computedViewMatrix: Matrix;
  109319. private _doNotComputeProjectionMatrix;
  109320. private _transformMatrix;
  109321. private _frustumPlanes;
  109322. private _refreshFrustumPlanes;
  109323. private _storedFov;
  109324. private _stateStored;
  109325. /**
  109326. * Instantiates a new camera object.
  109327. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  109328. * @see https://doc.babylonjs.com/features/cameras
  109329. * @param name Defines the name of the camera in the scene
  109330. * @param position Defines the position of the camera
  109331. * @param scene Defines the scene the camera belongs too
  109332. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  109333. */
  109334. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  109335. /**
  109336. * Store current camera state (fov, position, etc..)
  109337. * @returns the camera
  109338. */
  109339. storeState(): Camera;
  109340. /**
  109341. * Restores the camera state values if it has been stored. You must call storeState() first
  109342. */
  109343. protected _restoreStateValues(): boolean;
  109344. /**
  109345. * Restored camera state. You must call storeState() first.
  109346. * @returns true if restored and false otherwise
  109347. */
  109348. restoreState(): boolean;
  109349. /**
  109350. * Gets the class name of the camera.
  109351. * @returns the class name
  109352. */
  109353. getClassName(): string;
  109354. /** @hidden */
  109355. readonly _isCamera: boolean;
  109356. /**
  109357. * Gets a string representation of the camera useful for debug purpose.
  109358. * @param fullDetails Defines that a more verboe level of logging is required
  109359. * @returns the string representation
  109360. */
  109361. toString(fullDetails?: boolean): string;
  109362. /**
  109363. * Gets the current world space position of the camera.
  109364. */
  109365. get globalPosition(): Vector3;
  109366. /**
  109367. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  109368. * @returns the active meshe list
  109369. */
  109370. getActiveMeshes(): SmartArray<AbstractMesh>;
  109371. /**
  109372. * Check whether a mesh is part of the current active mesh list of the camera
  109373. * @param mesh Defines the mesh to check
  109374. * @returns true if active, false otherwise
  109375. */
  109376. isActiveMesh(mesh: Mesh): boolean;
  109377. /**
  109378. * Is this camera ready to be used/rendered
  109379. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  109380. * @return true if the camera is ready
  109381. */
  109382. isReady(completeCheck?: boolean): boolean;
  109383. /** @hidden */
  109384. _initCache(): void;
  109385. /** @hidden */
  109386. _updateCache(ignoreParentClass?: boolean): void;
  109387. /** @hidden */
  109388. _isSynchronized(): boolean;
  109389. /** @hidden */
  109390. _isSynchronizedViewMatrix(): boolean;
  109391. /** @hidden */
  109392. _isSynchronizedProjectionMatrix(): boolean;
  109393. /**
  109394. * Attach the input controls to a specific dom element to get the input from.
  109395. * @param element Defines the element the controls should be listened from
  109396. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109397. */
  109398. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109399. /**
  109400. * Detach the current controls from the specified dom element.
  109401. * @param element Defines the element to stop listening the inputs from
  109402. */
  109403. detachControl(element: HTMLElement): void;
  109404. /**
  109405. * Update the camera state according to the different inputs gathered during the frame.
  109406. */
  109407. update(): void;
  109408. /** @hidden */
  109409. _checkInputs(): void;
  109410. /** @hidden */
  109411. get rigCameras(): Camera[];
  109412. /**
  109413. * Gets the post process used by the rig cameras
  109414. */
  109415. get rigPostProcess(): Nullable<PostProcess>;
  109416. /**
  109417. * Internal, gets the first post proces.
  109418. * @returns the first post process to be run on this camera.
  109419. */
  109420. _getFirstPostProcess(): Nullable<PostProcess>;
  109421. private _cascadePostProcessesToRigCams;
  109422. /**
  109423. * Attach a post process to the camera.
  109424. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  109425. * @param postProcess The post process to attach to the camera
  109426. * @param insertAt The position of the post process in case several of them are in use in the scene
  109427. * @returns the position the post process has been inserted at
  109428. */
  109429. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  109430. /**
  109431. * Detach a post process to the camera.
  109432. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  109433. * @param postProcess The post process to detach from the camera
  109434. */
  109435. detachPostProcess(postProcess: PostProcess): void;
  109436. /**
  109437. * Gets the current world matrix of the camera
  109438. */
  109439. getWorldMatrix(): Matrix;
  109440. /** @hidden */
  109441. _getViewMatrix(): Matrix;
  109442. /**
  109443. * Gets the current view matrix of the camera.
  109444. * @param force forces the camera to recompute the matrix without looking at the cached state
  109445. * @returns the view matrix
  109446. */
  109447. getViewMatrix(force?: boolean): Matrix;
  109448. /**
  109449. * Freeze the projection matrix.
  109450. * It will prevent the cache check of the camera projection compute and can speed up perf
  109451. * if no parameter of the camera are meant to change
  109452. * @param projection Defines manually a projection if necessary
  109453. */
  109454. freezeProjectionMatrix(projection?: Matrix): void;
  109455. /**
  109456. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  109457. */
  109458. unfreezeProjectionMatrix(): void;
  109459. /**
  109460. * Gets the current projection matrix of the camera.
  109461. * @param force forces the camera to recompute the matrix without looking at the cached state
  109462. * @returns the projection matrix
  109463. */
  109464. getProjectionMatrix(force?: boolean): Matrix;
  109465. /**
  109466. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  109467. * @returns a Matrix
  109468. */
  109469. getTransformationMatrix(): Matrix;
  109470. private _updateFrustumPlanes;
  109471. /**
  109472. * Checks if a cullable object (mesh...) is in the camera frustum
  109473. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  109474. * @param target The object to check
  109475. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  109476. * @returns true if the object is in frustum otherwise false
  109477. */
  109478. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  109479. /**
  109480. * Checks if a cullable object (mesh...) is in the camera frustum
  109481. * Unlike isInFrustum this cheks the full bounding box
  109482. * @param target The object to check
  109483. * @returns true if the object is in frustum otherwise false
  109484. */
  109485. isCompletelyInFrustum(target: ICullable): boolean;
  109486. /**
  109487. * Gets a ray in the forward direction from the camera.
  109488. * @param length Defines the length of the ray to create
  109489. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  109490. * @param origin Defines the start point of the ray which defaults to the camera position
  109491. * @returns the forward ray
  109492. */
  109493. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  109494. /**
  109495. * Gets a ray in the forward direction from the camera.
  109496. * @param refRay the ray to (re)use when setting the values
  109497. * @param length Defines the length of the ray to create
  109498. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  109499. * @param origin Defines the start point of the ray which defaults to the camera position
  109500. * @returns the forward ray
  109501. */
  109502. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  109503. /**
  109504. * Releases resources associated with this node.
  109505. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109506. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109507. */
  109508. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109509. /** @hidden */
  109510. _isLeftCamera: boolean;
  109511. /**
  109512. * Gets the left camera of a rig setup in case of Rigged Camera
  109513. */
  109514. get isLeftCamera(): boolean;
  109515. /** @hidden */
  109516. _isRightCamera: boolean;
  109517. /**
  109518. * Gets the right camera of a rig setup in case of Rigged Camera
  109519. */
  109520. get isRightCamera(): boolean;
  109521. /**
  109522. * Gets the left camera of a rig setup in case of Rigged Camera
  109523. */
  109524. get leftCamera(): Nullable<FreeCamera>;
  109525. /**
  109526. * Gets the right camera of a rig setup in case of Rigged Camera
  109527. */
  109528. get rightCamera(): Nullable<FreeCamera>;
  109529. /**
  109530. * Gets the left camera target of a rig setup in case of Rigged Camera
  109531. * @returns the target position
  109532. */
  109533. getLeftTarget(): Nullable<Vector3>;
  109534. /**
  109535. * Gets the right camera target of a rig setup in case of Rigged Camera
  109536. * @returns the target position
  109537. */
  109538. getRightTarget(): Nullable<Vector3>;
  109539. /**
  109540. * @hidden
  109541. */
  109542. setCameraRigMode(mode: number, rigParams: any): void;
  109543. /** @hidden */
  109544. static _setStereoscopicRigMode(camera: Camera): void;
  109545. /** @hidden */
  109546. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  109547. /** @hidden */
  109548. static _setVRRigMode(camera: Camera, rigParams: any): void;
  109549. /** @hidden */
  109550. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  109551. /** @hidden */
  109552. _getVRProjectionMatrix(): Matrix;
  109553. protected _updateCameraRotationMatrix(): void;
  109554. protected _updateWebVRCameraRotationMatrix(): void;
  109555. /**
  109556. * This function MUST be overwritten by the different WebVR cameras available.
  109557. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  109558. * @hidden
  109559. */
  109560. _getWebVRProjectionMatrix(): Matrix;
  109561. /**
  109562. * This function MUST be overwritten by the different WebVR cameras available.
  109563. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  109564. * @hidden
  109565. */
  109566. _getWebVRViewMatrix(): Matrix;
  109567. /** @hidden */
  109568. setCameraRigParameter(name: string, value: any): void;
  109569. /**
  109570. * needs to be overridden by children so sub has required properties to be copied
  109571. * @hidden
  109572. */
  109573. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  109574. /**
  109575. * May need to be overridden by children
  109576. * @hidden
  109577. */
  109578. _updateRigCameras(): void;
  109579. /** @hidden */
  109580. _setupInputs(): void;
  109581. /**
  109582. * Serialiaze the camera setup to a json represention
  109583. * @returns the JSON representation
  109584. */
  109585. serialize(): any;
  109586. /**
  109587. * Clones the current camera.
  109588. * @param name The cloned camera name
  109589. * @returns the cloned camera
  109590. */
  109591. clone(name: string): Camera;
  109592. /**
  109593. * Gets the direction of the camera relative to a given local axis.
  109594. * @param localAxis Defines the reference axis to provide a relative direction.
  109595. * @return the direction
  109596. */
  109597. getDirection(localAxis: Vector3): Vector3;
  109598. /**
  109599. * Returns the current camera absolute rotation
  109600. */
  109601. get absoluteRotation(): Quaternion;
  109602. /**
  109603. * Gets the direction of the camera relative to a given local axis into a passed vector.
  109604. * @param localAxis Defines the reference axis to provide a relative direction.
  109605. * @param result Defines the vector to store the result in
  109606. */
  109607. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  109608. /**
  109609. * Gets a camera constructor for a given camera type
  109610. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  109611. * @param name The name of the camera the result will be able to instantiate
  109612. * @param scene The scene the result will construct the camera in
  109613. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  109614. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  109615. * @returns a factory method to construc the camera
  109616. */
  109617. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  109618. /**
  109619. * Compute the world matrix of the camera.
  109620. * @returns the camera world matrix
  109621. */
  109622. computeWorldMatrix(): Matrix;
  109623. /**
  109624. * Parse a JSON and creates the camera from the parsed information
  109625. * @param parsedCamera The JSON to parse
  109626. * @param scene The scene to instantiate the camera in
  109627. * @returns the newly constructed camera
  109628. */
  109629. static Parse(parsedCamera: any, scene: Scene): Camera;
  109630. }
  109631. }
  109632. declare module BABYLON {
  109633. /**
  109634. * Class containing static functions to help procedurally build meshes
  109635. */
  109636. export class DiscBuilder {
  109637. /**
  109638. * Creates a plane polygonal mesh. By default, this is a disc
  109639. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  109640. * * 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
  109641. * * 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
  109642. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109643. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109645. * @param name defines the name of the mesh
  109646. * @param options defines the options used to create the mesh
  109647. * @param scene defines the hosting scene
  109648. * @returns the plane polygonal mesh
  109649. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  109650. */
  109651. static CreateDisc(name: string, options: {
  109652. radius?: number;
  109653. tessellation?: number;
  109654. arc?: number;
  109655. updatable?: boolean;
  109656. sideOrientation?: number;
  109657. frontUVs?: Vector4;
  109658. backUVs?: Vector4;
  109659. }, scene?: Nullable<Scene>): Mesh;
  109660. }
  109661. }
  109662. declare module BABYLON {
  109663. /**
  109664. * Options to be used when creating a FresnelParameters.
  109665. */
  109666. export type IFresnelParametersCreationOptions = {
  109667. /**
  109668. * Define the color used on edges (grazing angle)
  109669. */
  109670. leftColor?: Color3;
  109671. /**
  109672. * Define the color used on center
  109673. */
  109674. rightColor?: Color3;
  109675. /**
  109676. * Define bias applied to computed fresnel term
  109677. */
  109678. bias?: number;
  109679. /**
  109680. * Defined the power exponent applied to fresnel term
  109681. */
  109682. power?: number;
  109683. /**
  109684. * Define if the fresnel effect is enable or not.
  109685. */
  109686. isEnabled?: boolean;
  109687. };
  109688. /**
  109689. * Serialized format for FresnelParameters.
  109690. */
  109691. export type IFresnelParametersSerialized = {
  109692. /**
  109693. * Define the color used on edges (grazing angle) [as an array]
  109694. */
  109695. leftColor: number[];
  109696. /**
  109697. * Define the color used on center [as an array]
  109698. */
  109699. rightColor: number[];
  109700. /**
  109701. * Define bias applied to computed fresnel term
  109702. */
  109703. bias: number;
  109704. /**
  109705. * Defined the power exponent applied to fresnel term
  109706. */
  109707. power?: number;
  109708. /**
  109709. * Define if the fresnel effect is enable or not.
  109710. */
  109711. isEnabled: boolean;
  109712. };
  109713. /**
  109714. * This represents all the required information to add a fresnel effect on a material:
  109715. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109716. */
  109717. export class FresnelParameters {
  109718. private _isEnabled;
  109719. /**
  109720. * Define if the fresnel effect is enable or not.
  109721. */
  109722. get isEnabled(): boolean;
  109723. set isEnabled(value: boolean);
  109724. /**
  109725. * Define the color used on edges (grazing angle)
  109726. */
  109727. leftColor: Color3;
  109728. /**
  109729. * Define the color used on center
  109730. */
  109731. rightColor: Color3;
  109732. /**
  109733. * Define bias applied to computed fresnel term
  109734. */
  109735. bias: number;
  109736. /**
  109737. * Defined the power exponent applied to fresnel term
  109738. */
  109739. power: number;
  109740. /**
  109741. * Creates a new FresnelParameters object.
  109742. *
  109743. * @param options provide your own settings to optionally to override defaults
  109744. */
  109745. constructor(options?: IFresnelParametersCreationOptions);
  109746. /**
  109747. * Clones the current fresnel and its valuues
  109748. * @returns a clone fresnel configuration
  109749. */
  109750. clone(): FresnelParameters;
  109751. /**
  109752. * Determines equality between FresnelParameters objects
  109753. * @param otherFresnelParameters defines the second operand
  109754. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  109755. */
  109756. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  109757. /**
  109758. * Serializes the current fresnel parameters to a JSON representation.
  109759. * @return the JSON serialization
  109760. */
  109761. serialize(): IFresnelParametersSerialized;
  109762. /**
  109763. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  109764. * @param parsedFresnelParameters Define the JSON representation
  109765. * @returns the parsed parameters
  109766. */
  109767. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  109768. }
  109769. }
  109770. declare module BABYLON {
  109771. /**
  109772. * This groups all the flags used to control the materials channel.
  109773. */
  109774. export class MaterialFlags {
  109775. private static _DiffuseTextureEnabled;
  109776. /**
  109777. * Are diffuse textures enabled in the application.
  109778. */
  109779. static get DiffuseTextureEnabled(): boolean;
  109780. static set DiffuseTextureEnabled(value: boolean);
  109781. private static _DetailTextureEnabled;
  109782. /**
  109783. * Are detail textures enabled in the application.
  109784. */
  109785. static get DetailTextureEnabled(): boolean;
  109786. static set DetailTextureEnabled(value: boolean);
  109787. private static _AmbientTextureEnabled;
  109788. /**
  109789. * Are ambient textures enabled in the application.
  109790. */
  109791. static get AmbientTextureEnabled(): boolean;
  109792. static set AmbientTextureEnabled(value: boolean);
  109793. private static _OpacityTextureEnabled;
  109794. /**
  109795. * Are opacity textures enabled in the application.
  109796. */
  109797. static get OpacityTextureEnabled(): boolean;
  109798. static set OpacityTextureEnabled(value: boolean);
  109799. private static _ReflectionTextureEnabled;
  109800. /**
  109801. * Are reflection textures enabled in the application.
  109802. */
  109803. static get ReflectionTextureEnabled(): boolean;
  109804. static set ReflectionTextureEnabled(value: boolean);
  109805. private static _EmissiveTextureEnabled;
  109806. /**
  109807. * Are emissive textures enabled in the application.
  109808. */
  109809. static get EmissiveTextureEnabled(): boolean;
  109810. static set EmissiveTextureEnabled(value: boolean);
  109811. private static _SpecularTextureEnabled;
  109812. /**
  109813. * Are specular textures enabled in the application.
  109814. */
  109815. static get SpecularTextureEnabled(): boolean;
  109816. static set SpecularTextureEnabled(value: boolean);
  109817. private static _BumpTextureEnabled;
  109818. /**
  109819. * Are bump textures enabled in the application.
  109820. */
  109821. static get BumpTextureEnabled(): boolean;
  109822. static set BumpTextureEnabled(value: boolean);
  109823. private static _LightmapTextureEnabled;
  109824. /**
  109825. * Are lightmap textures enabled in the application.
  109826. */
  109827. static get LightmapTextureEnabled(): boolean;
  109828. static set LightmapTextureEnabled(value: boolean);
  109829. private static _RefractionTextureEnabled;
  109830. /**
  109831. * Are refraction textures enabled in the application.
  109832. */
  109833. static get RefractionTextureEnabled(): boolean;
  109834. static set RefractionTextureEnabled(value: boolean);
  109835. private static _ColorGradingTextureEnabled;
  109836. /**
  109837. * Are color grading textures enabled in the application.
  109838. */
  109839. static get ColorGradingTextureEnabled(): boolean;
  109840. static set ColorGradingTextureEnabled(value: boolean);
  109841. private static _FresnelEnabled;
  109842. /**
  109843. * Are fresnels enabled in the application.
  109844. */
  109845. static get FresnelEnabled(): boolean;
  109846. static set FresnelEnabled(value: boolean);
  109847. private static _ClearCoatTextureEnabled;
  109848. /**
  109849. * Are clear coat textures enabled in the application.
  109850. */
  109851. static get ClearCoatTextureEnabled(): boolean;
  109852. static set ClearCoatTextureEnabled(value: boolean);
  109853. private static _ClearCoatBumpTextureEnabled;
  109854. /**
  109855. * Are clear coat bump textures enabled in the application.
  109856. */
  109857. static get ClearCoatBumpTextureEnabled(): boolean;
  109858. static set ClearCoatBumpTextureEnabled(value: boolean);
  109859. private static _ClearCoatTintTextureEnabled;
  109860. /**
  109861. * Are clear coat tint textures enabled in the application.
  109862. */
  109863. static get ClearCoatTintTextureEnabled(): boolean;
  109864. static set ClearCoatTintTextureEnabled(value: boolean);
  109865. private static _SheenTextureEnabled;
  109866. /**
  109867. * Are sheen textures enabled in the application.
  109868. */
  109869. static get SheenTextureEnabled(): boolean;
  109870. static set SheenTextureEnabled(value: boolean);
  109871. private static _AnisotropicTextureEnabled;
  109872. /**
  109873. * Are anisotropic textures enabled in the application.
  109874. */
  109875. static get AnisotropicTextureEnabled(): boolean;
  109876. static set AnisotropicTextureEnabled(value: boolean);
  109877. private static _ThicknessTextureEnabled;
  109878. /**
  109879. * Are thickness textures enabled in the application.
  109880. */
  109881. static get ThicknessTextureEnabled(): boolean;
  109882. static set ThicknessTextureEnabled(value: boolean);
  109883. }
  109884. }
  109885. declare module BABYLON {
  109886. /** @hidden */
  109887. export var defaultFragmentDeclaration: {
  109888. name: string;
  109889. shader: string;
  109890. };
  109891. }
  109892. declare module BABYLON {
  109893. /** @hidden */
  109894. export var defaultUboDeclaration: {
  109895. name: string;
  109896. shader: string;
  109897. };
  109898. }
  109899. declare module BABYLON {
  109900. /** @hidden */
  109901. export var prePassDeclaration: {
  109902. name: string;
  109903. shader: string;
  109904. };
  109905. }
  109906. declare module BABYLON {
  109907. /** @hidden */
  109908. export var lightFragmentDeclaration: {
  109909. name: string;
  109910. shader: string;
  109911. };
  109912. }
  109913. declare module BABYLON {
  109914. /** @hidden */
  109915. export var lightUboDeclaration: {
  109916. name: string;
  109917. shader: string;
  109918. };
  109919. }
  109920. declare module BABYLON {
  109921. /** @hidden */
  109922. export var lightsFragmentFunctions: {
  109923. name: string;
  109924. shader: string;
  109925. };
  109926. }
  109927. declare module BABYLON {
  109928. /** @hidden */
  109929. export var shadowsFragmentFunctions: {
  109930. name: string;
  109931. shader: string;
  109932. };
  109933. }
  109934. declare module BABYLON {
  109935. /** @hidden */
  109936. export var fresnelFunction: {
  109937. name: string;
  109938. shader: string;
  109939. };
  109940. }
  109941. declare module BABYLON {
  109942. /** @hidden */
  109943. export var bumpFragmentMainFunctions: {
  109944. name: string;
  109945. shader: string;
  109946. };
  109947. }
  109948. declare module BABYLON {
  109949. /** @hidden */
  109950. export var bumpFragmentFunctions: {
  109951. name: string;
  109952. shader: string;
  109953. };
  109954. }
  109955. declare module BABYLON {
  109956. /** @hidden */
  109957. export var logDepthDeclaration: {
  109958. name: string;
  109959. shader: string;
  109960. };
  109961. }
  109962. declare module BABYLON {
  109963. /** @hidden */
  109964. export var bumpFragment: {
  109965. name: string;
  109966. shader: string;
  109967. };
  109968. }
  109969. declare module BABYLON {
  109970. /** @hidden */
  109971. export var depthPrePass: {
  109972. name: string;
  109973. shader: string;
  109974. };
  109975. }
  109976. declare module BABYLON {
  109977. /** @hidden */
  109978. export var lightFragment: {
  109979. name: string;
  109980. shader: string;
  109981. };
  109982. }
  109983. declare module BABYLON {
  109984. /** @hidden */
  109985. export var logDepthFragment: {
  109986. name: string;
  109987. shader: string;
  109988. };
  109989. }
  109990. declare module BABYLON {
  109991. /** @hidden */
  109992. export var defaultPixelShader: {
  109993. name: string;
  109994. shader: string;
  109995. };
  109996. }
  109997. declare module BABYLON {
  109998. /** @hidden */
  109999. export var defaultVertexDeclaration: {
  110000. name: string;
  110001. shader: string;
  110002. };
  110003. }
  110004. declare module BABYLON {
  110005. /** @hidden */
  110006. export var bumpVertexDeclaration: {
  110007. name: string;
  110008. shader: string;
  110009. };
  110010. }
  110011. declare module BABYLON {
  110012. /** @hidden */
  110013. export var bumpVertex: {
  110014. name: string;
  110015. shader: string;
  110016. };
  110017. }
  110018. declare module BABYLON {
  110019. /** @hidden */
  110020. export var fogVertex: {
  110021. name: string;
  110022. shader: string;
  110023. };
  110024. }
  110025. declare module BABYLON {
  110026. /** @hidden */
  110027. export var shadowsVertex: {
  110028. name: string;
  110029. shader: string;
  110030. };
  110031. }
  110032. declare module BABYLON {
  110033. /** @hidden */
  110034. export var pointCloudVertex: {
  110035. name: string;
  110036. shader: string;
  110037. };
  110038. }
  110039. declare module BABYLON {
  110040. /** @hidden */
  110041. export var logDepthVertex: {
  110042. name: string;
  110043. shader: string;
  110044. };
  110045. }
  110046. declare module BABYLON {
  110047. /** @hidden */
  110048. export var defaultVertexShader: {
  110049. name: string;
  110050. shader: string;
  110051. };
  110052. }
  110053. declare module BABYLON {
  110054. /**
  110055. * @hidden
  110056. */
  110057. export interface IMaterialDetailMapDefines {
  110058. DETAIL: boolean;
  110059. DETAILDIRECTUV: number;
  110060. DETAIL_NORMALBLENDMETHOD: number;
  110061. /** @hidden */
  110062. _areTexturesDirty: boolean;
  110063. }
  110064. /**
  110065. * Define the code related to the detail map parameters of a material
  110066. *
  110067. * Inspired from:
  110068. * 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
  110069. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  110070. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  110071. */
  110072. export class DetailMapConfiguration {
  110073. private _texture;
  110074. /**
  110075. * The detail texture of the material.
  110076. */
  110077. texture: Nullable<BaseTexture>;
  110078. /**
  110079. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  110080. * Bigger values mean stronger blending
  110081. */
  110082. diffuseBlendLevel: number;
  110083. /**
  110084. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  110085. * Bigger values mean stronger blending. Only used with PBR materials
  110086. */
  110087. roughnessBlendLevel: number;
  110088. /**
  110089. * Defines how strong the bump effect from the detail map is
  110090. * Bigger values mean stronger effect
  110091. */
  110092. bumpLevel: number;
  110093. private _normalBlendMethod;
  110094. /**
  110095. * The method used to blend the bump and detail normals together
  110096. */
  110097. normalBlendMethod: number;
  110098. private _isEnabled;
  110099. /**
  110100. * Enable or disable the detail map on this material
  110101. */
  110102. isEnabled: boolean;
  110103. /** @hidden */
  110104. private _internalMarkAllSubMeshesAsTexturesDirty;
  110105. /** @hidden */
  110106. _markAllSubMeshesAsTexturesDirty(): void;
  110107. /**
  110108. * Instantiate a new detail map
  110109. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110110. */
  110111. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110112. /**
  110113. * Gets whether the submesh is ready to be used or not.
  110114. * @param defines the list of "defines" to update.
  110115. * @param scene defines the scene the material belongs to.
  110116. * @returns - boolean indicating that the submesh is ready or not.
  110117. */
  110118. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  110119. /**
  110120. * Update the defines for detail map usage
  110121. * @param defines the list of "defines" to update.
  110122. * @param scene defines the scene the material belongs to.
  110123. */
  110124. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  110125. /**
  110126. * Binds the material data.
  110127. * @param uniformBuffer defines the Uniform buffer to fill in.
  110128. * @param scene defines the scene the material belongs to.
  110129. * @param isFrozen defines whether the material is frozen or not.
  110130. */
  110131. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110132. /**
  110133. * Checks to see if a texture is used in the material.
  110134. * @param texture - Base texture to use.
  110135. * @returns - Boolean specifying if a texture is used in the material.
  110136. */
  110137. hasTexture(texture: BaseTexture): boolean;
  110138. /**
  110139. * Returns an array of the actively used textures.
  110140. * @param activeTextures Array of BaseTextures
  110141. */
  110142. getActiveTextures(activeTextures: BaseTexture[]): void;
  110143. /**
  110144. * Returns the animatable textures.
  110145. * @param animatables Array of animatable textures.
  110146. */
  110147. getAnimatables(animatables: IAnimatable[]): void;
  110148. /**
  110149. * Disposes the resources of the material.
  110150. * @param forceDisposeTextures - Forces the disposal of all textures.
  110151. */
  110152. dispose(forceDisposeTextures?: boolean): void;
  110153. /**
  110154. * Get the current class name useful for serialization or dynamic coding.
  110155. * @returns "DetailMap"
  110156. */
  110157. getClassName(): string;
  110158. /**
  110159. * Add the required uniforms to the current list.
  110160. * @param uniforms defines the current uniform list.
  110161. */
  110162. static AddUniforms(uniforms: string[]): void;
  110163. /**
  110164. * Add the required samplers to the current list.
  110165. * @param samplers defines the current sampler list.
  110166. */
  110167. static AddSamplers(samplers: string[]): void;
  110168. /**
  110169. * Add the required uniforms to the current buffer.
  110170. * @param uniformBuffer defines the current uniform buffer.
  110171. */
  110172. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110173. /**
  110174. * Makes a duplicate of the current instance into another one.
  110175. * @param detailMap define the instance where to copy the info
  110176. */
  110177. copyTo(detailMap: DetailMapConfiguration): void;
  110178. /**
  110179. * Serializes this detail map instance
  110180. * @returns - An object with the serialized instance.
  110181. */
  110182. serialize(): any;
  110183. /**
  110184. * Parses a detail map setting from a serialized object.
  110185. * @param source - Serialized object.
  110186. * @param scene Defines the scene we are parsing for
  110187. * @param rootUrl Defines the rootUrl to load from
  110188. */
  110189. parse(source: any, scene: Scene, rootUrl: string): void;
  110190. }
  110191. }
  110192. declare module BABYLON {
  110193. /** @hidden */
  110194. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  110195. MAINUV1: boolean;
  110196. MAINUV2: boolean;
  110197. DIFFUSE: boolean;
  110198. DIFFUSEDIRECTUV: number;
  110199. DETAIL: boolean;
  110200. DETAILDIRECTUV: number;
  110201. DETAIL_NORMALBLENDMETHOD: number;
  110202. AMBIENT: boolean;
  110203. AMBIENTDIRECTUV: number;
  110204. OPACITY: boolean;
  110205. OPACITYDIRECTUV: number;
  110206. OPACITYRGB: boolean;
  110207. REFLECTION: boolean;
  110208. EMISSIVE: boolean;
  110209. EMISSIVEDIRECTUV: number;
  110210. SPECULAR: boolean;
  110211. SPECULARDIRECTUV: number;
  110212. BUMP: boolean;
  110213. BUMPDIRECTUV: number;
  110214. PARALLAX: boolean;
  110215. PARALLAXOCCLUSION: boolean;
  110216. SPECULAROVERALPHA: boolean;
  110217. CLIPPLANE: boolean;
  110218. CLIPPLANE2: boolean;
  110219. CLIPPLANE3: boolean;
  110220. CLIPPLANE4: boolean;
  110221. CLIPPLANE5: boolean;
  110222. CLIPPLANE6: boolean;
  110223. ALPHATEST: boolean;
  110224. DEPTHPREPASS: boolean;
  110225. ALPHAFROMDIFFUSE: boolean;
  110226. POINTSIZE: boolean;
  110227. FOG: boolean;
  110228. SPECULARTERM: boolean;
  110229. DIFFUSEFRESNEL: boolean;
  110230. OPACITYFRESNEL: boolean;
  110231. REFLECTIONFRESNEL: boolean;
  110232. REFRACTIONFRESNEL: boolean;
  110233. EMISSIVEFRESNEL: boolean;
  110234. FRESNEL: boolean;
  110235. NORMAL: boolean;
  110236. UV1: boolean;
  110237. UV2: boolean;
  110238. VERTEXCOLOR: boolean;
  110239. VERTEXALPHA: boolean;
  110240. NUM_BONE_INFLUENCERS: number;
  110241. BonesPerMesh: number;
  110242. BONETEXTURE: boolean;
  110243. INSTANCES: boolean;
  110244. THIN_INSTANCES: boolean;
  110245. GLOSSINESS: boolean;
  110246. ROUGHNESS: boolean;
  110247. EMISSIVEASILLUMINATION: boolean;
  110248. LINKEMISSIVEWITHDIFFUSE: boolean;
  110249. REFLECTIONFRESNELFROMSPECULAR: boolean;
  110250. LIGHTMAP: boolean;
  110251. LIGHTMAPDIRECTUV: number;
  110252. OBJECTSPACE_NORMALMAP: boolean;
  110253. USELIGHTMAPASSHADOWMAP: boolean;
  110254. REFLECTIONMAP_3D: boolean;
  110255. REFLECTIONMAP_SPHERICAL: boolean;
  110256. REFLECTIONMAP_PLANAR: boolean;
  110257. REFLECTIONMAP_CUBIC: boolean;
  110258. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  110259. REFLECTIONMAP_PROJECTION: boolean;
  110260. REFLECTIONMAP_SKYBOX: boolean;
  110261. REFLECTIONMAP_EXPLICIT: boolean;
  110262. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  110263. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  110264. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  110265. INVERTCUBICMAP: boolean;
  110266. LOGARITHMICDEPTH: boolean;
  110267. REFRACTION: boolean;
  110268. REFRACTIONMAP_3D: boolean;
  110269. REFLECTIONOVERALPHA: boolean;
  110270. TWOSIDEDLIGHTING: boolean;
  110271. SHADOWFLOAT: boolean;
  110272. MORPHTARGETS: boolean;
  110273. MORPHTARGETS_NORMAL: boolean;
  110274. MORPHTARGETS_TANGENT: boolean;
  110275. MORPHTARGETS_UV: boolean;
  110276. NUM_MORPH_INFLUENCERS: number;
  110277. NONUNIFORMSCALING: boolean;
  110278. PREMULTIPLYALPHA: boolean;
  110279. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  110280. ALPHABLEND: boolean;
  110281. PREPASS: boolean;
  110282. SCENE_MRT_COUNT: number;
  110283. RGBDLIGHTMAP: boolean;
  110284. RGBDREFLECTION: boolean;
  110285. RGBDREFRACTION: boolean;
  110286. IMAGEPROCESSING: boolean;
  110287. VIGNETTE: boolean;
  110288. VIGNETTEBLENDMODEMULTIPLY: boolean;
  110289. VIGNETTEBLENDMODEOPAQUE: boolean;
  110290. TONEMAPPING: boolean;
  110291. TONEMAPPING_ACES: boolean;
  110292. CONTRAST: boolean;
  110293. COLORCURVES: boolean;
  110294. COLORGRADING: boolean;
  110295. COLORGRADING3D: boolean;
  110296. SAMPLER3DGREENDEPTH: boolean;
  110297. SAMPLER3DBGRMAP: boolean;
  110298. IMAGEPROCESSINGPOSTPROCESS: boolean;
  110299. MULTIVIEW: boolean;
  110300. /**
  110301. * If the reflection texture on this material is in linear color space
  110302. * @hidden
  110303. */
  110304. IS_REFLECTION_LINEAR: boolean;
  110305. /**
  110306. * If the refraction texture on this material is in linear color space
  110307. * @hidden
  110308. */
  110309. IS_REFRACTION_LINEAR: boolean;
  110310. EXPOSURE: boolean;
  110311. constructor();
  110312. setReflectionMode(modeToEnable: string): void;
  110313. }
  110314. /**
  110315. * This is the default material used in Babylon. It is the best trade off between quality
  110316. * and performances.
  110317. * @see https://doc.babylonjs.com/babylon101/materials
  110318. */
  110319. export class StandardMaterial extends PushMaterial {
  110320. private _diffuseTexture;
  110321. /**
  110322. * The basic texture of the material as viewed under a light.
  110323. */
  110324. diffuseTexture: Nullable<BaseTexture>;
  110325. private _ambientTexture;
  110326. /**
  110327. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  110328. */
  110329. ambientTexture: Nullable<BaseTexture>;
  110330. private _opacityTexture;
  110331. /**
  110332. * Define the transparency of the material from a texture.
  110333. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  110334. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  110335. */
  110336. opacityTexture: Nullable<BaseTexture>;
  110337. private _reflectionTexture;
  110338. /**
  110339. * Define the texture used to display the reflection.
  110340. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110341. */
  110342. reflectionTexture: Nullable<BaseTexture>;
  110343. private _emissiveTexture;
  110344. /**
  110345. * Define texture of the material as if self lit.
  110346. * This will be mixed in the final result even in the absence of light.
  110347. */
  110348. emissiveTexture: Nullable<BaseTexture>;
  110349. private _specularTexture;
  110350. /**
  110351. * Define how the color and intensity of the highlight given by the light in the material.
  110352. */
  110353. specularTexture: Nullable<BaseTexture>;
  110354. private _bumpTexture;
  110355. /**
  110356. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  110357. * 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.
  110358. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  110359. */
  110360. bumpTexture: Nullable<BaseTexture>;
  110361. private _lightmapTexture;
  110362. /**
  110363. * Complex lighting can be computationally expensive to compute at runtime.
  110364. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  110365. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  110366. */
  110367. lightmapTexture: Nullable<BaseTexture>;
  110368. private _refractionTexture;
  110369. /**
  110370. * Define the texture used to display the refraction.
  110371. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110372. */
  110373. refractionTexture: Nullable<BaseTexture>;
  110374. /**
  110375. * The color of the material lit by the environmental background lighting.
  110376. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  110377. */
  110378. ambientColor: Color3;
  110379. /**
  110380. * The basic color of the material as viewed under a light.
  110381. */
  110382. diffuseColor: Color3;
  110383. /**
  110384. * Define how the color and intensity of the highlight given by the light in the material.
  110385. */
  110386. specularColor: Color3;
  110387. /**
  110388. * Define the color of the material as if self lit.
  110389. * This will be mixed in the final result even in the absence of light.
  110390. */
  110391. emissiveColor: Color3;
  110392. /**
  110393. * Defines how sharp are the highlights in the material.
  110394. * The bigger the value the sharper giving a more glossy feeling to the result.
  110395. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  110396. */
  110397. specularPower: number;
  110398. private _useAlphaFromDiffuseTexture;
  110399. /**
  110400. * Does the transparency come from the diffuse texture alpha channel.
  110401. */
  110402. useAlphaFromDiffuseTexture: boolean;
  110403. private _useEmissiveAsIllumination;
  110404. /**
  110405. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  110406. */
  110407. useEmissiveAsIllumination: boolean;
  110408. private _linkEmissiveWithDiffuse;
  110409. /**
  110410. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  110411. * the emissive level when the final color is close to one.
  110412. */
  110413. linkEmissiveWithDiffuse: boolean;
  110414. private _useSpecularOverAlpha;
  110415. /**
  110416. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  110417. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  110418. */
  110419. useSpecularOverAlpha: boolean;
  110420. private _useReflectionOverAlpha;
  110421. /**
  110422. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  110423. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  110424. */
  110425. useReflectionOverAlpha: boolean;
  110426. private _disableLighting;
  110427. /**
  110428. * Does lights from the scene impacts this material.
  110429. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  110430. */
  110431. disableLighting: boolean;
  110432. private _useObjectSpaceNormalMap;
  110433. /**
  110434. * Allows using an object space normal map (instead of tangent space).
  110435. */
  110436. useObjectSpaceNormalMap: boolean;
  110437. private _useParallax;
  110438. /**
  110439. * Is parallax enabled or not.
  110440. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  110441. */
  110442. useParallax: boolean;
  110443. private _useParallaxOcclusion;
  110444. /**
  110445. * Is parallax occlusion enabled or not.
  110446. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  110447. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  110448. */
  110449. useParallaxOcclusion: boolean;
  110450. /**
  110451. * 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.
  110452. */
  110453. parallaxScaleBias: number;
  110454. private _roughness;
  110455. /**
  110456. * Helps to define how blurry the reflections should appears in the material.
  110457. */
  110458. roughness: number;
  110459. /**
  110460. * In case of refraction, define the value of the index of refraction.
  110461. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110462. */
  110463. indexOfRefraction: number;
  110464. /**
  110465. * Invert the refraction texture alongside the y axis.
  110466. * It can be useful with procedural textures or probe for instance.
  110467. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110468. */
  110469. invertRefractionY: boolean;
  110470. /**
  110471. * Defines the alpha limits in alpha test mode.
  110472. */
  110473. alphaCutOff: number;
  110474. private _useLightmapAsShadowmap;
  110475. /**
  110476. * In case of light mapping, define whether the map contains light or shadow informations.
  110477. */
  110478. useLightmapAsShadowmap: boolean;
  110479. private _diffuseFresnelParameters;
  110480. /**
  110481. * Define the diffuse fresnel parameters of the material.
  110482. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110483. */
  110484. diffuseFresnelParameters: FresnelParameters;
  110485. private _opacityFresnelParameters;
  110486. /**
  110487. * Define the opacity fresnel parameters of the material.
  110488. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110489. */
  110490. opacityFresnelParameters: FresnelParameters;
  110491. private _reflectionFresnelParameters;
  110492. /**
  110493. * Define the reflection fresnel parameters of the material.
  110494. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110495. */
  110496. reflectionFresnelParameters: FresnelParameters;
  110497. private _refractionFresnelParameters;
  110498. /**
  110499. * Define the refraction fresnel parameters of the material.
  110500. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110501. */
  110502. refractionFresnelParameters: FresnelParameters;
  110503. private _emissiveFresnelParameters;
  110504. /**
  110505. * Define the emissive fresnel parameters of the material.
  110506. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110507. */
  110508. emissiveFresnelParameters: FresnelParameters;
  110509. private _useReflectionFresnelFromSpecular;
  110510. /**
  110511. * If true automatically deducts the fresnels values from the material specularity.
  110512. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110513. */
  110514. useReflectionFresnelFromSpecular: boolean;
  110515. private _useGlossinessFromSpecularMapAlpha;
  110516. /**
  110517. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  110518. */
  110519. useGlossinessFromSpecularMapAlpha: boolean;
  110520. private _maxSimultaneousLights;
  110521. /**
  110522. * Defines the maximum number of lights that can be used in the material
  110523. */
  110524. maxSimultaneousLights: number;
  110525. private _invertNormalMapX;
  110526. /**
  110527. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  110528. */
  110529. invertNormalMapX: boolean;
  110530. private _invertNormalMapY;
  110531. /**
  110532. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  110533. */
  110534. invertNormalMapY: boolean;
  110535. private _twoSidedLighting;
  110536. /**
  110537. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  110538. */
  110539. twoSidedLighting: boolean;
  110540. /**
  110541. * Default configuration related to image processing available in the standard Material.
  110542. */
  110543. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  110544. /**
  110545. * Gets the image processing configuration used either in this material.
  110546. */
  110547. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  110548. /**
  110549. * Sets the Default image processing configuration used either in the this material.
  110550. *
  110551. * If sets to null, the scene one is in use.
  110552. */
  110553. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  110554. /**
  110555. * Keep track of the image processing observer to allow dispose and replace.
  110556. */
  110557. private _imageProcessingObserver;
  110558. /**
  110559. * Attaches a new image processing configuration to the Standard Material.
  110560. * @param configuration
  110561. */
  110562. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  110563. /**
  110564. * Gets wether the color curves effect is enabled.
  110565. */
  110566. get cameraColorCurvesEnabled(): boolean;
  110567. /**
  110568. * Sets wether the color curves effect is enabled.
  110569. */
  110570. set cameraColorCurvesEnabled(value: boolean);
  110571. /**
  110572. * Gets wether the color grading effect is enabled.
  110573. */
  110574. get cameraColorGradingEnabled(): boolean;
  110575. /**
  110576. * Gets wether the color grading effect is enabled.
  110577. */
  110578. set cameraColorGradingEnabled(value: boolean);
  110579. /**
  110580. * Gets wether tonemapping is enabled or not.
  110581. */
  110582. get cameraToneMappingEnabled(): boolean;
  110583. /**
  110584. * Sets wether tonemapping is enabled or not
  110585. */
  110586. set cameraToneMappingEnabled(value: boolean);
  110587. /**
  110588. * The camera exposure used on this material.
  110589. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110590. * This corresponds to a photographic exposure.
  110591. */
  110592. get cameraExposure(): number;
  110593. /**
  110594. * The camera exposure used on this material.
  110595. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110596. * This corresponds to a photographic exposure.
  110597. */
  110598. set cameraExposure(value: number);
  110599. /**
  110600. * Gets The camera contrast used on this material.
  110601. */
  110602. get cameraContrast(): number;
  110603. /**
  110604. * Sets The camera contrast used on this material.
  110605. */
  110606. set cameraContrast(value: number);
  110607. /**
  110608. * Gets the Color Grading 2D Lookup Texture.
  110609. */
  110610. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  110611. /**
  110612. * Sets the Color Grading 2D Lookup Texture.
  110613. */
  110614. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  110615. /**
  110616. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110617. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110618. * 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;
  110619. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110620. */
  110621. get cameraColorCurves(): Nullable<ColorCurves>;
  110622. /**
  110623. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110624. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110625. * 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;
  110626. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110627. */
  110628. set cameraColorCurves(value: Nullable<ColorCurves>);
  110629. /**
  110630. * Can this material render to several textures at once
  110631. */
  110632. get canRenderToMRT(): boolean;
  110633. /**
  110634. * Defines the detail map parameters for the material.
  110635. */
  110636. readonly detailMap: DetailMapConfiguration;
  110637. protected _renderTargets: SmartArray<RenderTargetTexture>;
  110638. protected _worldViewProjectionMatrix: Matrix;
  110639. protected _globalAmbientColor: Color3;
  110640. protected _useLogarithmicDepth: boolean;
  110641. protected _rebuildInParallel: boolean;
  110642. /**
  110643. * Instantiates a new standard material.
  110644. * This is the default material used in Babylon. It is the best trade off between quality
  110645. * and performances.
  110646. * @see https://doc.babylonjs.com/babylon101/materials
  110647. * @param name Define the name of the material in the scene
  110648. * @param scene Define the scene the material belong to
  110649. */
  110650. constructor(name: string, scene: Scene);
  110651. /**
  110652. * Gets a boolean indicating that current material needs to register RTT
  110653. */
  110654. get hasRenderTargetTextures(): boolean;
  110655. /**
  110656. * Gets the current class name of the material e.g. "StandardMaterial"
  110657. * Mainly use in serialization.
  110658. * @returns the class name
  110659. */
  110660. getClassName(): string;
  110661. /**
  110662. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  110663. * You can try switching to logarithmic depth.
  110664. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  110665. */
  110666. get useLogarithmicDepth(): boolean;
  110667. set useLogarithmicDepth(value: boolean);
  110668. /**
  110669. * Specifies if the material will require alpha blending
  110670. * @returns a boolean specifying if alpha blending is needed
  110671. */
  110672. needAlphaBlending(): boolean;
  110673. /**
  110674. * Specifies if this material should be rendered in alpha test mode
  110675. * @returns a boolean specifying if an alpha test is needed.
  110676. */
  110677. needAlphaTesting(): boolean;
  110678. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  110679. /**
  110680. * Get the texture used for alpha test purpose.
  110681. * @returns the diffuse texture in case of the standard material.
  110682. */
  110683. getAlphaTestTexture(): Nullable<BaseTexture>;
  110684. /**
  110685. * Get if the submesh is ready to be used and all its information available.
  110686. * Child classes can use it to update shaders
  110687. * @param mesh defines the mesh to check
  110688. * @param subMesh defines which submesh to check
  110689. * @param useInstances specifies that instances should be used
  110690. * @returns a boolean indicating that the submesh is ready or not
  110691. */
  110692. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110693. /**
  110694. * Builds the material UBO layouts.
  110695. * Used internally during the effect preparation.
  110696. */
  110697. buildUniformLayout(): void;
  110698. /**
  110699. * Unbinds the material from the mesh
  110700. */
  110701. unbind(): void;
  110702. /**
  110703. * Binds the submesh to this material by preparing the effect and shader to draw
  110704. * @param world defines the world transformation matrix
  110705. * @param mesh defines the mesh containing the submesh
  110706. * @param subMesh defines the submesh to bind the material to
  110707. */
  110708. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  110709. /**
  110710. * Get the list of animatables in the material.
  110711. * @returns the list of animatables object used in the material
  110712. */
  110713. getAnimatables(): IAnimatable[];
  110714. /**
  110715. * Gets the active textures from the material
  110716. * @returns an array of textures
  110717. */
  110718. getActiveTextures(): BaseTexture[];
  110719. /**
  110720. * Specifies if the material uses a texture
  110721. * @param texture defines the texture to check against the material
  110722. * @returns a boolean specifying if the material uses the texture
  110723. */
  110724. hasTexture(texture: BaseTexture): boolean;
  110725. /**
  110726. * Disposes the material
  110727. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  110728. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  110729. */
  110730. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  110731. /**
  110732. * Makes a duplicate of the material, and gives it a new name
  110733. * @param name defines the new name for the duplicated material
  110734. * @returns the cloned material
  110735. */
  110736. clone(name: string): StandardMaterial;
  110737. /**
  110738. * Serializes this material in a JSON representation
  110739. * @returns the serialized material object
  110740. */
  110741. serialize(): any;
  110742. /**
  110743. * Creates a standard material from parsed material data
  110744. * @param source defines the JSON representation of the material
  110745. * @param scene defines the hosting scene
  110746. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  110747. * @returns a new standard material
  110748. */
  110749. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  110750. /**
  110751. * Are diffuse textures enabled in the application.
  110752. */
  110753. static get DiffuseTextureEnabled(): boolean;
  110754. static set DiffuseTextureEnabled(value: boolean);
  110755. /**
  110756. * Are detail textures enabled in the application.
  110757. */
  110758. static get DetailTextureEnabled(): boolean;
  110759. static set DetailTextureEnabled(value: boolean);
  110760. /**
  110761. * Are ambient textures enabled in the application.
  110762. */
  110763. static get AmbientTextureEnabled(): boolean;
  110764. static set AmbientTextureEnabled(value: boolean);
  110765. /**
  110766. * Are opacity textures enabled in the application.
  110767. */
  110768. static get OpacityTextureEnabled(): boolean;
  110769. static set OpacityTextureEnabled(value: boolean);
  110770. /**
  110771. * Are reflection textures enabled in the application.
  110772. */
  110773. static get ReflectionTextureEnabled(): boolean;
  110774. static set ReflectionTextureEnabled(value: boolean);
  110775. /**
  110776. * Are emissive textures enabled in the application.
  110777. */
  110778. static get EmissiveTextureEnabled(): boolean;
  110779. static set EmissiveTextureEnabled(value: boolean);
  110780. /**
  110781. * Are specular textures enabled in the application.
  110782. */
  110783. static get SpecularTextureEnabled(): boolean;
  110784. static set SpecularTextureEnabled(value: boolean);
  110785. /**
  110786. * Are bump textures enabled in the application.
  110787. */
  110788. static get BumpTextureEnabled(): boolean;
  110789. static set BumpTextureEnabled(value: boolean);
  110790. /**
  110791. * Are lightmap textures enabled in the application.
  110792. */
  110793. static get LightmapTextureEnabled(): boolean;
  110794. static set LightmapTextureEnabled(value: boolean);
  110795. /**
  110796. * Are refraction textures enabled in the application.
  110797. */
  110798. static get RefractionTextureEnabled(): boolean;
  110799. static set RefractionTextureEnabled(value: boolean);
  110800. /**
  110801. * Are color grading textures enabled in the application.
  110802. */
  110803. static get ColorGradingTextureEnabled(): boolean;
  110804. static set ColorGradingTextureEnabled(value: boolean);
  110805. /**
  110806. * Are fresnels enabled in the application.
  110807. */
  110808. static get FresnelEnabled(): boolean;
  110809. static set FresnelEnabled(value: boolean);
  110810. }
  110811. }
  110812. declare module BABYLON {
  110813. /**
  110814. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  110815. *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.
  110816. * The SPS is also a particle system. It provides some methods to manage the particles.
  110817. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  110818. *
  110819. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  110820. */
  110821. export class SolidParticleSystem implements IDisposable {
  110822. /**
  110823. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  110824. * Example : var p = SPS.particles[i];
  110825. */
  110826. particles: SolidParticle[];
  110827. /**
  110828. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  110829. */
  110830. nbParticles: number;
  110831. /**
  110832. * If the particles must ever face the camera (default false). Useful for planar particles.
  110833. */
  110834. billboard: boolean;
  110835. /**
  110836. * Recompute normals when adding a shape
  110837. */
  110838. recomputeNormals: boolean;
  110839. /**
  110840. * This a counter ofr your own usage. It's not set by any SPS functions.
  110841. */
  110842. counter: number;
  110843. /**
  110844. * The SPS name. This name is also given to the underlying mesh.
  110845. */
  110846. name: string;
  110847. /**
  110848. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  110849. */
  110850. mesh: Mesh;
  110851. /**
  110852. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  110853. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  110854. */
  110855. vars: any;
  110856. /**
  110857. * This array is populated when the SPS is set as 'pickable'.
  110858. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  110859. * Each element of this array is an object `{idx: int, faceId: int}`.
  110860. * `idx` is the picked particle index in the `SPS.particles` array
  110861. * `faceId` is the picked face index counted within this particle.
  110862. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  110863. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  110864. * Use the method SPS.pickedParticle(pickingInfo) instead.
  110865. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  110866. */
  110867. pickedParticles: {
  110868. idx: number;
  110869. faceId: number;
  110870. }[];
  110871. /**
  110872. * This array is populated when the SPS is set as 'pickable'
  110873. * Each key of this array is a submesh index.
  110874. * Each element of this array is a second array defined like this :
  110875. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  110876. * Each element of this second array is an object `{idx: int, faceId: int}`.
  110877. * `idx` is the picked particle index in the `SPS.particles` array
  110878. * `faceId` is the picked face index counted within this particle.
  110879. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  110880. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  110881. */
  110882. pickedBySubMesh: {
  110883. idx: number;
  110884. faceId: number;
  110885. }[][];
  110886. /**
  110887. * This array is populated when `enableDepthSort` is set to true.
  110888. * Each element of this array is an instance of the class DepthSortedParticle.
  110889. */
  110890. depthSortedParticles: DepthSortedParticle[];
  110891. /**
  110892. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  110893. * @hidden
  110894. */
  110895. _bSphereOnly: boolean;
  110896. /**
  110897. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  110898. * @hidden
  110899. */
  110900. _bSphereRadiusFactor: number;
  110901. private _scene;
  110902. private _positions;
  110903. private _indices;
  110904. private _normals;
  110905. private _colors;
  110906. private _uvs;
  110907. private _indices32;
  110908. private _positions32;
  110909. private _normals32;
  110910. private _fixedNormal32;
  110911. private _colors32;
  110912. private _uvs32;
  110913. private _index;
  110914. private _updatable;
  110915. private _pickable;
  110916. private _isVisibilityBoxLocked;
  110917. private _alwaysVisible;
  110918. private _depthSort;
  110919. private _expandable;
  110920. private _shapeCounter;
  110921. private _copy;
  110922. private _color;
  110923. private _computeParticleColor;
  110924. private _computeParticleTexture;
  110925. private _computeParticleRotation;
  110926. private _computeParticleVertex;
  110927. private _computeBoundingBox;
  110928. private _depthSortParticles;
  110929. private _camera;
  110930. private _mustUnrotateFixedNormals;
  110931. private _particlesIntersect;
  110932. private _needs32Bits;
  110933. private _isNotBuilt;
  110934. private _lastParticleId;
  110935. private _idxOfId;
  110936. private _multimaterialEnabled;
  110937. private _useModelMaterial;
  110938. private _indicesByMaterial;
  110939. private _materialIndexes;
  110940. private _depthSortFunction;
  110941. private _materialSortFunction;
  110942. private _materials;
  110943. private _multimaterial;
  110944. private _materialIndexesById;
  110945. private _defaultMaterial;
  110946. private _autoUpdateSubMeshes;
  110947. private _tmpVertex;
  110948. /**
  110949. * Creates a SPS (Solid Particle System) object.
  110950. * @param name (String) is the SPS name, this will be the underlying mesh name.
  110951. * @param scene (Scene) is the scene in which the SPS is added.
  110952. * @param options defines the options of the sps e.g.
  110953. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  110954. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  110955. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  110956. * * 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.
  110957. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  110958. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  110959. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  110960. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  110961. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  110962. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  110963. */
  110964. constructor(name: string, scene: Scene, options?: {
  110965. updatable?: boolean;
  110966. isPickable?: boolean;
  110967. enableDepthSort?: boolean;
  110968. particleIntersection?: boolean;
  110969. boundingSphereOnly?: boolean;
  110970. bSphereRadiusFactor?: number;
  110971. expandable?: boolean;
  110972. useModelMaterial?: boolean;
  110973. enableMultiMaterial?: boolean;
  110974. });
  110975. /**
  110976. * Builds the SPS underlying mesh. Returns a standard Mesh.
  110977. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  110978. * @returns the created mesh
  110979. */
  110980. buildMesh(): Mesh;
  110981. /**
  110982. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  110983. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  110984. * Thus the particles generated from `digest()` have their property `position` set yet.
  110985. * @param mesh ( Mesh ) is the mesh to be digested
  110986. * @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
  110987. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  110988. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  110989. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  110990. * @returns the current SPS
  110991. */
  110992. digest(mesh: Mesh, options?: {
  110993. facetNb?: number;
  110994. number?: number;
  110995. delta?: number;
  110996. storage?: [];
  110997. }): SolidParticleSystem;
  110998. /**
  110999. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  111000. * @hidden
  111001. */
  111002. private _unrotateFixedNormals;
  111003. /**
  111004. * Resets the temporary working copy particle
  111005. * @hidden
  111006. */
  111007. private _resetCopy;
  111008. /**
  111009. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  111010. * @param p the current index in the positions array to be updated
  111011. * @param ind the current index in the indices array
  111012. * @param shape a Vector3 array, the shape geometry
  111013. * @param positions the positions array to be updated
  111014. * @param meshInd the shape indices array
  111015. * @param indices the indices array to be updated
  111016. * @param meshUV the shape uv array
  111017. * @param uvs the uv array to be updated
  111018. * @param meshCol the shape color array
  111019. * @param colors the color array to be updated
  111020. * @param meshNor the shape normals array
  111021. * @param normals the normals array to be updated
  111022. * @param idx the particle index
  111023. * @param idxInShape the particle index in its shape
  111024. * @param options the addShape() method passed options
  111025. * @model the particle model
  111026. * @hidden
  111027. */
  111028. private _meshBuilder;
  111029. /**
  111030. * Returns a shape Vector3 array from positions float array
  111031. * @param positions float array
  111032. * @returns a vector3 array
  111033. * @hidden
  111034. */
  111035. private _posToShape;
  111036. /**
  111037. * Returns a shapeUV array from a float uvs (array deep copy)
  111038. * @param uvs as a float array
  111039. * @returns a shapeUV array
  111040. * @hidden
  111041. */
  111042. private _uvsToShapeUV;
  111043. /**
  111044. * Adds a new particle object in the particles array
  111045. * @param idx particle index in particles array
  111046. * @param id particle id
  111047. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  111048. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  111049. * @param model particle ModelShape object
  111050. * @param shapeId model shape identifier
  111051. * @param idxInShape index of the particle in the current model
  111052. * @param bInfo model bounding info object
  111053. * @param storage target storage array, if any
  111054. * @hidden
  111055. */
  111056. private _addParticle;
  111057. /**
  111058. * Adds some particles to the SPS from the model shape. Returns the shape id.
  111059. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  111060. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  111061. * @param nb (positive integer) the number of particles to be created from this model
  111062. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  111063. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  111064. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  111065. * @returns the number of shapes in the system
  111066. */
  111067. addShape(mesh: Mesh, nb: number, options?: {
  111068. positionFunction?: any;
  111069. vertexFunction?: any;
  111070. storage?: [];
  111071. }): number;
  111072. /**
  111073. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  111074. * @hidden
  111075. */
  111076. private _rebuildParticle;
  111077. /**
  111078. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  111079. * @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.
  111080. * @returns the SPS.
  111081. */
  111082. rebuildMesh(reset?: boolean): SolidParticleSystem;
  111083. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  111084. * Returns an array with the removed particles.
  111085. * 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.
  111086. * The SPS can't be empty so at least one particle needs to remain in place.
  111087. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  111088. * @param start index of the first particle to remove
  111089. * @param end index of the last particle to remove (included)
  111090. * @returns an array populated with the removed particles
  111091. */
  111092. removeParticles(start: number, end: number): SolidParticle[];
  111093. /**
  111094. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  111095. * @param solidParticleArray an array populated with Solid Particles objects
  111096. * @returns the SPS
  111097. */
  111098. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  111099. /**
  111100. * Creates a new particle and modifies the SPS mesh geometry :
  111101. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  111102. * - calls _addParticle() to populate the particle array
  111103. * factorized code from addShape() and insertParticlesFromArray()
  111104. * @param idx particle index in the particles array
  111105. * @param i particle index in its shape
  111106. * @param modelShape particle ModelShape object
  111107. * @param shape shape vertex array
  111108. * @param meshInd shape indices array
  111109. * @param meshUV shape uv array
  111110. * @param meshCol shape color array
  111111. * @param meshNor shape normals array
  111112. * @param bbInfo shape bounding info
  111113. * @param storage target particle storage
  111114. * @options addShape() passed options
  111115. * @hidden
  111116. */
  111117. private _insertNewParticle;
  111118. /**
  111119. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  111120. * This method calls `updateParticle()` for each particle of the SPS.
  111121. * For an animated SPS, it is usually called within the render loop.
  111122. * 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.
  111123. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  111124. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  111125. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  111126. * @returns the SPS.
  111127. */
  111128. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  111129. /**
  111130. * Disposes the SPS.
  111131. */
  111132. dispose(): void;
  111133. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  111134. * idx is the particle index in the SPS
  111135. * faceId is the picked face index counted within this particle.
  111136. * Returns null if the pickInfo can't identify a picked particle.
  111137. * @param pickingInfo (PickingInfo object)
  111138. * @returns {idx: number, faceId: number} or null
  111139. */
  111140. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  111141. idx: number;
  111142. faceId: number;
  111143. }>;
  111144. /**
  111145. * Returns a SolidParticle object from its identifier : particle.id
  111146. * @param id (integer) the particle Id
  111147. * @returns the searched particle or null if not found in the SPS.
  111148. */
  111149. getParticleById(id: number): Nullable<SolidParticle>;
  111150. /**
  111151. * Returns a new array populated with the particles having the passed shapeId.
  111152. * @param shapeId (integer) the shape identifier
  111153. * @returns a new solid particle array
  111154. */
  111155. getParticlesByShapeId(shapeId: number): SolidParticle[];
  111156. /**
  111157. * Populates the passed array "ref" with the particles having the passed shapeId.
  111158. * @param shapeId the shape identifier
  111159. * @returns the SPS
  111160. * @param ref
  111161. */
  111162. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  111163. /**
  111164. * Computes the required SubMeshes according the materials assigned to the particles.
  111165. * @returns the solid particle system.
  111166. * Does nothing if called before the SPS mesh is built.
  111167. */
  111168. computeSubMeshes(): SolidParticleSystem;
  111169. /**
  111170. * Sorts the solid particles by material when MultiMaterial is enabled.
  111171. * Updates the indices32 array.
  111172. * Updates the indicesByMaterial array.
  111173. * Updates the mesh indices array.
  111174. * @returns the SPS
  111175. * @hidden
  111176. */
  111177. private _sortParticlesByMaterial;
  111178. /**
  111179. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  111180. * @hidden
  111181. */
  111182. private _setMaterialIndexesById;
  111183. /**
  111184. * Returns an array with unique values of Materials from the passed array
  111185. * @param array the material array to be checked and filtered
  111186. * @hidden
  111187. */
  111188. private _filterUniqueMaterialId;
  111189. /**
  111190. * Sets a new Standard Material as _defaultMaterial if not already set.
  111191. * @hidden
  111192. */
  111193. private _setDefaultMaterial;
  111194. /**
  111195. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  111196. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111197. * @returns the SPS.
  111198. */
  111199. refreshVisibleSize(): SolidParticleSystem;
  111200. /**
  111201. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  111202. * @param size the size (float) of the visibility box
  111203. * note : this doesn't lock the SPS mesh bounding box.
  111204. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111205. */
  111206. setVisibilityBox(size: number): void;
  111207. /**
  111208. * Gets whether the SPS as always visible or not
  111209. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111210. */
  111211. get isAlwaysVisible(): boolean;
  111212. /**
  111213. * Sets the SPS as always visible or not
  111214. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111215. */
  111216. set isAlwaysVisible(val: boolean);
  111217. /**
  111218. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  111219. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111220. */
  111221. set isVisibilityBoxLocked(val: boolean);
  111222. /**
  111223. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  111224. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111225. */
  111226. get isVisibilityBoxLocked(): boolean;
  111227. /**
  111228. * Tells to `setParticles()` to compute the particle rotations or not.
  111229. * Default value : true. The SPS is faster when it's set to false.
  111230. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  111231. */
  111232. set computeParticleRotation(val: boolean);
  111233. /**
  111234. * Tells to `setParticles()` to compute the particle colors or not.
  111235. * Default value : true. The SPS is faster when it's set to false.
  111236. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  111237. */
  111238. set computeParticleColor(val: boolean);
  111239. set computeParticleTexture(val: boolean);
  111240. /**
  111241. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  111242. * Default value : false. The SPS is faster when it's set to false.
  111243. * Note : the particle custom vertex positions aren't stored values.
  111244. */
  111245. set computeParticleVertex(val: boolean);
  111246. /**
  111247. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  111248. */
  111249. set computeBoundingBox(val: boolean);
  111250. /**
  111251. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  111252. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  111253. * Default : `true`
  111254. */
  111255. set depthSortParticles(val: boolean);
  111256. /**
  111257. * Gets if `setParticles()` computes the particle rotations or not.
  111258. * Default value : true. The SPS is faster when it's set to false.
  111259. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  111260. */
  111261. get computeParticleRotation(): boolean;
  111262. /**
  111263. * Gets if `setParticles()` computes the particle colors or not.
  111264. * Default value : true. The SPS is faster when it's set to false.
  111265. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  111266. */
  111267. get computeParticleColor(): boolean;
  111268. /**
  111269. * Gets if `setParticles()` computes the particle textures or not.
  111270. * Default value : true. The SPS is faster when it's set to false.
  111271. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  111272. */
  111273. get computeParticleTexture(): boolean;
  111274. /**
  111275. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  111276. * Default value : false. The SPS is faster when it's set to false.
  111277. * Note : the particle custom vertex positions aren't stored values.
  111278. */
  111279. get computeParticleVertex(): boolean;
  111280. /**
  111281. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  111282. */
  111283. get computeBoundingBox(): boolean;
  111284. /**
  111285. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  111286. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  111287. * Default : `true`
  111288. */
  111289. get depthSortParticles(): boolean;
  111290. /**
  111291. * Gets if the SPS is created as expandable at construction time.
  111292. * Default : `false`
  111293. */
  111294. get expandable(): boolean;
  111295. /**
  111296. * Gets if the SPS supports the Multi Materials
  111297. */
  111298. get multimaterialEnabled(): boolean;
  111299. /**
  111300. * Gets if the SPS uses the model materials for its own multimaterial.
  111301. */
  111302. get useModelMaterial(): boolean;
  111303. /**
  111304. * The SPS used material array.
  111305. */
  111306. get materials(): Material[];
  111307. /**
  111308. * Sets the SPS MultiMaterial from the passed materials.
  111309. * Note : the passed array is internally copied and not used then by reference.
  111310. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  111311. */
  111312. setMultiMaterial(materials: Material[]): void;
  111313. /**
  111314. * The SPS computed multimaterial object
  111315. */
  111316. get multimaterial(): MultiMaterial;
  111317. set multimaterial(mm: MultiMaterial);
  111318. /**
  111319. * If the subMeshes must be updated on the next call to setParticles()
  111320. */
  111321. get autoUpdateSubMeshes(): boolean;
  111322. set autoUpdateSubMeshes(val: boolean);
  111323. /**
  111324. * This function does nothing. It may be overwritten to set all the particle first values.
  111325. * The SPS doesn't call this function, you may have to call it by your own.
  111326. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111327. */
  111328. initParticles(): void;
  111329. /**
  111330. * This function does nothing. It may be overwritten to recycle a particle.
  111331. * The SPS doesn't call this function, you may have to call it by your own.
  111332. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111333. * @param particle The particle to recycle
  111334. * @returns the recycled particle
  111335. */
  111336. recycleParticle(particle: SolidParticle): SolidParticle;
  111337. /**
  111338. * Updates a particle : this function should be overwritten by the user.
  111339. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  111340. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111341. * @example : just set a particle position or velocity and recycle conditions
  111342. * @param particle The particle to update
  111343. * @returns the updated particle
  111344. */
  111345. updateParticle(particle: SolidParticle): SolidParticle;
  111346. /**
  111347. * Updates a vertex of a particle : it can be overwritten by the user.
  111348. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  111349. * @param particle the current particle
  111350. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  111351. * @param pt the index of the current vertex in the particle shape
  111352. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  111353. * @example : just set a vertex particle position or color
  111354. * @returns the sps
  111355. */
  111356. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  111357. /**
  111358. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  111359. * This does nothing and may be overwritten by the user.
  111360. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111361. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111362. * @param update the boolean update value actually passed to setParticles()
  111363. */
  111364. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  111365. /**
  111366. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  111367. * This will be passed three parameters.
  111368. * This does nothing and may be overwritten by the user.
  111369. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111370. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111371. * @param update the boolean update value actually passed to setParticles()
  111372. */
  111373. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  111374. }
  111375. }
  111376. declare module BABYLON {
  111377. /**
  111378. * Represents one particle of a solid particle system.
  111379. */
  111380. export class SolidParticle {
  111381. /**
  111382. * particle global index
  111383. */
  111384. idx: number;
  111385. /**
  111386. * particle identifier
  111387. */
  111388. id: number;
  111389. /**
  111390. * The color of the particle
  111391. */
  111392. color: Nullable<Color4>;
  111393. /**
  111394. * The world space position of the particle.
  111395. */
  111396. position: Vector3;
  111397. /**
  111398. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  111399. */
  111400. rotation: Vector3;
  111401. /**
  111402. * The world space rotation quaternion of the particle.
  111403. */
  111404. rotationQuaternion: Nullable<Quaternion>;
  111405. /**
  111406. * The scaling of the particle.
  111407. */
  111408. scaling: Vector3;
  111409. /**
  111410. * The uvs of the particle.
  111411. */
  111412. uvs: Vector4;
  111413. /**
  111414. * The current speed of the particle.
  111415. */
  111416. velocity: Vector3;
  111417. /**
  111418. * The pivot point in the particle local space.
  111419. */
  111420. pivot: Vector3;
  111421. /**
  111422. * Must the particle be translated from its pivot point in its local space ?
  111423. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  111424. * Default : false
  111425. */
  111426. translateFromPivot: boolean;
  111427. /**
  111428. * Is the particle active or not ?
  111429. */
  111430. alive: boolean;
  111431. /**
  111432. * Is the particle visible or not ?
  111433. */
  111434. isVisible: boolean;
  111435. /**
  111436. * Index of this particle in the global "positions" array (Internal use)
  111437. * @hidden
  111438. */
  111439. _pos: number;
  111440. /**
  111441. * @hidden Index of this particle in the global "indices" array (Internal use)
  111442. */
  111443. _ind: number;
  111444. /**
  111445. * @hidden ModelShape of this particle (Internal use)
  111446. */
  111447. _model: ModelShape;
  111448. /**
  111449. * ModelShape id of this particle
  111450. */
  111451. shapeId: number;
  111452. /**
  111453. * Index of the particle in its shape id
  111454. */
  111455. idxInShape: number;
  111456. /**
  111457. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  111458. */
  111459. _modelBoundingInfo: BoundingInfo;
  111460. /**
  111461. * @hidden Particle BoundingInfo object (Internal use)
  111462. */
  111463. _boundingInfo: BoundingInfo;
  111464. /**
  111465. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  111466. */
  111467. _sps: SolidParticleSystem;
  111468. /**
  111469. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  111470. */
  111471. _stillInvisible: boolean;
  111472. /**
  111473. * @hidden Last computed particle rotation matrix
  111474. */
  111475. _rotationMatrix: number[];
  111476. /**
  111477. * Parent particle Id, if any.
  111478. * Default null.
  111479. */
  111480. parentId: Nullable<number>;
  111481. /**
  111482. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  111483. */
  111484. materialIndex: Nullable<number>;
  111485. /**
  111486. * Custom object or properties.
  111487. */
  111488. props: Nullable<any>;
  111489. /**
  111490. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  111491. * The possible values are :
  111492. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  111493. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  111494. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  111495. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  111496. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  111497. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  111498. * */
  111499. cullingStrategy: number;
  111500. /**
  111501. * @hidden Internal global position in the SPS.
  111502. */
  111503. _globalPosition: Vector3;
  111504. /**
  111505. * Creates a Solid Particle object.
  111506. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  111507. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  111508. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  111509. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  111510. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  111511. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  111512. * @param shapeId (integer) is the model shape identifier in the SPS.
  111513. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  111514. * @param sps defines the sps it is associated to
  111515. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  111516. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  111517. */
  111518. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  111519. /**
  111520. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  111521. * @param target the particle target
  111522. * @returns the current particle
  111523. */
  111524. copyToRef(target: SolidParticle): SolidParticle;
  111525. /**
  111526. * Legacy support, changed scale to scaling
  111527. */
  111528. get scale(): Vector3;
  111529. /**
  111530. * Legacy support, changed scale to scaling
  111531. */
  111532. set scale(scale: Vector3);
  111533. /**
  111534. * Legacy support, changed quaternion to rotationQuaternion
  111535. */
  111536. get quaternion(): Nullable<Quaternion>;
  111537. /**
  111538. * Legacy support, changed quaternion to rotationQuaternion
  111539. */
  111540. set quaternion(q: Nullable<Quaternion>);
  111541. /**
  111542. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  111543. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  111544. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  111545. * @returns true if it intersects
  111546. */
  111547. intersectsMesh(target: Mesh | SolidParticle): boolean;
  111548. /**
  111549. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  111550. * A particle is in the frustum if its bounding box intersects the frustum
  111551. * @param frustumPlanes defines the frustum to test
  111552. * @returns true if the particle is in the frustum planes
  111553. */
  111554. isInFrustum(frustumPlanes: Plane[]): boolean;
  111555. /**
  111556. * get the rotation matrix of the particle
  111557. * @hidden
  111558. */
  111559. getRotationMatrix(m: Matrix): void;
  111560. }
  111561. /**
  111562. * Represents the shape of the model used by one particle of a solid particle system.
  111563. * SPS internal tool, don't use it manually.
  111564. */
  111565. export class ModelShape {
  111566. /**
  111567. * The shape id
  111568. * @hidden
  111569. */
  111570. shapeID: number;
  111571. /**
  111572. * flat array of model positions (internal use)
  111573. * @hidden
  111574. */
  111575. _shape: Vector3[];
  111576. /**
  111577. * flat array of model UVs (internal use)
  111578. * @hidden
  111579. */
  111580. _shapeUV: number[];
  111581. /**
  111582. * color array of the model
  111583. * @hidden
  111584. */
  111585. _shapeColors: number[];
  111586. /**
  111587. * indices array of the model
  111588. * @hidden
  111589. */
  111590. _indices: number[];
  111591. /**
  111592. * normals array of the model
  111593. * @hidden
  111594. */
  111595. _normals: number[];
  111596. /**
  111597. * length of the shape in the model indices array (internal use)
  111598. * @hidden
  111599. */
  111600. _indicesLength: number;
  111601. /**
  111602. * Custom position function (internal use)
  111603. * @hidden
  111604. */
  111605. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  111606. /**
  111607. * Custom vertex function (internal use)
  111608. * @hidden
  111609. */
  111610. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  111611. /**
  111612. * Model material (internal use)
  111613. * @hidden
  111614. */
  111615. _material: Nullable<Material>;
  111616. /**
  111617. * 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.
  111618. * SPS internal tool, don't use it manually.
  111619. * @hidden
  111620. */
  111621. 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>);
  111622. }
  111623. /**
  111624. * Represents a Depth Sorted Particle in the solid particle system.
  111625. * @hidden
  111626. */
  111627. export class DepthSortedParticle {
  111628. /**
  111629. * Particle index
  111630. */
  111631. idx: number;
  111632. /**
  111633. * Index of the particle in the "indices" array
  111634. */
  111635. ind: number;
  111636. /**
  111637. * Length of the particle shape in the "indices" array
  111638. */
  111639. indicesLength: number;
  111640. /**
  111641. * Squared distance from the particle to the camera
  111642. */
  111643. sqDistance: number;
  111644. /**
  111645. * Material index when used with MultiMaterials
  111646. */
  111647. materialIndex: number;
  111648. /**
  111649. * Creates a new sorted particle
  111650. * @param materialIndex
  111651. */
  111652. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  111653. }
  111654. /**
  111655. * Represents a solid particle vertex
  111656. */
  111657. export class SolidParticleVertex {
  111658. /**
  111659. * Vertex position
  111660. */
  111661. position: Vector3;
  111662. /**
  111663. * Vertex color
  111664. */
  111665. color: Color4;
  111666. /**
  111667. * Vertex UV
  111668. */
  111669. uv: Vector2;
  111670. /**
  111671. * Creates a new solid particle vertex
  111672. */
  111673. constructor();
  111674. /** Vertex x coordinate */
  111675. get x(): number;
  111676. set x(val: number);
  111677. /** Vertex y coordinate */
  111678. get y(): number;
  111679. set y(val: number);
  111680. /** Vertex z coordinate */
  111681. get z(): number;
  111682. set z(val: number);
  111683. }
  111684. }
  111685. declare module BABYLON {
  111686. /**
  111687. * @hidden
  111688. */
  111689. export class _MeshCollisionData {
  111690. _checkCollisions: boolean;
  111691. _collisionMask: number;
  111692. _collisionGroup: number;
  111693. _surroundingMeshes: Nullable<AbstractMesh[]>;
  111694. _collider: Nullable<Collider>;
  111695. _oldPositionForCollisions: Vector3;
  111696. _diffPositionForCollisions: Vector3;
  111697. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  111698. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  111699. _collisionResponse: boolean;
  111700. }
  111701. }
  111702. declare module BABYLON {
  111703. /** @hidden */
  111704. class _FacetDataStorage {
  111705. facetPositions: Vector3[];
  111706. facetNormals: Vector3[];
  111707. facetPartitioning: number[][];
  111708. facetNb: number;
  111709. partitioningSubdivisions: number;
  111710. partitioningBBoxRatio: number;
  111711. facetDataEnabled: boolean;
  111712. facetParameters: any;
  111713. bbSize: Vector3;
  111714. subDiv: {
  111715. max: number;
  111716. X: number;
  111717. Y: number;
  111718. Z: number;
  111719. };
  111720. facetDepthSort: boolean;
  111721. facetDepthSortEnabled: boolean;
  111722. depthSortedIndices: IndicesArray;
  111723. depthSortedFacets: {
  111724. ind: number;
  111725. sqDistance: number;
  111726. }[];
  111727. facetDepthSortFunction: (f1: {
  111728. ind: number;
  111729. sqDistance: number;
  111730. }, f2: {
  111731. ind: number;
  111732. sqDistance: number;
  111733. }) => number;
  111734. facetDepthSortFrom: Vector3;
  111735. facetDepthSortOrigin: Vector3;
  111736. invertedMatrix: Matrix;
  111737. }
  111738. /**
  111739. * @hidden
  111740. **/
  111741. class _InternalAbstractMeshDataInfo {
  111742. _hasVertexAlpha: boolean;
  111743. _useVertexColors: boolean;
  111744. _numBoneInfluencers: number;
  111745. _applyFog: boolean;
  111746. _receiveShadows: boolean;
  111747. _facetData: _FacetDataStorage;
  111748. _visibility: number;
  111749. _skeleton: Nullable<Skeleton>;
  111750. _layerMask: number;
  111751. _computeBonesUsingShaders: boolean;
  111752. _isActive: boolean;
  111753. _onlyForInstances: boolean;
  111754. _isActiveIntermediate: boolean;
  111755. _onlyForInstancesIntermediate: boolean;
  111756. _actAsRegularMesh: boolean;
  111757. }
  111758. /**
  111759. * Class used to store all common mesh properties
  111760. */
  111761. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  111762. /** No occlusion */
  111763. static OCCLUSION_TYPE_NONE: number;
  111764. /** Occlusion set to optimisitic */
  111765. static OCCLUSION_TYPE_OPTIMISTIC: number;
  111766. /** Occlusion set to strict */
  111767. static OCCLUSION_TYPE_STRICT: number;
  111768. /** Use an accurante occlusion algorithm */
  111769. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  111770. /** Use a conservative occlusion algorithm */
  111771. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  111772. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  111773. * Test order :
  111774. * Is the bounding sphere outside the frustum ?
  111775. * If not, are the bounding box vertices outside the frustum ?
  111776. * It not, then the cullable object is in the frustum.
  111777. */
  111778. static readonly CULLINGSTRATEGY_STANDARD: number;
  111779. /** Culling strategy : Bounding Sphere Only.
  111780. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  111781. * It's also less accurate than the standard because some not visible objects can still be selected.
  111782. * Test : is the bounding sphere outside the frustum ?
  111783. * If not, then the cullable object is in the frustum.
  111784. */
  111785. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  111786. /** Culling strategy : Optimistic Inclusion.
  111787. * This in an inclusion test first, then the standard exclusion test.
  111788. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  111789. * 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.
  111790. * Anyway, it's as accurate as the standard strategy.
  111791. * Test :
  111792. * Is the cullable object bounding sphere center in the frustum ?
  111793. * If not, apply the default culling strategy.
  111794. */
  111795. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  111796. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  111797. * This in an inclusion test first, then the bounding sphere only exclusion test.
  111798. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  111799. * 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.
  111800. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  111801. * Test :
  111802. * Is the cullable object bounding sphere center in the frustum ?
  111803. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  111804. */
  111805. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  111806. /**
  111807. * No billboard
  111808. */
  111809. static get BILLBOARDMODE_NONE(): number;
  111810. /** Billboard on X axis */
  111811. static get BILLBOARDMODE_X(): number;
  111812. /** Billboard on Y axis */
  111813. static get BILLBOARDMODE_Y(): number;
  111814. /** Billboard on Z axis */
  111815. static get BILLBOARDMODE_Z(): number;
  111816. /** Billboard on all axes */
  111817. static get BILLBOARDMODE_ALL(): number;
  111818. /** Billboard on using position instead of orientation */
  111819. static get BILLBOARDMODE_USE_POSITION(): number;
  111820. /** @hidden */
  111821. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  111822. /**
  111823. * The culling strategy to use to check whether the mesh must be rendered or not.
  111824. * This value can be changed at any time and will be used on the next render mesh selection.
  111825. * The possible values are :
  111826. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  111827. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  111828. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  111829. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  111830. * Please read each static variable documentation to get details about the culling process.
  111831. * */
  111832. cullingStrategy: number;
  111833. /**
  111834. * Gets the number of facets in the mesh
  111835. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  111836. */
  111837. get facetNb(): number;
  111838. /**
  111839. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  111840. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  111841. */
  111842. get partitioningSubdivisions(): number;
  111843. set partitioningSubdivisions(nb: number);
  111844. /**
  111845. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  111846. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  111847. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  111848. */
  111849. get partitioningBBoxRatio(): number;
  111850. set partitioningBBoxRatio(ratio: number);
  111851. /**
  111852. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  111853. * Works only for updatable meshes.
  111854. * Doesn't work with multi-materials
  111855. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  111856. */
  111857. get mustDepthSortFacets(): boolean;
  111858. set mustDepthSortFacets(sort: boolean);
  111859. /**
  111860. * The location (Vector3) where the facet depth sort must be computed from.
  111861. * By default, the active camera position.
  111862. * Used only when facet depth sort is enabled
  111863. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  111864. */
  111865. get facetDepthSortFrom(): Vector3;
  111866. set facetDepthSortFrom(location: Vector3);
  111867. /**
  111868. * gets a boolean indicating if facetData is enabled
  111869. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  111870. */
  111871. get isFacetDataEnabled(): boolean;
  111872. /** @hidden */
  111873. _updateNonUniformScalingState(value: boolean): boolean;
  111874. /**
  111875. * An event triggered when this mesh collides with another one
  111876. */
  111877. onCollideObservable: Observable<AbstractMesh>;
  111878. /** Set a function to call when this mesh collides with another one */
  111879. set onCollide(callback: () => void);
  111880. /**
  111881. * An event triggered when the collision's position changes
  111882. */
  111883. onCollisionPositionChangeObservable: Observable<Vector3>;
  111884. /** Set a function to call when the collision's position changes */
  111885. set onCollisionPositionChange(callback: () => void);
  111886. /**
  111887. * An event triggered when material is changed
  111888. */
  111889. onMaterialChangedObservable: Observable<AbstractMesh>;
  111890. /**
  111891. * Gets or sets the orientation for POV movement & rotation
  111892. */
  111893. definedFacingForward: boolean;
  111894. /** @hidden */
  111895. _occlusionQuery: Nullable<WebGLQuery>;
  111896. /** @hidden */
  111897. _renderingGroup: Nullable<RenderingGroup>;
  111898. /**
  111899. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  111900. */
  111901. get visibility(): number;
  111902. /**
  111903. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  111904. */
  111905. set visibility(value: number);
  111906. /** Gets or sets the alpha index used to sort transparent meshes
  111907. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  111908. */
  111909. alphaIndex: number;
  111910. /**
  111911. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  111912. */
  111913. isVisible: boolean;
  111914. /**
  111915. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  111916. */
  111917. isPickable: boolean;
  111918. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  111919. showSubMeshesBoundingBox: boolean;
  111920. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  111921. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111922. */
  111923. isBlocker: boolean;
  111924. /**
  111925. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  111926. */
  111927. enablePointerMoveEvents: boolean;
  111928. private _renderingGroupId;
  111929. /**
  111930. * Specifies the rendering group id for this mesh (0 by default)
  111931. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  111932. */
  111933. get renderingGroupId(): number;
  111934. set renderingGroupId(value: number);
  111935. private _material;
  111936. /** Gets or sets current material */
  111937. get material(): Nullable<Material>;
  111938. set material(value: Nullable<Material>);
  111939. /**
  111940. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  111941. * @see https://doc.babylonjs.com/babylon101/shadows
  111942. */
  111943. get receiveShadows(): boolean;
  111944. set receiveShadows(value: boolean);
  111945. /** Defines color to use when rendering outline */
  111946. outlineColor: Color3;
  111947. /** Define width to use when rendering outline */
  111948. outlineWidth: number;
  111949. /** Defines color to use when rendering overlay */
  111950. overlayColor: Color3;
  111951. /** Defines alpha to use when rendering overlay */
  111952. overlayAlpha: number;
  111953. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  111954. get hasVertexAlpha(): boolean;
  111955. set hasVertexAlpha(value: boolean);
  111956. /** 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) */
  111957. get useVertexColors(): boolean;
  111958. set useVertexColors(value: boolean);
  111959. /**
  111960. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  111961. */
  111962. get computeBonesUsingShaders(): boolean;
  111963. set computeBonesUsingShaders(value: boolean);
  111964. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  111965. get numBoneInfluencers(): number;
  111966. set numBoneInfluencers(value: number);
  111967. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  111968. get applyFog(): boolean;
  111969. set applyFog(value: boolean);
  111970. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  111971. useOctreeForRenderingSelection: boolean;
  111972. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  111973. useOctreeForPicking: boolean;
  111974. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  111975. useOctreeForCollisions: boolean;
  111976. /**
  111977. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  111978. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  111979. */
  111980. get layerMask(): number;
  111981. set layerMask(value: number);
  111982. /**
  111983. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  111984. */
  111985. alwaysSelectAsActiveMesh: boolean;
  111986. /**
  111987. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  111988. */
  111989. doNotSyncBoundingInfo: boolean;
  111990. /**
  111991. * Gets or sets the current action manager
  111992. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  111993. */
  111994. actionManager: Nullable<AbstractActionManager>;
  111995. private _meshCollisionData;
  111996. /**
  111997. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  111998. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  111999. */
  112000. ellipsoid: Vector3;
  112001. /**
  112002. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  112003. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112004. */
  112005. ellipsoidOffset: Vector3;
  112006. /**
  112007. * Gets or sets a collision mask used to mask collisions (default is -1).
  112008. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  112009. */
  112010. get collisionMask(): number;
  112011. set collisionMask(mask: number);
  112012. /**
  112013. * Gets or sets a collision response flag (default is true).
  112014. * when collisionResponse is false, events are still triggered but colliding entity has no response
  112015. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  112016. * to respond to the collision.
  112017. */
  112018. get collisionResponse(): boolean;
  112019. set collisionResponse(response: boolean);
  112020. /**
  112021. * Gets or sets the current collision group mask (-1 by default).
  112022. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  112023. */
  112024. get collisionGroup(): number;
  112025. set collisionGroup(mask: number);
  112026. /**
  112027. * Gets or sets current surrounding meshes (null by default).
  112028. *
  112029. * By default collision detection is tested against every mesh in the scene.
  112030. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  112031. * meshes will be tested for the collision.
  112032. *
  112033. * Note: if set to an empty array no collision will happen when this mesh is moved.
  112034. */
  112035. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  112036. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  112037. /**
  112038. * Defines edge width used when edgesRenderer is enabled
  112039. * @see https://www.babylonjs-playground.com/#10OJSG#13
  112040. */
  112041. edgesWidth: number;
  112042. /**
  112043. * Defines edge color used when edgesRenderer is enabled
  112044. * @see https://www.babylonjs-playground.com/#10OJSG#13
  112045. */
  112046. edgesColor: Color4;
  112047. /** @hidden */
  112048. _edgesRenderer: Nullable<IEdgesRenderer>;
  112049. /** @hidden */
  112050. _masterMesh: Nullable<AbstractMesh>;
  112051. /** @hidden */
  112052. _boundingInfo: Nullable<BoundingInfo>;
  112053. /** @hidden */
  112054. _renderId: number;
  112055. /**
  112056. * Gets or sets the list of subMeshes
  112057. * @see https://doc.babylonjs.com/how_to/multi_materials
  112058. */
  112059. subMeshes: SubMesh[];
  112060. /** @hidden */
  112061. _intersectionsInProgress: AbstractMesh[];
  112062. /** @hidden */
  112063. _unIndexed: boolean;
  112064. /** @hidden */
  112065. _lightSources: Light[];
  112066. /** Gets the list of lights affecting that mesh */
  112067. get lightSources(): Light[];
  112068. /** @hidden */
  112069. get _positions(): Nullable<Vector3[]>;
  112070. /** @hidden */
  112071. _waitingData: {
  112072. lods: Nullable<any>;
  112073. actions: Nullable<any>;
  112074. freezeWorldMatrix: Nullable<boolean>;
  112075. };
  112076. /** @hidden */
  112077. _bonesTransformMatrices: Nullable<Float32Array>;
  112078. /** @hidden */
  112079. _transformMatrixTexture: Nullable<RawTexture>;
  112080. /**
  112081. * Gets or sets a skeleton to apply skining transformations
  112082. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  112083. */
  112084. set skeleton(value: Nullable<Skeleton>);
  112085. get skeleton(): Nullable<Skeleton>;
  112086. /**
  112087. * An event triggered when the mesh is rebuilt.
  112088. */
  112089. onRebuildObservable: Observable<AbstractMesh>;
  112090. /**
  112091. * Creates a new AbstractMesh
  112092. * @param name defines the name of the mesh
  112093. * @param scene defines the hosting scene
  112094. */
  112095. constructor(name: string, scene?: Nullable<Scene>);
  112096. /**
  112097. * Returns the string "AbstractMesh"
  112098. * @returns "AbstractMesh"
  112099. */
  112100. getClassName(): string;
  112101. /**
  112102. * Gets a string representation of the current mesh
  112103. * @param fullDetails defines a boolean indicating if full details must be included
  112104. * @returns a string representation of the current mesh
  112105. */
  112106. toString(fullDetails?: boolean): string;
  112107. /**
  112108. * @hidden
  112109. */
  112110. protected _getEffectiveParent(): Nullable<Node>;
  112111. /** @hidden */
  112112. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  112113. /** @hidden */
  112114. _rebuild(): void;
  112115. /** @hidden */
  112116. _resyncLightSources(): void;
  112117. /** @hidden */
  112118. _resyncLightSource(light: Light): void;
  112119. /** @hidden */
  112120. _unBindEffect(): void;
  112121. /** @hidden */
  112122. _removeLightSource(light: Light, dispose: boolean): void;
  112123. private _markSubMeshesAsDirty;
  112124. /** @hidden */
  112125. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  112126. /** @hidden */
  112127. _markSubMeshesAsAttributesDirty(): void;
  112128. /** @hidden */
  112129. _markSubMeshesAsMiscDirty(): void;
  112130. /**
  112131. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  112132. */
  112133. get scaling(): Vector3;
  112134. set scaling(newScaling: Vector3);
  112135. /**
  112136. * Returns true if the mesh is blocked. Implemented by child classes
  112137. */
  112138. get isBlocked(): boolean;
  112139. /**
  112140. * Returns the mesh itself by default. Implemented by child classes
  112141. * @param camera defines the camera to use to pick the right LOD level
  112142. * @returns the currentAbstractMesh
  112143. */
  112144. getLOD(camera: Camera): Nullable<AbstractMesh>;
  112145. /**
  112146. * Returns 0 by default. Implemented by child classes
  112147. * @returns an integer
  112148. */
  112149. getTotalVertices(): number;
  112150. /**
  112151. * Returns a positive integer : the total number of indices in this mesh geometry.
  112152. * @returns the numner of indices or zero if the mesh has no geometry.
  112153. */
  112154. getTotalIndices(): number;
  112155. /**
  112156. * Returns null by default. Implemented by child classes
  112157. * @returns null
  112158. */
  112159. getIndices(): Nullable<IndicesArray>;
  112160. /**
  112161. * Returns the array of the requested vertex data kind. Implemented by child classes
  112162. * @param kind defines the vertex data kind to use
  112163. * @returns null
  112164. */
  112165. getVerticesData(kind: string): Nullable<FloatArray>;
  112166. /**
  112167. * Sets the vertex data of the mesh geometry for the requested `kind`.
  112168. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  112169. * Note that a new underlying VertexBuffer object is created each call.
  112170. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  112171. * @param kind defines vertex data kind:
  112172. * * VertexBuffer.PositionKind
  112173. * * VertexBuffer.UVKind
  112174. * * VertexBuffer.UV2Kind
  112175. * * VertexBuffer.UV3Kind
  112176. * * VertexBuffer.UV4Kind
  112177. * * VertexBuffer.UV5Kind
  112178. * * VertexBuffer.UV6Kind
  112179. * * VertexBuffer.ColorKind
  112180. * * VertexBuffer.MatricesIndicesKind
  112181. * * VertexBuffer.MatricesIndicesExtraKind
  112182. * * VertexBuffer.MatricesWeightsKind
  112183. * * VertexBuffer.MatricesWeightsExtraKind
  112184. * @param data defines the data source
  112185. * @param updatable defines if the data must be flagged as updatable (or static)
  112186. * @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
  112187. * @returns the current mesh
  112188. */
  112189. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  112190. /**
  112191. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  112192. * If the mesh has no geometry, it is simply returned as it is.
  112193. * @param kind defines vertex data kind:
  112194. * * VertexBuffer.PositionKind
  112195. * * VertexBuffer.UVKind
  112196. * * VertexBuffer.UV2Kind
  112197. * * VertexBuffer.UV3Kind
  112198. * * VertexBuffer.UV4Kind
  112199. * * VertexBuffer.UV5Kind
  112200. * * VertexBuffer.UV6Kind
  112201. * * VertexBuffer.ColorKind
  112202. * * VertexBuffer.MatricesIndicesKind
  112203. * * VertexBuffer.MatricesIndicesExtraKind
  112204. * * VertexBuffer.MatricesWeightsKind
  112205. * * VertexBuffer.MatricesWeightsExtraKind
  112206. * @param data defines the data source
  112207. * @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
  112208. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  112209. * @returns the current mesh
  112210. */
  112211. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  112212. /**
  112213. * Sets the mesh indices,
  112214. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  112215. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  112216. * @param totalVertices Defines the total number of vertices
  112217. * @returns the current mesh
  112218. */
  112219. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  112220. /**
  112221. * Gets a boolean indicating if specific vertex data is present
  112222. * @param kind defines the vertex data kind to use
  112223. * @returns true is data kind is present
  112224. */
  112225. isVerticesDataPresent(kind: string): boolean;
  112226. /**
  112227. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  112228. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  112229. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  112230. * @returns a BoundingInfo
  112231. */
  112232. getBoundingInfo(): BoundingInfo;
  112233. /**
  112234. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  112235. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  112236. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  112237. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  112238. * @returns the current mesh
  112239. */
  112240. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  112241. /**
  112242. * Overwrite the current bounding info
  112243. * @param boundingInfo defines the new bounding info
  112244. * @returns the current mesh
  112245. */
  112246. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  112247. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  112248. get useBones(): boolean;
  112249. /** @hidden */
  112250. _preActivate(): void;
  112251. /** @hidden */
  112252. _preActivateForIntermediateRendering(renderId: number): void;
  112253. /** @hidden */
  112254. _activate(renderId: number, intermediateRendering: boolean): boolean;
  112255. /** @hidden */
  112256. _postActivate(): void;
  112257. /** @hidden */
  112258. _freeze(): void;
  112259. /** @hidden */
  112260. _unFreeze(): void;
  112261. /**
  112262. * Gets the current world matrix
  112263. * @returns a Matrix
  112264. */
  112265. getWorldMatrix(): Matrix;
  112266. /** @hidden */
  112267. _getWorldMatrixDeterminant(): number;
  112268. /**
  112269. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  112270. */
  112271. get isAnInstance(): boolean;
  112272. /**
  112273. * Gets a boolean indicating if this mesh has instances
  112274. */
  112275. get hasInstances(): boolean;
  112276. /**
  112277. * Gets a boolean indicating if this mesh has thin instances
  112278. */
  112279. get hasThinInstances(): boolean;
  112280. /**
  112281. * Perform relative position change from the point of view of behind the front of the mesh.
  112282. * This is performed taking into account the meshes current rotation, so you do not have to care.
  112283. * Supports definition of mesh facing forward or backward
  112284. * @param amountRight defines the distance on the right axis
  112285. * @param amountUp defines the distance on the up axis
  112286. * @param amountForward defines the distance on the forward axis
  112287. * @returns the current mesh
  112288. */
  112289. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  112290. /**
  112291. * Calculate relative position change from the point of view of behind the front of the mesh.
  112292. * This is performed taking into account the meshes current rotation, so you do not have to care.
  112293. * Supports definition of mesh facing forward or backward
  112294. * @param amountRight defines the distance on the right axis
  112295. * @param amountUp defines the distance on the up axis
  112296. * @param amountForward defines the distance on the forward axis
  112297. * @returns the new displacement vector
  112298. */
  112299. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  112300. /**
  112301. * Perform relative rotation change from the point of view of behind the front of the mesh.
  112302. * Supports definition of mesh facing forward or backward
  112303. * @param flipBack defines the flip
  112304. * @param twirlClockwise defines the twirl
  112305. * @param tiltRight defines the tilt
  112306. * @returns the current mesh
  112307. */
  112308. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  112309. /**
  112310. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  112311. * Supports definition of mesh facing forward or backward.
  112312. * @param flipBack defines the flip
  112313. * @param twirlClockwise defines the twirl
  112314. * @param tiltRight defines the tilt
  112315. * @returns the new rotation vector
  112316. */
  112317. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  112318. /**
  112319. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  112320. * This means the mesh underlying bounding box and sphere are recomputed.
  112321. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  112322. * @returns the current mesh
  112323. */
  112324. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  112325. /** @hidden */
  112326. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  112327. /** @hidden */
  112328. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  112329. /** @hidden */
  112330. _updateBoundingInfo(): AbstractMesh;
  112331. /** @hidden */
  112332. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  112333. /** @hidden */
  112334. protected _afterComputeWorldMatrix(): void;
  112335. /** @hidden */
  112336. get _effectiveMesh(): AbstractMesh;
  112337. /**
  112338. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  112339. * A mesh is in the frustum if its bounding box intersects the frustum
  112340. * @param frustumPlanes defines the frustum to test
  112341. * @returns true if the mesh is in the frustum planes
  112342. */
  112343. isInFrustum(frustumPlanes: Plane[]): boolean;
  112344. /**
  112345. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  112346. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  112347. * @param frustumPlanes defines the frustum to test
  112348. * @returns true if the mesh is completely in the frustum planes
  112349. */
  112350. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  112351. /**
  112352. * True if the mesh intersects another mesh or a SolidParticle object
  112353. * @param mesh defines a target mesh or SolidParticle to test
  112354. * @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)
  112355. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  112356. * @returns true if there is an intersection
  112357. */
  112358. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  112359. /**
  112360. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  112361. * @param point defines the point to test
  112362. * @returns true if there is an intersection
  112363. */
  112364. intersectsPoint(point: Vector3): boolean;
  112365. /**
  112366. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  112367. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112368. */
  112369. get checkCollisions(): boolean;
  112370. set checkCollisions(collisionEnabled: boolean);
  112371. /**
  112372. * Gets Collider object used to compute collisions (not physics)
  112373. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112374. */
  112375. get collider(): Nullable<Collider>;
  112376. /**
  112377. * Move the mesh using collision engine
  112378. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112379. * @param displacement defines the requested displacement vector
  112380. * @returns the current mesh
  112381. */
  112382. moveWithCollisions(displacement: Vector3): AbstractMesh;
  112383. private _onCollisionPositionChange;
  112384. /** @hidden */
  112385. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  112386. /** @hidden */
  112387. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  112388. /** @hidden */
  112389. _checkCollision(collider: Collider): AbstractMesh;
  112390. /** @hidden */
  112391. _generatePointsArray(): boolean;
  112392. /**
  112393. * Checks if the passed Ray intersects with the mesh
  112394. * @param ray defines the ray to use
  112395. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  112396. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  112397. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  112398. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  112399. * @returns the picking info
  112400. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  112401. */
  112402. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  112403. /**
  112404. * Clones the current mesh
  112405. * @param name defines the mesh name
  112406. * @param newParent defines the new mesh parent
  112407. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  112408. * @returns the new mesh
  112409. */
  112410. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  112411. /**
  112412. * Disposes all the submeshes of the current meshnp
  112413. * @returns the current mesh
  112414. */
  112415. releaseSubMeshes(): AbstractMesh;
  112416. /**
  112417. * Releases resources associated with this abstract mesh.
  112418. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  112419. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  112420. */
  112421. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112422. /**
  112423. * Adds the passed mesh as a child to the current mesh
  112424. * @param mesh defines the child mesh
  112425. * @returns the current mesh
  112426. */
  112427. addChild(mesh: AbstractMesh): AbstractMesh;
  112428. /**
  112429. * Removes the passed mesh from the current mesh children list
  112430. * @param mesh defines the child mesh
  112431. * @returns the current mesh
  112432. */
  112433. removeChild(mesh: AbstractMesh): AbstractMesh;
  112434. /** @hidden */
  112435. private _initFacetData;
  112436. /**
  112437. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  112438. * This method can be called within the render loop.
  112439. * 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
  112440. * @returns the current mesh
  112441. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112442. */
  112443. updateFacetData(): AbstractMesh;
  112444. /**
  112445. * Returns the facetLocalNormals array.
  112446. * The normals are expressed in the mesh local spac
  112447. * @returns an array of Vector3
  112448. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112449. */
  112450. getFacetLocalNormals(): Vector3[];
  112451. /**
  112452. * Returns the facetLocalPositions array.
  112453. * The facet positions are expressed in the mesh local space
  112454. * @returns an array of Vector3
  112455. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112456. */
  112457. getFacetLocalPositions(): Vector3[];
  112458. /**
  112459. * Returns the facetLocalPartioning array
  112460. * @returns an array of array of numbers
  112461. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112462. */
  112463. getFacetLocalPartitioning(): number[][];
  112464. /**
  112465. * Returns the i-th facet position in the world system.
  112466. * This method allocates a new Vector3 per call
  112467. * @param i defines the facet index
  112468. * @returns a new Vector3
  112469. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112470. */
  112471. getFacetPosition(i: number): Vector3;
  112472. /**
  112473. * Sets the reference Vector3 with the i-th facet position in the world system
  112474. * @param i defines the facet index
  112475. * @param ref defines the target vector
  112476. * @returns the current mesh
  112477. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112478. */
  112479. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  112480. /**
  112481. * Returns the i-th facet normal in the world system.
  112482. * This method allocates a new Vector3 per call
  112483. * @param i defines the facet index
  112484. * @returns a new Vector3
  112485. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112486. */
  112487. getFacetNormal(i: number): Vector3;
  112488. /**
  112489. * Sets the reference Vector3 with the i-th facet normal in the world system
  112490. * @param i defines the facet index
  112491. * @param ref defines the target vector
  112492. * @returns the current mesh
  112493. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112494. */
  112495. getFacetNormalToRef(i: number, ref: Vector3): this;
  112496. /**
  112497. * 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)
  112498. * @param x defines x coordinate
  112499. * @param y defines y coordinate
  112500. * @param z defines z coordinate
  112501. * @returns the array of facet indexes
  112502. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112503. */
  112504. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  112505. /**
  112506. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  112507. * @param projected sets as the (x,y,z) world projection on the facet
  112508. * @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
  112509. * @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
  112510. * @param x defines x coordinate
  112511. * @param y defines y coordinate
  112512. * @param z defines z coordinate
  112513. * @returns the face index if found (or null instead)
  112514. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112515. */
  112516. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  112517. /**
  112518. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  112519. * @param projected sets as the (x,y,z) local projection on the facet
  112520. * @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
  112521. * @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
  112522. * @param x defines x coordinate
  112523. * @param y defines y coordinate
  112524. * @param z defines z coordinate
  112525. * @returns the face index if found (or null instead)
  112526. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112527. */
  112528. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  112529. /**
  112530. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  112531. * @returns the parameters
  112532. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112533. */
  112534. getFacetDataParameters(): any;
  112535. /**
  112536. * Disables the feature FacetData and frees the related memory
  112537. * @returns the current mesh
  112538. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112539. */
  112540. disableFacetData(): AbstractMesh;
  112541. /**
  112542. * Updates the AbstractMesh indices array
  112543. * @param indices defines the data source
  112544. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  112545. * @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)
  112546. * @returns the current mesh
  112547. */
  112548. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  112549. /**
  112550. * Creates new normals data for the mesh
  112551. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  112552. * @returns the current mesh
  112553. */
  112554. createNormals(updatable: boolean): AbstractMesh;
  112555. /**
  112556. * Align the mesh with a normal
  112557. * @param normal defines the normal to use
  112558. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  112559. * @returns the current mesh
  112560. */
  112561. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  112562. /** @hidden */
  112563. _checkOcclusionQuery(): boolean;
  112564. /**
  112565. * Disables the mesh edge rendering mode
  112566. * @returns the currentAbstractMesh
  112567. */
  112568. disableEdgesRendering(): AbstractMesh;
  112569. /**
  112570. * Enables the edge rendering mode on the mesh.
  112571. * This mode makes the mesh edges visible
  112572. * @param epsilon defines the maximal distance between two angles to detect a face
  112573. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  112574. * @returns the currentAbstractMesh
  112575. * @see https://www.babylonjs-playground.com/#19O9TU#0
  112576. */
  112577. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  112578. /**
  112579. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  112580. * @returns an array of particle systems in the scene that use the mesh as an emitter
  112581. */
  112582. getConnectedParticleSystems(): IParticleSystem[];
  112583. }
  112584. }
  112585. declare module BABYLON {
  112586. /**
  112587. * Interface used to define ActionEvent
  112588. */
  112589. export interface IActionEvent {
  112590. /** The mesh or sprite that triggered the action */
  112591. source: any;
  112592. /** The X mouse cursor position at the time of the event */
  112593. pointerX: number;
  112594. /** The Y mouse cursor position at the time of the event */
  112595. pointerY: number;
  112596. /** The mesh that is currently pointed at (can be null) */
  112597. meshUnderPointer: Nullable<AbstractMesh>;
  112598. /** the original (browser) event that triggered the ActionEvent */
  112599. sourceEvent?: any;
  112600. /** additional data for the event */
  112601. additionalData?: any;
  112602. }
  112603. /**
  112604. * ActionEvent is the event being sent when an action is triggered.
  112605. */
  112606. export class ActionEvent implements IActionEvent {
  112607. /** The mesh or sprite that triggered the action */
  112608. source: any;
  112609. /** The X mouse cursor position at the time of the event */
  112610. pointerX: number;
  112611. /** The Y mouse cursor position at the time of the event */
  112612. pointerY: number;
  112613. /** The mesh that is currently pointed at (can be null) */
  112614. meshUnderPointer: Nullable<AbstractMesh>;
  112615. /** the original (browser) event that triggered the ActionEvent */
  112616. sourceEvent?: any;
  112617. /** additional data for the event */
  112618. additionalData?: any;
  112619. /**
  112620. * Creates a new ActionEvent
  112621. * @param source The mesh or sprite that triggered the action
  112622. * @param pointerX The X mouse cursor position at the time of the event
  112623. * @param pointerY The Y mouse cursor position at the time of the event
  112624. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  112625. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  112626. * @param additionalData additional data for the event
  112627. */
  112628. constructor(
  112629. /** The mesh or sprite that triggered the action */
  112630. source: any,
  112631. /** The X mouse cursor position at the time of the event */
  112632. pointerX: number,
  112633. /** The Y mouse cursor position at the time of the event */
  112634. pointerY: number,
  112635. /** The mesh that is currently pointed at (can be null) */
  112636. meshUnderPointer: Nullable<AbstractMesh>,
  112637. /** the original (browser) event that triggered the ActionEvent */
  112638. sourceEvent?: any,
  112639. /** additional data for the event */
  112640. additionalData?: any);
  112641. /**
  112642. * Helper function to auto-create an ActionEvent from a source mesh.
  112643. * @param source The source mesh that triggered the event
  112644. * @param evt The original (browser) event
  112645. * @param additionalData additional data for the event
  112646. * @returns the new ActionEvent
  112647. */
  112648. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  112649. /**
  112650. * Helper function to auto-create an ActionEvent from a source sprite
  112651. * @param source The source sprite that triggered the event
  112652. * @param scene Scene associated with the sprite
  112653. * @param evt The original (browser) event
  112654. * @param additionalData additional data for the event
  112655. * @returns the new ActionEvent
  112656. */
  112657. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  112658. /**
  112659. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  112660. * @param scene the scene where the event occurred
  112661. * @param evt The original (browser) event
  112662. * @returns the new ActionEvent
  112663. */
  112664. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  112665. /**
  112666. * Helper function to auto-create an ActionEvent from a primitive
  112667. * @param prim defines the target primitive
  112668. * @param pointerPos defines the pointer position
  112669. * @param evt The original (browser) event
  112670. * @param additionalData additional data for the event
  112671. * @returns the new ActionEvent
  112672. */
  112673. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  112674. }
  112675. }
  112676. declare module BABYLON {
  112677. /**
  112678. * Abstract class used to decouple action Manager from scene and meshes.
  112679. * Do not instantiate.
  112680. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  112681. */
  112682. export abstract class AbstractActionManager implements IDisposable {
  112683. /** Gets the list of active triggers */
  112684. static Triggers: {
  112685. [key: string]: number;
  112686. };
  112687. /** Gets the cursor to use when hovering items */
  112688. hoverCursor: string;
  112689. /** Gets the list of actions */
  112690. actions: IAction[];
  112691. /**
  112692. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  112693. */
  112694. isRecursive: boolean;
  112695. /**
  112696. * Releases all associated resources
  112697. */
  112698. abstract dispose(): void;
  112699. /**
  112700. * Does this action manager has pointer triggers
  112701. */
  112702. abstract get hasPointerTriggers(): boolean;
  112703. /**
  112704. * Does this action manager has pick triggers
  112705. */
  112706. abstract get hasPickTriggers(): boolean;
  112707. /**
  112708. * Process a specific trigger
  112709. * @param trigger defines the trigger to process
  112710. * @param evt defines the event details to be processed
  112711. */
  112712. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  112713. /**
  112714. * Does this action manager handles actions of any of the given triggers
  112715. * @param triggers defines the triggers to be tested
  112716. * @return a boolean indicating whether one (or more) of the triggers is handled
  112717. */
  112718. abstract hasSpecificTriggers(triggers: number[]): boolean;
  112719. /**
  112720. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  112721. * speed.
  112722. * @param triggerA defines the trigger to be tested
  112723. * @param triggerB defines the trigger to be tested
  112724. * @return a boolean indicating whether one (or more) of the triggers is handled
  112725. */
  112726. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  112727. /**
  112728. * Does this action manager handles actions of a given trigger
  112729. * @param trigger defines the trigger to be tested
  112730. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  112731. * @return whether the trigger is handled
  112732. */
  112733. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  112734. /**
  112735. * Serialize this manager to a JSON object
  112736. * @param name defines the property name to store this manager
  112737. * @returns a JSON representation of this manager
  112738. */
  112739. abstract serialize(name: string): any;
  112740. /**
  112741. * Registers an action to this action manager
  112742. * @param action defines the action to be registered
  112743. * @return the action amended (prepared) after registration
  112744. */
  112745. abstract registerAction(action: IAction): Nullable<IAction>;
  112746. /**
  112747. * Unregisters an action to this action manager
  112748. * @param action defines the action to be unregistered
  112749. * @return a boolean indicating whether the action has been unregistered
  112750. */
  112751. abstract unregisterAction(action: IAction): Boolean;
  112752. /**
  112753. * Does exist one action manager with at least one trigger
  112754. **/
  112755. static get HasTriggers(): boolean;
  112756. /**
  112757. * Does exist one action manager with at least one pick trigger
  112758. **/
  112759. static get HasPickTriggers(): boolean;
  112760. /**
  112761. * Does exist one action manager that handles actions of a given trigger
  112762. * @param trigger defines the trigger to be tested
  112763. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  112764. **/
  112765. static HasSpecificTrigger(trigger: number): boolean;
  112766. }
  112767. }
  112768. declare module BABYLON {
  112769. /**
  112770. * Defines how a node can be built from a string name.
  112771. */
  112772. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  112773. /**
  112774. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  112775. */
  112776. export class Node implements IBehaviorAware<Node> {
  112777. /** @hidden */
  112778. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  112779. private static _NodeConstructors;
  112780. /**
  112781. * Add a new node constructor
  112782. * @param type defines the type name of the node to construct
  112783. * @param constructorFunc defines the constructor function
  112784. */
  112785. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  112786. /**
  112787. * Returns a node constructor based on type name
  112788. * @param type defines the type name
  112789. * @param name defines the new node name
  112790. * @param scene defines the hosting scene
  112791. * @param options defines optional options to transmit to constructors
  112792. * @returns the new constructor or null
  112793. */
  112794. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  112795. /**
  112796. * Gets or sets the name of the node
  112797. */
  112798. name: string;
  112799. /**
  112800. * Gets or sets the id of the node
  112801. */
  112802. id: string;
  112803. /**
  112804. * Gets or sets the unique id of the node
  112805. */
  112806. uniqueId: number;
  112807. /**
  112808. * Gets or sets a string used to store user defined state for the node
  112809. */
  112810. state: string;
  112811. /**
  112812. * Gets or sets an object used to store user defined information for the node
  112813. */
  112814. metadata: any;
  112815. /**
  112816. * For internal use only. Please do not use.
  112817. */
  112818. reservedDataStore: any;
  112819. /**
  112820. * List of inspectable custom properties (used by the Inspector)
  112821. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  112822. */
  112823. inspectableCustomProperties: IInspectable[];
  112824. private _doNotSerialize;
  112825. /**
  112826. * Gets or sets a boolean used to define if the node must be serialized
  112827. */
  112828. get doNotSerialize(): boolean;
  112829. set doNotSerialize(value: boolean);
  112830. /** @hidden */
  112831. _isDisposed: boolean;
  112832. /**
  112833. * Gets a list of Animations associated with the node
  112834. */
  112835. animations: Animation[];
  112836. protected _ranges: {
  112837. [name: string]: Nullable<AnimationRange>;
  112838. };
  112839. /**
  112840. * Callback raised when the node is ready to be used
  112841. */
  112842. onReady: Nullable<(node: Node) => void>;
  112843. private _isEnabled;
  112844. private _isParentEnabled;
  112845. private _isReady;
  112846. /** @hidden */
  112847. _currentRenderId: number;
  112848. private _parentUpdateId;
  112849. /** @hidden */
  112850. _childUpdateId: number;
  112851. /** @hidden */
  112852. _waitingParentId: Nullable<string>;
  112853. /** @hidden */
  112854. _scene: Scene;
  112855. /** @hidden */
  112856. _cache: any;
  112857. private _parentNode;
  112858. private _children;
  112859. /** @hidden */
  112860. _worldMatrix: Matrix;
  112861. /** @hidden */
  112862. _worldMatrixDeterminant: number;
  112863. /** @hidden */
  112864. _worldMatrixDeterminantIsDirty: boolean;
  112865. /** @hidden */
  112866. private _sceneRootNodesIndex;
  112867. /**
  112868. * Gets a boolean indicating if the node has been disposed
  112869. * @returns true if the node was disposed
  112870. */
  112871. isDisposed(): boolean;
  112872. /**
  112873. * Gets or sets the parent of the node (without keeping the current position in the scene)
  112874. * @see https://doc.babylonjs.com/how_to/parenting
  112875. */
  112876. set parent(parent: Nullable<Node>);
  112877. get parent(): Nullable<Node>;
  112878. /** @hidden */
  112879. _addToSceneRootNodes(): void;
  112880. /** @hidden */
  112881. _removeFromSceneRootNodes(): void;
  112882. private _animationPropertiesOverride;
  112883. /**
  112884. * Gets or sets the animation properties override
  112885. */
  112886. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  112887. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  112888. /**
  112889. * Gets a string identifying the name of the class
  112890. * @returns "Node" string
  112891. */
  112892. getClassName(): string;
  112893. /** @hidden */
  112894. readonly _isNode: boolean;
  112895. /**
  112896. * An event triggered when the mesh is disposed
  112897. */
  112898. onDisposeObservable: Observable<Node>;
  112899. private _onDisposeObserver;
  112900. /**
  112901. * Sets a callback that will be raised when the node will be disposed
  112902. */
  112903. set onDispose(callback: () => void);
  112904. /**
  112905. * Creates a new Node
  112906. * @param name the name and id to be given to this node
  112907. * @param scene the scene this node will be added to
  112908. */
  112909. constructor(name: string, scene?: Nullable<Scene>);
  112910. /**
  112911. * Gets the scene of the node
  112912. * @returns a scene
  112913. */
  112914. getScene(): Scene;
  112915. /**
  112916. * Gets the engine of the node
  112917. * @returns a Engine
  112918. */
  112919. getEngine(): Engine;
  112920. private _behaviors;
  112921. /**
  112922. * Attach a behavior to the node
  112923. * @see https://doc.babylonjs.com/features/behaviour
  112924. * @param behavior defines the behavior to attach
  112925. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  112926. * @returns the current Node
  112927. */
  112928. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  112929. /**
  112930. * Remove an attached behavior
  112931. * @see https://doc.babylonjs.com/features/behaviour
  112932. * @param behavior defines the behavior to attach
  112933. * @returns the current Node
  112934. */
  112935. removeBehavior(behavior: Behavior<Node>): Node;
  112936. /**
  112937. * Gets the list of attached behaviors
  112938. * @see https://doc.babylonjs.com/features/behaviour
  112939. */
  112940. get behaviors(): Behavior<Node>[];
  112941. /**
  112942. * Gets an attached behavior by name
  112943. * @param name defines the name of the behavior to look for
  112944. * @see https://doc.babylonjs.com/features/behaviour
  112945. * @returns null if behavior was not found else the requested behavior
  112946. */
  112947. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  112948. /**
  112949. * Returns the latest update of the World matrix
  112950. * @returns a Matrix
  112951. */
  112952. getWorldMatrix(): Matrix;
  112953. /** @hidden */
  112954. _getWorldMatrixDeterminant(): number;
  112955. /**
  112956. * Returns directly the latest state of the mesh World matrix.
  112957. * A Matrix is returned.
  112958. */
  112959. get worldMatrixFromCache(): Matrix;
  112960. /** @hidden */
  112961. _initCache(): void;
  112962. /** @hidden */
  112963. updateCache(force?: boolean): void;
  112964. /** @hidden */
  112965. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  112966. /** @hidden */
  112967. _updateCache(ignoreParentClass?: boolean): void;
  112968. /** @hidden */
  112969. _isSynchronized(): boolean;
  112970. /** @hidden */
  112971. _markSyncedWithParent(): void;
  112972. /** @hidden */
  112973. isSynchronizedWithParent(): boolean;
  112974. /** @hidden */
  112975. isSynchronized(): boolean;
  112976. /**
  112977. * Is this node ready to be used/rendered
  112978. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  112979. * @return true if the node is ready
  112980. */
  112981. isReady(completeCheck?: boolean): boolean;
  112982. /**
  112983. * Is this node enabled?
  112984. * 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
  112985. * @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
  112986. * @return whether this node (and its parent) is enabled
  112987. */
  112988. isEnabled(checkAncestors?: boolean): boolean;
  112989. /** @hidden */
  112990. protected _syncParentEnabledState(): void;
  112991. /**
  112992. * Set the enabled state of this node
  112993. * @param value defines the new enabled state
  112994. */
  112995. setEnabled(value: boolean): void;
  112996. /**
  112997. * Is this node a descendant of the given node?
  112998. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  112999. * @param ancestor defines the parent node to inspect
  113000. * @returns a boolean indicating if this node is a descendant of the given node
  113001. */
  113002. isDescendantOf(ancestor: Node): boolean;
  113003. /** @hidden */
  113004. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  113005. /**
  113006. * Will return all nodes that have this node as ascendant
  113007. * @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
  113008. * @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
  113009. * @return all children nodes of all types
  113010. */
  113011. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  113012. /**
  113013. * Get all child-meshes of this node
  113014. * @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)
  113015. * @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
  113016. * @returns an array of AbstractMesh
  113017. */
  113018. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  113019. /**
  113020. * Get all direct children of this node
  113021. * @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
  113022. * @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)
  113023. * @returns an array of Node
  113024. */
  113025. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  113026. /** @hidden */
  113027. _setReady(state: boolean): void;
  113028. /**
  113029. * Get an animation by name
  113030. * @param name defines the name of the animation to look for
  113031. * @returns null if not found else the requested animation
  113032. */
  113033. getAnimationByName(name: string): Nullable<Animation>;
  113034. /**
  113035. * Creates an animation range for this node
  113036. * @param name defines the name of the range
  113037. * @param from defines the starting key
  113038. * @param to defines the end key
  113039. */
  113040. createAnimationRange(name: string, from: number, to: number): void;
  113041. /**
  113042. * Delete a specific animation range
  113043. * @param name defines the name of the range to delete
  113044. * @param deleteFrames defines if animation frames from the range must be deleted as well
  113045. */
  113046. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  113047. /**
  113048. * Get an animation range by name
  113049. * @param name defines the name of the animation range to look for
  113050. * @returns null if not found else the requested animation range
  113051. */
  113052. getAnimationRange(name: string): Nullable<AnimationRange>;
  113053. /**
  113054. * Gets the list of all animation ranges defined on this node
  113055. * @returns an array
  113056. */
  113057. getAnimationRanges(): Nullable<AnimationRange>[];
  113058. /**
  113059. * Will start the animation sequence
  113060. * @param name defines the range frames for animation sequence
  113061. * @param loop defines if the animation should loop (false by default)
  113062. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  113063. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  113064. * @returns the object created for this animation. If range does not exist, it will return null
  113065. */
  113066. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  113067. /**
  113068. * Serialize animation ranges into a JSON compatible object
  113069. * @returns serialization object
  113070. */
  113071. serializeAnimationRanges(): any;
  113072. /**
  113073. * Computes the world matrix of the node
  113074. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  113075. * @returns the world matrix
  113076. */
  113077. computeWorldMatrix(force?: boolean): Matrix;
  113078. /**
  113079. * Releases resources associated with this node.
  113080. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113081. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113082. */
  113083. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113084. /**
  113085. * Parse animation range data from a serialization object and store them into a given node
  113086. * @param node defines where to store the animation ranges
  113087. * @param parsedNode defines the serialization object to read data from
  113088. * @param scene defines the hosting scene
  113089. */
  113090. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  113091. /**
  113092. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  113093. * @param includeDescendants Include bounding info from descendants as well (true by default)
  113094. * @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
  113095. * @returns the new bounding vectors
  113096. */
  113097. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  113098. min: Vector3;
  113099. max: Vector3;
  113100. };
  113101. }
  113102. }
  113103. declare module BABYLON {
  113104. /**
  113105. * @hidden
  113106. */
  113107. export class _IAnimationState {
  113108. key: number;
  113109. repeatCount: number;
  113110. workValue?: any;
  113111. loopMode?: number;
  113112. offsetValue?: any;
  113113. highLimitValue?: any;
  113114. }
  113115. /**
  113116. * Class used to store any kind of animation
  113117. */
  113118. export class Animation {
  113119. /**Name of the animation */
  113120. name: string;
  113121. /**Property to animate */
  113122. targetProperty: string;
  113123. /**The frames per second of the animation */
  113124. framePerSecond: number;
  113125. /**The data type of the animation */
  113126. dataType: number;
  113127. /**The loop mode of the animation */
  113128. loopMode?: number | undefined;
  113129. /**Specifies if blending should be enabled */
  113130. enableBlending?: boolean | undefined;
  113131. /**
  113132. * Use matrix interpolation instead of using direct key value when animating matrices
  113133. */
  113134. static AllowMatricesInterpolation: boolean;
  113135. /**
  113136. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  113137. */
  113138. static AllowMatrixDecomposeForInterpolation: boolean;
  113139. /** Define the Url to load snippets */
  113140. static SnippetUrl: string;
  113141. /** Snippet ID if the animation was created from the snippet server */
  113142. snippetId: string;
  113143. /**
  113144. * Stores the key frames of the animation
  113145. */
  113146. private _keys;
  113147. /**
  113148. * Stores the easing function of the animation
  113149. */
  113150. private _easingFunction;
  113151. /**
  113152. * @hidden Internal use only
  113153. */
  113154. _runtimeAnimations: RuntimeAnimation[];
  113155. /**
  113156. * The set of event that will be linked to this animation
  113157. */
  113158. private _events;
  113159. /**
  113160. * Stores an array of target property paths
  113161. */
  113162. targetPropertyPath: string[];
  113163. /**
  113164. * Stores the blending speed of the animation
  113165. */
  113166. blendingSpeed: number;
  113167. /**
  113168. * Stores the animation ranges for the animation
  113169. */
  113170. private _ranges;
  113171. /**
  113172. * @hidden Internal use
  113173. */
  113174. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  113175. /**
  113176. * Sets up an animation
  113177. * @param property The property to animate
  113178. * @param animationType The animation type to apply
  113179. * @param framePerSecond The frames per second of the animation
  113180. * @param easingFunction The easing function used in the animation
  113181. * @returns The created animation
  113182. */
  113183. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  113184. /**
  113185. * Create and start an animation on a node
  113186. * @param name defines the name of the global animation that will be run on all nodes
  113187. * @param node defines the root node where the animation will take place
  113188. * @param targetProperty defines property to animate
  113189. * @param framePerSecond defines the number of frame per second yo use
  113190. * @param totalFrame defines the number of frames in total
  113191. * @param from defines the initial value
  113192. * @param to defines the final value
  113193. * @param loopMode defines which loop mode you want to use (off by default)
  113194. * @param easingFunction defines the easing function to use (linear by default)
  113195. * @param onAnimationEnd defines the callback to call when animation end
  113196. * @returns the animatable created for this animation
  113197. */
  113198. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  113199. /**
  113200. * Create and start an animation on a node and its descendants
  113201. * @param name defines the name of the global animation that will be run on all nodes
  113202. * @param node defines the root node where the animation will take place
  113203. * @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
  113204. * @param targetProperty defines property to animate
  113205. * @param framePerSecond defines the number of frame per second to use
  113206. * @param totalFrame defines the number of frames in total
  113207. * @param from defines the initial value
  113208. * @param to defines the final value
  113209. * @param loopMode defines which loop mode you want to use (off by default)
  113210. * @param easingFunction defines the easing function to use (linear by default)
  113211. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  113212. * @returns the list of animatables created for all nodes
  113213. * @example https://www.babylonjs-playground.com/#MH0VLI
  113214. */
  113215. 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[]>;
  113216. /**
  113217. * Creates a new animation, merges it with the existing animations and starts it
  113218. * @param name Name of the animation
  113219. * @param node Node which contains the scene that begins the animations
  113220. * @param targetProperty Specifies which property to animate
  113221. * @param framePerSecond The frames per second of the animation
  113222. * @param totalFrame The total number of frames
  113223. * @param from The frame at the beginning of the animation
  113224. * @param to The frame at the end of the animation
  113225. * @param loopMode Specifies the loop mode of the animation
  113226. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  113227. * @param onAnimationEnd Callback to run once the animation is complete
  113228. * @returns Nullable animation
  113229. */
  113230. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  113231. /**
  113232. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  113233. * @param sourceAnimation defines the Animation containing keyframes to convert
  113234. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  113235. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  113236. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  113237. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  113238. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  113239. */
  113240. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  113241. /**
  113242. * Transition property of an host to the target Value
  113243. * @param property The property to transition
  113244. * @param targetValue The target Value of the property
  113245. * @param host The object where the property to animate belongs
  113246. * @param scene Scene used to run the animation
  113247. * @param frameRate Framerate (in frame/s) to use
  113248. * @param transition The transition type we want to use
  113249. * @param duration The duration of the animation, in milliseconds
  113250. * @param onAnimationEnd Callback trigger at the end of the animation
  113251. * @returns Nullable animation
  113252. */
  113253. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  113254. /**
  113255. * Return the array of runtime animations currently using this animation
  113256. */
  113257. get runtimeAnimations(): RuntimeAnimation[];
  113258. /**
  113259. * Specifies if any of the runtime animations are currently running
  113260. */
  113261. get hasRunningRuntimeAnimations(): boolean;
  113262. /**
  113263. * Initializes the animation
  113264. * @param name Name of the animation
  113265. * @param targetProperty Property to animate
  113266. * @param framePerSecond The frames per second of the animation
  113267. * @param dataType The data type of the animation
  113268. * @param loopMode The loop mode of the animation
  113269. * @param enableBlending Specifies if blending should be enabled
  113270. */
  113271. constructor(
  113272. /**Name of the animation */
  113273. name: string,
  113274. /**Property to animate */
  113275. targetProperty: string,
  113276. /**The frames per second of the animation */
  113277. framePerSecond: number,
  113278. /**The data type of the animation */
  113279. dataType: number,
  113280. /**The loop mode of the animation */
  113281. loopMode?: number | undefined,
  113282. /**Specifies if blending should be enabled */
  113283. enableBlending?: boolean | undefined);
  113284. /**
  113285. * Converts the animation to a string
  113286. * @param fullDetails support for multiple levels of logging within scene loading
  113287. * @returns String form of the animation
  113288. */
  113289. toString(fullDetails?: boolean): string;
  113290. /**
  113291. * Add an event to this animation
  113292. * @param event Event to add
  113293. */
  113294. addEvent(event: AnimationEvent): void;
  113295. /**
  113296. * Remove all events found at the given frame
  113297. * @param frame The frame to remove events from
  113298. */
  113299. removeEvents(frame: number): void;
  113300. /**
  113301. * Retrieves all the events from the animation
  113302. * @returns Events from the animation
  113303. */
  113304. getEvents(): AnimationEvent[];
  113305. /**
  113306. * Creates an animation range
  113307. * @param name Name of the animation range
  113308. * @param from Starting frame of the animation range
  113309. * @param to Ending frame of the animation
  113310. */
  113311. createRange(name: string, from: number, to: number): void;
  113312. /**
  113313. * Deletes an animation range by name
  113314. * @param name Name of the animation range to delete
  113315. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  113316. */
  113317. deleteRange(name: string, deleteFrames?: boolean): void;
  113318. /**
  113319. * Gets the animation range by name, or null if not defined
  113320. * @param name Name of the animation range
  113321. * @returns Nullable animation range
  113322. */
  113323. getRange(name: string): Nullable<AnimationRange>;
  113324. /**
  113325. * Gets the key frames from the animation
  113326. * @returns The key frames of the animation
  113327. */
  113328. getKeys(): Array<IAnimationKey>;
  113329. /**
  113330. * Gets the highest frame rate of the animation
  113331. * @returns Highest frame rate of the animation
  113332. */
  113333. getHighestFrame(): number;
  113334. /**
  113335. * Gets the easing function of the animation
  113336. * @returns Easing function of the animation
  113337. */
  113338. getEasingFunction(): IEasingFunction;
  113339. /**
  113340. * Sets the easing function of the animation
  113341. * @param easingFunction A custom mathematical formula for animation
  113342. */
  113343. setEasingFunction(easingFunction: EasingFunction): void;
  113344. /**
  113345. * Interpolates a scalar linearly
  113346. * @param startValue Start value of the animation curve
  113347. * @param endValue End value of the animation curve
  113348. * @param gradient Scalar amount to interpolate
  113349. * @returns Interpolated scalar value
  113350. */
  113351. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  113352. /**
  113353. * Interpolates a scalar cubically
  113354. * @param startValue Start value of the animation curve
  113355. * @param outTangent End tangent of the animation
  113356. * @param endValue End value of the animation curve
  113357. * @param inTangent Start tangent of the animation curve
  113358. * @param gradient Scalar amount to interpolate
  113359. * @returns Interpolated scalar value
  113360. */
  113361. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  113362. /**
  113363. * Interpolates a quaternion using a spherical linear interpolation
  113364. * @param startValue Start value of the animation curve
  113365. * @param endValue End value of the animation curve
  113366. * @param gradient Scalar amount to interpolate
  113367. * @returns Interpolated quaternion value
  113368. */
  113369. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  113370. /**
  113371. * Interpolates a quaternion cubically
  113372. * @param startValue Start value of the animation curve
  113373. * @param outTangent End tangent of the animation curve
  113374. * @param endValue End value of the animation curve
  113375. * @param inTangent Start tangent of the animation curve
  113376. * @param gradient Scalar amount to interpolate
  113377. * @returns Interpolated quaternion value
  113378. */
  113379. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  113380. /**
  113381. * Interpolates a Vector3 linearl
  113382. * @param startValue Start value of the animation curve
  113383. * @param endValue End value of the animation curve
  113384. * @param gradient Scalar amount to interpolate
  113385. * @returns Interpolated scalar value
  113386. */
  113387. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  113388. /**
  113389. * Interpolates a Vector3 cubically
  113390. * @param startValue Start value of the animation curve
  113391. * @param outTangent End tangent of the animation
  113392. * @param endValue End value of the animation curve
  113393. * @param inTangent Start tangent of the animation curve
  113394. * @param gradient Scalar amount to interpolate
  113395. * @returns InterpolatedVector3 value
  113396. */
  113397. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  113398. /**
  113399. * Interpolates a Vector2 linearly
  113400. * @param startValue Start value of the animation curve
  113401. * @param endValue End value of the animation curve
  113402. * @param gradient Scalar amount to interpolate
  113403. * @returns Interpolated Vector2 value
  113404. */
  113405. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  113406. /**
  113407. * Interpolates a Vector2 cubically
  113408. * @param startValue Start value of the animation curve
  113409. * @param outTangent End tangent of the animation
  113410. * @param endValue End value of the animation curve
  113411. * @param inTangent Start tangent of the animation curve
  113412. * @param gradient Scalar amount to interpolate
  113413. * @returns Interpolated Vector2 value
  113414. */
  113415. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  113416. /**
  113417. * Interpolates a size linearly
  113418. * @param startValue Start value of the animation curve
  113419. * @param endValue End value of the animation curve
  113420. * @param gradient Scalar amount to interpolate
  113421. * @returns Interpolated Size value
  113422. */
  113423. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  113424. /**
  113425. * Interpolates a Color3 linearly
  113426. * @param startValue Start value of the animation curve
  113427. * @param endValue End value of the animation curve
  113428. * @param gradient Scalar amount to interpolate
  113429. * @returns Interpolated Color3 value
  113430. */
  113431. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  113432. /**
  113433. * Interpolates a Color4 linearly
  113434. * @param startValue Start value of the animation curve
  113435. * @param endValue End value of the animation curve
  113436. * @param gradient Scalar amount to interpolate
  113437. * @returns Interpolated Color3 value
  113438. */
  113439. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  113440. /**
  113441. * @hidden Internal use only
  113442. */
  113443. _getKeyValue(value: any): any;
  113444. /**
  113445. * @hidden Internal use only
  113446. */
  113447. _interpolate(currentFrame: number, state: _IAnimationState): any;
  113448. /**
  113449. * Defines the function to use to interpolate matrices
  113450. * @param startValue defines the start matrix
  113451. * @param endValue defines the end matrix
  113452. * @param gradient defines the gradient between both matrices
  113453. * @param result defines an optional target matrix where to store the interpolation
  113454. * @returns the interpolated matrix
  113455. */
  113456. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  113457. /**
  113458. * Makes a copy of the animation
  113459. * @returns Cloned animation
  113460. */
  113461. clone(): Animation;
  113462. /**
  113463. * Sets the key frames of the animation
  113464. * @param values The animation key frames to set
  113465. */
  113466. setKeys(values: Array<IAnimationKey>): void;
  113467. /**
  113468. * Serializes the animation to an object
  113469. * @returns Serialized object
  113470. */
  113471. serialize(): any;
  113472. /**
  113473. * Float animation type
  113474. */
  113475. static readonly ANIMATIONTYPE_FLOAT: number;
  113476. /**
  113477. * Vector3 animation type
  113478. */
  113479. static readonly ANIMATIONTYPE_VECTOR3: number;
  113480. /**
  113481. * Quaternion animation type
  113482. */
  113483. static readonly ANIMATIONTYPE_QUATERNION: number;
  113484. /**
  113485. * Matrix animation type
  113486. */
  113487. static readonly ANIMATIONTYPE_MATRIX: number;
  113488. /**
  113489. * Color3 animation type
  113490. */
  113491. static readonly ANIMATIONTYPE_COLOR3: number;
  113492. /**
  113493. * Color3 animation type
  113494. */
  113495. static readonly ANIMATIONTYPE_COLOR4: number;
  113496. /**
  113497. * Vector2 animation type
  113498. */
  113499. static readonly ANIMATIONTYPE_VECTOR2: number;
  113500. /**
  113501. * Size animation type
  113502. */
  113503. static readonly ANIMATIONTYPE_SIZE: number;
  113504. /**
  113505. * Relative Loop Mode
  113506. */
  113507. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  113508. /**
  113509. * Cycle Loop Mode
  113510. */
  113511. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  113512. /**
  113513. * Constant Loop Mode
  113514. */
  113515. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  113516. /** @hidden */
  113517. static _UniversalLerp(left: any, right: any, amount: number): any;
  113518. /**
  113519. * Parses an animation object and creates an animation
  113520. * @param parsedAnimation Parsed animation object
  113521. * @returns Animation object
  113522. */
  113523. static Parse(parsedAnimation: any): Animation;
  113524. /**
  113525. * Appends the serialized animations from the source animations
  113526. * @param source Source containing the animations
  113527. * @param destination Target to store the animations
  113528. */
  113529. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  113530. /**
  113531. * Creates a new animation or an array of animations from a snippet saved in a remote file
  113532. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  113533. * @param url defines the url to load from
  113534. * @returns a promise that will resolve to the new animation or an array of animations
  113535. */
  113536. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  113537. /**
  113538. * Creates an animation or an array of animations from a snippet saved by the Inspector
  113539. * @param snippetId defines the snippet to load
  113540. * @returns a promise that will resolve to the new animation or a new array of animations
  113541. */
  113542. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  113543. }
  113544. }
  113545. declare module BABYLON {
  113546. /**
  113547. * Interface containing an array of animations
  113548. */
  113549. export interface IAnimatable {
  113550. /**
  113551. * Array of animations
  113552. */
  113553. animations: Nullable<Array<Animation>>;
  113554. }
  113555. }
  113556. declare module BABYLON {
  113557. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  113558. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113559. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113560. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113561. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113562. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113563. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113564. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113565. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113566. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113567. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113568. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113569. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113570. /**
  113571. * Decorator used to define property that can be serialized as reference to a camera
  113572. * @param sourceName defines the name of the property to decorate
  113573. */
  113574. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  113575. /**
  113576. * Class used to help serialization objects
  113577. */
  113578. export class SerializationHelper {
  113579. /** @hidden */
  113580. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  113581. /** @hidden */
  113582. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  113583. /** @hidden */
  113584. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  113585. /** @hidden */
  113586. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  113587. /**
  113588. * Appends the serialized animations from the source animations
  113589. * @param source Source containing the animations
  113590. * @param destination Target to store the animations
  113591. */
  113592. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  113593. /**
  113594. * Static function used to serialized a specific entity
  113595. * @param entity defines the entity to serialize
  113596. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  113597. * @returns a JSON compatible object representing the serialization of the entity
  113598. */
  113599. static Serialize<T>(entity: T, serializationObject?: any): any;
  113600. /**
  113601. * Creates a new entity from a serialization data object
  113602. * @param creationFunction defines a function used to instanciated the new entity
  113603. * @param source defines the source serialization data
  113604. * @param scene defines the hosting scene
  113605. * @param rootUrl defines the root url for resources
  113606. * @returns a new entity
  113607. */
  113608. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  113609. /**
  113610. * Clones an object
  113611. * @param creationFunction defines the function used to instanciate the new object
  113612. * @param source defines the source object
  113613. * @returns the cloned object
  113614. */
  113615. static Clone<T>(creationFunction: () => T, source: T): T;
  113616. /**
  113617. * Instanciates a new object based on a source one (some data will be shared between both object)
  113618. * @param creationFunction defines the function used to instanciate the new object
  113619. * @param source defines the source object
  113620. * @returns the new object
  113621. */
  113622. static Instanciate<T>(creationFunction: () => T, source: T): T;
  113623. }
  113624. }
  113625. declare module BABYLON {
  113626. /**
  113627. * Base class of all the textures in babylon.
  113628. * It groups all the common properties the materials, post process, lights... might need
  113629. * in order to make a correct use of the texture.
  113630. */
  113631. export class BaseTexture implements IAnimatable {
  113632. /**
  113633. * Default anisotropic filtering level for the application.
  113634. * It is set to 4 as a good tradeoff between perf and quality.
  113635. */
  113636. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  113637. /**
  113638. * Gets or sets the unique id of the texture
  113639. */
  113640. uniqueId: number;
  113641. /**
  113642. * Define the name of the texture.
  113643. */
  113644. name: string;
  113645. /**
  113646. * Gets or sets an object used to store user defined information.
  113647. */
  113648. metadata: any;
  113649. /**
  113650. * For internal use only. Please do not use.
  113651. */
  113652. reservedDataStore: any;
  113653. private _hasAlpha;
  113654. /**
  113655. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  113656. */
  113657. set hasAlpha(value: boolean);
  113658. get hasAlpha(): boolean;
  113659. /**
  113660. * Defines if the alpha value should be determined via the rgb values.
  113661. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  113662. */
  113663. getAlphaFromRGB: boolean;
  113664. /**
  113665. * Intensity or strength of the texture.
  113666. * It is commonly used by materials to fine tune the intensity of the texture
  113667. */
  113668. level: number;
  113669. /**
  113670. * Define the UV chanel to use starting from 0 and defaulting to 0.
  113671. * This is part of the texture as textures usually maps to one uv set.
  113672. */
  113673. coordinatesIndex: number;
  113674. protected _coordinatesMode: number;
  113675. /**
  113676. * How a texture is mapped.
  113677. *
  113678. * | Value | Type | Description |
  113679. * | ----- | ----------------------------------- | ----------- |
  113680. * | 0 | EXPLICIT_MODE | |
  113681. * | 1 | SPHERICAL_MODE | |
  113682. * | 2 | PLANAR_MODE | |
  113683. * | 3 | CUBIC_MODE | |
  113684. * | 4 | PROJECTION_MODE | |
  113685. * | 5 | SKYBOX_MODE | |
  113686. * | 6 | INVCUBIC_MODE | |
  113687. * | 7 | EQUIRECTANGULAR_MODE | |
  113688. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  113689. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  113690. */
  113691. set coordinatesMode(value: number);
  113692. get coordinatesMode(): number;
  113693. private _wrapU;
  113694. /**
  113695. * | Value | Type | Description |
  113696. * | ----- | ------------------ | ----------- |
  113697. * | 0 | CLAMP_ADDRESSMODE | |
  113698. * | 1 | WRAP_ADDRESSMODE | |
  113699. * | 2 | MIRROR_ADDRESSMODE | |
  113700. */
  113701. get wrapU(): number;
  113702. set wrapU(value: number);
  113703. private _wrapV;
  113704. /**
  113705. * | Value | Type | Description |
  113706. * | ----- | ------------------ | ----------- |
  113707. * | 0 | CLAMP_ADDRESSMODE | |
  113708. * | 1 | WRAP_ADDRESSMODE | |
  113709. * | 2 | MIRROR_ADDRESSMODE | |
  113710. */
  113711. get wrapV(): number;
  113712. set wrapV(value: number);
  113713. /**
  113714. * | Value | Type | Description |
  113715. * | ----- | ------------------ | ----------- |
  113716. * | 0 | CLAMP_ADDRESSMODE | |
  113717. * | 1 | WRAP_ADDRESSMODE | |
  113718. * | 2 | MIRROR_ADDRESSMODE | |
  113719. */
  113720. wrapR: number;
  113721. /**
  113722. * With compliant hardware and browser (supporting anisotropic filtering)
  113723. * this defines the level of anisotropic filtering in the texture.
  113724. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  113725. */
  113726. anisotropicFilteringLevel: number;
  113727. /**
  113728. * Define if the texture is a cube texture or if false a 2d texture.
  113729. */
  113730. get isCube(): boolean;
  113731. set isCube(value: boolean);
  113732. /**
  113733. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  113734. */
  113735. get is3D(): boolean;
  113736. set is3D(value: boolean);
  113737. /**
  113738. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  113739. */
  113740. get is2DArray(): boolean;
  113741. set is2DArray(value: boolean);
  113742. private _gammaSpace;
  113743. /**
  113744. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  113745. * HDR texture are usually stored in linear space.
  113746. * This only impacts the PBR and Background materials
  113747. */
  113748. get gammaSpace(): boolean;
  113749. set gammaSpace(gamma: boolean);
  113750. /**
  113751. * Gets or sets whether or not the texture contains RGBD data.
  113752. */
  113753. get isRGBD(): boolean;
  113754. set isRGBD(value: boolean);
  113755. /**
  113756. * Is Z inverted in the texture (useful in a cube texture).
  113757. */
  113758. invertZ: boolean;
  113759. /**
  113760. * Are mip maps generated for this texture or not.
  113761. */
  113762. get noMipmap(): boolean;
  113763. /**
  113764. * @hidden
  113765. */
  113766. lodLevelInAlpha: boolean;
  113767. /**
  113768. * With prefiltered texture, defined the offset used during the prefiltering steps.
  113769. */
  113770. get lodGenerationOffset(): number;
  113771. set lodGenerationOffset(value: number);
  113772. /**
  113773. * With prefiltered texture, defined the scale used during the prefiltering steps.
  113774. */
  113775. get lodGenerationScale(): number;
  113776. set lodGenerationScale(value: number);
  113777. /**
  113778. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  113779. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  113780. * average roughness values.
  113781. */
  113782. get linearSpecularLOD(): boolean;
  113783. set linearSpecularLOD(value: boolean);
  113784. /**
  113785. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  113786. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  113787. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  113788. */
  113789. get irradianceTexture(): Nullable<BaseTexture>;
  113790. set irradianceTexture(value: Nullable<BaseTexture>);
  113791. /**
  113792. * Define if the texture is a render target.
  113793. */
  113794. isRenderTarget: boolean;
  113795. /**
  113796. * Define the unique id of the texture in the scene.
  113797. */
  113798. get uid(): string;
  113799. /** @hidden */
  113800. _prefiltered: boolean;
  113801. /**
  113802. * Return a string representation of the texture.
  113803. * @returns the texture as a string
  113804. */
  113805. toString(): string;
  113806. /**
  113807. * Get the class name of the texture.
  113808. * @returns "BaseTexture"
  113809. */
  113810. getClassName(): string;
  113811. /**
  113812. * Define the list of animation attached to the texture.
  113813. */
  113814. animations: Animation[];
  113815. /**
  113816. * An event triggered when the texture is disposed.
  113817. */
  113818. onDisposeObservable: Observable<BaseTexture>;
  113819. private _onDisposeObserver;
  113820. /**
  113821. * Callback triggered when the texture has been disposed.
  113822. * Kept for back compatibility, you can use the onDisposeObservable instead.
  113823. */
  113824. set onDispose(callback: () => void);
  113825. /**
  113826. * Define the current state of the loading sequence when in delayed load mode.
  113827. */
  113828. delayLoadState: number;
  113829. protected _scene: Nullable<Scene>;
  113830. protected _engine: Nullable<ThinEngine>;
  113831. /** @hidden */
  113832. _texture: Nullable<InternalTexture>;
  113833. private _uid;
  113834. /**
  113835. * Define if the texture is preventinga material to render or not.
  113836. * If not and the texture is not ready, the engine will use a default black texture instead.
  113837. */
  113838. get isBlocking(): boolean;
  113839. /**
  113840. * Instantiates a new BaseTexture.
  113841. * Base class of all the textures in babylon.
  113842. * It groups all the common properties the materials, post process, lights... might need
  113843. * in order to make a correct use of the texture.
  113844. * @param sceneOrEngine Define the scene or engine the texture blongs to
  113845. */
  113846. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  113847. /**
  113848. * Get the scene the texture belongs to.
  113849. * @returns the scene or null if undefined
  113850. */
  113851. getScene(): Nullable<Scene>;
  113852. /** @hidden */
  113853. protected _getEngine(): Nullable<ThinEngine>;
  113854. /**
  113855. * Get the texture transform matrix used to offset tile the texture for istance.
  113856. * @returns the transformation matrix
  113857. */
  113858. getTextureMatrix(): Matrix;
  113859. /**
  113860. * Get the texture reflection matrix used to rotate/transform the reflection.
  113861. * @returns the reflection matrix
  113862. */
  113863. getReflectionTextureMatrix(): Matrix;
  113864. /**
  113865. * Get the underlying lower level texture from Babylon.
  113866. * @returns the insternal texture
  113867. */
  113868. getInternalTexture(): Nullable<InternalTexture>;
  113869. /**
  113870. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  113871. * @returns true if ready or not blocking
  113872. */
  113873. isReadyOrNotBlocking(): boolean;
  113874. /**
  113875. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  113876. * @returns true if fully ready
  113877. */
  113878. isReady(): boolean;
  113879. private _cachedSize;
  113880. /**
  113881. * Get the size of the texture.
  113882. * @returns the texture size.
  113883. */
  113884. getSize(): ISize;
  113885. /**
  113886. * Get the base size of the texture.
  113887. * It can be different from the size if the texture has been resized for POT for instance
  113888. * @returns the base size
  113889. */
  113890. getBaseSize(): ISize;
  113891. /**
  113892. * Update the sampling mode of the texture.
  113893. * Default is Trilinear mode.
  113894. *
  113895. * | Value | Type | Description |
  113896. * | ----- | ------------------ | ----------- |
  113897. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  113898. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  113899. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  113900. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  113901. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  113902. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  113903. * | 7 | NEAREST_LINEAR | |
  113904. * | 8 | NEAREST_NEAREST | |
  113905. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  113906. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  113907. * | 11 | LINEAR_LINEAR | |
  113908. * | 12 | LINEAR_NEAREST | |
  113909. *
  113910. * > _mag_: magnification filter (close to the viewer)
  113911. * > _min_: minification filter (far from the viewer)
  113912. * > _mip_: filter used between mip map levels
  113913. *@param samplingMode Define the new sampling mode of the texture
  113914. */
  113915. updateSamplingMode(samplingMode: number): void;
  113916. /**
  113917. * Scales the texture if is `canRescale()`
  113918. * @param ratio the resize factor we want to use to rescale
  113919. */
  113920. scale(ratio: number): void;
  113921. /**
  113922. * Get if the texture can rescale.
  113923. */
  113924. get canRescale(): boolean;
  113925. /** @hidden */
  113926. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  113927. /** @hidden */
  113928. _rebuild(): void;
  113929. /**
  113930. * Triggers the load sequence in delayed load mode.
  113931. */
  113932. delayLoad(): void;
  113933. /**
  113934. * Clones the texture.
  113935. * @returns the cloned texture
  113936. */
  113937. clone(): Nullable<BaseTexture>;
  113938. /**
  113939. * Get the texture underlying type (INT, FLOAT...)
  113940. */
  113941. get textureType(): number;
  113942. /**
  113943. * Get the texture underlying format (RGB, RGBA...)
  113944. */
  113945. get textureFormat(): number;
  113946. /**
  113947. * Indicates that textures need to be re-calculated for all materials
  113948. */
  113949. protected _markAllSubMeshesAsTexturesDirty(): void;
  113950. /**
  113951. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  113952. * This will returns an RGBA array buffer containing either in values (0-255) or
  113953. * float values (0-1) depending of the underlying buffer type.
  113954. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  113955. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  113956. * @param buffer defines a user defined buffer to fill with data (can be null)
  113957. * @returns The Array buffer containing the pixels data.
  113958. */
  113959. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  113960. /**
  113961. * Release and destroy the underlying lower level texture aka internalTexture.
  113962. */
  113963. releaseInternalTexture(): void;
  113964. /** @hidden */
  113965. get _lodTextureHigh(): Nullable<BaseTexture>;
  113966. /** @hidden */
  113967. get _lodTextureMid(): Nullable<BaseTexture>;
  113968. /** @hidden */
  113969. get _lodTextureLow(): Nullable<BaseTexture>;
  113970. /**
  113971. * Dispose the texture and release its associated resources.
  113972. */
  113973. dispose(): void;
  113974. /**
  113975. * Serialize the texture into a JSON representation that can be parsed later on.
  113976. * @returns the JSON representation of the texture
  113977. */
  113978. serialize(): any;
  113979. /**
  113980. * Helper function to be called back once a list of texture contains only ready textures.
  113981. * @param textures Define the list of textures to wait for
  113982. * @param callback Define the callback triggered once the entire list will be ready
  113983. */
  113984. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  113985. private static _isScene;
  113986. }
  113987. }
  113988. declare module BABYLON {
  113989. /**
  113990. * Options to be used when creating an effect.
  113991. */
  113992. export interface IEffectCreationOptions {
  113993. /**
  113994. * Atrributes that will be used in the shader.
  113995. */
  113996. attributes: string[];
  113997. /**
  113998. * Uniform varible names that will be set in the shader.
  113999. */
  114000. uniformsNames: string[];
  114001. /**
  114002. * Uniform buffer variable names that will be set in the shader.
  114003. */
  114004. uniformBuffersNames: string[];
  114005. /**
  114006. * Sampler texture variable names that will be set in the shader.
  114007. */
  114008. samplers: string[];
  114009. /**
  114010. * Define statements that will be set in the shader.
  114011. */
  114012. defines: any;
  114013. /**
  114014. * Possible fallbacks for this effect to improve performance when needed.
  114015. */
  114016. fallbacks: Nullable<IEffectFallbacks>;
  114017. /**
  114018. * Callback that will be called when the shader is compiled.
  114019. */
  114020. onCompiled: Nullable<(effect: Effect) => void>;
  114021. /**
  114022. * Callback that will be called if an error occurs during shader compilation.
  114023. */
  114024. onError: Nullable<(effect: Effect, errors: string) => void>;
  114025. /**
  114026. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  114027. */
  114028. indexParameters?: any;
  114029. /**
  114030. * Max number of lights that can be used in the shader.
  114031. */
  114032. maxSimultaneousLights?: number;
  114033. /**
  114034. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  114035. */
  114036. transformFeedbackVaryings?: Nullable<string[]>;
  114037. /**
  114038. * 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
  114039. */
  114040. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  114041. /**
  114042. * Is this effect rendering to several color attachments ?
  114043. */
  114044. multiTarget?: boolean;
  114045. }
  114046. /**
  114047. * Effect containing vertex and fragment shader that can be executed on an object.
  114048. */
  114049. export class Effect implements IDisposable {
  114050. /**
  114051. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  114052. */
  114053. static ShadersRepository: string;
  114054. /**
  114055. * Enable logging of the shader code when a compilation error occurs
  114056. */
  114057. static LogShaderCodeOnCompilationError: boolean;
  114058. /**
  114059. * Name of the effect.
  114060. */
  114061. name: any;
  114062. /**
  114063. * String container all the define statements that should be set on the shader.
  114064. */
  114065. defines: string;
  114066. /**
  114067. * Callback that will be called when the shader is compiled.
  114068. */
  114069. onCompiled: Nullable<(effect: Effect) => void>;
  114070. /**
  114071. * Callback that will be called if an error occurs during shader compilation.
  114072. */
  114073. onError: Nullable<(effect: Effect, errors: string) => void>;
  114074. /**
  114075. * Callback that will be called when effect is bound.
  114076. */
  114077. onBind: Nullable<(effect: Effect) => void>;
  114078. /**
  114079. * Unique ID of the effect.
  114080. */
  114081. uniqueId: number;
  114082. /**
  114083. * Observable that will be called when the shader is compiled.
  114084. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  114085. */
  114086. onCompileObservable: Observable<Effect>;
  114087. /**
  114088. * Observable that will be called if an error occurs during shader compilation.
  114089. */
  114090. onErrorObservable: Observable<Effect>;
  114091. /** @hidden */
  114092. _onBindObservable: Nullable<Observable<Effect>>;
  114093. /**
  114094. * @hidden
  114095. * Specifies if the effect was previously ready
  114096. */
  114097. _wasPreviouslyReady: boolean;
  114098. /**
  114099. * Observable that will be called when effect is bound.
  114100. */
  114101. get onBindObservable(): Observable<Effect>;
  114102. /** @hidden */
  114103. _bonesComputationForcedToCPU: boolean;
  114104. /** @hidden */
  114105. _multiTarget: boolean;
  114106. private static _uniqueIdSeed;
  114107. private _engine;
  114108. private _uniformBuffersNames;
  114109. private _uniformBuffersNamesList;
  114110. private _uniformsNames;
  114111. private _samplerList;
  114112. private _samplers;
  114113. private _isReady;
  114114. private _compilationError;
  114115. private _allFallbacksProcessed;
  114116. private _attributesNames;
  114117. private _attributes;
  114118. private _attributeLocationByName;
  114119. private _uniforms;
  114120. /**
  114121. * Key for the effect.
  114122. * @hidden
  114123. */
  114124. _key: string;
  114125. private _indexParameters;
  114126. private _fallbacks;
  114127. private _vertexSourceCode;
  114128. private _fragmentSourceCode;
  114129. private _vertexSourceCodeOverride;
  114130. private _fragmentSourceCodeOverride;
  114131. private _transformFeedbackVaryings;
  114132. /**
  114133. * Compiled shader to webGL program.
  114134. * @hidden
  114135. */
  114136. _pipelineContext: Nullable<IPipelineContext>;
  114137. private _valueCache;
  114138. private static _baseCache;
  114139. /**
  114140. * Instantiates an effect.
  114141. * An effect can be used to create/manage/execute vertex and fragment shaders.
  114142. * @param baseName Name of the effect.
  114143. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  114144. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  114145. * @param samplers List of sampler variables that will be passed to the shader.
  114146. * @param engine Engine to be used to render the effect
  114147. * @param defines Define statements to be added to the shader.
  114148. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  114149. * @param onCompiled Callback that will be called when the shader is compiled.
  114150. * @param onError Callback that will be called if an error occurs during shader compilation.
  114151. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  114152. */
  114153. 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);
  114154. private _useFinalCode;
  114155. /**
  114156. * Unique key for this effect
  114157. */
  114158. get key(): string;
  114159. /**
  114160. * If the effect has been compiled and prepared.
  114161. * @returns if the effect is compiled and prepared.
  114162. */
  114163. isReady(): boolean;
  114164. private _isReadyInternal;
  114165. /**
  114166. * The engine the effect was initialized with.
  114167. * @returns the engine.
  114168. */
  114169. getEngine(): Engine;
  114170. /**
  114171. * The pipeline context for this effect
  114172. * @returns the associated pipeline context
  114173. */
  114174. getPipelineContext(): Nullable<IPipelineContext>;
  114175. /**
  114176. * The set of names of attribute variables for the shader.
  114177. * @returns An array of attribute names.
  114178. */
  114179. getAttributesNames(): string[];
  114180. /**
  114181. * Returns the attribute at the given index.
  114182. * @param index The index of the attribute.
  114183. * @returns The location of the attribute.
  114184. */
  114185. getAttributeLocation(index: number): number;
  114186. /**
  114187. * Returns the attribute based on the name of the variable.
  114188. * @param name of the attribute to look up.
  114189. * @returns the attribute location.
  114190. */
  114191. getAttributeLocationByName(name: string): number;
  114192. /**
  114193. * The number of attributes.
  114194. * @returns the numnber of attributes.
  114195. */
  114196. getAttributesCount(): number;
  114197. /**
  114198. * Gets the index of a uniform variable.
  114199. * @param uniformName of the uniform to look up.
  114200. * @returns the index.
  114201. */
  114202. getUniformIndex(uniformName: string): number;
  114203. /**
  114204. * Returns the attribute based on the name of the variable.
  114205. * @param uniformName of the uniform to look up.
  114206. * @returns the location of the uniform.
  114207. */
  114208. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  114209. /**
  114210. * Returns an array of sampler variable names
  114211. * @returns The array of sampler variable names.
  114212. */
  114213. getSamplers(): string[];
  114214. /**
  114215. * Returns an array of uniform variable names
  114216. * @returns The array of uniform variable names.
  114217. */
  114218. getUniformNames(): string[];
  114219. /**
  114220. * Returns an array of uniform buffer variable names
  114221. * @returns The array of uniform buffer variable names.
  114222. */
  114223. getUniformBuffersNames(): string[];
  114224. /**
  114225. * Returns the index parameters used to create the effect
  114226. * @returns The index parameters object
  114227. */
  114228. getIndexParameters(): any;
  114229. /**
  114230. * The error from the last compilation.
  114231. * @returns the error string.
  114232. */
  114233. getCompilationError(): string;
  114234. /**
  114235. * Gets a boolean indicating that all fallbacks were used during compilation
  114236. * @returns true if all fallbacks were used
  114237. */
  114238. allFallbacksProcessed(): boolean;
  114239. /**
  114240. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  114241. * @param func The callback to be used.
  114242. */
  114243. executeWhenCompiled(func: (effect: Effect) => void): void;
  114244. private _checkIsReady;
  114245. private _loadShader;
  114246. /**
  114247. * Gets the vertex shader source code of this effect
  114248. */
  114249. get vertexSourceCode(): string;
  114250. /**
  114251. * Gets the fragment shader source code of this effect
  114252. */
  114253. get fragmentSourceCode(): string;
  114254. /**
  114255. * Recompiles the webGL program
  114256. * @param vertexSourceCode The source code for the vertex shader.
  114257. * @param fragmentSourceCode The source code for the fragment shader.
  114258. * @param onCompiled Callback called when completed.
  114259. * @param onError Callback called on error.
  114260. * @hidden
  114261. */
  114262. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  114263. /**
  114264. * Prepares the effect
  114265. * @hidden
  114266. */
  114267. _prepareEffect(): void;
  114268. private _getShaderCodeAndErrorLine;
  114269. private _processCompilationErrors;
  114270. /**
  114271. * Checks if the effect is supported. (Must be called after compilation)
  114272. */
  114273. get isSupported(): boolean;
  114274. /**
  114275. * Binds a texture to the engine to be used as output of the shader.
  114276. * @param channel Name of the output variable.
  114277. * @param texture Texture to bind.
  114278. * @hidden
  114279. */
  114280. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  114281. /**
  114282. * Sets a texture on the engine to be used in the shader.
  114283. * @param channel Name of the sampler variable.
  114284. * @param texture Texture to set.
  114285. */
  114286. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  114287. /**
  114288. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  114289. * @param channel Name of the sampler variable.
  114290. * @param texture Texture to set.
  114291. */
  114292. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  114293. /**
  114294. * Sets an array of textures on the engine to be used in the shader.
  114295. * @param channel Name of the variable.
  114296. * @param textures Textures to set.
  114297. */
  114298. setTextureArray(channel: string, textures: BaseTexture[]): void;
  114299. /**
  114300. * 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)
  114301. * @param channel Name of the sampler variable.
  114302. * @param postProcess Post process to get the input texture from.
  114303. */
  114304. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  114305. /**
  114306. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  114307. * 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)
  114308. * @param channel Name of the sampler variable.
  114309. * @param postProcess Post process to get the output texture from.
  114310. */
  114311. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  114312. /** @hidden */
  114313. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  114314. /** @hidden */
  114315. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  114316. /** @hidden */
  114317. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  114318. /** @hidden */
  114319. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  114320. /**
  114321. * Binds a buffer to a uniform.
  114322. * @param buffer Buffer to bind.
  114323. * @param name Name of the uniform variable to bind to.
  114324. */
  114325. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  114326. /**
  114327. * Binds block to a uniform.
  114328. * @param blockName Name of the block to bind.
  114329. * @param index Index to bind.
  114330. */
  114331. bindUniformBlock(blockName: string, index: number): void;
  114332. /**
  114333. * Sets an interger value on a uniform variable.
  114334. * @param uniformName Name of the variable.
  114335. * @param value Value to be set.
  114336. * @returns this effect.
  114337. */
  114338. setInt(uniformName: string, value: number): Effect;
  114339. /**
  114340. * Sets an int array on a uniform variable.
  114341. * @param uniformName Name of the variable.
  114342. * @param array array to be set.
  114343. * @returns this effect.
  114344. */
  114345. setIntArray(uniformName: string, array: Int32Array): Effect;
  114346. /**
  114347. * 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)
  114348. * @param uniformName Name of the variable.
  114349. * @param array array to be set.
  114350. * @returns this effect.
  114351. */
  114352. setIntArray2(uniformName: string, array: Int32Array): Effect;
  114353. /**
  114354. * 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)
  114355. * @param uniformName Name of the variable.
  114356. * @param array array to be set.
  114357. * @returns this effect.
  114358. */
  114359. setIntArray3(uniformName: string, array: Int32Array): Effect;
  114360. /**
  114361. * 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)
  114362. * @param uniformName Name of the variable.
  114363. * @param array array to be set.
  114364. * @returns this effect.
  114365. */
  114366. setIntArray4(uniformName: string, array: Int32Array): Effect;
  114367. /**
  114368. * Sets an float array on a uniform variable.
  114369. * @param uniformName Name of the variable.
  114370. * @param array array to be set.
  114371. * @returns this effect.
  114372. */
  114373. setFloatArray(uniformName: string, array: Float32Array): Effect;
  114374. /**
  114375. * 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)
  114376. * @param uniformName Name of the variable.
  114377. * @param array array to be set.
  114378. * @returns this effect.
  114379. */
  114380. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  114381. /**
  114382. * 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)
  114383. * @param uniformName Name of the variable.
  114384. * @param array array to be set.
  114385. * @returns this effect.
  114386. */
  114387. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  114388. /**
  114389. * 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)
  114390. * @param uniformName Name of the variable.
  114391. * @param array array to be set.
  114392. * @returns this effect.
  114393. */
  114394. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  114395. /**
  114396. * Sets an array on a uniform variable.
  114397. * @param uniformName Name of the variable.
  114398. * @param array array to be set.
  114399. * @returns this effect.
  114400. */
  114401. setArray(uniformName: string, array: number[]): Effect;
  114402. /**
  114403. * 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)
  114404. * @param uniformName Name of the variable.
  114405. * @param array array to be set.
  114406. * @returns this effect.
  114407. */
  114408. setArray2(uniformName: string, array: number[]): Effect;
  114409. /**
  114410. * 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)
  114411. * @param uniformName Name of the variable.
  114412. * @param array array to be set.
  114413. * @returns this effect.
  114414. */
  114415. setArray3(uniformName: string, array: number[]): Effect;
  114416. /**
  114417. * 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)
  114418. * @param uniformName Name of the variable.
  114419. * @param array array to be set.
  114420. * @returns this effect.
  114421. */
  114422. setArray4(uniformName: string, array: number[]): Effect;
  114423. /**
  114424. * Sets matrices on a uniform variable.
  114425. * @param uniformName Name of the variable.
  114426. * @param matrices matrices to be set.
  114427. * @returns this effect.
  114428. */
  114429. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  114430. /**
  114431. * Sets matrix on a uniform variable.
  114432. * @param uniformName Name of the variable.
  114433. * @param matrix matrix to be set.
  114434. * @returns this effect.
  114435. */
  114436. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  114437. /**
  114438. * 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)
  114439. * @param uniformName Name of the variable.
  114440. * @param matrix matrix to be set.
  114441. * @returns this effect.
  114442. */
  114443. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  114444. /**
  114445. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  114446. * @param uniformName Name of the variable.
  114447. * @param matrix matrix to be set.
  114448. * @returns this effect.
  114449. */
  114450. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  114451. /**
  114452. * Sets a float on a uniform variable.
  114453. * @param uniformName Name of the variable.
  114454. * @param value value to be set.
  114455. * @returns this effect.
  114456. */
  114457. setFloat(uniformName: string, value: number): Effect;
  114458. /**
  114459. * Sets a boolean on a uniform variable.
  114460. * @param uniformName Name of the variable.
  114461. * @param bool value to be set.
  114462. * @returns this effect.
  114463. */
  114464. setBool(uniformName: string, bool: boolean): Effect;
  114465. /**
  114466. * Sets a Vector2 on a uniform variable.
  114467. * @param uniformName Name of the variable.
  114468. * @param vector2 vector2 to be set.
  114469. * @returns this effect.
  114470. */
  114471. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  114472. /**
  114473. * Sets a float2 on a uniform variable.
  114474. * @param uniformName Name of the variable.
  114475. * @param x First float in float2.
  114476. * @param y Second float in float2.
  114477. * @returns this effect.
  114478. */
  114479. setFloat2(uniformName: string, x: number, y: number): Effect;
  114480. /**
  114481. * Sets a Vector3 on a uniform variable.
  114482. * @param uniformName Name of the variable.
  114483. * @param vector3 Value to be set.
  114484. * @returns this effect.
  114485. */
  114486. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  114487. /**
  114488. * Sets a float3 on a uniform variable.
  114489. * @param uniformName Name of the variable.
  114490. * @param x First float in float3.
  114491. * @param y Second float in float3.
  114492. * @param z Third float in float3.
  114493. * @returns this effect.
  114494. */
  114495. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  114496. /**
  114497. * Sets a Vector4 on a uniform variable.
  114498. * @param uniformName Name of the variable.
  114499. * @param vector4 Value to be set.
  114500. * @returns this effect.
  114501. */
  114502. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  114503. /**
  114504. * Sets a float4 on a uniform variable.
  114505. * @param uniformName Name of the variable.
  114506. * @param x First float in float4.
  114507. * @param y Second float in float4.
  114508. * @param z Third float in float4.
  114509. * @param w Fourth float in float4.
  114510. * @returns this effect.
  114511. */
  114512. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  114513. /**
  114514. * Sets a Color3 on a uniform variable.
  114515. * @param uniformName Name of the variable.
  114516. * @param color3 Value to be set.
  114517. * @returns this effect.
  114518. */
  114519. setColor3(uniformName: string, color3: IColor3Like): Effect;
  114520. /**
  114521. * Sets a Color4 on a uniform variable.
  114522. * @param uniformName Name of the variable.
  114523. * @param color3 Value to be set.
  114524. * @param alpha Alpha value to be set.
  114525. * @returns this effect.
  114526. */
  114527. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  114528. /**
  114529. * Sets a Color4 on a uniform variable
  114530. * @param uniformName defines the name of the variable
  114531. * @param color4 defines the value to be set
  114532. * @returns this effect.
  114533. */
  114534. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  114535. /** Release all associated resources */
  114536. dispose(): void;
  114537. /**
  114538. * This function will add a new shader to the shader store
  114539. * @param name the name of the shader
  114540. * @param pixelShader optional pixel shader content
  114541. * @param vertexShader optional vertex shader content
  114542. */
  114543. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  114544. /**
  114545. * Store of each shader (The can be looked up using effect.key)
  114546. */
  114547. static ShadersStore: {
  114548. [key: string]: string;
  114549. };
  114550. /**
  114551. * Store of each included file for a shader (The can be looked up using effect.key)
  114552. */
  114553. static IncludesShadersStore: {
  114554. [key: string]: string;
  114555. };
  114556. /**
  114557. * Resets the cache of effects.
  114558. */
  114559. static ResetCache(): void;
  114560. }
  114561. }
  114562. declare module BABYLON {
  114563. /**
  114564. * Interface used to describe the capabilities of the engine relatively to the current browser
  114565. */
  114566. export interface EngineCapabilities {
  114567. /** Maximum textures units per fragment shader */
  114568. maxTexturesImageUnits: number;
  114569. /** Maximum texture units per vertex shader */
  114570. maxVertexTextureImageUnits: number;
  114571. /** Maximum textures units in the entire pipeline */
  114572. maxCombinedTexturesImageUnits: number;
  114573. /** Maximum texture size */
  114574. maxTextureSize: number;
  114575. /** Maximum texture samples */
  114576. maxSamples?: number;
  114577. /** Maximum cube texture size */
  114578. maxCubemapTextureSize: number;
  114579. /** Maximum render texture size */
  114580. maxRenderTextureSize: number;
  114581. /** Maximum number of vertex attributes */
  114582. maxVertexAttribs: number;
  114583. /** Maximum number of varyings */
  114584. maxVaryingVectors: number;
  114585. /** Maximum number of uniforms per vertex shader */
  114586. maxVertexUniformVectors: number;
  114587. /** Maximum number of uniforms per fragment shader */
  114588. maxFragmentUniformVectors: number;
  114589. /** Defines if standard derivates (dx/dy) are supported */
  114590. standardDerivatives: boolean;
  114591. /** Defines if s3tc texture compression is supported */
  114592. s3tc?: WEBGL_compressed_texture_s3tc;
  114593. /** Defines if pvrtc texture compression is supported */
  114594. pvrtc: any;
  114595. /** Defines if etc1 texture compression is supported */
  114596. etc1: any;
  114597. /** Defines if etc2 texture compression is supported */
  114598. etc2: any;
  114599. /** Defines if astc texture compression is supported */
  114600. astc: any;
  114601. /** Defines if bptc texture compression is supported */
  114602. bptc: any;
  114603. /** Defines if float textures are supported */
  114604. textureFloat: boolean;
  114605. /** Defines if vertex array objects are supported */
  114606. vertexArrayObject: boolean;
  114607. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  114608. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  114609. /** Gets the maximum level of anisotropy supported */
  114610. maxAnisotropy: number;
  114611. /** Defines if instancing is supported */
  114612. instancedArrays: boolean;
  114613. /** Defines if 32 bits indices are supported */
  114614. uintIndices: boolean;
  114615. /** Defines if high precision shaders are supported */
  114616. highPrecisionShaderSupported: boolean;
  114617. /** Defines if depth reading in the fragment shader is supported */
  114618. fragmentDepthSupported: boolean;
  114619. /** Defines if float texture linear filtering is supported*/
  114620. textureFloatLinearFiltering: boolean;
  114621. /** Defines if rendering to float textures is supported */
  114622. textureFloatRender: boolean;
  114623. /** Defines if half float textures are supported*/
  114624. textureHalfFloat: boolean;
  114625. /** Defines if half float texture linear filtering is supported*/
  114626. textureHalfFloatLinearFiltering: boolean;
  114627. /** Defines if rendering to half float textures is supported */
  114628. textureHalfFloatRender: boolean;
  114629. /** Defines if textureLOD shader command is supported */
  114630. textureLOD: boolean;
  114631. /** Defines if draw buffers extension is supported */
  114632. drawBuffersExtension: boolean;
  114633. /** Defines if depth textures are supported */
  114634. depthTextureExtension: boolean;
  114635. /** Defines if float color buffer are supported */
  114636. colorBufferFloat: boolean;
  114637. /** Gets disjoint timer query extension (null if not supported) */
  114638. timerQuery?: EXT_disjoint_timer_query;
  114639. /** Defines if timestamp can be used with timer query */
  114640. canUseTimestampForTimerQuery: boolean;
  114641. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  114642. multiview?: any;
  114643. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  114644. oculusMultiview?: any;
  114645. /** Function used to let the system compiles shaders in background */
  114646. parallelShaderCompile?: {
  114647. COMPLETION_STATUS_KHR: number;
  114648. };
  114649. /** Max number of texture samples for MSAA */
  114650. maxMSAASamples: number;
  114651. /** Defines if the blend min max extension is supported */
  114652. blendMinMax: boolean;
  114653. }
  114654. }
  114655. declare module BABYLON {
  114656. /**
  114657. * @hidden
  114658. **/
  114659. export class DepthCullingState {
  114660. private _isDepthTestDirty;
  114661. private _isDepthMaskDirty;
  114662. private _isDepthFuncDirty;
  114663. private _isCullFaceDirty;
  114664. private _isCullDirty;
  114665. private _isZOffsetDirty;
  114666. private _isFrontFaceDirty;
  114667. private _depthTest;
  114668. private _depthMask;
  114669. private _depthFunc;
  114670. private _cull;
  114671. private _cullFace;
  114672. private _zOffset;
  114673. private _frontFace;
  114674. /**
  114675. * Initializes the state.
  114676. */
  114677. constructor();
  114678. get isDirty(): boolean;
  114679. get zOffset(): number;
  114680. set zOffset(value: number);
  114681. get cullFace(): Nullable<number>;
  114682. set cullFace(value: Nullable<number>);
  114683. get cull(): Nullable<boolean>;
  114684. set cull(value: Nullable<boolean>);
  114685. get depthFunc(): Nullable<number>;
  114686. set depthFunc(value: Nullable<number>);
  114687. get depthMask(): boolean;
  114688. set depthMask(value: boolean);
  114689. get depthTest(): boolean;
  114690. set depthTest(value: boolean);
  114691. get frontFace(): Nullable<number>;
  114692. set frontFace(value: Nullable<number>);
  114693. reset(): void;
  114694. apply(gl: WebGLRenderingContext): void;
  114695. }
  114696. }
  114697. declare module BABYLON {
  114698. /**
  114699. * @hidden
  114700. **/
  114701. export class StencilState {
  114702. /** 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 */
  114703. static readonly ALWAYS: number;
  114704. /** Passed to stencilOperation to specify that stencil value must be kept */
  114705. static readonly KEEP: number;
  114706. /** Passed to stencilOperation to specify that stencil value must be replaced */
  114707. static readonly REPLACE: number;
  114708. private _isStencilTestDirty;
  114709. private _isStencilMaskDirty;
  114710. private _isStencilFuncDirty;
  114711. private _isStencilOpDirty;
  114712. private _stencilTest;
  114713. private _stencilMask;
  114714. private _stencilFunc;
  114715. private _stencilFuncRef;
  114716. private _stencilFuncMask;
  114717. private _stencilOpStencilFail;
  114718. private _stencilOpDepthFail;
  114719. private _stencilOpStencilDepthPass;
  114720. get isDirty(): boolean;
  114721. get stencilFunc(): number;
  114722. set stencilFunc(value: number);
  114723. get stencilFuncRef(): number;
  114724. set stencilFuncRef(value: number);
  114725. get stencilFuncMask(): number;
  114726. set stencilFuncMask(value: number);
  114727. get stencilOpStencilFail(): number;
  114728. set stencilOpStencilFail(value: number);
  114729. get stencilOpDepthFail(): number;
  114730. set stencilOpDepthFail(value: number);
  114731. get stencilOpStencilDepthPass(): number;
  114732. set stencilOpStencilDepthPass(value: number);
  114733. get stencilMask(): number;
  114734. set stencilMask(value: number);
  114735. get stencilTest(): boolean;
  114736. set stencilTest(value: boolean);
  114737. constructor();
  114738. reset(): void;
  114739. apply(gl: WebGLRenderingContext): void;
  114740. }
  114741. }
  114742. declare module BABYLON {
  114743. /**
  114744. * @hidden
  114745. **/
  114746. export class AlphaState {
  114747. private _isAlphaBlendDirty;
  114748. private _isBlendFunctionParametersDirty;
  114749. private _isBlendEquationParametersDirty;
  114750. private _isBlendConstantsDirty;
  114751. private _alphaBlend;
  114752. private _blendFunctionParameters;
  114753. private _blendEquationParameters;
  114754. private _blendConstants;
  114755. /**
  114756. * Initializes the state.
  114757. */
  114758. constructor();
  114759. get isDirty(): boolean;
  114760. get alphaBlend(): boolean;
  114761. set alphaBlend(value: boolean);
  114762. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  114763. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  114764. setAlphaEquationParameters(rgb: number, alpha: number): void;
  114765. reset(): void;
  114766. apply(gl: WebGLRenderingContext): void;
  114767. }
  114768. }
  114769. declare module BABYLON {
  114770. /** @hidden */
  114771. export class WebGL2ShaderProcessor implements IShaderProcessor {
  114772. attributeProcessor(attribute: string): string;
  114773. varyingProcessor(varying: string, isFragment: boolean): string;
  114774. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  114775. }
  114776. }
  114777. declare module BABYLON {
  114778. /**
  114779. * Interface for attribute information associated with buffer instanciation
  114780. */
  114781. export interface InstancingAttributeInfo {
  114782. /**
  114783. * Name of the GLSL attribute
  114784. * if attribute index is not specified, this is used to retrieve the index from the effect
  114785. */
  114786. attributeName: string;
  114787. /**
  114788. * Index/offset of the attribute in the vertex shader
  114789. * if not specified, this will be computes from the name.
  114790. */
  114791. index?: number;
  114792. /**
  114793. * size of the attribute, 1, 2, 3 or 4
  114794. */
  114795. attributeSize: number;
  114796. /**
  114797. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  114798. */
  114799. offset: number;
  114800. /**
  114801. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  114802. * default to 1
  114803. */
  114804. divisor?: number;
  114805. /**
  114806. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  114807. * default is FLOAT
  114808. */
  114809. attributeType?: number;
  114810. /**
  114811. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  114812. */
  114813. normalized?: boolean;
  114814. }
  114815. }
  114816. declare module BABYLON {
  114817. interface ThinEngine {
  114818. /**
  114819. * Update a video texture
  114820. * @param texture defines the texture to update
  114821. * @param video defines the video element to use
  114822. * @param invertY defines if data must be stored with Y axis inverted
  114823. */
  114824. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  114825. }
  114826. }
  114827. declare module BABYLON {
  114828. interface ThinEngine {
  114829. /**
  114830. * Creates a dynamic texture
  114831. * @param width defines the width of the texture
  114832. * @param height defines the height of the texture
  114833. * @param generateMipMaps defines if the engine should generate the mip levels
  114834. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  114835. * @returns the dynamic texture inside an InternalTexture
  114836. */
  114837. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  114838. /**
  114839. * Update the content of a dynamic texture
  114840. * @param texture defines the texture to update
  114841. * @param canvas defines the canvas containing the source
  114842. * @param invertY defines if data must be stored with Y axis inverted
  114843. * @param premulAlpha defines if alpha is stored as premultiplied
  114844. * @param format defines the format of the data
  114845. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  114846. */
  114847. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  114848. }
  114849. }
  114850. declare module BABYLON {
  114851. /**
  114852. * Settings for finer control over video usage
  114853. */
  114854. export interface VideoTextureSettings {
  114855. /**
  114856. * Applies `autoplay` to video, if specified
  114857. */
  114858. autoPlay?: boolean;
  114859. /**
  114860. * Applies `loop` to video, if specified
  114861. */
  114862. loop?: boolean;
  114863. /**
  114864. * Automatically updates internal texture from video at every frame in the render loop
  114865. */
  114866. autoUpdateTexture: boolean;
  114867. /**
  114868. * Image src displayed during the video loading or until the user interacts with the video.
  114869. */
  114870. poster?: string;
  114871. }
  114872. /**
  114873. * If you want to display a video in your scene, this is the special texture for that.
  114874. * This special texture works similar to other textures, with the exception of a few parameters.
  114875. * @see https://doc.babylonjs.com/how_to/video_texture
  114876. */
  114877. export class VideoTexture extends Texture {
  114878. /**
  114879. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  114880. */
  114881. readonly autoUpdateTexture: boolean;
  114882. /**
  114883. * The video instance used by the texture internally
  114884. */
  114885. readonly video: HTMLVideoElement;
  114886. private _onUserActionRequestedObservable;
  114887. /**
  114888. * Event triggerd when a dom action is required by the user to play the video.
  114889. * This happens due to recent changes in browser policies preventing video to auto start.
  114890. */
  114891. get onUserActionRequestedObservable(): Observable<Texture>;
  114892. private _generateMipMaps;
  114893. private _stillImageCaptured;
  114894. private _displayingPosterTexture;
  114895. private _settings;
  114896. private _createInternalTextureOnEvent;
  114897. private _frameId;
  114898. private _currentSrc;
  114899. /**
  114900. * Creates a video texture.
  114901. * If you want to display a video in your scene, this is the special texture for that.
  114902. * This special texture works similar to other textures, with the exception of a few parameters.
  114903. * @see https://doc.babylonjs.com/how_to/video_texture
  114904. * @param name optional name, will detect from video source, if not defined
  114905. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  114906. * @param scene is obviously the current scene.
  114907. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  114908. * @param invertY is false by default but can be used to invert video on Y axis
  114909. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  114910. * @param settings allows finer control over video usage
  114911. */
  114912. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  114913. private _getName;
  114914. private _getVideo;
  114915. private _createInternalTexture;
  114916. private reset;
  114917. /**
  114918. * @hidden Internal method to initiate `update`.
  114919. */
  114920. _rebuild(): void;
  114921. /**
  114922. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  114923. */
  114924. update(): void;
  114925. /**
  114926. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  114927. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  114928. */
  114929. updateTexture(isVisible: boolean): void;
  114930. protected _updateInternalTexture: () => void;
  114931. /**
  114932. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  114933. * @param url New url.
  114934. */
  114935. updateURL(url: string): void;
  114936. /**
  114937. * Clones the texture.
  114938. * @returns the cloned texture
  114939. */
  114940. clone(): VideoTexture;
  114941. /**
  114942. * Dispose the texture and release its associated resources.
  114943. */
  114944. dispose(): void;
  114945. /**
  114946. * Creates a video texture straight from a stream.
  114947. * @param scene Define the scene the texture should be created in
  114948. * @param stream Define the stream the texture should be created from
  114949. * @returns The created video texture as a promise
  114950. */
  114951. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  114952. /**
  114953. * Creates a video texture straight from your WebCam video feed.
  114954. * @param scene Define the scene the texture should be created in
  114955. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  114956. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  114957. * @returns The created video texture as a promise
  114958. */
  114959. static CreateFromWebCamAsync(scene: Scene, constraints: {
  114960. minWidth: number;
  114961. maxWidth: number;
  114962. minHeight: number;
  114963. maxHeight: number;
  114964. deviceId: string;
  114965. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  114966. /**
  114967. * Creates a video texture straight from your WebCam video feed.
  114968. * @param scene Define the scene the texture should be created in
  114969. * @param onReady Define a callback to triggered once the texture will be ready
  114970. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  114971. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  114972. */
  114973. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  114974. minWidth: number;
  114975. maxWidth: number;
  114976. minHeight: number;
  114977. maxHeight: number;
  114978. deviceId: string;
  114979. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  114980. }
  114981. }
  114982. declare module BABYLON {
  114983. /**
  114984. * Defines the interface used by objects working like Scene
  114985. * @hidden
  114986. */
  114987. export interface ISceneLike {
  114988. _addPendingData(data: any): void;
  114989. _removePendingData(data: any): void;
  114990. offlineProvider: IOfflineProvider;
  114991. }
  114992. /**
  114993. * Information about the current host
  114994. */
  114995. export interface HostInformation {
  114996. /**
  114997. * Defines if the current host is a mobile
  114998. */
  114999. isMobile: boolean;
  115000. }
  115001. /** Interface defining initialization parameters for Engine class */
  115002. export interface EngineOptions extends WebGLContextAttributes {
  115003. /**
  115004. * Defines if the engine should no exceed a specified device ratio
  115005. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  115006. */
  115007. limitDeviceRatio?: number;
  115008. /**
  115009. * Defines if webvr should be enabled automatically
  115010. * @see https://doc.babylonjs.com/how_to/webvr_camera
  115011. */
  115012. autoEnableWebVR?: boolean;
  115013. /**
  115014. * Defines if webgl2 should be turned off even if supported
  115015. * @see https://doc.babylonjs.com/features/webgl2
  115016. */
  115017. disableWebGL2Support?: boolean;
  115018. /**
  115019. * Defines if webaudio should be initialized as well
  115020. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115021. */
  115022. audioEngine?: boolean;
  115023. /**
  115024. * Defines if animations should run using a deterministic lock step
  115025. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115026. */
  115027. deterministicLockstep?: boolean;
  115028. /** Defines the maximum steps to use with deterministic lock step mode */
  115029. lockstepMaxSteps?: number;
  115030. /** Defines the seconds between each deterministic lock step */
  115031. timeStep?: number;
  115032. /**
  115033. * Defines that engine should ignore context lost events
  115034. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  115035. */
  115036. doNotHandleContextLost?: boolean;
  115037. /**
  115038. * Defines that engine should ignore modifying touch action attribute and style
  115039. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  115040. */
  115041. doNotHandleTouchAction?: boolean;
  115042. /**
  115043. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  115044. */
  115045. useHighPrecisionFloats?: boolean;
  115046. /**
  115047. * Make the canvas XR Compatible for XR sessions
  115048. */
  115049. xrCompatible?: boolean;
  115050. /**
  115051. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  115052. */
  115053. useHighPrecisionMatrix?: boolean;
  115054. }
  115055. /**
  115056. * The base engine class (root of all engines)
  115057. */
  115058. export class ThinEngine {
  115059. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  115060. static ExceptionList: ({
  115061. key: string;
  115062. capture: string;
  115063. captureConstraint: number;
  115064. targets: string[];
  115065. } | {
  115066. key: string;
  115067. capture: null;
  115068. captureConstraint: null;
  115069. targets: string[];
  115070. })[];
  115071. /** @hidden */
  115072. static _TextureLoaders: IInternalTextureLoader[];
  115073. /**
  115074. * Returns the current npm package of the sdk
  115075. */
  115076. static get NpmPackage(): string;
  115077. /**
  115078. * Returns the current version of the framework
  115079. */
  115080. static get Version(): string;
  115081. /**
  115082. * Returns a string describing the current engine
  115083. */
  115084. get description(): string;
  115085. /**
  115086. * Gets or sets the epsilon value used by collision engine
  115087. */
  115088. static CollisionsEpsilon: number;
  115089. /**
  115090. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  115091. */
  115092. static get ShadersRepository(): string;
  115093. static set ShadersRepository(value: string);
  115094. /** @hidden */
  115095. _shaderProcessor: IShaderProcessor;
  115096. /**
  115097. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  115098. */
  115099. forcePOTTextures: boolean;
  115100. /**
  115101. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  115102. */
  115103. isFullscreen: boolean;
  115104. /**
  115105. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  115106. */
  115107. cullBackFaces: boolean;
  115108. /**
  115109. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  115110. */
  115111. renderEvenInBackground: boolean;
  115112. /**
  115113. * Gets or sets a boolean indicating that cache can be kept between frames
  115114. */
  115115. preventCacheWipeBetweenFrames: boolean;
  115116. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  115117. validateShaderPrograms: boolean;
  115118. /**
  115119. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  115120. * This can provide greater z depth for distant objects.
  115121. */
  115122. useReverseDepthBuffer: boolean;
  115123. /**
  115124. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  115125. */
  115126. disableUniformBuffers: boolean;
  115127. /** @hidden */
  115128. _uniformBuffers: UniformBuffer[];
  115129. /**
  115130. * Gets a boolean indicating that the engine supports uniform buffers
  115131. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  115132. */
  115133. get supportsUniformBuffers(): boolean;
  115134. /** @hidden */
  115135. _gl: WebGLRenderingContext;
  115136. /** @hidden */
  115137. _webGLVersion: number;
  115138. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  115139. protected _windowIsBackground: boolean;
  115140. protected _creationOptions: EngineOptions;
  115141. protected _highPrecisionShadersAllowed: boolean;
  115142. /** @hidden */
  115143. get _shouldUseHighPrecisionShader(): boolean;
  115144. /**
  115145. * Gets a boolean indicating that only power of 2 textures are supported
  115146. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  115147. */
  115148. get needPOTTextures(): boolean;
  115149. /** @hidden */
  115150. _badOS: boolean;
  115151. /** @hidden */
  115152. _badDesktopOS: boolean;
  115153. private _hardwareScalingLevel;
  115154. /** @hidden */
  115155. _caps: EngineCapabilities;
  115156. private _isStencilEnable;
  115157. private _glVersion;
  115158. private _glRenderer;
  115159. private _glVendor;
  115160. /** @hidden */
  115161. _videoTextureSupported: boolean;
  115162. protected _renderingQueueLaunched: boolean;
  115163. protected _activeRenderLoops: (() => void)[];
  115164. /**
  115165. * Observable signaled when a context lost event is raised
  115166. */
  115167. onContextLostObservable: Observable<ThinEngine>;
  115168. /**
  115169. * Observable signaled when a context restored event is raised
  115170. */
  115171. onContextRestoredObservable: Observable<ThinEngine>;
  115172. private _onContextLost;
  115173. private _onContextRestored;
  115174. protected _contextWasLost: boolean;
  115175. /** @hidden */
  115176. _doNotHandleContextLost: boolean;
  115177. /**
  115178. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  115179. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  115180. */
  115181. get doNotHandleContextLost(): boolean;
  115182. set doNotHandleContextLost(value: boolean);
  115183. /**
  115184. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  115185. */
  115186. disableVertexArrayObjects: boolean;
  115187. /** @hidden */
  115188. protected _colorWrite: boolean;
  115189. /** @hidden */
  115190. protected _colorWriteChanged: boolean;
  115191. /** @hidden */
  115192. protected _depthCullingState: DepthCullingState;
  115193. /** @hidden */
  115194. protected _stencilState: StencilState;
  115195. /** @hidden */
  115196. _alphaState: AlphaState;
  115197. /** @hidden */
  115198. _alphaMode: number;
  115199. /** @hidden */
  115200. _alphaEquation: number;
  115201. /** @hidden */
  115202. _internalTexturesCache: InternalTexture[];
  115203. /** @hidden */
  115204. protected _activeChannel: number;
  115205. private _currentTextureChannel;
  115206. /** @hidden */
  115207. protected _boundTexturesCache: {
  115208. [key: string]: Nullable<InternalTexture>;
  115209. };
  115210. /** @hidden */
  115211. protected _currentEffect: Nullable<Effect>;
  115212. /** @hidden */
  115213. protected _currentProgram: Nullable<WebGLProgram>;
  115214. private _compiledEffects;
  115215. private _vertexAttribArraysEnabled;
  115216. /** @hidden */
  115217. protected _cachedViewport: Nullable<IViewportLike>;
  115218. private _cachedVertexArrayObject;
  115219. /** @hidden */
  115220. protected _cachedVertexBuffers: any;
  115221. /** @hidden */
  115222. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  115223. /** @hidden */
  115224. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  115225. /** @hidden */
  115226. _currentRenderTarget: Nullable<InternalTexture>;
  115227. private _uintIndicesCurrentlySet;
  115228. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  115229. /** @hidden */
  115230. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  115231. /** @hidden */
  115232. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  115233. private _currentBufferPointers;
  115234. private _currentInstanceLocations;
  115235. private _currentInstanceBuffers;
  115236. private _textureUnits;
  115237. /** @hidden */
  115238. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  115239. /** @hidden */
  115240. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  115241. /** @hidden */
  115242. _boundRenderFunction: any;
  115243. private _vaoRecordInProgress;
  115244. private _mustWipeVertexAttributes;
  115245. private _emptyTexture;
  115246. private _emptyCubeTexture;
  115247. private _emptyTexture3D;
  115248. private _emptyTexture2DArray;
  115249. /** @hidden */
  115250. _frameHandler: number;
  115251. private _nextFreeTextureSlots;
  115252. private _maxSimultaneousTextures;
  115253. private _activeRequests;
  115254. /** @hidden */
  115255. _transformTextureUrl: Nullable<(url: string) => string>;
  115256. /**
  115257. * Gets information about the current host
  115258. */
  115259. hostInformation: HostInformation;
  115260. protected get _supportsHardwareTextureRescaling(): boolean;
  115261. private _framebufferDimensionsObject;
  115262. /**
  115263. * sets the object from which width and height will be taken from when getting render width and height
  115264. * Will fallback to the gl object
  115265. * @param dimensions the framebuffer width and height that will be used.
  115266. */
  115267. set framebufferDimensionsObject(dimensions: Nullable<{
  115268. framebufferWidth: number;
  115269. framebufferHeight: number;
  115270. }>);
  115271. /**
  115272. * Gets the current viewport
  115273. */
  115274. get currentViewport(): Nullable<IViewportLike>;
  115275. /**
  115276. * Gets the default empty texture
  115277. */
  115278. get emptyTexture(): InternalTexture;
  115279. /**
  115280. * Gets the default empty 3D texture
  115281. */
  115282. get emptyTexture3D(): InternalTexture;
  115283. /**
  115284. * Gets the default empty 2D array texture
  115285. */
  115286. get emptyTexture2DArray(): InternalTexture;
  115287. /**
  115288. * Gets the default empty cube texture
  115289. */
  115290. get emptyCubeTexture(): InternalTexture;
  115291. /**
  115292. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  115293. */
  115294. readonly premultipliedAlpha: boolean;
  115295. /**
  115296. * Observable event triggered before each texture is initialized
  115297. */
  115298. onBeforeTextureInitObservable: Observable<Texture>;
  115299. /**
  115300. * Creates a new engine
  115301. * @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
  115302. * @param antialias defines enable antialiasing (default: false)
  115303. * @param options defines further options to be sent to the getContext() function
  115304. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  115305. */
  115306. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  115307. private _rebuildInternalTextures;
  115308. private _rebuildEffects;
  115309. /**
  115310. * Gets a boolean indicating if all created effects are ready
  115311. * @returns true if all effects are ready
  115312. */
  115313. areAllEffectsReady(): boolean;
  115314. protected _rebuildBuffers(): void;
  115315. protected _initGLContext(): void;
  115316. /**
  115317. * Gets version of the current webGL context
  115318. */
  115319. get webGLVersion(): number;
  115320. /**
  115321. * Gets a string identifying the name of the class
  115322. * @returns "Engine" string
  115323. */
  115324. getClassName(): string;
  115325. /**
  115326. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  115327. */
  115328. get isStencilEnable(): boolean;
  115329. /** @hidden */
  115330. _prepareWorkingCanvas(): void;
  115331. /**
  115332. * Reset the texture cache to empty state
  115333. */
  115334. resetTextureCache(): void;
  115335. /**
  115336. * Gets an object containing information about the current webGL context
  115337. * @returns an object containing the vender, the renderer and the version of the current webGL context
  115338. */
  115339. getGlInfo(): {
  115340. vendor: string;
  115341. renderer: string;
  115342. version: string;
  115343. };
  115344. /**
  115345. * Defines the hardware scaling level.
  115346. * By default the hardware scaling level is computed from the window device ratio.
  115347. * 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.
  115348. * @param level defines the level to use
  115349. */
  115350. setHardwareScalingLevel(level: number): void;
  115351. /**
  115352. * Gets the current hardware scaling level.
  115353. * By default the hardware scaling level is computed from the window device ratio.
  115354. * 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.
  115355. * @returns a number indicating the current hardware scaling level
  115356. */
  115357. getHardwareScalingLevel(): number;
  115358. /**
  115359. * Gets the list of loaded textures
  115360. * @returns an array containing all loaded textures
  115361. */
  115362. getLoadedTexturesCache(): InternalTexture[];
  115363. /**
  115364. * Gets the object containing all engine capabilities
  115365. * @returns the EngineCapabilities object
  115366. */
  115367. getCaps(): EngineCapabilities;
  115368. /**
  115369. * stop executing a render loop function and remove it from the execution array
  115370. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  115371. */
  115372. stopRenderLoop(renderFunction?: () => void): void;
  115373. /** @hidden */
  115374. _renderLoop(): void;
  115375. /**
  115376. * Gets the HTML canvas attached with the current webGL context
  115377. * @returns a HTML canvas
  115378. */
  115379. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  115380. /**
  115381. * Gets host window
  115382. * @returns the host window object
  115383. */
  115384. getHostWindow(): Nullable<Window>;
  115385. /**
  115386. * Gets the current render width
  115387. * @param useScreen defines if screen size must be used (or the current render target if any)
  115388. * @returns a number defining the current render width
  115389. */
  115390. getRenderWidth(useScreen?: boolean): number;
  115391. /**
  115392. * Gets the current render height
  115393. * @param useScreen defines if screen size must be used (or the current render target if any)
  115394. * @returns a number defining the current render height
  115395. */
  115396. getRenderHeight(useScreen?: boolean): number;
  115397. /**
  115398. * Can be used to override the current requestAnimationFrame requester.
  115399. * @hidden
  115400. */
  115401. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  115402. /**
  115403. * Register and execute a render loop. The engine can have more than one render function
  115404. * @param renderFunction defines the function to continuously execute
  115405. */
  115406. runRenderLoop(renderFunction: () => void): void;
  115407. /**
  115408. * Clear the current render buffer or the current render target (if any is set up)
  115409. * @param color defines the color to use
  115410. * @param backBuffer defines if the back buffer must be cleared
  115411. * @param depth defines if the depth buffer must be cleared
  115412. * @param stencil defines if the stencil buffer must be cleared
  115413. */
  115414. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  115415. private _viewportCached;
  115416. /** @hidden */
  115417. _viewport(x: number, y: number, width: number, height: number): void;
  115418. /**
  115419. * Set the WebGL's viewport
  115420. * @param viewport defines the viewport element to be used
  115421. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  115422. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  115423. */
  115424. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  115425. /**
  115426. * Begin a new frame
  115427. */
  115428. beginFrame(): void;
  115429. /**
  115430. * Enf the current frame
  115431. */
  115432. endFrame(): void;
  115433. /**
  115434. * Resize the view according to the canvas' size
  115435. */
  115436. resize(): void;
  115437. /**
  115438. * Force a specific size of the canvas
  115439. * @param width defines the new canvas' width
  115440. * @param height defines the new canvas' height
  115441. * @returns true if the size was changed
  115442. */
  115443. setSize(width: number, height: number): boolean;
  115444. /**
  115445. * Binds the frame buffer to the specified texture.
  115446. * @param texture The texture to render to or null for the default canvas
  115447. * @param faceIndex The face of the texture to render to in case of cube texture
  115448. * @param requiredWidth The width of the target to render to
  115449. * @param requiredHeight The height of the target to render to
  115450. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  115451. * @param lodLevel defines the lod level to bind to the frame buffer
  115452. * @param layer defines the 2d array index to bind to frame buffer to
  115453. */
  115454. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  115455. /** @hidden */
  115456. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  115457. /**
  115458. * Unbind the current render target texture from the webGL context
  115459. * @param texture defines the render target texture to unbind
  115460. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  115461. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  115462. */
  115463. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  115464. /**
  115465. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  115466. */
  115467. flushFramebuffer(): void;
  115468. /**
  115469. * Unbind the current render target and bind the default framebuffer
  115470. */
  115471. restoreDefaultFramebuffer(): void;
  115472. /** @hidden */
  115473. protected _resetVertexBufferBinding(): void;
  115474. /**
  115475. * Creates a vertex buffer
  115476. * @param data the data for the vertex buffer
  115477. * @returns the new WebGL static buffer
  115478. */
  115479. createVertexBuffer(data: DataArray): DataBuffer;
  115480. private _createVertexBuffer;
  115481. /**
  115482. * Creates a dynamic vertex buffer
  115483. * @param data the data for the dynamic vertex buffer
  115484. * @returns the new WebGL dynamic buffer
  115485. */
  115486. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  115487. protected _resetIndexBufferBinding(): void;
  115488. /**
  115489. * Creates a new index buffer
  115490. * @param indices defines the content of the index buffer
  115491. * @param updatable defines if the index buffer must be updatable
  115492. * @returns a new webGL buffer
  115493. */
  115494. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  115495. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  115496. /**
  115497. * Bind a webGL buffer to the webGL context
  115498. * @param buffer defines the buffer to bind
  115499. */
  115500. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  115501. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  115502. private bindBuffer;
  115503. /**
  115504. * update the bound buffer with the given data
  115505. * @param data defines the data to update
  115506. */
  115507. updateArrayBuffer(data: Float32Array): void;
  115508. private _vertexAttribPointer;
  115509. /** @hidden */
  115510. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  115511. private _bindVertexBuffersAttributes;
  115512. /**
  115513. * Records a vertex array object
  115514. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  115515. * @param vertexBuffers defines the list of vertex buffers to store
  115516. * @param indexBuffer defines the index buffer to store
  115517. * @param effect defines the effect to store
  115518. * @returns the new vertex array object
  115519. */
  115520. recordVertexArrayObject(vertexBuffers: {
  115521. [key: string]: VertexBuffer;
  115522. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  115523. /**
  115524. * Bind a specific vertex array object
  115525. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  115526. * @param vertexArrayObject defines the vertex array object to bind
  115527. * @param indexBuffer defines the index buffer to bind
  115528. */
  115529. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  115530. /**
  115531. * Bind webGl buffers directly to the webGL context
  115532. * @param vertexBuffer defines the vertex buffer to bind
  115533. * @param indexBuffer defines the index buffer to bind
  115534. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  115535. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  115536. * @param effect defines the effect associated with the vertex buffer
  115537. */
  115538. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  115539. private _unbindVertexArrayObject;
  115540. /**
  115541. * Bind a list of vertex buffers to the webGL context
  115542. * @param vertexBuffers defines the list of vertex buffers to bind
  115543. * @param indexBuffer defines the index buffer to bind
  115544. * @param effect defines the effect associated with the vertex buffers
  115545. */
  115546. bindBuffers(vertexBuffers: {
  115547. [key: string]: Nullable<VertexBuffer>;
  115548. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  115549. /**
  115550. * Unbind all instance attributes
  115551. */
  115552. unbindInstanceAttributes(): void;
  115553. /**
  115554. * Release and free the memory of a vertex array object
  115555. * @param vao defines the vertex array object to delete
  115556. */
  115557. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  115558. /** @hidden */
  115559. _releaseBuffer(buffer: DataBuffer): boolean;
  115560. protected _deleteBuffer(buffer: DataBuffer): void;
  115561. /**
  115562. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  115563. * @param instancesBuffer defines the webGL buffer to update and bind
  115564. * @param data defines the data to store in the buffer
  115565. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  115566. */
  115567. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  115568. /**
  115569. * Bind the content of a webGL buffer used with instantiation
  115570. * @param instancesBuffer defines the webGL buffer to bind
  115571. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  115572. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  115573. */
  115574. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  115575. /**
  115576. * Disable the instance attribute corresponding to the name in parameter
  115577. * @param name defines the name of the attribute to disable
  115578. */
  115579. disableInstanceAttributeByName(name: string): void;
  115580. /**
  115581. * Disable the instance attribute corresponding to the location in parameter
  115582. * @param attributeLocation defines the attribute location of the attribute to disable
  115583. */
  115584. disableInstanceAttribute(attributeLocation: number): void;
  115585. /**
  115586. * Disable the attribute corresponding to the location in parameter
  115587. * @param attributeLocation defines the attribute location of the attribute to disable
  115588. */
  115589. disableAttributeByIndex(attributeLocation: number): void;
  115590. /**
  115591. * Send a draw order
  115592. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  115593. * @param indexStart defines the starting index
  115594. * @param indexCount defines the number of index to draw
  115595. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115596. */
  115597. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  115598. /**
  115599. * Draw a list of points
  115600. * @param verticesStart defines the index of first vertex to draw
  115601. * @param verticesCount defines the count of vertices to draw
  115602. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115603. */
  115604. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115605. /**
  115606. * Draw a list of unindexed primitives
  115607. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  115608. * @param verticesStart defines the index of first vertex to draw
  115609. * @param verticesCount defines the count of vertices to draw
  115610. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115611. */
  115612. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115613. /**
  115614. * Draw a list of indexed primitives
  115615. * @param fillMode defines the primitive to use
  115616. * @param indexStart defines the starting index
  115617. * @param indexCount defines the number of index to draw
  115618. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115619. */
  115620. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  115621. /**
  115622. * Draw a list of unindexed primitives
  115623. * @param fillMode defines the primitive to use
  115624. * @param verticesStart defines the index of first vertex to draw
  115625. * @param verticesCount defines the count of vertices to draw
  115626. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  115627. */
  115628. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  115629. private _drawMode;
  115630. /** @hidden */
  115631. protected _reportDrawCall(): void;
  115632. /** @hidden */
  115633. _releaseEffect(effect: Effect): void;
  115634. /** @hidden */
  115635. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  115636. /**
  115637. * Create a new effect (used to store vertex/fragment shaders)
  115638. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  115639. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  115640. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  115641. * @param samplers defines an array of string used to represent textures
  115642. * @param defines defines the string containing the defines to use to compile the shaders
  115643. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  115644. * @param onCompiled defines a function to call when the effect creation is successful
  115645. * @param onError defines a function to call when the effect creation has failed
  115646. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  115647. * @returns the new Effect
  115648. */
  115649. 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;
  115650. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  115651. private _compileShader;
  115652. private _compileRawShader;
  115653. /** @hidden */
  115654. _getShaderSource(shader: WebGLShader): Nullable<string>;
  115655. /**
  115656. * Directly creates a webGL program
  115657. * @param pipelineContext defines the pipeline context to attach to
  115658. * @param vertexCode defines the vertex shader code to use
  115659. * @param fragmentCode defines the fragment shader code to use
  115660. * @param context defines the webGL context to use (if not set, the current one will be used)
  115661. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  115662. * @returns the new webGL program
  115663. */
  115664. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115665. /**
  115666. * Creates a webGL program
  115667. * @param pipelineContext defines the pipeline context to attach to
  115668. * @param vertexCode defines the vertex shader code to use
  115669. * @param fragmentCode defines the fragment shader code to use
  115670. * @param defines defines the string containing the defines to use to compile the shaders
  115671. * @param context defines the webGL context to use (if not set, the current one will be used)
  115672. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  115673. * @returns the new webGL program
  115674. */
  115675. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115676. /**
  115677. * Creates a new pipeline context
  115678. * @returns the new pipeline
  115679. */
  115680. createPipelineContext(): IPipelineContext;
  115681. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115682. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  115683. /** @hidden */
  115684. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  115685. /** @hidden */
  115686. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  115687. /** @hidden */
  115688. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  115689. /**
  115690. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  115691. * @param pipelineContext defines the pipeline context to use
  115692. * @param uniformsNames defines the list of uniform names
  115693. * @returns an array of webGL uniform locations
  115694. */
  115695. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  115696. /**
  115697. * Gets the lsit of active attributes for a given webGL program
  115698. * @param pipelineContext defines the pipeline context to use
  115699. * @param attributesNames defines the list of attribute names to get
  115700. * @returns an array of indices indicating the offset of each attribute
  115701. */
  115702. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  115703. /**
  115704. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  115705. * @param effect defines the effect to activate
  115706. */
  115707. enableEffect(effect: Nullable<Effect>): void;
  115708. /**
  115709. * Set the value of an uniform to a number (int)
  115710. * @param uniform defines the webGL uniform location where to store the value
  115711. * @param value defines the int number to store
  115712. */
  115713. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  115714. /**
  115715. * Set the value of an uniform to an array of int32
  115716. * @param uniform defines the webGL uniform location where to store the value
  115717. * @param array defines the array of int32 to store
  115718. */
  115719. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115720. /**
  115721. * Set the value of an uniform to an array of int32 (stored as vec2)
  115722. * @param uniform defines the webGL uniform location where to store the value
  115723. * @param array defines the array of int32 to store
  115724. */
  115725. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115726. /**
  115727. * Set the value of an uniform to an array of int32 (stored as vec3)
  115728. * @param uniform defines the webGL uniform location where to store the value
  115729. * @param array defines the array of int32 to store
  115730. */
  115731. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115732. /**
  115733. * Set the value of an uniform to an array of int32 (stored as vec4)
  115734. * @param uniform defines the webGL uniform location where to store the value
  115735. * @param array defines the array of int32 to store
  115736. */
  115737. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  115738. /**
  115739. * Set the value of an uniform to an array of number
  115740. * @param uniform defines the webGL uniform location where to store the value
  115741. * @param array defines the array of number to store
  115742. */
  115743. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  115744. /**
  115745. * Set the value of an uniform to an array of number (stored as vec2)
  115746. * @param uniform defines the webGL uniform location where to store the value
  115747. * @param array defines the array of number to store
  115748. */
  115749. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  115750. /**
  115751. * Set the value of an uniform to an array of number (stored as vec3)
  115752. * @param uniform defines the webGL uniform location where to store the value
  115753. * @param array defines the array of number to store
  115754. */
  115755. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  115756. /**
  115757. * Set the value of an uniform to an array of number (stored as vec4)
  115758. * @param uniform defines the webGL uniform location where to store the value
  115759. * @param array defines the array of number to store
  115760. */
  115761. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  115762. /**
  115763. * Set the value of an uniform to an array of float32 (stored as matrices)
  115764. * @param uniform defines the webGL uniform location where to store the value
  115765. * @param matrices defines the array of float32 to store
  115766. */
  115767. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  115768. /**
  115769. * Set the value of an uniform to a matrix (3x3)
  115770. * @param uniform defines the webGL uniform location where to store the value
  115771. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  115772. */
  115773. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  115774. /**
  115775. * Set the value of an uniform to a matrix (2x2)
  115776. * @param uniform defines the webGL uniform location where to store the value
  115777. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  115778. */
  115779. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  115780. /**
  115781. * Set the value of an uniform to a number (float)
  115782. * @param uniform defines the webGL uniform location where to store the value
  115783. * @param value defines the float number to store
  115784. */
  115785. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  115786. /**
  115787. * Set the value of an uniform to a vec2
  115788. * @param uniform defines the webGL uniform location where to store the value
  115789. * @param x defines the 1st component of the value
  115790. * @param y defines the 2nd component of the value
  115791. */
  115792. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  115793. /**
  115794. * Set the value of an uniform to a vec3
  115795. * @param uniform defines the webGL uniform location where to store the value
  115796. * @param x defines the 1st component of the value
  115797. * @param y defines the 2nd component of the value
  115798. * @param z defines the 3rd component of the value
  115799. */
  115800. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  115801. /**
  115802. * Set the value of an uniform to a vec4
  115803. * @param uniform defines the webGL uniform location where to store the value
  115804. * @param x defines the 1st component of the value
  115805. * @param y defines the 2nd component of the value
  115806. * @param z defines the 3rd component of the value
  115807. * @param w defines the 4th component of the value
  115808. */
  115809. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  115810. /**
  115811. * Apply all cached states (depth, culling, stencil and alpha)
  115812. */
  115813. applyStates(): void;
  115814. /**
  115815. * Enable or disable color writing
  115816. * @param enable defines the state to set
  115817. */
  115818. setColorWrite(enable: boolean): void;
  115819. /**
  115820. * Gets a boolean indicating if color writing is enabled
  115821. * @returns the current color writing state
  115822. */
  115823. getColorWrite(): boolean;
  115824. /**
  115825. * Gets the depth culling state manager
  115826. */
  115827. get depthCullingState(): DepthCullingState;
  115828. /**
  115829. * Gets the alpha state manager
  115830. */
  115831. get alphaState(): AlphaState;
  115832. /**
  115833. * Gets the stencil state manager
  115834. */
  115835. get stencilState(): StencilState;
  115836. /**
  115837. * Clears the list of texture accessible through engine.
  115838. * This can help preventing texture load conflict due to name collision.
  115839. */
  115840. clearInternalTexturesCache(): void;
  115841. /**
  115842. * Force the entire cache to be cleared
  115843. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  115844. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  115845. */
  115846. wipeCaches(bruteForce?: boolean): void;
  115847. /** @hidden */
  115848. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  115849. min: number;
  115850. mag: number;
  115851. };
  115852. /** @hidden */
  115853. _createTexture(): WebGLTexture;
  115854. /**
  115855. * Usually called from Texture.ts.
  115856. * Passed information to create a WebGLTexture
  115857. * @param url defines a value which contains one of the following:
  115858. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  115859. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  115860. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  115861. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  115862. * @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)
  115863. * @param scene needed for loading to the correct scene
  115864. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  115865. * @param onLoad optional callback to be called upon successful completion
  115866. * @param onError optional callback to be called upon failure
  115867. * @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
  115868. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  115869. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  115870. * @param forcedExtension defines the extension to use to pick the right loader
  115871. * @param mimeType defines an optional mime type
  115872. * @returns a InternalTexture for assignment back into BABYLON.Texture
  115873. */
  115874. 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;
  115875. /**
  115876. * Loads an image as an HTMLImageElement.
  115877. * @param input url string, ArrayBuffer, or Blob to load
  115878. * @param onLoad callback called when the image successfully loads
  115879. * @param onError callback called when the image fails to load
  115880. * @param offlineProvider offline provider for caching
  115881. * @param mimeType optional mime type
  115882. * @returns the HTMLImageElement of the loaded image
  115883. * @hidden
  115884. */
  115885. 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>;
  115886. /**
  115887. * @hidden
  115888. */
  115889. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  115890. private _unpackFlipYCached;
  115891. /**
  115892. * In case you are sharing the context with other applications, it might
  115893. * be interested to not cache the unpack flip y state to ensure a consistent
  115894. * value would be set.
  115895. */
  115896. enableUnpackFlipYCached: boolean;
  115897. /** @hidden */
  115898. _unpackFlipY(value: boolean): void;
  115899. /** @hidden */
  115900. _getUnpackAlignement(): number;
  115901. private _getTextureTarget;
  115902. /**
  115903. * Update the sampling mode of a given texture
  115904. * @param samplingMode defines the required sampling mode
  115905. * @param texture defines the texture to update
  115906. * @param generateMipMaps defines whether to generate mipmaps for the texture
  115907. */
  115908. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  115909. /**
  115910. * Update the sampling mode of a given texture
  115911. * @param texture defines the texture to update
  115912. * @param wrapU defines the texture wrap mode of the u coordinates
  115913. * @param wrapV defines the texture wrap mode of the v coordinates
  115914. * @param wrapR defines the texture wrap mode of the r coordinates
  115915. */
  115916. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  115917. /** @hidden */
  115918. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  115919. width: number;
  115920. height: number;
  115921. layers?: number;
  115922. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  115923. /** @hidden */
  115924. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  115925. /** @hidden */
  115926. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  115927. /**
  115928. * Update a portion of an internal texture
  115929. * @param texture defines the texture to update
  115930. * @param imageData defines the data to store into the texture
  115931. * @param xOffset defines the x coordinates of the update rectangle
  115932. * @param yOffset defines the y coordinates of the update rectangle
  115933. * @param width defines the width of the update rectangle
  115934. * @param height defines the height of the update rectangle
  115935. * @param faceIndex defines the face index if texture is a cube (0 by default)
  115936. * @param lod defines the lod level to update (0 by default)
  115937. */
  115938. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  115939. /** @hidden */
  115940. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  115941. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  115942. private _prepareWebGLTexture;
  115943. /** @hidden */
  115944. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  115945. private _getDepthStencilBuffer;
  115946. /** @hidden */
  115947. _releaseFramebufferObjects(texture: InternalTexture): void;
  115948. /** @hidden */
  115949. _releaseTexture(texture: InternalTexture): void;
  115950. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  115951. protected _setProgram(program: WebGLProgram): void;
  115952. protected _boundUniforms: {
  115953. [key: number]: WebGLUniformLocation;
  115954. };
  115955. /**
  115956. * Binds an effect to the webGL context
  115957. * @param effect defines the effect to bind
  115958. */
  115959. bindSamplers(effect: Effect): void;
  115960. private _activateCurrentTexture;
  115961. /** @hidden */
  115962. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  115963. /** @hidden */
  115964. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  115965. /**
  115966. * Unbind all textures from the webGL context
  115967. */
  115968. unbindAllTextures(): void;
  115969. /**
  115970. * Sets a texture to the according uniform.
  115971. * @param channel The texture channel
  115972. * @param uniform The uniform to set
  115973. * @param texture The texture to apply
  115974. */
  115975. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  115976. private _bindSamplerUniformToChannel;
  115977. private _getTextureWrapMode;
  115978. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  115979. /**
  115980. * Sets an array of texture to the webGL context
  115981. * @param channel defines the channel where the texture array must be set
  115982. * @param uniform defines the associated uniform location
  115983. * @param textures defines the array of textures to bind
  115984. */
  115985. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  115986. /** @hidden */
  115987. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  115988. private _setTextureParameterFloat;
  115989. private _setTextureParameterInteger;
  115990. /**
  115991. * Unbind all vertex attributes from the webGL context
  115992. */
  115993. unbindAllAttributes(): void;
  115994. /**
  115995. * 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
  115996. */
  115997. releaseEffects(): void;
  115998. /**
  115999. * Dispose and release all associated resources
  116000. */
  116001. dispose(): void;
  116002. /**
  116003. * Attach a new callback raised when context lost event is fired
  116004. * @param callback defines the callback to call
  116005. */
  116006. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  116007. /**
  116008. * Attach a new callback raised when context restored event is fired
  116009. * @param callback defines the callback to call
  116010. */
  116011. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  116012. /**
  116013. * Get the current error code of the webGL context
  116014. * @returns the error code
  116015. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  116016. */
  116017. getError(): number;
  116018. private _canRenderToFloatFramebuffer;
  116019. private _canRenderToHalfFloatFramebuffer;
  116020. private _canRenderToFramebuffer;
  116021. /** @hidden */
  116022. _getWebGLTextureType(type: number): number;
  116023. /** @hidden */
  116024. _getInternalFormat(format: number): number;
  116025. /** @hidden */
  116026. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  116027. /** @hidden */
  116028. _getRGBAMultiSampleBufferFormat(type: number): number;
  116029. /** @hidden */
  116030. _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;
  116031. /**
  116032. * Loads a file from a url
  116033. * @param url url to load
  116034. * @param onSuccess callback called when the file successfully loads
  116035. * @param onProgress callback called while file is loading (if the server supports this mode)
  116036. * @param offlineProvider defines the offline provider for caching
  116037. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116038. * @param onError callback called when the file fails to load
  116039. * @returns a file request object
  116040. * @hidden
  116041. */
  116042. 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;
  116043. /**
  116044. * Reads pixels from the current frame buffer. Please note that this function can be slow
  116045. * @param x defines the x coordinate of the rectangle where pixels must be read
  116046. * @param y defines the y coordinate of the rectangle where pixels must be read
  116047. * @param width defines the width of the rectangle where pixels must be read
  116048. * @param height defines the height of the rectangle where pixels must be read
  116049. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  116050. * @returns a Uint8Array containing RGBA colors
  116051. */
  116052. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  116053. private static _isSupported;
  116054. /**
  116055. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  116056. * @returns true if the engine can be created
  116057. * @ignorenaming
  116058. */
  116059. static isSupported(): boolean;
  116060. /**
  116061. * Find the next highest power of two.
  116062. * @param x Number to start search from.
  116063. * @return Next highest power of two.
  116064. */
  116065. static CeilingPOT(x: number): number;
  116066. /**
  116067. * Find the next lowest power of two.
  116068. * @param x Number to start search from.
  116069. * @return Next lowest power of two.
  116070. */
  116071. static FloorPOT(x: number): number;
  116072. /**
  116073. * Find the nearest power of two.
  116074. * @param x Number to start search from.
  116075. * @return Next nearest power of two.
  116076. */
  116077. static NearestPOT(x: number): number;
  116078. /**
  116079. * Get the closest exponent of two
  116080. * @param value defines the value to approximate
  116081. * @param max defines the maximum value to return
  116082. * @param mode defines how to define the closest value
  116083. * @returns closest exponent of two of the given value
  116084. */
  116085. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  116086. /**
  116087. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  116088. * @param func - the function to be called
  116089. * @param requester - the object that will request the next frame. Falls back to window.
  116090. * @returns frame number
  116091. */
  116092. static QueueNewFrame(func: () => void, requester?: any): number;
  116093. /**
  116094. * Gets host document
  116095. * @returns the host document object
  116096. */
  116097. getHostDocument(): Nullable<Document>;
  116098. }
  116099. }
  116100. declare module BABYLON {
  116101. /**
  116102. * Class representing spherical harmonics coefficients to the 3rd degree
  116103. */
  116104. export class SphericalHarmonics {
  116105. /**
  116106. * Defines whether or not the harmonics have been prescaled for rendering.
  116107. */
  116108. preScaled: boolean;
  116109. /**
  116110. * The l0,0 coefficients of the spherical harmonics
  116111. */
  116112. l00: Vector3;
  116113. /**
  116114. * The l1,-1 coefficients of the spherical harmonics
  116115. */
  116116. l1_1: Vector3;
  116117. /**
  116118. * The l1,0 coefficients of the spherical harmonics
  116119. */
  116120. l10: Vector3;
  116121. /**
  116122. * The l1,1 coefficients of the spherical harmonics
  116123. */
  116124. l11: Vector3;
  116125. /**
  116126. * The l2,-2 coefficients of the spherical harmonics
  116127. */
  116128. l2_2: Vector3;
  116129. /**
  116130. * The l2,-1 coefficients of the spherical harmonics
  116131. */
  116132. l2_1: Vector3;
  116133. /**
  116134. * The l2,0 coefficients of the spherical harmonics
  116135. */
  116136. l20: Vector3;
  116137. /**
  116138. * The l2,1 coefficients of the spherical harmonics
  116139. */
  116140. l21: Vector3;
  116141. /**
  116142. * The l2,2 coefficients of the spherical harmonics
  116143. */
  116144. l22: Vector3;
  116145. /**
  116146. * Adds a light to the spherical harmonics
  116147. * @param direction the direction of the light
  116148. * @param color the color of the light
  116149. * @param deltaSolidAngle the delta solid angle of the light
  116150. */
  116151. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  116152. /**
  116153. * Scales the spherical harmonics by the given amount
  116154. * @param scale the amount to scale
  116155. */
  116156. scaleInPlace(scale: number): void;
  116157. /**
  116158. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  116159. *
  116160. * ```
  116161. * E_lm = A_l * L_lm
  116162. * ```
  116163. *
  116164. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  116165. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  116166. * the scaling factors are given in equation 9.
  116167. */
  116168. convertIncidentRadianceToIrradiance(): void;
  116169. /**
  116170. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  116171. *
  116172. * ```
  116173. * L = (1/pi) * E * rho
  116174. * ```
  116175. *
  116176. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  116177. */
  116178. convertIrradianceToLambertianRadiance(): void;
  116179. /**
  116180. * Integrates the reconstruction coefficients directly in to the SH preventing further
  116181. * required operations at run time.
  116182. *
  116183. * This is simply done by scaling back the SH with Ylm constants parameter.
  116184. * The trigonometric part being applied by the shader at run time.
  116185. */
  116186. preScaleForRendering(): void;
  116187. /**
  116188. * Constructs a spherical harmonics from an array.
  116189. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  116190. * @returns the spherical harmonics
  116191. */
  116192. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  116193. /**
  116194. * Gets the spherical harmonics from polynomial
  116195. * @param polynomial the spherical polynomial
  116196. * @returns the spherical harmonics
  116197. */
  116198. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  116199. }
  116200. /**
  116201. * Class representing spherical polynomial coefficients to the 3rd degree
  116202. */
  116203. export class SphericalPolynomial {
  116204. private _harmonics;
  116205. /**
  116206. * The spherical harmonics used to create the polynomials.
  116207. */
  116208. get preScaledHarmonics(): SphericalHarmonics;
  116209. /**
  116210. * The x coefficients of the spherical polynomial
  116211. */
  116212. x: Vector3;
  116213. /**
  116214. * The y coefficients of the spherical polynomial
  116215. */
  116216. y: Vector3;
  116217. /**
  116218. * The z coefficients of the spherical polynomial
  116219. */
  116220. z: Vector3;
  116221. /**
  116222. * The xx coefficients of the spherical polynomial
  116223. */
  116224. xx: Vector3;
  116225. /**
  116226. * The yy coefficients of the spherical polynomial
  116227. */
  116228. yy: Vector3;
  116229. /**
  116230. * The zz coefficients of the spherical polynomial
  116231. */
  116232. zz: Vector3;
  116233. /**
  116234. * The xy coefficients of the spherical polynomial
  116235. */
  116236. xy: Vector3;
  116237. /**
  116238. * The yz coefficients of the spherical polynomial
  116239. */
  116240. yz: Vector3;
  116241. /**
  116242. * The zx coefficients of the spherical polynomial
  116243. */
  116244. zx: Vector3;
  116245. /**
  116246. * Adds an ambient color to the spherical polynomial
  116247. * @param color the color to add
  116248. */
  116249. addAmbient(color: Color3): void;
  116250. /**
  116251. * Scales the spherical polynomial by the given amount
  116252. * @param scale the amount to scale
  116253. */
  116254. scaleInPlace(scale: number): void;
  116255. /**
  116256. * Gets the spherical polynomial from harmonics
  116257. * @param harmonics the spherical harmonics
  116258. * @returns the spherical polynomial
  116259. */
  116260. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  116261. /**
  116262. * Constructs a spherical polynomial from an array.
  116263. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  116264. * @returns the spherical polynomial
  116265. */
  116266. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  116267. }
  116268. }
  116269. declare module BABYLON {
  116270. /**
  116271. * Defines the source of the internal texture
  116272. */
  116273. export enum InternalTextureSource {
  116274. /**
  116275. * The source of the texture data is unknown
  116276. */
  116277. Unknown = 0,
  116278. /**
  116279. * Texture data comes from an URL
  116280. */
  116281. Url = 1,
  116282. /**
  116283. * Texture data is only used for temporary storage
  116284. */
  116285. Temp = 2,
  116286. /**
  116287. * Texture data comes from raw data (ArrayBuffer)
  116288. */
  116289. Raw = 3,
  116290. /**
  116291. * Texture content is dynamic (video or dynamic texture)
  116292. */
  116293. Dynamic = 4,
  116294. /**
  116295. * Texture content is generated by rendering to it
  116296. */
  116297. RenderTarget = 5,
  116298. /**
  116299. * Texture content is part of a multi render target process
  116300. */
  116301. MultiRenderTarget = 6,
  116302. /**
  116303. * Texture data comes from a cube data file
  116304. */
  116305. Cube = 7,
  116306. /**
  116307. * Texture data comes from a raw cube data
  116308. */
  116309. CubeRaw = 8,
  116310. /**
  116311. * Texture data come from a prefiltered cube data file
  116312. */
  116313. CubePrefiltered = 9,
  116314. /**
  116315. * Texture content is raw 3D data
  116316. */
  116317. Raw3D = 10,
  116318. /**
  116319. * Texture content is raw 2D array data
  116320. */
  116321. Raw2DArray = 11,
  116322. /**
  116323. * Texture content is a depth texture
  116324. */
  116325. Depth = 12,
  116326. /**
  116327. * Texture data comes from a raw cube data encoded with RGBD
  116328. */
  116329. CubeRawRGBD = 13
  116330. }
  116331. /**
  116332. * Class used to store data associated with WebGL texture data for the engine
  116333. * This class should not be used directly
  116334. */
  116335. export class InternalTexture {
  116336. /** @hidden */
  116337. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  116338. /**
  116339. * Defines if the texture is ready
  116340. */
  116341. isReady: boolean;
  116342. /**
  116343. * Defines if the texture is a cube texture
  116344. */
  116345. isCube: boolean;
  116346. /**
  116347. * Defines if the texture contains 3D data
  116348. */
  116349. is3D: boolean;
  116350. /**
  116351. * Defines if the texture contains 2D array data
  116352. */
  116353. is2DArray: boolean;
  116354. /**
  116355. * Defines if the texture contains multiview data
  116356. */
  116357. isMultiview: boolean;
  116358. /**
  116359. * Gets the URL used to load this texture
  116360. */
  116361. url: string;
  116362. /**
  116363. * Gets the sampling mode of the texture
  116364. */
  116365. samplingMode: number;
  116366. /**
  116367. * Gets a boolean indicating if the texture needs mipmaps generation
  116368. */
  116369. generateMipMaps: boolean;
  116370. /**
  116371. * Gets the number of samples used by the texture (WebGL2+ only)
  116372. */
  116373. samples: number;
  116374. /**
  116375. * Gets the type of the texture (int, float...)
  116376. */
  116377. type: number;
  116378. /**
  116379. * Gets the format of the texture (RGB, RGBA...)
  116380. */
  116381. format: number;
  116382. /**
  116383. * Observable called when the texture is loaded
  116384. */
  116385. onLoadedObservable: Observable<InternalTexture>;
  116386. /**
  116387. * Gets the width of the texture
  116388. */
  116389. width: number;
  116390. /**
  116391. * Gets the height of the texture
  116392. */
  116393. height: number;
  116394. /**
  116395. * Gets the depth of the texture
  116396. */
  116397. depth: number;
  116398. /**
  116399. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  116400. */
  116401. baseWidth: number;
  116402. /**
  116403. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  116404. */
  116405. baseHeight: number;
  116406. /**
  116407. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  116408. */
  116409. baseDepth: number;
  116410. /**
  116411. * Gets a boolean indicating if the texture is inverted on Y axis
  116412. */
  116413. invertY: boolean;
  116414. /** @hidden */
  116415. _invertVScale: boolean;
  116416. /** @hidden */
  116417. _associatedChannel: number;
  116418. /** @hidden */
  116419. _source: InternalTextureSource;
  116420. /** @hidden */
  116421. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  116422. /** @hidden */
  116423. _bufferView: Nullable<ArrayBufferView>;
  116424. /** @hidden */
  116425. _bufferViewArray: Nullable<ArrayBufferView[]>;
  116426. /** @hidden */
  116427. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  116428. /** @hidden */
  116429. _size: number;
  116430. /** @hidden */
  116431. _extension: string;
  116432. /** @hidden */
  116433. _files: Nullable<string[]>;
  116434. /** @hidden */
  116435. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  116436. /** @hidden */
  116437. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  116438. /** @hidden */
  116439. _framebuffer: Nullable<WebGLFramebuffer>;
  116440. /** @hidden */
  116441. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  116442. /** @hidden */
  116443. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  116444. /** @hidden */
  116445. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  116446. /** @hidden */
  116447. _attachments: Nullable<number[]>;
  116448. /** @hidden */
  116449. _textureArray: Nullable<InternalTexture[]>;
  116450. /** @hidden */
  116451. _cachedCoordinatesMode: Nullable<number>;
  116452. /** @hidden */
  116453. _cachedWrapU: Nullable<number>;
  116454. /** @hidden */
  116455. _cachedWrapV: Nullable<number>;
  116456. /** @hidden */
  116457. _cachedWrapR: Nullable<number>;
  116458. /** @hidden */
  116459. _cachedAnisotropicFilteringLevel: Nullable<number>;
  116460. /** @hidden */
  116461. _isDisabled: boolean;
  116462. /** @hidden */
  116463. _compression: Nullable<string>;
  116464. /** @hidden */
  116465. _generateStencilBuffer: boolean;
  116466. /** @hidden */
  116467. _generateDepthBuffer: boolean;
  116468. /** @hidden */
  116469. _comparisonFunction: number;
  116470. /** @hidden */
  116471. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  116472. /** @hidden */
  116473. _lodGenerationScale: number;
  116474. /** @hidden */
  116475. _lodGenerationOffset: number;
  116476. /** @hidden */
  116477. _depthStencilTexture: Nullable<InternalTexture>;
  116478. /** @hidden */
  116479. _colorTextureArray: Nullable<WebGLTexture>;
  116480. /** @hidden */
  116481. _depthStencilTextureArray: Nullable<WebGLTexture>;
  116482. /** @hidden */
  116483. _lodTextureHigh: Nullable<BaseTexture>;
  116484. /** @hidden */
  116485. _lodTextureMid: Nullable<BaseTexture>;
  116486. /** @hidden */
  116487. _lodTextureLow: Nullable<BaseTexture>;
  116488. /** @hidden */
  116489. _isRGBD: boolean;
  116490. /** @hidden */
  116491. _linearSpecularLOD: boolean;
  116492. /** @hidden */
  116493. _irradianceTexture: Nullable<BaseTexture>;
  116494. /** @hidden */
  116495. _webGLTexture: Nullable<WebGLTexture>;
  116496. /** @hidden */
  116497. _references: number;
  116498. /** @hidden */
  116499. _gammaSpace: Nullable<boolean>;
  116500. private _engine;
  116501. /**
  116502. * Gets the Engine the texture belongs to.
  116503. * @returns The babylon engine
  116504. */
  116505. getEngine(): ThinEngine;
  116506. /**
  116507. * Gets the data source type of the texture
  116508. */
  116509. get source(): InternalTextureSource;
  116510. /**
  116511. * Creates a new InternalTexture
  116512. * @param engine defines the engine to use
  116513. * @param source defines the type of data that will be used
  116514. * @param delayAllocation if the texture allocation should be delayed (default: false)
  116515. */
  116516. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  116517. /**
  116518. * Increments the number of references (ie. the number of Texture that point to it)
  116519. */
  116520. incrementReferences(): void;
  116521. /**
  116522. * Change the size of the texture (not the size of the content)
  116523. * @param width defines the new width
  116524. * @param height defines the new height
  116525. * @param depth defines the new depth (1 by default)
  116526. */
  116527. updateSize(width: int, height: int, depth?: int): void;
  116528. /** @hidden */
  116529. _rebuild(): void;
  116530. /** @hidden */
  116531. _swapAndDie(target: InternalTexture): void;
  116532. /**
  116533. * Dispose the current allocated resources
  116534. */
  116535. dispose(): void;
  116536. }
  116537. }
  116538. declare module BABYLON {
  116539. /**
  116540. * Class used to work with sound analyzer using fast fourier transform (FFT)
  116541. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116542. */
  116543. export class Analyser {
  116544. /**
  116545. * Gets or sets the smoothing
  116546. * @ignorenaming
  116547. */
  116548. SMOOTHING: number;
  116549. /**
  116550. * Gets or sets the FFT table size
  116551. * @ignorenaming
  116552. */
  116553. FFT_SIZE: number;
  116554. /**
  116555. * Gets or sets the bar graph amplitude
  116556. * @ignorenaming
  116557. */
  116558. BARGRAPHAMPLITUDE: number;
  116559. /**
  116560. * Gets or sets the position of the debug canvas
  116561. * @ignorenaming
  116562. */
  116563. DEBUGCANVASPOS: {
  116564. x: number;
  116565. y: number;
  116566. };
  116567. /**
  116568. * Gets or sets the debug canvas size
  116569. * @ignorenaming
  116570. */
  116571. DEBUGCANVASSIZE: {
  116572. width: number;
  116573. height: number;
  116574. };
  116575. private _byteFreqs;
  116576. private _byteTime;
  116577. private _floatFreqs;
  116578. private _webAudioAnalyser;
  116579. private _debugCanvas;
  116580. private _debugCanvasContext;
  116581. private _scene;
  116582. private _registerFunc;
  116583. private _audioEngine;
  116584. /**
  116585. * Creates a new analyser
  116586. * @param scene defines hosting scene
  116587. */
  116588. constructor(scene: Scene);
  116589. /**
  116590. * Get the number of data values you will have to play with for the visualization
  116591. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  116592. * @returns a number
  116593. */
  116594. getFrequencyBinCount(): number;
  116595. /**
  116596. * Gets the current frequency data as a byte array
  116597. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  116598. * @returns a Uint8Array
  116599. */
  116600. getByteFrequencyData(): Uint8Array;
  116601. /**
  116602. * Gets the current waveform as a byte array
  116603. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  116604. * @returns a Uint8Array
  116605. */
  116606. getByteTimeDomainData(): Uint8Array;
  116607. /**
  116608. * Gets the current frequency data as a float array
  116609. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  116610. * @returns a Float32Array
  116611. */
  116612. getFloatFrequencyData(): Float32Array;
  116613. /**
  116614. * Renders the debug canvas
  116615. */
  116616. drawDebugCanvas(): void;
  116617. /**
  116618. * Stops rendering the debug canvas and removes it
  116619. */
  116620. stopDebugCanvas(): void;
  116621. /**
  116622. * Connects two audio nodes
  116623. * @param inputAudioNode defines first node to connect
  116624. * @param outputAudioNode defines second node to connect
  116625. */
  116626. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  116627. /**
  116628. * Releases all associated resources
  116629. */
  116630. dispose(): void;
  116631. }
  116632. }
  116633. declare module BABYLON {
  116634. /**
  116635. * This represents an audio engine and it is responsible
  116636. * to play, synchronize and analyse sounds throughout the application.
  116637. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116638. */
  116639. export interface IAudioEngine extends IDisposable {
  116640. /**
  116641. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  116642. */
  116643. readonly canUseWebAudio: boolean;
  116644. /**
  116645. * Gets the current AudioContext if available.
  116646. */
  116647. readonly audioContext: Nullable<AudioContext>;
  116648. /**
  116649. * The master gain node defines the global audio volume of your audio engine.
  116650. */
  116651. readonly masterGain: GainNode;
  116652. /**
  116653. * Gets whether or not mp3 are supported by your browser.
  116654. */
  116655. readonly isMP3supported: boolean;
  116656. /**
  116657. * Gets whether or not ogg are supported by your browser.
  116658. */
  116659. readonly isOGGsupported: boolean;
  116660. /**
  116661. * Defines if Babylon should emit a warning if WebAudio is not supported.
  116662. * @ignoreNaming
  116663. */
  116664. WarnedWebAudioUnsupported: boolean;
  116665. /**
  116666. * Defines if the audio engine relies on a custom unlocked button.
  116667. * In this case, the embedded button will not be displayed.
  116668. */
  116669. useCustomUnlockedButton: boolean;
  116670. /**
  116671. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  116672. */
  116673. readonly unlocked: boolean;
  116674. /**
  116675. * Event raised when audio has been unlocked on the browser.
  116676. */
  116677. onAudioUnlockedObservable: Observable<AudioEngine>;
  116678. /**
  116679. * Event raised when audio has been locked on the browser.
  116680. */
  116681. onAudioLockedObservable: Observable<AudioEngine>;
  116682. /**
  116683. * Flags the audio engine in Locked state.
  116684. * This happens due to new browser policies preventing audio to autoplay.
  116685. */
  116686. lock(): void;
  116687. /**
  116688. * Unlocks the audio engine once a user action has been done on the dom.
  116689. * This is helpful to resume play once browser policies have been satisfied.
  116690. */
  116691. unlock(): void;
  116692. /**
  116693. * Gets the global volume sets on the master gain.
  116694. * @returns the global volume if set or -1 otherwise
  116695. */
  116696. getGlobalVolume(): number;
  116697. /**
  116698. * Sets the global volume of your experience (sets on the master gain).
  116699. * @param newVolume Defines the new global volume of the application
  116700. */
  116701. setGlobalVolume(newVolume: number): void;
  116702. /**
  116703. * Connect the audio engine to an audio analyser allowing some amazing
  116704. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  116705. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  116706. * @param analyser The analyser to connect to the engine
  116707. */
  116708. connectToAnalyser(analyser: Analyser): void;
  116709. }
  116710. /**
  116711. * This represents the default audio engine used in babylon.
  116712. * It is responsible to play, synchronize and analyse sounds throughout the application.
  116713. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  116714. */
  116715. export class AudioEngine implements IAudioEngine {
  116716. private _audioContext;
  116717. private _audioContextInitialized;
  116718. private _muteButton;
  116719. private _hostElement;
  116720. /**
  116721. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  116722. */
  116723. canUseWebAudio: boolean;
  116724. /**
  116725. * The master gain node defines the global audio volume of your audio engine.
  116726. */
  116727. masterGain: GainNode;
  116728. /**
  116729. * Defines if Babylon should emit a warning if WebAudio is not supported.
  116730. * @ignoreNaming
  116731. */
  116732. WarnedWebAudioUnsupported: boolean;
  116733. /**
  116734. * Gets whether or not mp3 are supported by your browser.
  116735. */
  116736. isMP3supported: boolean;
  116737. /**
  116738. * Gets whether or not ogg are supported by your browser.
  116739. */
  116740. isOGGsupported: boolean;
  116741. /**
  116742. * Gets whether audio has been unlocked on the device.
  116743. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  116744. * a user interaction has happened.
  116745. */
  116746. unlocked: boolean;
  116747. /**
  116748. * Defines if the audio engine relies on a custom unlocked button.
  116749. * In this case, the embedded button will not be displayed.
  116750. */
  116751. useCustomUnlockedButton: boolean;
  116752. /**
  116753. * Event raised when audio has been unlocked on the browser.
  116754. */
  116755. onAudioUnlockedObservable: Observable<AudioEngine>;
  116756. /**
  116757. * Event raised when audio has been locked on the browser.
  116758. */
  116759. onAudioLockedObservable: Observable<AudioEngine>;
  116760. /**
  116761. * Gets the current AudioContext if available.
  116762. */
  116763. get audioContext(): Nullable<AudioContext>;
  116764. private _connectedAnalyser;
  116765. /**
  116766. * Instantiates a new audio engine.
  116767. *
  116768. * There should be only one per page as some browsers restrict the number
  116769. * of audio contexts you can create.
  116770. * @param hostElement defines the host element where to display the mute icon if necessary
  116771. */
  116772. constructor(hostElement?: Nullable<HTMLElement>);
  116773. /**
  116774. * Flags the audio engine in Locked state.
  116775. * This happens due to new browser policies preventing audio to autoplay.
  116776. */
  116777. lock(): void;
  116778. /**
  116779. * Unlocks the audio engine once a user action has been done on the dom.
  116780. * This is helpful to resume play once browser policies have been satisfied.
  116781. */
  116782. unlock(): void;
  116783. private _resumeAudioContext;
  116784. private _initializeAudioContext;
  116785. private _tryToRun;
  116786. private _triggerRunningState;
  116787. private _triggerSuspendedState;
  116788. private _displayMuteButton;
  116789. private _moveButtonToTopLeft;
  116790. private _onResize;
  116791. private _hideMuteButton;
  116792. /**
  116793. * Destroy and release the resources associated with the audio ccontext.
  116794. */
  116795. dispose(): void;
  116796. /**
  116797. * Gets the global volume sets on the master gain.
  116798. * @returns the global volume if set or -1 otherwise
  116799. */
  116800. getGlobalVolume(): number;
  116801. /**
  116802. * Sets the global volume of your experience (sets on the master gain).
  116803. * @param newVolume Defines the new global volume of the application
  116804. */
  116805. setGlobalVolume(newVolume: number): void;
  116806. /**
  116807. * Connect the audio engine to an audio analyser allowing some amazing
  116808. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  116809. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  116810. * @param analyser The analyser to connect to the engine
  116811. */
  116812. connectToAnalyser(analyser: Analyser): void;
  116813. }
  116814. }
  116815. declare module BABYLON {
  116816. /**
  116817. * Interface used to present a loading screen while loading a scene
  116818. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116819. */
  116820. export interface ILoadingScreen {
  116821. /**
  116822. * Function called to display the loading screen
  116823. */
  116824. displayLoadingUI: () => void;
  116825. /**
  116826. * Function called to hide the loading screen
  116827. */
  116828. hideLoadingUI: () => void;
  116829. /**
  116830. * Gets or sets the color to use for the background
  116831. */
  116832. loadingUIBackgroundColor: string;
  116833. /**
  116834. * Gets or sets the text to display while loading
  116835. */
  116836. loadingUIText: string;
  116837. }
  116838. /**
  116839. * Class used for the default loading screen
  116840. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  116841. */
  116842. export class DefaultLoadingScreen implements ILoadingScreen {
  116843. private _renderingCanvas;
  116844. private _loadingText;
  116845. private _loadingDivBackgroundColor;
  116846. private _loadingDiv;
  116847. private _loadingTextDiv;
  116848. /** Gets or sets the logo url to use for the default loading screen */
  116849. static DefaultLogoUrl: string;
  116850. /** Gets or sets the spinner url to use for the default loading screen */
  116851. static DefaultSpinnerUrl: string;
  116852. /**
  116853. * Creates a new default loading screen
  116854. * @param _renderingCanvas defines the canvas used to render the scene
  116855. * @param _loadingText defines the default text to display
  116856. * @param _loadingDivBackgroundColor defines the default background color
  116857. */
  116858. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  116859. /**
  116860. * Function called to display the loading screen
  116861. */
  116862. displayLoadingUI(): void;
  116863. /**
  116864. * Function called to hide the loading screen
  116865. */
  116866. hideLoadingUI(): void;
  116867. /**
  116868. * Gets or sets the text to display while loading
  116869. */
  116870. set loadingUIText(text: string);
  116871. get loadingUIText(): string;
  116872. /**
  116873. * Gets or sets the color to use for the background
  116874. */
  116875. get loadingUIBackgroundColor(): string;
  116876. set loadingUIBackgroundColor(color: string);
  116877. private _resizeLoadingUI;
  116878. }
  116879. }
  116880. declare module BABYLON {
  116881. /**
  116882. * Interface for any object that can request an animation frame
  116883. */
  116884. export interface ICustomAnimationFrameRequester {
  116885. /**
  116886. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  116887. */
  116888. renderFunction?: Function;
  116889. /**
  116890. * Called to request the next frame to render to
  116891. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  116892. */
  116893. requestAnimationFrame: Function;
  116894. /**
  116895. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  116896. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  116897. */
  116898. requestID?: number;
  116899. }
  116900. }
  116901. declare module BABYLON {
  116902. /**
  116903. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  116904. */
  116905. export class PerformanceMonitor {
  116906. private _enabled;
  116907. private _rollingFrameTime;
  116908. private _lastFrameTimeMs;
  116909. /**
  116910. * constructor
  116911. * @param frameSampleSize The number of samples required to saturate the sliding window
  116912. */
  116913. constructor(frameSampleSize?: number);
  116914. /**
  116915. * Samples current frame
  116916. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  116917. */
  116918. sampleFrame(timeMs?: number): void;
  116919. /**
  116920. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  116921. */
  116922. get averageFrameTime(): number;
  116923. /**
  116924. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  116925. */
  116926. get averageFrameTimeVariance(): number;
  116927. /**
  116928. * Returns the frame time of the most recent frame
  116929. */
  116930. get instantaneousFrameTime(): number;
  116931. /**
  116932. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  116933. */
  116934. get averageFPS(): number;
  116935. /**
  116936. * Returns the average framerate in frames per second using the most recent frame time
  116937. */
  116938. get instantaneousFPS(): number;
  116939. /**
  116940. * Returns true if enough samples have been taken to completely fill the sliding window
  116941. */
  116942. get isSaturated(): boolean;
  116943. /**
  116944. * Enables contributions to the sliding window sample set
  116945. */
  116946. enable(): void;
  116947. /**
  116948. * Disables contributions to the sliding window sample set
  116949. * Samples will not be interpolated over the disabled period
  116950. */
  116951. disable(): void;
  116952. /**
  116953. * Returns true if sampling is enabled
  116954. */
  116955. get isEnabled(): boolean;
  116956. /**
  116957. * Resets performance monitor
  116958. */
  116959. reset(): void;
  116960. }
  116961. /**
  116962. * RollingAverage
  116963. *
  116964. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  116965. */
  116966. export class RollingAverage {
  116967. /**
  116968. * Current average
  116969. */
  116970. average: number;
  116971. /**
  116972. * Current variance
  116973. */
  116974. variance: number;
  116975. protected _samples: Array<number>;
  116976. protected _sampleCount: number;
  116977. protected _pos: number;
  116978. protected _m2: number;
  116979. /**
  116980. * constructor
  116981. * @param length The number of samples required to saturate the sliding window
  116982. */
  116983. constructor(length: number);
  116984. /**
  116985. * Adds a sample to the sample set
  116986. * @param v The sample value
  116987. */
  116988. add(v: number): void;
  116989. /**
  116990. * Returns previously added values or null if outside of history or outside the sliding window domain
  116991. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  116992. * @return Value previously recorded with add() or null if outside of range
  116993. */
  116994. history(i: number): number;
  116995. /**
  116996. * Returns true if enough samples have been taken to completely fill the sliding window
  116997. * @return true if sample-set saturated
  116998. */
  116999. isSaturated(): boolean;
  117000. /**
  117001. * Resets the rolling average (equivalent to 0 samples taken so far)
  117002. */
  117003. reset(): void;
  117004. /**
  117005. * Wraps a value around the sample range boundaries
  117006. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  117007. * @return Wrapped position in sample range
  117008. */
  117009. protected _wrapPosition(i: number): number;
  117010. }
  117011. }
  117012. declare module BABYLON {
  117013. /**
  117014. * This class is used to track a performance counter which is number based.
  117015. * The user has access to many properties which give statistics of different nature.
  117016. *
  117017. * The implementer can track two kinds of Performance Counter: time and count.
  117018. * 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.
  117019. * 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.
  117020. */
  117021. export class PerfCounter {
  117022. /**
  117023. * Gets or sets a global boolean to turn on and off all the counters
  117024. */
  117025. static Enabled: boolean;
  117026. /**
  117027. * Returns the smallest value ever
  117028. */
  117029. get min(): number;
  117030. /**
  117031. * Returns the biggest value ever
  117032. */
  117033. get max(): number;
  117034. /**
  117035. * Returns the average value since the performance counter is running
  117036. */
  117037. get average(): number;
  117038. /**
  117039. * Returns the average value of the last second the counter was monitored
  117040. */
  117041. get lastSecAverage(): number;
  117042. /**
  117043. * Returns the current value
  117044. */
  117045. get current(): number;
  117046. /**
  117047. * Gets the accumulated total
  117048. */
  117049. get total(): number;
  117050. /**
  117051. * Gets the total value count
  117052. */
  117053. get count(): number;
  117054. /**
  117055. * Creates a new counter
  117056. */
  117057. constructor();
  117058. /**
  117059. * Call this method to start monitoring a new frame.
  117060. * 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.
  117061. */
  117062. fetchNewFrame(): void;
  117063. /**
  117064. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  117065. * @param newCount the count value to add to the monitored count
  117066. * @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.
  117067. */
  117068. addCount(newCount: number, fetchResult: boolean): void;
  117069. /**
  117070. * Start monitoring this performance counter
  117071. */
  117072. beginMonitoring(): void;
  117073. /**
  117074. * Compute the time lapsed since the previous beginMonitoring() call.
  117075. * @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
  117076. */
  117077. endMonitoring(newFrame?: boolean): void;
  117078. private _fetchResult;
  117079. private _startMonitoringTime;
  117080. private _min;
  117081. private _max;
  117082. private _average;
  117083. private _current;
  117084. private _totalValueCount;
  117085. private _totalAccumulated;
  117086. private _lastSecAverage;
  117087. private _lastSecAccumulated;
  117088. private _lastSecTime;
  117089. private _lastSecValueCount;
  117090. }
  117091. }
  117092. declare module BABYLON {
  117093. interface ThinEngine {
  117094. /** @hidden */
  117095. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  117096. }
  117097. }
  117098. declare module BABYLON {
  117099. /**
  117100. * Defines the interface used by display changed events
  117101. */
  117102. export interface IDisplayChangedEventArgs {
  117103. /** Gets the vrDisplay object (if any) */
  117104. vrDisplay: Nullable<any>;
  117105. /** Gets a boolean indicating if webVR is supported */
  117106. vrSupported: boolean;
  117107. }
  117108. /**
  117109. * Defines the interface used by objects containing a viewport (like a camera)
  117110. */
  117111. interface IViewportOwnerLike {
  117112. /**
  117113. * Gets or sets the viewport
  117114. */
  117115. viewport: IViewportLike;
  117116. }
  117117. /**
  117118. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  117119. */
  117120. export class Engine extends ThinEngine {
  117121. /** Defines that alpha blending is disabled */
  117122. static readonly ALPHA_DISABLE: number;
  117123. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  117124. static readonly ALPHA_ADD: number;
  117125. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  117126. static readonly ALPHA_COMBINE: number;
  117127. /** Defines that alpha blending to DEST - SRC * DEST */
  117128. static readonly ALPHA_SUBTRACT: number;
  117129. /** Defines that alpha blending to SRC * DEST */
  117130. static readonly ALPHA_MULTIPLY: number;
  117131. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  117132. static readonly ALPHA_MAXIMIZED: number;
  117133. /** Defines that alpha blending to SRC + DEST */
  117134. static readonly ALPHA_ONEONE: number;
  117135. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  117136. static readonly ALPHA_PREMULTIPLIED: number;
  117137. /**
  117138. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  117139. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  117140. */
  117141. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  117142. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  117143. static readonly ALPHA_INTERPOLATE: number;
  117144. /**
  117145. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  117146. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  117147. */
  117148. static readonly ALPHA_SCREENMODE: number;
  117149. /** Defines that the ressource is not delayed*/
  117150. static readonly DELAYLOADSTATE_NONE: number;
  117151. /** Defines that the ressource was successfully delay loaded */
  117152. static readonly DELAYLOADSTATE_LOADED: number;
  117153. /** Defines that the ressource is currently delay loading */
  117154. static readonly DELAYLOADSTATE_LOADING: number;
  117155. /** Defines that the ressource is delayed and has not started loading */
  117156. static readonly DELAYLOADSTATE_NOTLOADED: number;
  117157. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  117158. static readonly NEVER: number;
  117159. /** 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 */
  117160. static readonly ALWAYS: number;
  117161. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  117162. static readonly LESS: number;
  117163. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  117164. static readonly EQUAL: number;
  117165. /** 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 */
  117166. static readonly LEQUAL: number;
  117167. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  117168. static readonly GREATER: number;
  117169. /** 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 */
  117170. static readonly GEQUAL: number;
  117171. /** 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 */
  117172. static readonly NOTEQUAL: number;
  117173. /** Passed to stencilOperation to specify that stencil value must be kept */
  117174. static readonly KEEP: number;
  117175. /** Passed to stencilOperation to specify that stencil value must be replaced */
  117176. static readonly REPLACE: number;
  117177. /** Passed to stencilOperation to specify that stencil value must be incremented */
  117178. static readonly INCR: number;
  117179. /** Passed to stencilOperation to specify that stencil value must be decremented */
  117180. static readonly DECR: number;
  117181. /** Passed to stencilOperation to specify that stencil value must be inverted */
  117182. static readonly INVERT: number;
  117183. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  117184. static readonly INCR_WRAP: number;
  117185. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  117186. static readonly DECR_WRAP: number;
  117187. /** Texture is not repeating outside of 0..1 UVs */
  117188. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  117189. /** Texture is repeating outside of 0..1 UVs */
  117190. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  117191. /** Texture is repeating and mirrored */
  117192. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  117193. /** ALPHA */
  117194. static readonly TEXTUREFORMAT_ALPHA: number;
  117195. /** LUMINANCE */
  117196. static readonly TEXTUREFORMAT_LUMINANCE: number;
  117197. /** LUMINANCE_ALPHA */
  117198. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  117199. /** RGB */
  117200. static readonly TEXTUREFORMAT_RGB: number;
  117201. /** RGBA */
  117202. static readonly TEXTUREFORMAT_RGBA: number;
  117203. /** RED */
  117204. static readonly TEXTUREFORMAT_RED: number;
  117205. /** RED (2nd reference) */
  117206. static readonly TEXTUREFORMAT_R: number;
  117207. /** RG */
  117208. static readonly TEXTUREFORMAT_RG: number;
  117209. /** RED_INTEGER */
  117210. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  117211. /** RED_INTEGER (2nd reference) */
  117212. static readonly TEXTUREFORMAT_R_INTEGER: number;
  117213. /** RG_INTEGER */
  117214. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  117215. /** RGB_INTEGER */
  117216. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  117217. /** RGBA_INTEGER */
  117218. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  117219. /** UNSIGNED_BYTE */
  117220. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  117221. /** UNSIGNED_BYTE (2nd reference) */
  117222. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  117223. /** FLOAT */
  117224. static readonly TEXTURETYPE_FLOAT: number;
  117225. /** HALF_FLOAT */
  117226. static readonly TEXTURETYPE_HALF_FLOAT: number;
  117227. /** BYTE */
  117228. static readonly TEXTURETYPE_BYTE: number;
  117229. /** SHORT */
  117230. static readonly TEXTURETYPE_SHORT: number;
  117231. /** UNSIGNED_SHORT */
  117232. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  117233. /** INT */
  117234. static readonly TEXTURETYPE_INT: number;
  117235. /** UNSIGNED_INT */
  117236. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  117237. /** UNSIGNED_SHORT_4_4_4_4 */
  117238. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  117239. /** UNSIGNED_SHORT_5_5_5_1 */
  117240. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  117241. /** UNSIGNED_SHORT_5_6_5 */
  117242. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  117243. /** UNSIGNED_INT_2_10_10_10_REV */
  117244. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  117245. /** UNSIGNED_INT_24_8 */
  117246. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  117247. /** UNSIGNED_INT_10F_11F_11F_REV */
  117248. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  117249. /** UNSIGNED_INT_5_9_9_9_REV */
  117250. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  117251. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  117252. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  117253. /** nearest is mag = nearest and min = nearest and mip = linear */
  117254. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  117255. /** Bilinear is mag = linear and min = linear and mip = nearest */
  117256. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  117257. /** Trilinear is mag = linear and min = linear and mip = linear */
  117258. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  117259. /** nearest is mag = nearest and min = nearest and mip = linear */
  117260. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  117261. /** Bilinear is mag = linear and min = linear and mip = nearest */
  117262. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  117263. /** Trilinear is mag = linear and min = linear and mip = linear */
  117264. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  117265. /** mag = nearest and min = nearest and mip = nearest */
  117266. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  117267. /** mag = nearest and min = linear and mip = nearest */
  117268. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  117269. /** mag = nearest and min = linear and mip = linear */
  117270. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  117271. /** mag = nearest and min = linear and mip = none */
  117272. static readonly TEXTURE_NEAREST_LINEAR: number;
  117273. /** mag = nearest and min = nearest and mip = none */
  117274. static readonly TEXTURE_NEAREST_NEAREST: number;
  117275. /** mag = linear and min = nearest and mip = nearest */
  117276. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  117277. /** mag = linear and min = nearest and mip = linear */
  117278. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  117279. /** mag = linear and min = linear and mip = none */
  117280. static readonly TEXTURE_LINEAR_LINEAR: number;
  117281. /** mag = linear and min = nearest and mip = none */
  117282. static readonly TEXTURE_LINEAR_NEAREST: number;
  117283. /** Explicit coordinates mode */
  117284. static readonly TEXTURE_EXPLICIT_MODE: number;
  117285. /** Spherical coordinates mode */
  117286. static readonly TEXTURE_SPHERICAL_MODE: number;
  117287. /** Planar coordinates mode */
  117288. static readonly TEXTURE_PLANAR_MODE: number;
  117289. /** Cubic coordinates mode */
  117290. static readonly TEXTURE_CUBIC_MODE: number;
  117291. /** Projection coordinates mode */
  117292. static readonly TEXTURE_PROJECTION_MODE: number;
  117293. /** Skybox coordinates mode */
  117294. static readonly TEXTURE_SKYBOX_MODE: number;
  117295. /** Inverse Cubic coordinates mode */
  117296. static readonly TEXTURE_INVCUBIC_MODE: number;
  117297. /** Equirectangular coordinates mode */
  117298. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  117299. /** Equirectangular Fixed coordinates mode */
  117300. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  117301. /** Equirectangular Fixed Mirrored coordinates mode */
  117302. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  117303. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  117304. static readonly SCALEMODE_FLOOR: number;
  117305. /** Defines that texture rescaling will look for the nearest power of 2 size */
  117306. static readonly SCALEMODE_NEAREST: number;
  117307. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  117308. static readonly SCALEMODE_CEILING: number;
  117309. /**
  117310. * Returns the current npm package of the sdk
  117311. */
  117312. static get NpmPackage(): string;
  117313. /**
  117314. * Returns the current version of the framework
  117315. */
  117316. static get Version(): string;
  117317. /** Gets the list of created engines */
  117318. static get Instances(): Engine[];
  117319. /**
  117320. * Gets the latest created engine
  117321. */
  117322. static get LastCreatedEngine(): Nullable<Engine>;
  117323. /**
  117324. * Gets the latest created scene
  117325. */
  117326. static get LastCreatedScene(): Nullable<Scene>;
  117327. /**
  117328. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  117329. * @param flag defines which part of the materials must be marked as dirty
  117330. * @param predicate defines a predicate used to filter which materials should be affected
  117331. */
  117332. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  117333. /**
  117334. * Method called to create the default loading screen.
  117335. * This can be overriden in your own app.
  117336. * @param canvas The rendering canvas element
  117337. * @returns The loading screen
  117338. */
  117339. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  117340. /**
  117341. * Method called to create the default rescale post process on each engine.
  117342. */
  117343. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  117344. /**
  117345. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  117346. **/
  117347. enableOfflineSupport: boolean;
  117348. /**
  117349. * 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)
  117350. **/
  117351. disableManifestCheck: boolean;
  117352. /**
  117353. * Gets the list of created scenes
  117354. */
  117355. scenes: Scene[];
  117356. /**
  117357. * Event raised when a new scene is created
  117358. */
  117359. onNewSceneAddedObservable: Observable<Scene>;
  117360. /**
  117361. * Gets the list of created postprocesses
  117362. */
  117363. postProcesses: PostProcess[];
  117364. /**
  117365. * Gets a boolean indicating if the pointer is currently locked
  117366. */
  117367. isPointerLock: boolean;
  117368. /**
  117369. * Observable event triggered each time the rendering canvas is resized
  117370. */
  117371. onResizeObservable: Observable<Engine>;
  117372. /**
  117373. * Observable event triggered each time the canvas loses focus
  117374. */
  117375. onCanvasBlurObservable: Observable<Engine>;
  117376. /**
  117377. * Observable event triggered each time the canvas gains focus
  117378. */
  117379. onCanvasFocusObservable: Observable<Engine>;
  117380. /**
  117381. * Observable event triggered each time the canvas receives pointerout event
  117382. */
  117383. onCanvasPointerOutObservable: Observable<PointerEvent>;
  117384. /**
  117385. * Observable raised when the engine begins a new frame
  117386. */
  117387. onBeginFrameObservable: Observable<Engine>;
  117388. /**
  117389. * If set, will be used to request the next animation frame for the render loop
  117390. */
  117391. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  117392. /**
  117393. * Observable raised when the engine ends the current frame
  117394. */
  117395. onEndFrameObservable: Observable<Engine>;
  117396. /**
  117397. * Observable raised when the engine is about to compile a shader
  117398. */
  117399. onBeforeShaderCompilationObservable: Observable<Engine>;
  117400. /**
  117401. * Observable raised when the engine has jsut compiled a shader
  117402. */
  117403. onAfterShaderCompilationObservable: Observable<Engine>;
  117404. /**
  117405. * Gets the audio engine
  117406. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117407. * @ignorenaming
  117408. */
  117409. static audioEngine: IAudioEngine;
  117410. /**
  117411. * Default AudioEngine factory responsible of creating the Audio Engine.
  117412. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  117413. */
  117414. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  117415. /**
  117416. * Default offline support factory responsible of creating a tool used to store data locally.
  117417. * By default, this will create a Database object if the workload has been embedded.
  117418. */
  117419. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  117420. private _loadingScreen;
  117421. private _pointerLockRequested;
  117422. private _rescalePostProcess;
  117423. private _deterministicLockstep;
  117424. private _lockstepMaxSteps;
  117425. private _timeStep;
  117426. protected get _supportsHardwareTextureRescaling(): boolean;
  117427. private _fps;
  117428. private _deltaTime;
  117429. /** @hidden */
  117430. _drawCalls: PerfCounter;
  117431. /** 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 */
  117432. canvasTabIndex: number;
  117433. /**
  117434. * Turn this value on if you want to pause FPS computation when in background
  117435. */
  117436. disablePerformanceMonitorInBackground: boolean;
  117437. private _performanceMonitor;
  117438. /**
  117439. * Gets the performance monitor attached to this engine
  117440. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  117441. */
  117442. get performanceMonitor(): PerformanceMonitor;
  117443. private _onFocus;
  117444. private _onBlur;
  117445. private _onCanvasPointerOut;
  117446. private _onCanvasBlur;
  117447. private _onCanvasFocus;
  117448. private _onFullscreenChange;
  117449. private _onPointerLockChange;
  117450. /**
  117451. * Gets the HTML element used to attach event listeners
  117452. * @returns a HTML element
  117453. */
  117454. getInputElement(): Nullable<HTMLElement>;
  117455. /**
  117456. * Creates a new engine
  117457. * @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
  117458. * @param antialias defines enable antialiasing (default: false)
  117459. * @param options defines further options to be sent to the getContext() function
  117460. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  117461. */
  117462. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  117463. /**
  117464. * Gets current aspect ratio
  117465. * @param viewportOwner defines the camera to use to get the aspect ratio
  117466. * @param useScreen defines if screen size must be used (or the current render target if any)
  117467. * @returns a number defining the aspect ratio
  117468. */
  117469. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  117470. /**
  117471. * Gets current screen aspect ratio
  117472. * @returns a number defining the aspect ratio
  117473. */
  117474. getScreenAspectRatio(): number;
  117475. /**
  117476. * Gets the client rect of the HTML canvas attached with the current webGL context
  117477. * @returns a client rectanglee
  117478. */
  117479. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  117480. /**
  117481. * Gets the client rect of the HTML element used for events
  117482. * @returns a client rectanglee
  117483. */
  117484. getInputElementClientRect(): Nullable<ClientRect>;
  117485. /**
  117486. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  117487. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117488. * @returns true if engine is in deterministic lock step mode
  117489. */
  117490. isDeterministicLockStep(): boolean;
  117491. /**
  117492. * Gets the max steps when engine is running in deterministic lock step
  117493. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117494. * @returns the max steps
  117495. */
  117496. getLockstepMaxSteps(): number;
  117497. /**
  117498. * Returns the time in ms between steps when using deterministic lock step.
  117499. * @returns time step in (ms)
  117500. */
  117501. getTimeStep(): number;
  117502. /**
  117503. * Force the mipmap generation for the given render target texture
  117504. * @param texture defines the render target texture to use
  117505. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  117506. */
  117507. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  117508. /** States */
  117509. /**
  117510. * Set various states to the webGL context
  117511. * @param culling defines backface culling state
  117512. * @param zOffset defines the value to apply to zOffset (0 by default)
  117513. * @param force defines if states must be applied even if cache is up to date
  117514. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  117515. */
  117516. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  117517. /**
  117518. * Set the z offset to apply to current rendering
  117519. * @param value defines the offset to apply
  117520. */
  117521. setZOffset(value: number): void;
  117522. /**
  117523. * Gets the current value of the zOffset
  117524. * @returns the current zOffset state
  117525. */
  117526. getZOffset(): number;
  117527. /**
  117528. * Enable or disable depth buffering
  117529. * @param enable defines the state to set
  117530. */
  117531. setDepthBuffer(enable: boolean): void;
  117532. /**
  117533. * Gets a boolean indicating if depth writing is enabled
  117534. * @returns the current depth writing state
  117535. */
  117536. getDepthWrite(): boolean;
  117537. /**
  117538. * Enable or disable depth writing
  117539. * @param enable defines the state to set
  117540. */
  117541. setDepthWrite(enable: boolean): void;
  117542. /**
  117543. * Gets a boolean indicating if stencil buffer is enabled
  117544. * @returns the current stencil buffer state
  117545. */
  117546. getStencilBuffer(): boolean;
  117547. /**
  117548. * Enable or disable the stencil buffer
  117549. * @param enable defines if the stencil buffer must be enabled or disabled
  117550. */
  117551. setStencilBuffer(enable: boolean): void;
  117552. /**
  117553. * Gets the current stencil mask
  117554. * @returns a number defining the new stencil mask to use
  117555. */
  117556. getStencilMask(): number;
  117557. /**
  117558. * Sets the current stencil mask
  117559. * @param mask defines the new stencil mask to use
  117560. */
  117561. setStencilMask(mask: number): void;
  117562. /**
  117563. * Gets the current stencil function
  117564. * @returns a number defining the stencil function to use
  117565. */
  117566. getStencilFunction(): number;
  117567. /**
  117568. * Gets the current stencil reference value
  117569. * @returns a number defining the stencil reference value to use
  117570. */
  117571. getStencilFunctionReference(): number;
  117572. /**
  117573. * Gets the current stencil mask
  117574. * @returns a number defining the stencil mask to use
  117575. */
  117576. getStencilFunctionMask(): number;
  117577. /**
  117578. * Sets the current stencil function
  117579. * @param stencilFunc defines the new stencil function to use
  117580. */
  117581. setStencilFunction(stencilFunc: number): void;
  117582. /**
  117583. * Sets the current stencil reference
  117584. * @param reference defines the new stencil reference to use
  117585. */
  117586. setStencilFunctionReference(reference: number): void;
  117587. /**
  117588. * Sets the current stencil mask
  117589. * @param mask defines the new stencil mask to use
  117590. */
  117591. setStencilFunctionMask(mask: number): void;
  117592. /**
  117593. * Gets the current stencil operation when stencil fails
  117594. * @returns a number defining stencil operation to use when stencil fails
  117595. */
  117596. getStencilOperationFail(): number;
  117597. /**
  117598. * Gets the current stencil operation when depth fails
  117599. * @returns a number defining stencil operation to use when depth fails
  117600. */
  117601. getStencilOperationDepthFail(): number;
  117602. /**
  117603. * Gets the current stencil operation when stencil passes
  117604. * @returns a number defining stencil operation to use when stencil passes
  117605. */
  117606. getStencilOperationPass(): number;
  117607. /**
  117608. * Sets the stencil operation to use when stencil fails
  117609. * @param operation defines the stencil operation to use when stencil fails
  117610. */
  117611. setStencilOperationFail(operation: number): void;
  117612. /**
  117613. * Sets the stencil operation to use when depth fails
  117614. * @param operation defines the stencil operation to use when depth fails
  117615. */
  117616. setStencilOperationDepthFail(operation: number): void;
  117617. /**
  117618. * Sets the stencil operation to use when stencil passes
  117619. * @param operation defines the stencil operation to use when stencil passes
  117620. */
  117621. setStencilOperationPass(operation: number): void;
  117622. /**
  117623. * Sets a boolean indicating if the dithering state is enabled or disabled
  117624. * @param value defines the dithering state
  117625. */
  117626. setDitheringState(value: boolean): void;
  117627. /**
  117628. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  117629. * @param value defines the rasterizer state
  117630. */
  117631. setRasterizerState(value: boolean): void;
  117632. /**
  117633. * Gets the current depth function
  117634. * @returns a number defining the depth function
  117635. */
  117636. getDepthFunction(): Nullable<number>;
  117637. /**
  117638. * Sets the current depth function
  117639. * @param depthFunc defines the function to use
  117640. */
  117641. setDepthFunction(depthFunc: number): void;
  117642. /**
  117643. * Sets the current depth function to GREATER
  117644. */
  117645. setDepthFunctionToGreater(): void;
  117646. /**
  117647. * Sets the current depth function to GEQUAL
  117648. */
  117649. setDepthFunctionToGreaterOrEqual(): void;
  117650. /**
  117651. * Sets the current depth function to LESS
  117652. */
  117653. setDepthFunctionToLess(): void;
  117654. /**
  117655. * Sets the current depth function to LEQUAL
  117656. */
  117657. setDepthFunctionToLessOrEqual(): void;
  117658. private _cachedStencilBuffer;
  117659. private _cachedStencilFunction;
  117660. private _cachedStencilMask;
  117661. private _cachedStencilOperationPass;
  117662. private _cachedStencilOperationFail;
  117663. private _cachedStencilOperationDepthFail;
  117664. private _cachedStencilReference;
  117665. /**
  117666. * Caches the the state of the stencil buffer
  117667. */
  117668. cacheStencilState(): void;
  117669. /**
  117670. * Restores the state of the stencil buffer
  117671. */
  117672. restoreStencilState(): void;
  117673. /**
  117674. * Directly set the WebGL Viewport
  117675. * @param x defines the x coordinate of the viewport (in screen space)
  117676. * @param y defines the y coordinate of the viewport (in screen space)
  117677. * @param width defines the width of the viewport (in screen space)
  117678. * @param height defines the height of the viewport (in screen space)
  117679. * @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
  117680. */
  117681. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  117682. /**
  117683. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  117684. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  117685. * @param y defines the y-coordinate of the corner of the clear rectangle
  117686. * @param width defines the width of the clear rectangle
  117687. * @param height defines the height of the clear rectangle
  117688. * @param clearColor defines the clear color
  117689. */
  117690. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  117691. /**
  117692. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  117693. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  117694. * @param y defines the y-coordinate of the corner of the clear rectangle
  117695. * @param width defines the width of the clear rectangle
  117696. * @param height defines the height of the clear rectangle
  117697. */
  117698. enableScissor(x: number, y: number, width: number, height: number): void;
  117699. /**
  117700. * Disable previously set scissor test rectangle
  117701. */
  117702. disableScissor(): void;
  117703. protected _reportDrawCall(): void;
  117704. /**
  117705. * Initializes a webVR display and starts listening to display change events
  117706. * The onVRDisplayChangedObservable will be notified upon these changes
  117707. * @returns The onVRDisplayChangedObservable
  117708. */
  117709. initWebVR(): Observable<IDisplayChangedEventArgs>;
  117710. /** @hidden */
  117711. _prepareVRComponent(): void;
  117712. /** @hidden */
  117713. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  117714. /** @hidden */
  117715. _submitVRFrame(): void;
  117716. /**
  117717. * Call this function to leave webVR mode
  117718. * Will do nothing if webVR is not supported or if there is no webVR device
  117719. * @see https://doc.babylonjs.com/how_to/webvr_camera
  117720. */
  117721. disableVR(): void;
  117722. /**
  117723. * Gets a boolean indicating that the system is in VR mode and is presenting
  117724. * @returns true if VR mode is engaged
  117725. */
  117726. isVRPresenting(): boolean;
  117727. /** @hidden */
  117728. _requestVRFrame(): void;
  117729. /** @hidden */
  117730. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  117731. /**
  117732. * Gets the source code of the vertex shader associated with a specific webGL program
  117733. * @param program defines the program to use
  117734. * @returns a string containing the source code of the vertex shader associated with the program
  117735. */
  117736. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  117737. /**
  117738. * Gets the source code of the fragment shader associated with a specific webGL program
  117739. * @param program defines the program to use
  117740. * @returns a string containing the source code of the fragment shader associated with the program
  117741. */
  117742. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  117743. /**
  117744. * Sets a depth stencil texture from a render target to the according uniform.
  117745. * @param channel The texture channel
  117746. * @param uniform The uniform to set
  117747. * @param texture The render target texture containing the depth stencil texture to apply
  117748. */
  117749. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  117750. /**
  117751. * Sets a texture to the webGL context from a postprocess
  117752. * @param channel defines the channel to use
  117753. * @param postProcess defines the source postprocess
  117754. */
  117755. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  117756. /**
  117757. * Binds the output of the passed in post process to the texture channel specified
  117758. * @param channel The channel the texture should be bound to
  117759. * @param postProcess The post process which's output should be bound
  117760. */
  117761. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  117762. protected _rebuildBuffers(): void;
  117763. /** @hidden */
  117764. _renderFrame(): void;
  117765. _renderLoop(): void;
  117766. /** @hidden */
  117767. _renderViews(): boolean;
  117768. /**
  117769. * Toggle full screen mode
  117770. * @param requestPointerLock defines if a pointer lock should be requested from the user
  117771. */
  117772. switchFullscreen(requestPointerLock: boolean): void;
  117773. /**
  117774. * Enters full screen mode
  117775. * @param requestPointerLock defines if a pointer lock should be requested from the user
  117776. */
  117777. enterFullscreen(requestPointerLock: boolean): void;
  117778. /**
  117779. * Exits full screen mode
  117780. */
  117781. exitFullscreen(): void;
  117782. /**
  117783. * Enters Pointerlock mode
  117784. */
  117785. enterPointerlock(): void;
  117786. /**
  117787. * Exits Pointerlock mode
  117788. */
  117789. exitPointerlock(): void;
  117790. /**
  117791. * Begin a new frame
  117792. */
  117793. beginFrame(): void;
  117794. /**
  117795. * Enf the current frame
  117796. */
  117797. endFrame(): void;
  117798. resize(): void;
  117799. /**
  117800. * Force a specific size of the canvas
  117801. * @param width defines the new canvas' width
  117802. * @param height defines the new canvas' height
  117803. * @returns true if the size was changed
  117804. */
  117805. setSize(width: number, height: number): boolean;
  117806. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  117807. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  117808. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  117809. _releaseTexture(texture: InternalTexture): void;
  117810. /**
  117811. * @hidden
  117812. * Rescales a texture
  117813. * @param source input texutre
  117814. * @param destination destination texture
  117815. * @param scene scene to use to render the resize
  117816. * @param internalFormat format to use when resizing
  117817. * @param onComplete callback to be called when resize has completed
  117818. */
  117819. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  117820. /**
  117821. * Gets the current framerate
  117822. * @returns a number representing the framerate
  117823. */
  117824. getFps(): number;
  117825. /**
  117826. * Gets the time spent between current and previous frame
  117827. * @returns a number representing the delta time in ms
  117828. */
  117829. getDeltaTime(): number;
  117830. private _measureFps;
  117831. /** @hidden */
  117832. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  117833. /**
  117834. * Updates the sample count of a render target texture
  117835. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  117836. * @param texture defines the texture to update
  117837. * @param samples defines the sample count to set
  117838. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  117839. */
  117840. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  117841. /**
  117842. * Updates a depth texture Comparison Mode and Function.
  117843. * If the comparison Function is equal to 0, the mode will be set to none.
  117844. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  117845. * @param texture The texture to set the comparison function for
  117846. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  117847. */
  117848. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  117849. /**
  117850. * Creates a webGL buffer to use with instanciation
  117851. * @param capacity defines the size of the buffer
  117852. * @returns the webGL buffer
  117853. */
  117854. createInstancesBuffer(capacity: number): DataBuffer;
  117855. /**
  117856. * Delete a webGL buffer used with instanciation
  117857. * @param buffer defines the webGL buffer to delete
  117858. */
  117859. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  117860. private _clientWaitAsync;
  117861. /** @hidden */
  117862. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  117863. dispose(): void;
  117864. private _disableTouchAction;
  117865. /**
  117866. * Display the loading screen
  117867. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117868. */
  117869. displayLoadingUI(): void;
  117870. /**
  117871. * Hide the loading screen
  117872. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117873. */
  117874. hideLoadingUI(): void;
  117875. /**
  117876. * Gets the current loading screen object
  117877. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117878. */
  117879. get loadingScreen(): ILoadingScreen;
  117880. /**
  117881. * Sets the current loading screen object
  117882. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117883. */
  117884. set loadingScreen(loadingScreen: ILoadingScreen);
  117885. /**
  117886. * Sets the current loading screen text
  117887. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117888. */
  117889. set loadingUIText(text: string);
  117890. /**
  117891. * Sets the current loading screen background color
  117892. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117893. */
  117894. set loadingUIBackgroundColor(color: string);
  117895. /** Pointerlock and fullscreen */
  117896. /**
  117897. * Ask the browser to promote the current element to pointerlock mode
  117898. * @param element defines the DOM element to promote
  117899. */
  117900. static _RequestPointerlock(element: HTMLElement): void;
  117901. /**
  117902. * Asks the browser to exit pointerlock mode
  117903. */
  117904. static _ExitPointerlock(): void;
  117905. /**
  117906. * Ask the browser to promote the current element to fullscreen rendering mode
  117907. * @param element defines the DOM element to promote
  117908. */
  117909. static _RequestFullscreen(element: HTMLElement): void;
  117910. /**
  117911. * Asks the browser to exit fullscreen mode
  117912. */
  117913. static _ExitFullscreen(): void;
  117914. }
  117915. }
  117916. declare module BABYLON {
  117917. /**
  117918. * The engine store class is responsible to hold all the instances of Engine and Scene created
  117919. * during the life time of the application.
  117920. */
  117921. export class EngineStore {
  117922. /** Gets the list of created engines */
  117923. static Instances: Engine[];
  117924. /** @hidden */
  117925. static _LastCreatedScene: Nullable<Scene>;
  117926. /**
  117927. * Gets the latest created engine
  117928. */
  117929. static get LastCreatedEngine(): Nullable<Engine>;
  117930. /**
  117931. * Gets the latest created scene
  117932. */
  117933. static get LastCreatedScene(): Nullable<Scene>;
  117934. /**
  117935. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  117936. * @ignorenaming
  117937. */
  117938. static UseFallbackTexture: boolean;
  117939. /**
  117940. * Texture content used if a texture cannot loaded
  117941. * @ignorenaming
  117942. */
  117943. static FallbackTexture: string;
  117944. }
  117945. }
  117946. declare module BABYLON {
  117947. /**
  117948. * Helper class that provides a small promise polyfill
  117949. */
  117950. export class PromisePolyfill {
  117951. /**
  117952. * Static function used to check if the polyfill is required
  117953. * If this is the case then the function will inject the polyfill to window.Promise
  117954. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  117955. */
  117956. static Apply(force?: boolean): void;
  117957. }
  117958. }
  117959. declare module BABYLON {
  117960. /**
  117961. * Interface for screenshot methods with describe argument called `size` as object with options
  117962. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  117963. */
  117964. export interface IScreenshotSize {
  117965. /**
  117966. * number in pixels for canvas height
  117967. */
  117968. height?: number;
  117969. /**
  117970. * multiplier allowing render at a higher or lower resolution
  117971. * If value is defined then height and width will be ignored and taken from camera
  117972. */
  117973. precision?: number;
  117974. /**
  117975. * number in pixels for canvas width
  117976. */
  117977. width?: number;
  117978. }
  117979. }
  117980. declare module BABYLON {
  117981. interface IColor4Like {
  117982. r: float;
  117983. g: float;
  117984. b: float;
  117985. a: float;
  117986. }
  117987. /**
  117988. * Class containing a set of static utilities functions
  117989. */
  117990. export class Tools {
  117991. /**
  117992. * Gets or sets the base URL to use to load assets
  117993. */
  117994. static get BaseUrl(): string;
  117995. static set BaseUrl(value: string);
  117996. /**
  117997. * Enable/Disable Custom HTTP Request Headers globally.
  117998. * default = false
  117999. * @see CustomRequestHeaders
  118000. */
  118001. static UseCustomRequestHeaders: boolean;
  118002. /**
  118003. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  118004. * i.e. when loading files, where the server/service expects an Authorization header
  118005. */
  118006. static CustomRequestHeaders: {
  118007. [key: string]: string;
  118008. };
  118009. /**
  118010. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  118011. */
  118012. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  118013. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  118014. /**
  118015. * Default behaviour for cors in the application.
  118016. * It can be a string if the expected behavior is identical in the entire app.
  118017. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  118018. */
  118019. static get CorsBehavior(): string | ((url: string | string[]) => string);
  118020. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  118021. /**
  118022. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  118023. * @ignorenaming
  118024. */
  118025. static get UseFallbackTexture(): boolean;
  118026. static set UseFallbackTexture(value: boolean);
  118027. /**
  118028. * Use this object to register external classes like custom textures or material
  118029. * to allow the laoders to instantiate them
  118030. */
  118031. static get RegisteredExternalClasses(): {
  118032. [key: string]: Object;
  118033. };
  118034. static set RegisteredExternalClasses(classes: {
  118035. [key: string]: Object;
  118036. });
  118037. /**
  118038. * Texture content used if a texture cannot loaded
  118039. * @ignorenaming
  118040. */
  118041. static get fallbackTexture(): string;
  118042. static set fallbackTexture(value: string);
  118043. /**
  118044. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  118045. * @param u defines the coordinate on X axis
  118046. * @param v defines the coordinate on Y axis
  118047. * @param width defines the width of the source data
  118048. * @param height defines the height of the source data
  118049. * @param pixels defines the source byte array
  118050. * @param color defines the output color
  118051. */
  118052. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  118053. /**
  118054. * Interpolates between a and b via alpha
  118055. * @param a The lower value (returned when alpha = 0)
  118056. * @param b The upper value (returned when alpha = 1)
  118057. * @param alpha The interpolation-factor
  118058. * @return The mixed value
  118059. */
  118060. static Mix(a: number, b: number, alpha: number): number;
  118061. /**
  118062. * Tries to instantiate a new object from a given class name
  118063. * @param className defines the class name to instantiate
  118064. * @returns the new object or null if the system was not able to do the instantiation
  118065. */
  118066. static Instantiate(className: string): any;
  118067. /**
  118068. * Provides a slice function that will work even on IE
  118069. * @param data defines the array to slice
  118070. * @param start defines the start of the data (optional)
  118071. * @param end defines the end of the data (optional)
  118072. * @returns the new sliced array
  118073. */
  118074. static Slice<T>(data: T, start?: number, end?: number): T;
  118075. /**
  118076. * Polyfill for setImmediate
  118077. * @param action defines the action to execute after the current execution block
  118078. */
  118079. static SetImmediate(action: () => void): void;
  118080. /**
  118081. * Function indicating if a number is an exponent of 2
  118082. * @param value defines the value to test
  118083. * @returns true if the value is an exponent of 2
  118084. */
  118085. static IsExponentOfTwo(value: number): boolean;
  118086. private static _tmpFloatArray;
  118087. /**
  118088. * Returns the nearest 32-bit single precision float representation of a Number
  118089. * @param value A Number. If the parameter is of a different type, it will get converted
  118090. * to a number or to NaN if it cannot be converted
  118091. * @returns number
  118092. */
  118093. static FloatRound(value: number): number;
  118094. /**
  118095. * Extracts the filename from a path
  118096. * @param path defines the path to use
  118097. * @returns the filename
  118098. */
  118099. static GetFilename(path: string): string;
  118100. /**
  118101. * Extracts the "folder" part of a path (everything before the filename).
  118102. * @param uri The URI to extract the info from
  118103. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  118104. * @returns The "folder" part of the path
  118105. */
  118106. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  118107. /**
  118108. * Extracts text content from a DOM element hierarchy
  118109. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  118110. */
  118111. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  118112. /**
  118113. * Convert an angle in radians to degrees
  118114. * @param angle defines the angle to convert
  118115. * @returns the angle in degrees
  118116. */
  118117. static ToDegrees(angle: number): number;
  118118. /**
  118119. * Convert an angle in degrees to radians
  118120. * @param angle defines the angle to convert
  118121. * @returns the angle in radians
  118122. */
  118123. static ToRadians(angle: number): number;
  118124. /**
  118125. * Returns an array if obj is not an array
  118126. * @param obj defines the object to evaluate as an array
  118127. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  118128. * @returns either obj directly if obj is an array or a new array containing obj
  118129. */
  118130. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  118131. /**
  118132. * Gets the pointer prefix to use
  118133. * @param engine defines the engine we are finding the prefix for
  118134. * @returns "pointer" if touch is enabled. Else returns "mouse"
  118135. */
  118136. static GetPointerPrefix(engine: Engine): string;
  118137. /**
  118138. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  118139. * @param url define the url we are trying
  118140. * @param element define the dom element where to configure the cors policy
  118141. */
  118142. static SetCorsBehavior(url: string | string[], element: {
  118143. crossOrigin: string | null;
  118144. }): void;
  118145. /**
  118146. * Removes unwanted characters from an url
  118147. * @param url defines the url to clean
  118148. * @returns the cleaned url
  118149. */
  118150. static CleanUrl(url: string): string;
  118151. /**
  118152. * Gets or sets a function used to pre-process url before using them to load assets
  118153. */
  118154. static get PreprocessUrl(): (url: string) => string;
  118155. static set PreprocessUrl(processor: (url: string) => string);
  118156. /**
  118157. * Loads an image as an HTMLImageElement.
  118158. * @param input url string, ArrayBuffer, or Blob to load
  118159. * @param onLoad callback called when the image successfully loads
  118160. * @param onError callback called when the image fails to load
  118161. * @param offlineProvider offline provider for caching
  118162. * @param mimeType optional mime type
  118163. * @returns the HTMLImageElement of the loaded image
  118164. */
  118165. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  118166. /**
  118167. * Loads a file from a url
  118168. * @param url url string, ArrayBuffer, or Blob to load
  118169. * @param onSuccess callback called when the file successfully loads
  118170. * @param onProgress callback called while file is loading (if the server supports this mode)
  118171. * @param offlineProvider defines the offline provider for caching
  118172. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  118173. * @param onError callback called when the file fails to load
  118174. * @returns a file request object
  118175. */
  118176. 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;
  118177. /**
  118178. * Loads a file from a url
  118179. * @param url the file url to load
  118180. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  118181. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  118182. */
  118183. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  118184. /**
  118185. * Load a script (identified by an url). When the url returns, the
  118186. * content of this file is added into a new script element, attached to the DOM (body element)
  118187. * @param scriptUrl defines the url of the script to laod
  118188. * @param onSuccess defines the callback called when the script is loaded
  118189. * @param onError defines the callback to call if an error occurs
  118190. * @param scriptId defines the id of the script element
  118191. */
  118192. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  118193. /**
  118194. * Load an asynchronous script (identified by an url). When the url returns, the
  118195. * content of this file is added into a new script element, attached to the DOM (body element)
  118196. * @param scriptUrl defines the url of the script to laod
  118197. * @param scriptId defines the id of the script element
  118198. * @returns a promise request object
  118199. */
  118200. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  118201. /**
  118202. * Loads a file from a blob
  118203. * @param fileToLoad defines the blob to use
  118204. * @param callback defines the callback to call when data is loaded
  118205. * @param progressCallback defines the callback to call during loading process
  118206. * @returns a file request object
  118207. */
  118208. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  118209. /**
  118210. * Reads a file from a File object
  118211. * @param file defines the file to load
  118212. * @param onSuccess defines the callback to call when data is loaded
  118213. * @param onProgress defines the callback to call during loading process
  118214. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  118215. * @param onError defines the callback to call when an error occurs
  118216. * @returns a file request object
  118217. */
  118218. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  118219. /**
  118220. * Creates a data url from a given string content
  118221. * @param content defines the content to convert
  118222. * @returns the new data url link
  118223. */
  118224. static FileAsURL(content: string): string;
  118225. /**
  118226. * Format the given number to a specific decimal format
  118227. * @param value defines the number to format
  118228. * @param decimals defines the number of decimals to use
  118229. * @returns the formatted string
  118230. */
  118231. static Format(value: number, decimals?: number): string;
  118232. /**
  118233. * Tries to copy an object by duplicating every property
  118234. * @param source defines the source object
  118235. * @param destination defines the target object
  118236. * @param doNotCopyList defines a list of properties to avoid
  118237. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  118238. */
  118239. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  118240. /**
  118241. * Gets a boolean indicating if the given object has no own property
  118242. * @param obj defines the object to test
  118243. * @returns true if object has no own property
  118244. */
  118245. static IsEmpty(obj: any): boolean;
  118246. /**
  118247. * Function used to register events at window level
  118248. * @param windowElement defines the Window object to use
  118249. * @param events defines the events to register
  118250. */
  118251. static RegisterTopRootEvents(windowElement: Window, events: {
  118252. name: string;
  118253. handler: Nullable<(e: FocusEvent) => any>;
  118254. }[]): void;
  118255. /**
  118256. * Function used to unregister events from window level
  118257. * @param windowElement defines the Window object to use
  118258. * @param events defines the events to unregister
  118259. */
  118260. static UnregisterTopRootEvents(windowElement: Window, events: {
  118261. name: string;
  118262. handler: Nullable<(e: FocusEvent) => any>;
  118263. }[]): void;
  118264. /**
  118265. * @ignore
  118266. */
  118267. static _ScreenshotCanvas: HTMLCanvasElement;
  118268. /**
  118269. * Dumps the current bound framebuffer
  118270. * @param width defines the rendering width
  118271. * @param height defines the rendering height
  118272. * @param engine defines the hosting engine
  118273. * @param successCallback defines the callback triggered once the data are available
  118274. * @param mimeType defines the mime type of the result
  118275. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  118276. */
  118277. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  118278. /**
  118279. * Converts the canvas data to blob.
  118280. * This acts as a polyfill for browsers not supporting the to blob function.
  118281. * @param canvas Defines the canvas to extract the data from
  118282. * @param successCallback Defines the callback triggered once the data are available
  118283. * @param mimeType Defines the mime type of the result
  118284. */
  118285. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  118286. /**
  118287. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  118288. * @param successCallback defines the callback triggered once the data are available
  118289. * @param mimeType defines the mime type of the result
  118290. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  118291. */
  118292. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  118293. /**
  118294. * Downloads a blob in the browser
  118295. * @param blob defines the blob to download
  118296. * @param fileName defines the name of the downloaded file
  118297. */
  118298. static Download(blob: Blob, fileName: string): void;
  118299. /**
  118300. * Captures a screenshot of the current rendering
  118301. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118302. * @param engine defines the rendering engine
  118303. * @param camera defines the source camera
  118304. * @param size This parameter can be set to a single number or to an object with the
  118305. * following (optional) properties: precision, width, height. If a single number is passed,
  118306. * it will be used for both width and height. If an object is passed, the screenshot size
  118307. * will be derived from the parameters. The precision property is a multiplier allowing
  118308. * rendering at a higher or lower resolution
  118309. * @param successCallback defines the callback receives a single parameter which contains the
  118310. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  118311. * src parameter of an <img> to display it
  118312. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  118313. * Check your browser for supported MIME types
  118314. */
  118315. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  118316. /**
  118317. * Captures a screenshot of the current rendering
  118318. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118319. * @param engine defines the rendering engine
  118320. * @param camera defines the source camera
  118321. * @param size This parameter can be set to a single number or to an object with the
  118322. * following (optional) properties: precision, width, height. If a single number is passed,
  118323. * it will be used for both width and height. If an object is passed, the screenshot size
  118324. * will be derived from the parameters. The precision property is a multiplier allowing
  118325. * rendering at a higher or lower resolution
  118326. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  118327. * Check your browser for supported MIME types
  118328. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  118329. * to the src parameter of an <img> to display it
  118330. */
  118331. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  118332. /**
  118333. * Generates an image screenshot from the specified camera.
  118334. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118335. * @param engine The engine to use for rendering
  118336. * @param camera The camera to use for rendering
  118337. * @param size This parameter can be set to a single number or to an object with the
  118338. * following (optional) properties: precision, width, height. If a single number is passed,
  118339. * it will be used for both width and height. If an object is passed, the screenshot size
  118340. * will be derived from the parameters. The precision property is a multiplier allowing
  118341. * rendering at a higher or lower resolution
  118342. * @param successCallback The callback receives a single parameter which contains the
  118343. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  118344. * src parameter of an <img> to display it
  118345. * @param mimeType The MIME type of the screenshot image (default: image/png).
  118346. * Check your browser for supported MIME types
  118347. * @param samples Texture samples (default: 1)
  118348. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  118349. * @param fileName A name for for the downloaded file.
  118350. */
  118351. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  118352. /**
  118353. * Generates an image screenshot from the specified camera.
  118354. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118355. * @param engine The engine to use for rendering
  118356. * @param camera The camera to use for rendering
  118357. * @param size This parameter can be set to a single number or to an object with the
  118358. * following (optional) properties: precision, width, height. If a single number is passed,
  118359. * it will be used for both width and height. If an object is passed, the screenshot size
  118360. * will be derived from the parameters. The precision property is a multiplier allowing
  118361. * rendering at a higher or lower resolution
  118362. * @param mimeType The MIME type of the screenshot image (default: image/png).
  118363. * Check your browser for supported MIME types
  118364. * @param samples Texture samples (default: 1)
  118365. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  118366. * @param fileName A name for for the downloaded file.
  118367. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  118368. * to the src parameter of an <img> to display it
  118369. */
  118370. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  118371. /**
  118372. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  118373. * Be aware Math.random() could cause collisions, but:
  118374. * "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"
  118375. * @returns a pseudo random id
  118376. */
  118377. static RandomId(): string;
  118378. /**
  118379. * Test if the given uri is a base64 string
  118380. * @param uri The uri to test
  118381. * @return True if the uri is a base64 string or false otherwise
  118382. */
  118383. static IsBase64(uri: string): boolean;
  118384. /**
  118385. * Decode the given base64 uri.
  118386. * @param uri The uri to decode
  118387. * @return The decoded base64 data.
  118388. */
  118389. static DecodeBase64(uri: string): ArrayBuffer;
  118390. /**
  118391. * Gets the absolute url.
  118392. * @param url the input url
  118393. * @return the absolute url
  118394. */
  118395. static GetAbsoluteUrl(url: string): string;
  118396. /**
  118397. * No log
  118398. */
  118399. static readonly NoneLogLevel: number;
  118400. /**
  118401. * Only message logs
  118402. */
  118403. static readonly MessageLogLevel: number;
  118404. /**
  118405. * Only warning logs
  118406. */
  118407. static readonly WarningLogLevel: number;
  118408. /**
  118409. * Only error logs
  118410. */
  118411. static readonly ErrorLogLevel: number;
  118412. /**
  118413. * All logs
  118414. */
  118415. static readonly AllLogLevel: number;
  118416. /**
  118417. * Gets a value indicating the number of loading errors
  118418. * @ignorenaming
  118419. */
  118420. static get errorsCount(): number;
  118421. /**
  118422. * Callback called when a new log is added
  118423. */
  118424. static OnNewCacheEntry: (entry: string) => void;
  118425. /**
  118426. * Log a message to the console
  118427. * @param message defines the message to log
  118428. */
  118429. static Log(message: string): void;
  118430. /**
  118431. * Write a warning message to the console
  118432. * @param message defines the message to log
  118433. */
  118434. static Warn(message: string): void;
  118435. /**
  118436. * Write an error message to the console
  118437. * @param message defines the message to log
  118438. */
  118439. static Error(message: string): void;
  118440. /**
  118441. * Gets current log cache (list of logs)
  118442. */
  118443. static get LogCache(): string;
  118444. /**
  118445. * Clears the log cache
  118446. */
  118447. static ClearLogCache(): void;
  118448. /**
  118449. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  118450. */
  118451. static set LogLevels(level: number);
  118452. /**
  118453. * Checks if the window object exists
  118454. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  118455. */
  118456. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  118457. /**
  118458. * No performance log
  118459. */
  118460. static readonly PerformanceNoneLogLevel: number;
  118461. /**
  118462. * Use user marks to log performance
  118463. */
  118464. static readonly PerformanceUserMarkLogLevel: number;
  118465. /**
  118466. * Log performance to the console
  118467. */
  118468. static readonly PerformanceConsoleLogLevel: number;
  118469. private static _performance;
  118470. /**
  118471. * Sets the current performance log level
  118472. */
  118473. static set PerformanceLogLevel(level: number);
  118474. private static _StartPerformanceCounterDisabled;
  118475. private static _EndPerformanceCounterDisabled;
  118476. private static _StartUserMark;
  118477. private static _EndUserMark;
  118478. private static _StartPerformanceConsole;
  118479. private static _EndPerformanceConsole;
  118480. /**
  118481. * Starts a performance counter
  118482. */
  118483. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  118484. /**
  118485. * Ends a specific performance coutner
  118486. */
  118487. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  118488. /**
  118489. * Gets either window.performance.now() if supported or Date.now() else
  118490. */
  118491. static get Now(): number;
  118492. /**
  118493. * This method will return the name of the class used to create the instance of the given object.
  118494. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  118495. * @param object the object to get the class name from
  118496. * @param isType defines if the object is actually a type
  118497. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  118498. */
  118499. static GetClassName(object: any, isType?: boolean): string;
  118500. /**
  118501. * Gets the first element of an array satisfying a given predicate
  118502. * @param array defines the array to browse
  118503. * @param predicate defines the predicate to use
  118504. * @returns null if not found or the element
  118505. */
  118506. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  118507. /**
  118508. * This method will return the name of the full name of the class, including its owning module (if any).
  118509. * 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).
  118510. * @param object the object to get the class name from
  118511. * @param isType defines if the object is actually a type
  118512. * @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.
  118513. * @ignorenaming
  118514. */
  118515. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  118516. /**
  118517. * Returns a promise that resolves after the given amount of time.
  118518. * @param delay Number of milliseconds to delay
  118519. * @returns Promise that resolves after the given amount of time
  118520. */
  118521. static DelayAsync(delay: number): Promise<void>;
  118522. /**
  118523. * Utility function to detect if the current user agent is Safari
  118524. * @returns whether or not the current user agent is safari
  118525. */
  118526. static IsSafari(): boolean;
  118527. }
  118528. /**
  118529. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  118530. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  118531. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  118532. * @param name The name of the class, case should be preserved
  118533. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  118534. */
  118535. export function className(name: string, module?: string): (target: Object) => void;
  118536. /**
  118537. * An implementation of a loop for asynchronous functions.
  118538. */
  118539. export class AsyncLoop {
  118540. /**
  118541. * Defines the number of iterations for the loop
  118542. */
  118543. iterations: number;
  118544. /**
  118545. * Defines the current index of the loop.
  118546. */
  118547. index: number;
  118548. private _done;
  118549. private _fn;
  118550. private _successCallback;
  118551. /**
  118552. * Constructor.
  118553. * @param iterations the number of iterations.
  118554. * @param func the function to run each iteration
  118555. * @param successCallback the callback that will be called upon succesful execution
  118556. * @param offset starting offset.
  118557. */
  118558. constructor(
  118559. /**
  118560. * Defines the number of iterations for the loop
  118561. */
  118562. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  118563. /**
  118564. * Execute the next iteration. Must be called after the last iteration was finished.
  118565. */
  118566. executeNext(): void;
  118567. /**
  118568. * Break the loop and run the success callback.
  118569. */
  118570. breakLoop(): void;
  118571. /**
  118572. * Create and run an async loop.
  118573. * @param iterations the number of iterations.
  118574. * @param fn the function to run each iteration
  118575. * @param successCallback the callback that will be called upon succesful execution
  118576. * @param offset starting offset.
  118577. * @returns the created async loop object
  118578. */
  118579. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  118580. /**
  118581. * A for-loop that will run a given number of iterations synchronous and the rest async.
  118582. * @param iterations total number of iterations
  118583. * @param syncedIterations number of synchronous iterations in each async iteration.
  118584. * @param fn the function to call each iteration.
  118585. * @param callback a success call back that will be called when iterating stops.
  118586. * @param breakFunction a break condition (optional)
  118587. * @param timeout timeout settings for the setTimeout function. default - 0.
  118588. * @returns the created async loop object
  118589. */
  118590. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  118591. }
  118592. }
  118593. declare module BABYLON {
  118594. /**
  118595. * This class implement a typical dictionary using a string as key and the generic type T as value.
  118596. * The underlying implementation relies on an associative array to ensure the best performances.
  118597. * The value can be anything including 'null' but except 'undefined'
  118598. */
  118599. export class StringDictionary<T> {
  118600. /**
  118601. * This will clear this dictionary and copy the content from the 'source' one.
  118602. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  118603. * @param source the dictionary to take the content from and copy to this dictionary
  118604. */
  118605. copyFrom(source: StringDictionary<T>): void;
  118606. /**
  118607. * Get a value based from its key
  118608. * @param key the given key to get the matching value from
  118609. * @return the value if found, otherwise undefined is returned
  118610. */
  118611. get(key: string): T | undefined;
  118612. /**
  118613. * Get a value from its key or add it if it doesn't exist.
  118614. * This method will ensure you that a given key/data will be present in the dictionary.
  118615. * @param key the given key to get the matching value from
  118616. * @param factory the factory that will create the value if the key is not present in the dictionary.
  118617. * The factory will only be invoked if there's no data for the given key.
  118618. * @return the value corresponding to the key.
  118619. */
  118620. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  118621. /**
  118622. * Get a value from its key if present in the dictionary otherwise add it
  118623. * @param key the key to get the value from
  118624. * @param val if there's no such key/value pair in the dictionary add it with this value
  118625. * @return the value corresponding to the key
  118626. */
  118627. getOrAdd(key: string, val: T): T;
  118628. /**
  118629. * Check if there's a given key in the dictionary
  118630. * @param key the key to check for
  118631. * @return true if the key is present, false otherwise
  118632. */
  118633. contains(key: string): boolean;
  118634. /**
  118635. * Add a new key and its corresponding value
  118636. * @param key the key to add
  118637. * @param value the value corresponding to the key
  118638. * @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
  118639. */
  118640. add(key: string, value: T): boolean;
  118641. /**
  118642. * Update a specific value associated to a key
  118643. * @param key defines the key to use
  118644. * @param value defines the value to store
  118645. * @returns true if the value was updated (or false if the key was not found)
  118646. */
  118647. set(key: string, value: T): boolean;
  118648. /**
  118649. * Get the element of the given key and remove it from the dictionary
  118650. * @param key defines the key to search
  118651. * @returns the value associated with the key or null if not found
  118652. */
  118653. getAndRemove(key: string): Nullable<T>;
  118654. /**
  118655. * Remove a key/value from the dictionary.
  118656. * @param key the key to remove
  118657. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  118658. */
  118659. remove(key: string): boolean;
  118660. /**
  118661. * Clear the whole content of the dictionary
  118662. */
  118663. clear(): void;
  118664. /**
  118665. * Gets the current count
  118666. */
  118667. get count(): number;
  118668. /**
  118669. * Execute a callback on each key/val of the dictionary.
  118670. * Note that you can remove any element in this dictionary in the callback implementation
  118671. * @param callback the callback to execute on a given key/value pair
  118672. */
  118673. forEach(callback: (key: string, val: T) => void): void;
  118674. /**
  118675. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  118676. * If the callback returns null or undefined the method will iterate to the next key/value pair
  118677. * Note that you can remove any element in this dictionary in the callback implementation
  118678. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  118679. * @returns the first item
  118680. */
  118681. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  118682. private _count;
  118683. private _data;
  118684. }
  118685. }
  118686. declare module BABYLON {
  118687. /** @hidden */
  118688. export interface ICollisionCoordinator {
  118689. createCollider(): Collider;
  118690. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  118691. init(scene: Scene): void;
  118692. }
  118693. /** @hidden */
  118694. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  118695. private _scene;
  118696. private _scaledPosition;
  118697. private _scaledVelocity;
  118698. private _finalPosition;
  118699. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  118700. createCollider(): Collider;
  118701. init(scene: Scene): void;
  118702. private _collideWithWorld;
  118703. }
  118704. }
  118705. declare module BABYLON {
  118706. /**
  118707. * Class used to manage all inputs for the scene.
  118708. */
  118709. export class InputManager {
  118710. /** The distance in pixel that you have to move to prevent some events */
  118711. static DragMovementThreshold: number;
  118712. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  118713. static LongPressDelay: number;
  118714. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  118715. static DoubleClickDelay: number;
  118716. /** If you need to check double click without raising a single click at first click, enable this flag */
  118717. static ExclusiveDoubleClickMode: boolean;
  118718. /** 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. */
  118719. private _alreadyAttached;
  118720. private _wheelEventName;
  118721. private _onPointerMove;
  118722. private _onPointerDown;
  118723. private _onPointerUp;
  118724. private _initClickEvent;
  118725. private _initActionManager;
  118726. private _delayedSimpleClick;
  118727. private _delayedSimpleClickTimeout;
  118728. private _previousDelayedSimpleClickTimeout;
  118729. private _meshPickProceed;
  118730. private _previousButtonPressed;
  118731. private _currentPickResult;
  118732. private _previousPickResult;
  118733. private _totalPointersPressed;
  118734. private _doubleClickOccured;
  118735. private _pointerOverMesh;
  118736. private _pickedDownMesh;
  118737. private _pickedUpMesh;
  118738. private _pointerX;
  118739. private _pointerY;
  118740. private _unTranslatedPointerX;
  118741. private _unTranslatedPointerY;
  118742. private _startingPointerPosition;
  118743. private _previousStartingPointerPosition;
  118744. private _startingPointerTime;
  118745. private _previousStartingPointerTime;
  118746. private _pointerCaptures;
  118747. private _meshUnderPointerId;
  118748. private _onKeyDown;
  118749. private _onKeyUp;
  118750. private _onCanvasFocusObserver;
  118751. private _onCanvasBlurObserver;
  118752. private _scene;
  118753. /**
  118754. * Creates a new InputManager
  118755. * @param scene defines the hosting scene
  118756. */
  118757. constructor(scene: Scene);
  118758. /**
  118759. * Gets the mesh that is currently under the pointer
  118760. */
  118761. get meshUnderPointer(): Nullable<AbstractMesh>;
  118762. /**
  118763. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  118764. * @param pointerId the pointer id to use
  118765. * @returns The mesh under this pointer id or null if not found
  118766. */
  118767. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  118768. /**
  118769. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  118770. */
  118771. get unTranslatedPointer(): Vector2;
  118772. /**
  118773. * Gets or sets the current on-screen X position of the pointer
  118774. */
  118775. get pointerX(): number;
  118776. set pointerX(value: number);
  118777. /**
  118778. * Gets or sets the current on-screen Y position of the pointer
  118779. */
  118780. get pointerY(): number;
  118781. set pointerY(value: number);
  118782. private _updatePointerPosition;
  118783. private _processPointerMove;
  118784. private _setRayOnPointerInfo;
  118785. private _checkPrePointerObservable;
  118786. /**
  118787. * Use this method to simulate a pointer move on a mesh
  118788. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  118789. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  118790. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  118791. */
  118792. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  118793. /**
  118794. * Use this method to simulate a pointer down on a mesh
  118795. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  118796. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  118797. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  118798. */
  118799. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  118800. private _processPointerDown;
  118801. /** @hidden */
  118802. _isPointerSwiping(): boolean;
  118803. /**
  118804. * Use this method to simulate a pointer up on a mesh
  118805. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  118806. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  118807. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  118808. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  118809. */
  118810. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  118811. private _processPointerUp;
  118812. /**
  118813. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  118814. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  118815. * @returns true if the pointer was captured
  118816. */
  118817. isPointerCaptured(pointerId?: number): boolean;
  118818. /**
  118819. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  118820. * @param attachUp defines if you want to attach events to pointerup
  118821. * @param attachDown defines if you want to attach events to pointerdown
  118822. * @param attachMove defines if you want to attach events to pointermove
  118823. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  118824. */
  118825. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  118826. /**
  118827. * Detaches all event handlers
  118828. */
  118829. detachControl(): void;
  118830. /**
  118831. * Force the value of meshUnderPointer
  118832. * @param mesh defines the mesh to use
  118833. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  118834. */
  118835. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  118836. /**
  118837. * Gets the mesh under the pointer
  118838. * @returns a Mesh or null if no mesh is under the pointer
  118839. */
  118840. getPointerOverMesh(): Nullable<AbstractMesh>;
  118841. }
  118842. }
  118843. declare module BABYLON {
  118844. /**
  118845. * This class defines the direct association between an animation and a target
  118846. */
  118847. export class TargetedAnimation {
  118848. /**
  118849. * Animation to perform
  118850. */
  118851. animation: Animation;
  118852. /**
  118853. * Target to animate
  118854. */
  118855. target: any;
  118856. /**
  118857. * Returns the string "TargetedAnimation"
  118858. * @returns "TargetedAnimation"
  118859. */
  118860. getClassName(): string;
  118861. /**
  118862. * Serialize the object
  118863. * @returns the JSON object representing the current entity
  118864. */
  118865. serialize(): any;
  118866. }
  118867. /**
  118868. * Use this class to create coordinated animations on multiple targets
  118869. */
  118870. export class AnimationGroup implements IDisposable {
  118871. /** The name of the animation group */
  118872. name: string;
  118873. private _scene;
  118874. private _targetedAnimations;
  118875. private _animatables;
  118876. private _from;
  118877. private _to;
  118878. private _isStarted;
  118879. private _isPaused;
  118880. private _speedRatio;
  118881. private _loopAnimation;
  118882. private _isAdditive;
  118883. /**
  118884. * Gets or sets the unique id of the node
  118885. */
  118886. uniqueId: number;
  118887. /**
  118888. * This observable will notify when one animation have ended
  118889. */
  118890. onAnimationEndObservable: Observable<TargetedAnimation>;
  118891. /**
  118892. * Observer raised when one animation loops
  118893. */
  118894. onAnimationLoopObservable: Observable<TargetedAnimation>;
  118895. /**
  118896. * Observer raised when all animations have looped
  118897. */
  118898. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  118899. /**
  118900. * This observable will notify when all animations have ended.
  118901. */
  118902. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  118903. /**
  118904. * This observable will notify when all animations have paused.
  118905. */
  118906. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  118907. /**
  118908. * This observable will notify when all animations are playing.
  118909. */
  118910. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  118911. /**
  118912. * Gets the first frame
  118913. */
  118914. get from(): number;
  118915. /**
  118916. * Gets the last frame
  118917. */
  118918. get to(): number;
  118919. /**
  118920. * Define if the animations are started
  118921. */
  118922. get isStarted(): boolean;
  118923. /**
  118924. * Gets a value indicating that the current group is playing
  118925. */
  118926. get isPlaying(): boolean;
  118927. /**
  118928. * Gets or sets the speed ratio to use for all animations
  118929. */
  118930. get speedRatio(): number;
  118931. /**
  118932. * Gets or sets the speed ratio to use for all animations
  118933. */
  118934. set speedRatio(value: number);
  118935. /**
  118936. * Gets or sets if all animations should loop or not
  118937. */
  118938. get loopAnimation(): boolean;
  118939. set loopAnimation(value: boolean);
  118940. /**
  118941. * Gets or sets if all animations should be evaluated additively
  118942. */
  118943. get isAdditive(): boolean;
  118944. set isAdditive(value: boolean);
  118945. /**
  118946. * Gets the targeted animations for this animation group
  118947. */
  118948. get targetedAnimations(): Array<TargetedAnimation>;
  118949. /**
  118950. * returning the list of animatables controlled by this animation group.
  118951. */
  118952. get animatables(): Array<Animatable>;
  118953. /**
  118954. * Gets the list of target animations
  118955. */
  118956. get children(): TargetedAnimation[];
  118957. /**
  118958. * Instantiates a new Animation Group.
  118959. * This helps managing several animations at once.
  118960. * @see https://doc.babylonjs.com/how_to/group
  118961. * @param name Defines the name of the group
  118962. * @param scene Defines the scene the group belongs to
  118963. */
  118964. constructor(
  118965. /** The name of the animation group */
  118966. name: string, scene?: Nullable<Scene>);
  118967. /**
  118968. * Add an animation (with its target) in the group
  118969. * @param animation defines the animation we want to add
  118970. * @param target defines the target of the animation
  118971. * @returns the TargetedAnimation object
  118972. */
  118973. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  118974. /**
  118975. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  118976. * It can add constant keys at begin or end
  118977. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  118978. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  118979. * @returns the animation group
  118980. */
  118981. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  118982. private _animationLoopCount;
  118983. private _animationLoopFlags;
  118984. private _processLoop;
  118985. /**
  118986. * Start all animations on given targets
  118987. * @param loop defines if animations must loop
  118988. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  118989. * @param from defines the from key (optional)
  118990. * @param to defines the to key (optional)
  118991. * @param isAdditive defines the additive state for the resulting animatables (optional)
  118992. * @returns the current animation group
  118993. */
  118994. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  118995. /**
  118996. * Pause all animations
  118997. * @returns the animation group
  118998. */
  118999. pause(): AnimationGroup;
  119000. /**
  119001. * Play all animations to initial state
  119002. * This function will start() the animations if they were not started or will restart() them if they were paused
  119003. * @param loop defines if animations must loop
  119004. * @returns the animation group
  119005. */
  119006. play(loop?: boolean): AnimationGroup;
  119007. /**
  119008. * Reset all animations to initial state
  119009. * @returns the animation group
  119010. */
  119011. reset(): AnimationGroup;
  119012. /**
  119013. * Restart animations from key 0
  119014. * @returns the animation group
  119015. */
  119016. restart(): AnimationGroup;
  119017. /**
  119018. * Stop all animations
  119019. * @returns the animation group
  119020. */
  119021. stop(): AnimationGroup;
  119022. /**
  119023. * Set animation weight for all animatables
  119024. * @param weight defines the weight to use
  119025. * @return the animationGroup
  119026. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  119027. */
  119028. setWeightForAllAnimatables(weight: number): AnimationGroup;
  119029. /**
  119030. * Synchronize and normalize all animatables with a source animatable
  119031. * @param root defines the root animatable to synchronize with
  119032. * @return the animationGroup
  119033. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  119034. */
  119035. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  119036. /**
  119037. * Goes to a specific frame in this animation group
  119038. * @param frame the frame number to go to
  119039. * @return the animationGroup
  119040. */
  119041. goToFrame(frame: number): AnimationGroup;
  119042. /**
  119043. * Dispose all associated resources
  119044. */
  119045. dispose(): void;
  119046. private _checkAnimationGroupEnded;
  119047. /**
  119048. * Clone the current animation group and returns a copy
  119049. * @param newName defines the name of the new group
  119050. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  119051. * @returns the new aniamtion group
  119052. */
  119053. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  119054. /**
  119055. * Serializes the animationGroup to an object
  119056. * @returns Serialized object
  119057. */
  119058. serialize(): any;
  119059. /**
  119060. * Returns a new AnimationGroup object parsed from the source provided.
  119061. * @param parsedAnimationGroup defines the source
  119062. * @param scene defines the scene that will receive the animationGroup
  119063. * @returns a new AnimationGroup
  119064. */
  119065. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  119066. /**
  119067. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  119068. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  119069. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  119070. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  119071. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  119072. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  119073. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  119074. */
  119075. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  119076. /**
  119077. * Returns the string "AnimationGroup"
  119078. * @returns "AnimationGroup"
  119079. */
  119080. getClassName(): string;
  119081. /**
  119082. * Creates a detailled string about the object
  119083. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  119084. * @returns a string representing the object
  119085. */
  119086. toString(fullDetails?: boolean): string;
  119087. }
  119088. }
  119089. declare module BABYLON {
  119090. /**
  119091. * Define an interface for all classes that will hold resources
  119092. */
  119093. export interface IDisposable {
  119094. /**
  119095. * Releases all held resources
  119096. */
  119097. dispose(): void;
  119098. }
  119099. /** Interface defining initialization parameters for Scene class */
  119100. export interface SceneOptions {
  119101. /**
  119102. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  119103. * It will improve performance when the number of geometries becomes important.
  119104. */
  119105. useGeometryUniqueIdsMap?: boolean;
  119106. /**
  119107. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  119108. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  119109. */
  119110. useMaterialMeshMap?: boolean;
  119111. /**
  119112. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  119113. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  119114. */
  119115. useClonedMeshMap?: boolean;
  119116. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  119117. virtual?: boolean;
  119118. }
  119119. /**
  119120. * Represents a scene to be rendered by the engine.
  119121. * @see https://doc.babylonjs.com/features/scene
  119122. */
  119123. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  119124. /** The fog is deactivated */
  119125. static readonly FOGMODE_NONE: number;
  119126. /** The fog density is following an exponential function */
  119127. static readonly FOGMODE_EXP: number;
  119128. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  119129. static readonly FOGMODE_EXP2: number;
  119130. /** The fog density is following a linear function. */
  119131. static readonly FOGMODE_LINEAR: number;
  119132. /**
  119133. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  119134. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119135. */
  119136. static MinDeltaTime: number;
  119137. /**
  119138. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  119139. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119140. */
  119141. static MaxDeltaTime: number;
  119142. /**
  119143. * Factory used to create the default material.
  119144. * @param name The name of the material to create
  119145. * @param scene The scene to create the material for
  119146. * @returns The default material
  119147. */
  119148. static DefaultMaterialFactory(scene: Scene): Material;
  119149. /**
  119150. * Factory used to create the a collision coordinator.
  119151. * @returns The collision coordinator
  119152. */
  119153. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  119154. /** @hidden */
  119155. _inputManager: InputManager;
  119156. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  119157. cameraToUseForPointers: Nullable<Camera>;
  119158. /** @hidden */
  119159. readonly _isScene: boolean;
  119160. /** @hidden */
  119161. _blockEntityCollection: boolean;
  119162. /**
  119163. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  119164. */
  119165. autoClear: boolean;
  119166. /**
  119167. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  119168. */
  119169. autoClearDepthAndStencil: boolean;
  119170. /**
  119171. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  119172. */
  119173. clearColor: Color4;
  119174. /**
  119175. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  119176. */
  119177. ambientColor: Color3;
  119178. /**
  119179. * This is use to store the default BRDF lookup for PBR materials in your scene.
  119180. * It should only be one of the following (if not the default embedded one):
  119181. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  119182. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  119183. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  119184. * The material properties need to be setup according to the type of texture in use.
  119185. */
  119186. environmentBRDFTexture: BaseTexture;
  119187. /**
  119188. * Texture used in all pbr material as the reflection texture.
  119189. * As in the majority of the scene they are the same (exception for multi room and so on),
  119190. * this is easier to reference from here than from all the materials.
  119191. */
  119192. get environmentTexture(): Nullable<BaseTexture>;
  119193. /**
  119194. * Texture used in all pbr material as the reflection texture.
  119195. * As in the majority of the scene they are the same (exception for multi room and so on),
  119196. * this is easier to set here than in all the materials.
  119197. */
  119198. set environmentTexture(value: Nullable<BaseTexture>);
  119199. /** @hidden */
  119200. protected _environmentIntensity: number;
  119201. /**
  119202. * Intensity of the environment in all pbr material.
  119203. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  119204. * As in the majority of the scene they are the same (exception for multi room and so on),
  119205. * this is easier to reference from here than from all the materials.
  119206. */
  119207. get environmentIntensity(): number;
  119208. /**
  119209. * Intensity of the environment in all pbr material.
  119210. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  119211. * As in the majority of the scene they are the same (exception for multi room and so on),
  119212. * this is easier to set here than in all the materials.
  119213. */
  119214. set environmentIntensity(value: number);
  119215. /** @hidden */
  119216. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  119217. /**
  119218. * Default image processing configuration used either in the rendering
  119219. * Forward main pass or through the imageProcessingPostProcess if present.
  119220. * As in the majority of the scene they are the same (exception for multi camera),
  119221. * this is easier to reference from here than from all the materials and post process.
  119222. *
  119223. * No setter as we it is a shared configuration, you can set the values instead.
  119224. */
  119225. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  119226. private _forceWireframe;
  119227. /**
  119228. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  119229. */
  119230. set forceWireframe(value: boolean);
  119231. get forceWireframe(): boolean;
  119232. private _skipFrustumClipping;
  119233. /**
  119234. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  119235. */
  119236. set skipFrustumClipping(value: boolean);
  119237. get skipFrustumClipping(): boolean;
  119238. private _forcePointsCloud;
  119239. /**
  119240. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  119241. */
  119242. set forcePointsCloud(value: boolean);
  119243. get forcePointsCloud(): boolean;
  119244. /**
  119245. * Gets or sets the active clipplane 1
  119246. */
  119247. clipPlane: Nullable<Plane>;
  119248. /**
  119249. * Gets or sets the active clipplane 2
  119250. */
  119251. clipPlane2: Nullable<Plane>;
  119252. /**
  119253. * Gets or sets the active clipplane 3
  119254. */
  119255. clipPlane3: Nullable<Plane>;
  119256. /**
  119257. * Gets or sets the active clipplane 4
  119258. */
  119259. clipPlane4: Nullable<Plane>;
  119260. /**
  119261. * Gets or sets the active clipplane 5
  119262. */
  119263. clipPlane5: Nullable<Plane>;
  119264. /**
  119265. * Gets or sets the active clipplane 6
  119266. */
  119267. clipPlane6: Nullable<Plane>;
  119268. /**
  119269. * Gets or sets a boolean indicating if animations are enabled
  119270. */
  119271. animationsEnabled: boolean;
  119272. private _animationPropertiesOverride;
  119273. /**
  119274. * Gets or sets the animation properties override
  119275. */
  119276. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  119277. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  119278. /**
  119279. * Gets or sets a boolean indicating if a constant deltatime has to be used
  119280. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  119281. */
  119282. useConstantAnimationDeltaTime: boolean;
  119283. /**
  119284. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  119285. * Please note that it requires to run a ray cast through the scene on every frame
  119286. */
  119287. constantlyUpdateMeshUnderPointer: boolean;
  119288. /**
  119289. * Defines the HTML cursor to use when hovering over interactive elements
  119290. */
  119291. hoverCursor: string;
  119292. /**
  119293. * Defines the HTML default cursor to use (empty by default)
  119294. */
  119295. defaultCursor: string;
  119296. /**
  119297. * Defines whether cursors are handled by the scene.
  119298. */
  119299. doNotHandleCursors: boolean;
  119300. /**
  119301. * This is used to call preventDefault() on pointer down
  119302. * in order to block unwanted artifacts like system double clicks
  119303. */
  119304. preventDefaultOnPointerDown: boolean;
  119305. /**
  119306. * This is used to call preventDefault() on pointer up
  119307. * in order to block unwanted artifacts like system double clicks
  119308. */
  119309. preventDefaultOnPointerUp: boolean;
  119310. /**
  119311. * Gets or sets user defined metadata
  119312. */
  119313. metadata: any;
  119314. /**
  119315. * For internal use only. Please do not use.
  119316. */
  119317. reservedDataStore: any;
  119318. /**
  119319. * Gets the name of the plugin used to load this scene (null by default)
  119320. */
  119321. loadingPluginName: string;
  119322. /**
  119323. * Use this array to add regular expressions used to disable offline support for specific urls
  119324. */
  119325. disableOfflineSupportExceptionRules: RegExp[];
  119326. /**
  119327. * An event triggered when the scene is disposed.
  119328. */
  119329. onDisposeObservable: Observable<Scene>;
  119330. private _onDisposeObserver;
  119331. /** Sets a function to be executed when this scene is disposed. */
  119332. set onDispose(callback: () => void);
  119333. /**
  119334. * An event triggered before rendering the scene (right after animations and physics)
  119335. */
  119336. onBeforeRenderObservable: Observable<Scene>;
  119337. private _onBeforeRenderObserver;
  119338. /** Sets a function to be executed before rendering this scene */
  119339. set beforeRender(callback: Nullable<() => void>);
  119340. /**
  119341. * An event triggered after rendering the scene
  119342. */
  119343. onAfterRenderObservable: Observable<Scene>;
  119344. /**
  119345. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  119346. */
  119347. onAfterRenderCameraObservable: Observable<Camera>;
  119348. private _onAfterRenderObserver;
  119349. /** Sets a function to be executed after rendering this scene */
  119350. set afterRender(callback: Nullable<() => void>);
  119351. /**
  119352. * An event triggered before animating the scene
  119353. */
  119354. onBeforeAnimationsObservable: Observable<Scene>;
  119355. /**
  119356. * An event triggered after animations processing
  119357. */
  119358. onAfterAnimationsObservable: Observable<Scene>;
  119359. /**
  119360. * An event triggered before draw calls are ready to be sent
  119361. */
  119362. onBeforeDrawPhaseObservable: Observable<Scene>;
  119363. /**
  119364. * An event triggered after draw calls have been sent
  119365. */
  119366. onAfterDrawPhaseObservable: Observable<Scene>;
  119367. /**
  119368. * An event triggered when the scene is ready
  119369. */
  119370. onReadyObservable: Observable<Scene>;
  119371. /**
  119372. * An event triggered before rendering a camera
  119373. */
  119374. onBeforeCameraRenderObservable: Observable<Camera>;
  119375. private _onBeforeCameraRenderObserver;
  119376. /** Sets a function to be executed before rendering a camera*/
  119377. set beforeCameraRender(callback: () => void);
  119378. /**
  119379. * An event triggered after rendering a camera
  119380. */
  119381. onAfterCameraRenderObservable: Observable<Camera>;
  119382. private _onAfterCameraRenderObserver;
  119383. /** Sets a function to be executed after rendering a camera*/
  119384. set afterCameraRender(callback: () => void);
  119385. /**
  119386. * An event triggered when active meshes evaluation is about to start
  119387. */
  119388. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  119389. /**
  119390. * An event triggered when active meshes evaluation is done
  119391. */
  119392. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  119393. /**
  119394. * An event triggered when particles rendering is about to start
  119395. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  119396. */
  119397. onBeforeParticlesRenderingObservable: Observable<Scene>;
  119398. /**
  119399. * An event triggered when particles rendering is done
  119400. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  119401. */
  119402. onAfterParticlesRenderingObservable: Observable<Scene>;
  119403. /**
  119404. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  119405. */
  119406. onDataLoadedObservable: Observable<Scene>;
  119407. /**
  119408. * An event triggered when a camera is created
  119409. */
  119410. onNewCameraAddedObservable: Observable<Camera>;
  119411. /**
  119412. * An event triggered when a camera is removed
  119413. */
  119414. onCameraRemovedObservable: Observable<Camera>;
  119415. /**
  119416. * An event triggered when a light is created
  119417. */
  119418. onNewLightAddedObservable: Observable<Light>;
  119419. /**
  119420. * An event triggered when a light is removed
  119421. */
  119422. onLightRemovedObservable: Observable<Light>;
  119423. /**
  119424. * An event triggered when a geometry is created
  119425. */
  119426. onNewGeometryAddedObservable: Observable<Geometry>;
  119427. /**
  119428. * An event triggered when a geometry is removed
  119429. */
  119430. onGeometryRemovedObservable: Observable<Geometry>;
  119431. /**
  119432. * An event triggered when a transform node is created
  119433. */
  119434. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  119435. /**
  119436. * An event triggered when a transform node is removed
  119437. */
  119438. onTransformNodeRemovedObservable: Observable<TransformNode>;
  119439. /**
  119440. * An event triggered when a mesh is created
  119441. */
  119442. onNewMeshAddedObservable: Observable<AbstractMesh>;
  119443. /**
  119444. * An event triggered when a mesh is removed
  119445. */
  119446. onMeshRemovedObservable: Observable<AbstractMesh>;
  119447. /**
  119448. * An event triggered when a skeleton is created
  119449. */
  119450. onNewSkeletonAddedObservable: Observable<Skeleton>;
  119451. /**
  119452. * An event triggered when a skeleton is removed
  119453. */
  119454. onSkeletonRemovedObservable: Observable<Skeleton>;
  119455. /**
  119456. * An event triggered when a material is created
  119457. */
  119458. onNewMaterialAddedObservable: Observable<Material>;
  119459. /**
  119460. * An event triggered when a material is removed
  119461. */
  119462. onMaterialRemovedObservable: Observable<Material>;
  119463. /**
  119464. * An event triggered when a texture is created
  119465. */
  119466. onNewTextureAddedObservable: Observable<BaseTexture>;
  119467. /**
  119468. * An event triggered when a texture is removed
  119469. */
  119470. onTextureRemovedObservable: Observable<BaseTexture>;
  119471. /**
  119472. * An event triggered when render targets are about to be rendered
  119473. * Can happen multiple times per frame.
  119474. */
  119475. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  119476. /**
  119477. * An event triggered when render targets were rendered.
  119478. * Can happen multiple times per frame.
  119479. */
  119480. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  119481. /**
  119482. * An event triggered before calculating deterministic simulation step
  119483. */
  119484. onBeforeStepObservable: Observable<Scene>;
  119485. /**
  119486. * An event triggered after calculating deterministic simulation step
  119487. */
  119488. onAfterStepObservable: Observable<Scene>;
  119489. /**
  119490. * An event triggered when the activeCamera property is updated
  119491. */
  119492. onActiveCameraChanged: Observable<Scene>;
  119493. /**
  119494. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  119495. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  119496. * 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)
  119497. */
  119498. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  119499. /**
  119500. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  119501. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  119502. * 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)
  119503. */
  119504. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  119505. /**
  119506. * This Observable will when a mesh has been imported into the scene.
  119507. */
  119508. onMeshImportedObservable: Observable<AbstractMesh>;
  119509. /**
  119510. * This Observable will when an animation file has been imported into the scene.
  119511. */
  119512. onAnimationFileImportedObservable: Observable<Scene>;
  119513. /**
  119514. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  119515. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  119516. */
  119517. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  119518. /** @hidden */
  119519. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  119520. /**
  119521. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  119522. */
  119523. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  119524. /**
  119525. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  119526. */
  119527. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  119528. /**
  119529. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  119530. */
  119531. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  119532. /** Callback called when a pointer move is detected */
  119533. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  119534. /** Callback called when a pointer down is detected */
  119535. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  119536. /** Callback called when a pointer up is detected */
  119537. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  119538. /** Callback called when a pointer pick is detected */
  119539. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  119540. /**
  119541. * 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).
  119542. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  119543. */
  119544. onPrePointerObservable: Observable<PointerInfoPre>;
  119545. /**
  119546. * Observable event triggered each time an input event is received from the rendering canvas
  119547. */
  119548. onPointerObservable: Observable<PointerInfo>;
  119549. /**
  119550. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  119551. */
  119552. get unTranslatedPointer(): Vector2;
  119553. /**
  119554. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  119555. */
  119556. static get DragMovementThreshold(): number;
  119557. static set DragMovementThreshold(value: number);
  119558. /**
  119559. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  119560. */
  119561. static get LongPressDelay(): number;
  119562. static set LongPressDelay(value: number);
  119563. /**
  119564. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  119565. */
  119566. static get DoubleClickDelay(): number;
  119567. static set DoubleClickDelay(value: number);
  119568. /** If you need to check double click without raising a single click at first click, enable this flag */
  119569. static get ExclusiveDoubleClickMode(): boolean;
  119570. static set ExclusiveDoubleClickMode(value: boolean);
  119571. /** @hidden */
  119572. _mirroredCameraPosition: Nullable<Vector3>;
  119573. /**
  119574. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  119575. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  119576. */
  119577. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  119578. /**
  119579. * Observable event triggered each time an keyboard event is received from the hosting window
  119580. */
  119581. onKeyboardObservable: Observable<KeyboardInfo>;
  119582. private _useRightHandedSystem;
  119583. /**
  119584. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  119585. */
  119586. set useRightHandedSystem(value: boolean);
  119587. get useRightHandedSystem(): boolean;
  119588. private _timeAccumulator;
  119589. private _currentStepId;
  119590. private _currentInternalStep;
  119591. /**
  119592. * Sets the step Id used by deterministic lock step
  119593. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119594. * @param newStepId defines the step Id
  119595. */
  119596. setStepId(newStepId: number): void;
  119597. /**
  119598. * Gets the step Id used by deterministic lock step
  119599. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119600. * @returns the step Id
  119601. */
  119602. getStepId(): number;
  119603. /**
  119604. * Gets the internal step used by deterministic lock step
  119605. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119606. * @returns the internal step
  119607. */
  119608. getInternalStep(): number;
  119609. private _fogEnabled;
  119610. /**
  119611. * Gets or sets a boolean indicating if fog is enabled on this scene
  119612. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119613. * (Default is true)
  119614. */
  119615. set fogEnabled(value: boolean);
  119616. get fogEnabled(): boolean;
  119617. private _fogMode;
  119618. /**
  119619. * Gets or sets the fog mode to use
  119620. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119621. * | mode | value |
  119622. * | --- | --- |
  119623. * | FOGMODE_NONE | 0 |
  119624. * | FOGMODE_EXP | 1 |
  119625. * | FOGMODE_EXP2 | 2 |
  119626. * | FOGMODE_LINEAR | 3 |
  119627. */
  119628. set fogMode(value: number);
  119629. get fogMode(): number;
  119630. /**
  119631. * Gets or sets the fog color to use
  119632. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119633. * (Default is Color3(0.2, 0.2, 0.3))
  119634. */
  119635. fogColor: Color3;
  119636. /**
  119637. * Gets or sets the fog density to use
  119638. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119639. * (Default is 0.1)
  119640. */
  119641. fogDensity: number;
  119642. /**
  119643. * Gets or sets the fog start distance to use
  119644. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119645. * (Default is 0)
  119646. */
  119647. fogStart: number;
  119648. /**
  119649. * Gets or sets the fog end distance to use
  119650. * @see https://doc.babylonjs.com/babylon101/environment#fog
  119651. * (Default is 1000)
  119652. */
  119653. fogEnd: number;
  119654. /**
  119655. * Flag indicating that the frame buffer binding is handled by another component
  119656. */
  119657. prePass: boolean;
  119658. private _shadowsEnabled;
  119659. /**
  119660. * Gets or sets a boolean indicating if shadows are enabled on this scene
  119661. */
  119662. set shadowsEnabled(value: boolean);
  119663. get shadowsEnabled(): boolean;
  119664. private _lightsEnabled;
  119665. /**
  119666. * Gets or sets a boolean indicating if lights are enabled on this scene
  119667. */
  119668. set lightsEnabled(value: boolean);
  119669. get lightsEnabled(): boolean;
  119670. /** All of the active cameras added to this scene. */
  119671. activeCameras: Camera[];
  119672. /** @hidden */
  119673. _activeCamera: Nullable<Camera>;
  119674. /** Gets or sets the current active camera */
  119675. get activeCamera(): Nullable<Camera>;
  119676. set activeCamera(value: Nullable<Camera>);
  119677. private _defaultMaterial;
  119678. /** The default material used on meshes when no material is affected */
  119679. get defaultMaterial(): Material;
  119680. /** The default material used on meshes when no material is affected */
  119681. set defaultMaterial(value: Material);
  119682. private _texturesEnabled;
  119683. /**
  119684. * Gets or sets a boolean indicating if textures are enabled on this scene
  119685. */
  119686. set texturesEnabled(value: boolean);
  119687. get texturesEnabled(): boolean;
  119688. /**
  119689. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  119690. */
  119691. physicsEnabled: boolean;
  119692. /**
  119693. * Gets or sets a boolean indicating if particles are enabled on this scene
  119694. */
  119695. particlesEnabled: boolean;
  119696. /**
  119697. * Gets or sets a boolean indicating if sprites are enabled on this scene
  119698. */
  119699. spritesEnabled: boolean;
  119700. private _skeletonsEnabled;
  119701. /**
  119702. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  119703. */
  119704. set skeletonsEnabled(value: boolean);
  119705. get skeletonsEnabled(): boolean;
  119706. /**
  119707. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  119708. */
  119709. lensFlaresEnabled: boolean;
  119710. /**
  119711. * Gets or sets a boolean indicating if collisions are enabled on this scene
  119712. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  119713. */
  119714. collisionsEnabled: boolean;
  119715. private _collisionCoordinator;
  119716. /** @hidden */
  119717. get collisionCoordinator(): ICollisionCoordinator;
  119718. /**
  119719. * Defines the gravity applied to this scene (used only for collisions)
  119720. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  119721. */
  119722. gravity: Vector3;
  119723. /**
  119724. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  119725. */
  119726. postProcessesEnabled: boolean;
  119727. /**
  119728. * Gets the current postprocess manager
  119729. */
  119730. postProcessManager: PostProcessManager;
  119731. /**
  119732. * Gets or sets a boolean indicating if render targets are enabled on this scene
  119733. */
  119734. renderTargetsEnabled: boolean;
  119735. /**
  119736. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  119737. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  119738. */
  119739. dumpNextRenderTargets: boolean;
  119740. /**
  119741. * The list of user defined render targets added to the scene
  119742. */
  119743. customRenderTargets: RenderTargetTexture[];
  119744. /**
  119745. * Defines if texture loading must be delayed
  119746. * If true, textures will only be loaded when they need to be rendered
  119747. */
  119748. useDelayedTextureLoading: boolean;
  119749. /**
  119750. * Gets the list of meshes imported to the scene through SceneLoader
  119751. */
  119752. importedMeshesFiles: String[];
  119753. /**
  119754. * Gets or sets a boolean indicating if probes are enabled on this scene
  119755. */
  119756. probesEnabled: boolean;
  119757. /**
  119758. * Gets or sets the current offline provider to use to store scene data
  119759. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  119760. */
  119761. offlineProvider: IOfflineProvider;
  119762. /**
  119763. * Gets or sets the action manager associated with the scene
  119764. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  119765. */
  119766. actionManager: AbstractActionManager;
  119767. private _meshesForIntersections;
  119768. /**
  119769. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  119770. */
  119771. proceduralTexturesEnabled: boolean;
  119772. private _engine;
  119773. private _totalVertices;
  119774. /** @hidden */
  119775. _activeIndices: PerfCounter;
  119776. /** @hidden */
  119777. _activeParticles: PerfCounter;
  119778. /** @hidden */
  119779. _activeBones: PerfCounter;
  119780. private _animationRatio;
  119781. /** @hidden */
  119782. _animationTimeLast: number;
  119783. /** @hidden */
  119784. _animationTime: number;
  119785. /**
  119786. * Gets or sets a general scale for animation speed
  119787. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  119788. */
  119789. animationTimeScale: number;
  119790. /** @hidden */
  119791. _cachedMaterial: Nullable<Material>;
  119792. /** @hidden */
  119793. _cachedEffect: Nullable<Effect>;
  119794. /** @hidden */
  119795. _cachedVisibility: Nullable<number>;
  119796. private _renderId;
  119797. private _frameId;
  119798. private _executeWhenReadyTimeoutId;
  119799. private _intermediateRendering;
  119800. private _viewUpdateFlag;
  119801. private _projectionUpdateFlag;
  119802. /** @hidden */
  119803. _toBeDisposed: Nullable<IDisposable>[];
  119804. private _activeRequests;
  119805. /** @hidden */
  119806. _pendingData: any[];
  119807. private _isDisposed;
  119808. /**
  119809. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  119810. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  119811. */
  119812. dispatchAllSubMeshesOfActiveMeshes: boolean;
  119813. private _activeMeshes;
  119814. private _processedMaterials;
  119815. private _renderTargets;
  119816. /** @hidden */
  119817. _activeParticleSystems: SmartArray<IParticleSystem>;
  119818. private _activeSkeletons;
  119819. private _softwareSkinnedMeshes;
  119820. private _renderingManager;
  119821. /** @hidden */
  119822. _activeAnimatables: Animatable[];
  119823. private _transformMatrix;
  119824. private _sceneUbo;
  119825. /** @hidden */
  119826. _viewMatrix: Matrix;
  119827. private _projectionMatrix;
  119828. /** @hidden */
  119829. _forcedViewPosition: Nullable<Vector3>;
  119830. /** @hidden */
  119831. _frustumPlanes: Plane[];
  119832. /**
  119833. * Gets the list of frustum planes (built from the active camera)
  119834. */
  119835. get frustumPlanes(): Plane[];
  119836. /**
  119837. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  119838. * This is useful if there are more lights that the maximum simulteanous authorized
  119839. */
  119840. requireLightSorting: boolean;
  119841. /** @hidden */
  119842. readonly useMaterialMeshMap: boolean;
  119843. /** @hidden */
  119844. readonly useClonedMeshMap: boolean;
  119845. private _externalData;
  119846. private _uid;
  119847. /**
  119848. * @hidden
  119849. * Backing store of defined scene components.
  119850. */
  119851. _components: ISceneComponent[];
  119852. /**
  119853. * @hidden
  119854. * Backing store of defined scene components.
  119855. */
  119856. _serializableComponents: ISceneSerializableComponent[];
  119857. /**
  119858. * List of components to register on the next registration step.
  119859. */
  119860. private _transientComponents;
  119861. /**
  119862. * Registers the transient components if needed.
  119863. */
  119864. private _registerTransientComponents;
  119865. /**
  119866. * @hidden
  119867. * Add a component to the scene.
  119868. * Note that the ccomponent could be registered on th next frame if this is called after
  119869. * the register component stage.
  119870. * @param component Defines the component to add to the scene
  119871. */
  119872. _addComponent(component: ISceneComponent): void;
  119873. /**
  119874. * @hidden
  119875. * Gets a component from the scene.
  119876. * @param name defines the name of the component to retrieve
  119877. * @returns the component or null if not present
  119878. */
  119879. _getComponent(name: string): Nullable<ISceneComponent>;
  119880. /**
  119881. * @hidden
  119882. * Defines the actions happening before camera updates.
  119883. */
  119884. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  119885. /**
  119886. * @hidden
  119887. * Defines the actions happening before clear the canvas.
  119888. */
  119889. _beforeClearStage: Stage<SimpleStageAction>;
  119890. /**
  119891. * @hidden
  119892. * Defines the actions when collecting render targets for the frame.
  119893. */
  119894. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  119895. /**
  119896. * @hidden
  119897. * Defines the actions happening for one camera in the frame.
  119898. */
  119899. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  119900. /**
  119901. * @hidden
  119902. * Defines the actions happening during the per mesh ready checks.
  119903. */
  119904. _isReadyForMeshStage: Stage<MeshStageAction>;
  119905. /**
  119906. * @hidden
  119907. * Defines the actions happening before evaluate active mesh checks.
  119908. */
  119909. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  119910. /**
  119911. * @hidden
  119912. * Defines the actions happening during the evaluate sub mesh checks.
  119913. */
  119914. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  119915. /**
  119916. * @hidden
  119917. * Defines the actions happening during the active mesh stage.
  119918. */
  119919. _activeMeshStage: Stage<ActiveMeshStageAction>;
  119920. /**
  119921. * @hidden
  119922. * Defines the actions happening during the per camera render target step.
  119923. */
  119924. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  119925. /**
  119926. * @hidden
  119927. * Defines the actions happening just before the active camera is drawing.
  119928. */
  119929. _beforeCameraDrawStage: Stage<CameraStageAction>;
  119930. /**
  119931. * @hidden
  119932. * Defines the actions happening just before a render target is drawing.
  119933. */
  119934. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  119935. /**
  119936. * @hidden
  119937. * Defines the actions happening just before a rendering group is drawing.
  119938. */
  119939. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  119940. /**
  119941. * @hidden
  119942. * Defines the actions happening just before a mesh is drawing.
  119943. */
  119944. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  119945. /**
  119946. * @hidden
  119947. * Defines the actions happening just after a mesh has been drawn.
  119948. */
  119949. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  119950. /**
  119951. * @hidden
  119952. * Defines the actions happening just after a rendering group has been drawn.
  119953. */
  119954. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  119955. /**
  119956. * @hidden
  119957. * Defines the actions happening just after the active camera has been drawn.
  119958. */
  119959. _afterCameraDrawStage: Stage<CameraStageAction>;
  119960. /**
  119961. * @hidden
  119962. * Defines the actions happening just after a render target has been drawn.
  119963. */
  119964. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  119965. /**
  119966. * @hidden
  119967. * Defines the actions happening just after rendering all cameras and computing intersections.
  119968. */
  119969. _afterRenderStage: Stage<SimpleStageAction>;
  119970. /**
  119971. * @hidden
  119972. * Defines the actions happening when a pointer move event happens.
  119973. */
  119974. _pointerMoveStage: Stage<PointerMoveStageAction>;
  119975. /**
  119976. * @hidden
  119977. * Defines the actions happening when a pointer down event happens.
  119978. */
  119979. _pointerDownStage: Stage<PointerUpDownStageAction>;
  119980. /**
  119981. * @hidden
  119982. * Defines the actions happening when a pointer up event happens.
  119983. */
  119984. _pointerUpStage: Stage<PointerUpDownStageAction>;
  119985. /**
  119986. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  119987. */
  119988. private geometriesByUniqueId;
  119989. /**
  119990. * Creates a new Scene
  119991. * @param engine defines the engine to use to render this scene
  119992. * @param options defines the scene options
  119993. */
  119994. constructor(engine: Engine, options?: SceneOptions);
  119995. /**
  119996. * Gets a string identifying the name of the class
  119997. * @returns "Scene" string
  119998. */
  119999. getClassName(): string;
  120000. private _defaultMeshCandidates;
  120001. /**
  120002. * @hidden
  120003. */
  120004. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  120005. private _defaultSubMeshCandidates;
  120006. /**
  120007. * @hidden
  120008. */
  120009. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  120010. /**
  120011. * Sets the default candidate providers for the scene.
  120012. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  120013. * and getCollidingSubMeshCandidates to their default function
  120014. */
  120015. setDefaultCandidateProviders(): void;
  120016. /**
  120017. * Gets the mesh that is currently under the pointer
  120018. */
  120019. get meshUnderPointer(): Nullable<AbstractMesh>;
  120020. /**
  120021. * Gets or sets the current on-screen X position of the pointer
  120022. */
  120023. get pointerX(): number;
  120024. set pointerX(value: number);
  120025. /**
  120026. * Gets or sets the current on-screen Y position of the pointer
  120027. */
  120028. get pointerY(): number;
  120029. set pointerY(value: number);
  120030. /**
  120031. * Gets the cached material (ie. the latest rendered one)
  120032. * @returns the cached material
  120033. */
  120034. getCachedMaterial(): Nullable<Material>;
  120035. /**
  120036. * Gets the cached effect (ie. the latest rendered one)
  120037. * @returns the cached effect
  120038. */
  120039. getCachedEffect(): Nullable<Effect>;
  120040. /**
  120041. * Gets the cached visibility state (ie. the latest rendered one)
  120042. * @returns the cached visibility state
  120043. */
  120044. getCachedVisibility(): Nullable<number>;
  120045. /**
  120046. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  120047. * @param material defines the current material
  120048. * @param effect defines the current effect
  120049. * @param visibility defines the current visibility state
  120050. * @returns true if one parameter is not cached
  120051. */
  120052. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  120053. /**
  120054. * Gets the engine associated with the scene
  120055. * @returns an Engine
  120056. */
  120057. getEngine(): Engine;
  120058. /**
  120059. * Gets the total number of vertices rendered per frame
  120060. * @returns the total number of vertices rendered per frame
  120061. */
  120062. getTotalVertices(): number;
  120063. /**
  120064. * Gets the performance counter for total vertices
  120065. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120066. */
  120067. get totalVerticesPerfCounter(): PerfCounter;
  120068. /**
  120069. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  120070. * @returns the total number of active indices rendered per frame
  120071. */
  120072. getActiveIndices(): number;
  120073. /**
  120074. * Gets the performance counter for active indices
  120075. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120076. */
  120077. get totalActiveIndicesPerfCounter(): PerfCounter;
  120078. /**
  120079. * Gets the total number of active particles rendered per frame
  120080. * @returns the total number of active particles rendered per frame
  120081. */
  120082. getActiveParticles(): number;
  120083. /**
  120084. * Gets the performance counter for active particles
  120085. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120086. */
  120087. get activeParticlesPerfCounter(): PerfCounter;
  120088. /**
  120089. * Gets the total number of active bones rendered per frame
  120090. * @returns the total number of active bones rendered per frame
  120091. */
  120092. getActiveBones(): number;
  120093. /**
  120094. * Gets the performance counter for active bones
  120095. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120096. */
  120097. get activeBonesPerfCounter(): PerfCounter;
  120098. /**
  120099. * Gets the array of active meshes
  120100. * @returns an array of AbstractMesh
  120101. */
  120102. getActiveMeshes(): SmartArray<AbstractMesh>;
  120103. /**
  120104. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  120105. * @returns a number
  120106. */
  120107. getAnimationRatio(): number;
  120108. /**
  120109. * Gets an unique Id for the current render phase
  120110. * @returns a number
  120111. */
  120112. getRenderId(): number;
  120113. /**
  120114. * Gets an unique Id for the current frame
  120115. * @returns a number
  120116. */
  120117. getFrameId(): number;
  120118. /** Call this function if you want to manually increment the render Id*/
  120119. incrementRenderId(): void;
  120120. private _createUbo;
  120121. /**
  120122. * Use this method to simulate a pointer move on a mesh
  120123. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120124. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120125. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120126. * @returns the current scene
  120127. */
  120128. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  120129. /**
  120130. * Use this method to simulate a pointer down on a mesh
  120131. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120132. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120133. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120134. * @returns the current scene
  120135. */
  120136. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  120137. /**
  120138. * Use this method to simulate a pointer up on a mesh
  120139. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120140. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120141. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120142. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  120143. * @returns the current scene
  120144. */
  120145. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  120146. /**
  120147. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  120148. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  120149. * @returns true if the pointer was captured
  120150. */
  120151. isPointerCaptured(pointerId?: number): boolean;
  120152. /**
  120153. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  120154. * @param attachUp defines if you want to attach events to pointerup
  120155. * @param attachDown defines if you want to attach events to pointerdown
  120156. * @param attachMove defines if you want to attach events to pointermove
  120157. */
  120158. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  120159. /** Detaches all event handlers*/
  120160. detachControl(): void;
  120161. /**
  120162. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  120163. * Delay loaded resources are not taking in account
  120164. * @return true if all required resources are ready
  120165. */
  120166. isReady(): boolean;
  120167. /** Resets all cached information relative to material (including effect and visibility) */
  120168. resetCachedMaterial(): void;
  120169. /**
  120170. * Registers a function to be called before every frame render
  120171. * @param func defines the function to register
  120172. */
  120173. registerBeforeRender(func: () => void): void;
  120174. /**
  120175. * Unregisters a function called before every frame render
  120176. * @param func defines the function to unregister
  120177. */
  120178. unregisterBeforeRender(func: () => void): void;
  120179. /**
  120180. * Registers a function to be called after every frame render
  120181. * @param func defines the function to register
  120182. */
  120183. registerAfterRender(func: () => void): void;
  120184. /**
  120185. * Unregisters a function called after every frame render
  120186. * @param func defines the function to unregister
  120187. */
  120188. unregisterAfterRender(func: () => void): void;
  120189. private _executeOnceBeforeRender;
  120190. /**
  120191. * The provided function will run before render once and will be disposed afterwards.
  120192. * A timeout delay can be provided so that the function will be executed in N ms.
  120193. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  120194. * @param func The function to be executed.
  120195. * @param timeout optional delay in ms
  120196. */
  120197. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  120198. /** @hidden */
  120199. _addPendingData(data: any): void;
  120200. /** @hidden */
  120201. _removePendingData(data: any): void;
  120202. /**
  120203. * Returns the number of items waiting to be loaded
  120204. * @returns the number of items waiting to be loaded
  120205. */
  120206. getWaitingItemsCount(): number;
  120207. /**
  120208. * Returns a boolean indicating if the scene is still loading data
  120209. */
  120210. get isLoading(): boolean;
  120211. /**
  120212. * Registers a function to be executed when the scene is ready
  120213. * @param {Function} func - the function to be executed
  120214. */
  120215. executeWhenReady(func: () => void): void;
  120216. /**
  120217. * Returns a promise that resolves when the scene is ready
  120218. * @returns A promise that resolves when the scene is ready
  120219. */
  120220. whenReadyAsync(): Promise<void>;
  120221. /** @hidden */
  120222. _checkIsReady(): void;
  120223. /**
  120224. * Gets all animatable attached to the scene
  120225. */
  120226. get animatables(): Animatable[];
  120227. /**
  120228. * Resets the last animation time frame.
  120229. * Useful to override when animations start running when loading a scene for the first time.
  120230. */
  120231. resetLastAnimationTimeFrame(): void;
  120232. /**
  120233. * Gets the current view matrix
  120234. * @returns a Matrix
  120235. */
  120236. getViewMatrix(): Matrix;
  120237. /**
  120238. * Gets the current projection matrix
  120239. * @returns a Matrix
  120240. */
  120241. getProjectionMatrix(): Matrix;
  120242. /**
  120243. * Gets the current transform matrix
  120244. * @returns a Matrix made of View * Projection
  120245. */
  120246. getTransformMatrix(): Matrix;
  120247. /**
  120248. * Sets the current transform matrix
  120249. * @param viewL defines the View matrix to use
  120250. * @param projectionL defines the Projection matrix to use
  120251. * @param viewR defines the right View matrix to use (if provided)
  120252. * @param projectionR defines the right Projection matrix to use (if provided)
  120253. */
  120254. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  120255. /**
  120256. * Gets the uniform buffer used to store scene data
  120257. * @returns a UniformBuffer
  120258. */
  120259. getSceneUniformBuffer(): UniformBuffer;
  120260. /**
  120261. * Gets an unique (relatively to the current scene) Id
  120262. * @returns an unique number for the scene
  120263. */
  120264. getUniqueId(): number;
  120265. /**
  120266. * Add a mesh to the list of scene's meshes
  120267. * @param newMesh defines the mesh to add
  120268. * @param recursive if all child meshes should also be added to the scene
  120269. */
  120270. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  120271. /**
  120272. * Remove a mesh for the list of scene's meshes
  120273. * @param toRemove defines the mesh to remove
  120274. * @param recursive if all child meshes should also be removed from the scene
  120275. * @returns the index where the mesh was in the mesh list
  120276. */
  120277. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  120278. /**
  120279. * Add a transform node to the list of scene's transform nodes
  120280. * @param newTransformNode defines the transform node to add
  120281. */
  120282. addTransformNode(newTransformNode: TransformNode): void;
  120283. /**
  120284. * Remove a transform node for the list of scene's transform nodes
  120285. * @param toRemove defines the transform node to remove
  120286. * @returns the index where the transform node was in the transform node list
  120287. */
  120288. removeTransformNode(toRemove: TransformNode): number;
  120289. /**
  120290. * Remove a skeleton for the list of scene's skeletons
  120291. * @param toRemove defines the skeleton to remove
  120292. * @returns the index where the skeleton was in the skeleton list
  120293. */
  120294. removeSkeleton(toRemove: Skeleton): number;
  120295. /**
  120296. * Remove a morph target for the list of scene's morph targets
  120297. * @param toRemove defines the morph target to remove
  120298. * @returns the index where the morph target was in the morph target list
  120299. */
  120300. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  120301. /**
  120302. * Remove a light for the list of scene's lights
  120303. * @param toRemove defines the light to remove
  120304. * @returns the index where the light was in the light list
  120305. */
  120306. removeLight(toRemove: Light): number;
  120307. /**
  120308. * Remove a camera for the list of scene's cameras
  120309. * @param toRemove defines the camera to remove
  120310. * @returns the index where the camera was in the camera list
  120311. */
  120312. removeCamera(toRemove: Camera): number;
  120313. /**
  120314. * Remove a particle system for the list of scene's particle systems
  120315. * @param toRemove defines the particle system to remove
  120316. * @returns the index where the particle system was in the particle system list
  120317. */
  120318. removeParticleSystem(toRemove: IParticleSystem): number;
  120319. /**
  120320. * Remove a animation for the list of scene's animations
  120321. * @param toRemove defines the animation to remove
  120322. * @returns the index where the animation was in the animation list
  120323. */
  120324. removeAnimation(toRemove: Animation): number;
  120325. /**
  120326. * Will stop the animation of the given target
  120327. * @param target - the target
  120328. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  120329. * @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)
  120330. */
  120331. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  120332. /**
  120333. * Removes the given animation group from this scene.
  120334. * @param toRemove The animation group to remove
  120335. * @returns The index of the removed animation group
  120336. */
  120337. removeAnimationGroup(toRemove: AnimationGroup): number;
  120338. /**
  120339. * Removes the given multi-material from this scene.
  120340. * @param toRemove The multi-material to remove
  120341. * @returns The index of the removed multi-material
  120342. */
  120343. removeMultiMaterial(toRemove: MultiMaterial): number;
  120344. /**
  120345. * Removes the given material from this scene.
  120346. * @param toRemove The material to remove
  120347. * @returns The index of the removed material
  120348. */
  120349. removeMaterial(toRemove: Material): number;
  120350. /**
  120351. * Removes the given action manager from this scene.
  120352. * @param toRemove The action manager to remove
  120353. * @returns The index of the removed action manager
  120354. */
  120355. removeActionManager(toRemove: AbstractActionManager): number;
  120356. /**
  120357. * Removes the given texture from this scene.
  120358. * @param toRemove The texture to remove
  120359. * @returns The index of the removed texture
  120360. */
  120361. removeTexture(toRemove: BaseTexture): number;
  120362. /**
  120363. * Adds the given light to this scene
  120364. * @param newLight The light to add
  120365. */
  120366. addLight(newLight: Light): void;
  120367. /**
  120368. * Sorts the list list based on light priorities
  120369. */
  120370. sortLightsByPriority(): void;
  120371. /**
  120372. * Adds the given camera to this scene
  120373. * @param newCamera The camera to add
  120374. */
  120375. addCamera(newCamera: Camera): void;
  120376. /**
  120377. * Adds the given skeleton to this scene
  120378. * @param newSkeleton The skeleton to add
  120379. */
  120380. addSkeleton(newSkeleton: Skeleton): void;
  120381. /**
  120382. * Adds the given particle system to this scene
  120383. * @param newParticleSystem The particle system to add
  120384. */
  120385. addParticleSystem(newParticleSystem: IParticleSystem): void;
  120386. /**
  120387. * Adds the given animation to this scene
  120388. * @param newAnimation The animation to add
  120389. */
  120390. addAnimation(newAnimation: Animation): void;
  120391. /**
  120392. * Adds the given animation group to this scene.
  120393. * @param newAnimationGroup The animation group to add
  120394. */
  120395. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  120396. /**
  120397. * Adds the given multi-material to this scene
  120398. * @param newMultiMaterial The multi-material to add
  120399. */
  120400. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  120401. /**
  120402. * Adds the given material to this scene
  120403. * @param newMaterial The material to add
  120404. */
  120405. addMaterial(newMaterial: Material): void;
  120406. /**
  120407. * Adds the given morph target to this scene
  120408. * @param newMorphTargetManager The morph target to add
  120409. */
  120410. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  120411. /**
  120412. * Adds the given geometry to this scene
  120413. * @param newGeometry The geometry to add
  120414. */
  120415. addGeometry(newGeometry: Geometry): void;
  120416. /**
  120417. * Adds the given action manager to this scene
  120418. * @param newActionManager The action manager to add
  120419. */
  120420. addActionManager(newActionManager: AbstractActionManager): void;
  120421. /**
  120422. * Adds the given texture to this scene.
  120423. * @param newTexture The texture to add
  120424. */
  120425. addTexture(newTexture: BaseTexture): void;
  120426. /**
  120427. * Switch active camera
  120428. * @param newCamera defines the new active camera
  120429. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  120430. */
  120431. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  120432. /**
  120433. * sets the active camera of the scene using its ID
  120434. * @param id defines the camera's ID
  120435. * @return the new active camera or null if none found.
  120436. */
  120437. setActiveCameraByID(id: string): Nullable<Camera>;
  120438. /**
  120439. * sets the active camera of the scene using its name
  120440. * @param name defines the camera's name
  120441. * @returns the new active camera or null if none found.
  120442. */
  120443. setActiveCameraByName(name: string): Nullable<Camera>;
  120444. /**
  120445. * get an animation group using its name
  120446. * @param name defines the material's name
  120447. * @return the animation group or null if none found.
  120448. */
  120449. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  120450. /**
  120451. * Get a material using its unique id
  120452. * @param uniqueId defines the material's unique id
  120453. * @return the material or null if none found.
  120454. */
  120455. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  120456. /**
  120457. * get a material using its id
  120458. * @param id defines the material's ID
  120459. * @return the material or null if none found.
  120460. */
  120461. getMaterialByID(id: string): Nullable<Material>;
  120462. /**
  120463. * Gets a the last added material using a given id
  120464. * @param id defines the material's ID
  120465. * @return the last material with the given id or null if none found.
  120466. */
  120467. getLastMaterialByID(id: string): Nullable<Material>;
  120468. /**
  120469. * Gets a material using its name
  120470. * @param name defines the material's name
  120471. * @return the material or null if none found.
  120472. */
  120473. getMaterialByName(name: string): Nullable<Material>;
  120474. /**
  120475. * Get a texture using its unique id
  120476. * @param uniqueId defines the texture's unique id
  120477. * @return the texture or null if none found.
  120478. */
  120479. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  120480. /**
  120481. * Gets a camera using its id
  120482. * @param id defines the id to look for
  120483. * @returns the camera or null if not found
  120484. */
  120485. getCameraByID(id: string): Nullable<Camera>;
  120486. /**
  120487. * Gets a camera using its unique id
  120488. * @param uniqueId defines the unique id to look for
  120489. * @returns the camera or null if not found
  120490. */
  120491. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  120492. /**
  120493. * Gets a camera using its name
  120494. * @param name defines the camera's name
  120495. * @return the camera or null if none found.
  120496. */
  120497. getCameraByName(name: string): Nullable<Camera>;
  120498. /**
  120499. * Gets a bone using its id
  120500. * @param id defines the bone's id
  120501. * @return the bone or null if not found
  120502. */
  120503. getBoneByID(id: string): Nullable<Bone>;
  120504. /**
  120505. * Gets a bone using its id
  120506. * @param name defines the bone's name
  120507. * @return the bone or null if not found
  120508. */
  120509. getBoneByName(name: string): Nullable<Bone>;
  120510. /**
  120511. * Gets a light node using its name
  120512. * @param name defines the the light's name
  120513. * @return the light or null if none found.
  120514. */
  120515. getLightByName(name: string): Nullable<Light>;
  120516. /**
  120517. * Gets a light node using its id
  120518. * @param id defines the light's id
  120519. * @return the light or null if none found.
  120520. */
  120521. getLightByID(id: string): Nullable<Light>;
  120522. /**
  120523. * Gets a light node using its scene-generated unique ID
  120524. * @param uniqueId defines the light's unique id
  120525. * @return the light or null if none found.
  120526. */
  120527. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  120528. /**
  120529. * Gets a particle system by id
  120530. * @param id defines the particle system id
  120531. * @return the corresponding system or null if none found
  120532. */
  120533. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  120534. /**
  120535. * Gets a geometry using its ID
  120536. * @param id defines the geometry's id
  120537. * @return the geometry or null if none found.
  120538. */
  120539. getGeometryByID(id: string): Nullable<Geometry>;
  120540. private _getGeometryByUniqueID;
  120541. /**
  120542. * Add a new geometry to this scene
  120543. * @param geometry defines the geometry to be added to the scene.
  120544. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  120545. * @return a boolean defining if the geometry was added or not
  120546. */
  120547. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  120548. /**
  120549. * Removes an existing geometry
  120550. * @param geometry defines the geometry to be removed from the scene
  120551. * @return a boolean defining if the geometry was removed or not
  120552. */
  120553. removeGeometry(geometry: Geometry): boolean;
  120554. /**
  120555. * Gets the list of geometries attached to the scene
  120556. * @returns an array of Geometry
  120557. */
  120558. getGeometries(): Geometry[];
  120559. /**
  120560. * Gets the first added mesh found of a given ID
  120561. * @param id defines the id to search for
  120562. * @return the mesh found or null if not found at all
  120563. */
  120564. getMeshByID(id: string): Nullable<AbstractMesh>;
  120565. /**
  120566. * Gets a list of meshes using their id
  120567. * @param id defines the id to search for
  120568. * @returns a list of meshes
  120569. */
  120570. getMeshesByID(id: string): Array<AbstractMesh>;
  120571. /**
  120572. * Gets the first added transform node found of a given ID
  120573. * @param id defines the id to search for
  120574. * @return the found transform node or null if not found at all.
  120575. */
  120576. getTransformNodeByID(id: string): Nullable<TransformNode>;
  120577. /**
  120578. * Gets a transform node with its auto-generated unique id
  120579. * @param uniqueId efines the unique id to search for
  120580. * @return the found transform node or null if not found at all.
  120581. */
  120582. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  120583. /**
  120584. * Gets a list of transform nodes using their id
  120585. * @param id defines the id to search for
  120586. * @returns a list of transform nodes
  120587. */
  120588. getTransformNodesByID(id: string): Array<TransformNode>;
  120589. /**
  120590. * Gets a mesh with its auto-generated unique id
  120591. * @param uniqueId defines the unique id to search for
  120592. * @return the found mesh or null if not found at all.
  120593. */
  120594. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  120595. /**
  120596. * Gets a the last added mesh using a given id
  120597. * @param id defines the id to search for
  120598. * @return the found mesh or null if not found at all.
  120599. */
  120600. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  120601. /**
  120602. * Gets a the last added node (Mesh, Camera, Light) using a given id
  120603. * @param id defines the id to search for
  120604. * @return the found node or null if not found at all
  120605. */
  120606. getLastEntryByID(id: string): Nullable<Node>;
  120607. /**
  120608. * Gets a node (Mesh, Camera, Light) using a given id
  120609. * @param id defines the id to search for
  120610. * @return the found node or null if not found at all
  120611. */
  120612. getNodeByID(id: string): Nullable<Node>;
  120613. /**
  120614. * Gets a node (Mesh, Camera, Light) using a given name
  120615. * @param name defines the name to search for
  120616. * @return the found node or null if not found at all.
  120617. */
  120618. getNodeByName(name: string): Nullable<Node>;
  120619. /**
  120620. * Gets a mesh using a given name
  120621. * @param name defines the name to search for
  120622. * @return the found mesh or null if not found at all.
  120623. */
  120624. getMeshByName(name: string): Nullable<AbstractMesh>;
  120625. /**
  120626. * Gets a transform node using a given name
  120627. * @param name defines the name to search for
  120628. * @return the found transform node or null if not found at all.
  120629. */
  120630. getTransformNodeByName(name: string): Nullable<TransformNode>;
  120631. /**
  120632. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  120633. * @param id defines the id to search for
  120634. * @return the found skeleton or null if not found at all.
  120635. */
  120636. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  120637. /**
  120638. * Gets a skeleton using a given auto generated unique id
  120639. * @param uniqueId defines the unique id to search for
  120640. * @return the found skeleton or null if not found at all.
  120641. */
  120642. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  120643. /**
  120644. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  120645. * @param id defines the id to search for
  120646. * @return the found skeleton or null if not found at all.
  120647. */
  120648. getSkeletonById(id: string): Nullable<Skeleton>;
  120649. /**
  120650. * Gets a skeleton using a given name
  120651. * @param name defines the name to search for
  120652. * @return the found skeleton or null if not found at all.
  120653. */
  120654. getSkeletonByName(name: string): Nullable<Skeleton>;
  120655. /**
  120656. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  120657. * @param id defines the id to search for
  120658. * @return the found morph target manager or null if not found at all.
  120659. */
  120660. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  120661. /**
  120662. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  120663. * @param id defines the id to search for
  120664. * @return the found morph target or null if not found at all.
  120665. */
  120666. getMorphTargetById(id: string): Nullable<MorphTarget>;
  120667. /**
  120668. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  120669. * @param name defines the name to search for
  120670. * @return the found morph target or null if not found at all.
  120671. */
  120672. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  120673. /**
  120674. * Gets a post process using a given name (if many are found, this function will pick the first one)
  120675. * @param name defines the name to search for
  120676. * @return the found post process or null if not found at all.
  120677. */
  120678. getPostProcessByName(name: string): Nullable<PostProcess>;
  120679. /**
  120680. * Gets a boolean indicating if the given mesh is active
  120681. * @param mesh defines the mesh to look for
  120682. * @returns true if the mesh is in the active list
  120683. */
  120684. isActiveMesh(mesh: AbstractMesh): boolean;
  120685. /**
  120686. * Return a unique id as a string which can serve as an identifier for the scene
  120687. */
  120688. get uid(): string;
  120689. /**
  120690. * Add an externaly attached data from its key.
  120691. * This method call will fail and return false, if such key already exists.
  120692. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  120693. * @param key the unique key that identifies the data
  120694. * @param data the data object to associate to the key for this Engine instance
  120695. * @return true if no such key were already present and the data was added successfully, false otherwise
  120696. */
  120697. addExternalData<T>(key: string, data: T): boolean;
  120698. /**
  120699. * Get an externaly attached data from its key
  120700. * @param key the unique key that identifies the data
  120701. * @return the associated data, if present (can be null), or undefined if not present
  120702. */
  120703. getExternalData<T>(key: string): Nullable<T>;
  120704. /**
  120705. * Get an externaly attached data from its key, create it using a factory if it's not already present
  120706. * @param key the unique key that identifies the data
  120707. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  120708. * @return the associated data, can be null if the factory returned null.
  120709. */
  120710. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  120711. /**
  120712. * Remove an externaly attached data from the Engine instance
  120713. * @param key the unique key that identifies the data
  120714. * @return true if the data was successfully removed, false if it doesn't exist
  120715. */
  120716. removeExternalData(key: string): boolean;
  120717. private _evaluateSubMesh;
  120718. /**
  120719. * Clear the processed materials smart array preventing retention point in material dispose.
  120720. */
  120721. freeProcessedMaterials(): void;
  120722. private _preventFreeActiveMeshesAndRenderingGroups;
  120723. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  120724. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  120725. * when disposing several meshes in a row or a hierarchy of meshes.
  120726. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  120727. */
  120728. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  120729. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  120730. /**
  120731. * Clear the active meshes smart array preventing retention point in mesh dispose.
  120732. */
  120733. freeActiveMeshes(): void;
  120734. /**
  120735. * Clear the info related to rendering groups preventing retention points during dispose.
  120736. */
  120737. freeRenderingGroups(): void;
  120738. /** @hidden */
  120739. _isInIntermediateRendering(): boolean;
  120740. /**
  120741. * Lambda returning the list of potentially active meshes.
  120742. */
  120743. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  120744. /**
  120745. * Lambda returning the list of potentially active sub meshes.
  120746. */
  120747. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  120748. /**
  120749. * Lambda returning the list of potentially intersecting sub meshes.
  120750. */
  120751. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  120752. /**
  120753. * Lambda returning the list of potentially colliding sub meshes.
  120754. */
  120755. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  120756. private _activeMeshesFrozen;
  120757. private _skipEvaluateActiveMeshesCompletely;
  120758. /**
  120759. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  120760. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  120761. * @returns the current scene
  120762. */
  120763. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  120764. /**
  120765. * Use this function to restart evaluating active meshes on every frame
  120766. * @returns the current scene
  120767. */
  120768. unfreezeActiveMeshes(): Scene;
  120769. private _evaluateActiveMeshes;
  120770. private _activeMesh;
  120771. /**
  120772. * Update the transform matrix to update from the current active camera
  120773. * @param force defines a boolean used to force the update even if cache is up to date
  120774. */
  120775. updateTransformMatrix(force?: boolean): void;
  120776. private _bindFrameBuffer;
  120777. /** @hidden */
  120778. _allowPostProcessClearColor: boolean;
  120779. /** @hidden */
  120780. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  120781. private _processSubCameras;
  120782. private _checkIntersections;
  120783. /** @hidden */
  120784. _advancePhysicsEngineStep(step: number): void;
  120785. /**
  120786. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  120787. */
  120788. getDeterministicFrameTime: () => number;
  120789. /** @hidden */
  120790. _animate(): void;
  120791. /** Execute all animations (for a frame) */
  120792. animate(): void;
  120793. /**
  120794. * Render the scene
  120795. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  120796. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  120797. */
  120798. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  120799. /**
  120800. * Freeze all materials
  120801. * A frozen material will not be updatable but should be faster to render
  120802. */
  120803. freezeMaterials(): void;
  120804. /**
  120805. * Unfreeze all materials
  120806. * A frozen material will not be updatable but should be faster to render
  120807. */
  120808. unfreezeMaterials(): void;
  120809. /**
  120810. * Releases all held ressources
  120811. */
  120812. dispose(): void;
  120813. /**
  120814. * Gets if the scene is already disposed
  120815. */
  120816. get isDisposed(): boolean;
  120817. /**
  120818. * Call this function to reduce memory footprint of the scene.
  120819. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  120820. */
  120821. clearCachedVertexData(): void;
  120822. /**
  120823. * This function will remove the local cached buffer data from texture.
  120824. * It will save memory but will prevent the texture from being rebuilt
  120825. */
  120826. cleanCachedTextureBuffer(): void;
  120827. /**
  120828. * Get the world extend vectors with an optional filter
  120829. *
  120830. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  120831. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  120832. */
  120833. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  120834. min: Vector3;
  120835. max: Vector3;
  120836. };
  120837. /**
  120838. * Creates a ray that can be used to pick in the scene
  120839. * @param x defines the x coordinate of the origin (on-screen)
  120840. * @param y defines the y coordinate of the origin (on-screen)
  120841. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  120842. * @param camera defines the camera to use for the picking
  120843. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  120844. * @returns a Ray
  120845. */
  120846. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  120847. /**
  120848. * Creates a ray that can be used to pick in the scene
  120849. * @param x defines the x coordinate of the origin (on-screen)
  120850. * @param y defines the y coordinate of the origin (on-screen)
  120851. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  120852. * @param result defines the ray where to store the picking ray
  120853. * @param camera defines the camera to use for the picking
  120854. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  120855. * @returns the current scene
  120856. */
  120857. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  120858. /**
  120859. * Creates a ray that can be used to pick in the scene
  120860. * @param x defines the x coordinate of the origin (on-screen)
  120861. * @param y defines the y coordinate of the origin (on-screen)
  120862. * @param camera defines the camera to use for the picking
  120863. * @returns a Ray
  120864. */
  120865. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  120866. /**
  120867. * Creates a ray that can be used to pick in the scene
  120868. * @param x defines the x coordinate of the origin (on-screen)
  120869. * @param y defines the y coordinate of the origin (on-screen)
  120870. * @param result defines the ray where to store the picking ray
  120871. * @param camera defines the camera to use for the picking
  120872. * @returns the current scene
  120873. */
  120874. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  120875. /** Launch a ray to try to pick a mesh in the scene
  120876. * @param x position on screen
  120877. * @param y position on screen
  120878. * @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
  120879. * @param fastCheck defines if the first intersection will be used (and not the closest)
  120880. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  120881. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120882. * @returns a PickingInfo
  120883. */
  120884. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  120885. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  120886. * @param x position on screen
  120887. * @param y position on screen
  120888. * @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
  120889. * @param fastCheck defines if the first intersection will be used (and not the closest)
  120890. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  120891. * @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)
  120892. */
  120893. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  120894. /** Use the given ray to pick a mesh in the scene
  120895. * @param ray The ray to use to pick meshes
  120896. * @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
  120897. * @param fastCheck defines if the first intersection will be used (and not the closest)
  120898. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120899. * @returns a PickingInfo
  120900. */
  120901. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  120902. /**
  120903. * Launch a ray to try to pick a mesh in the scene
  120904. * @param x X position on screen
  120905. * @param y Y position on screen
  120906. * @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
  120907. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  120908. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120909. * @returns an array of PickingInfo
  120910. */
  120911. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  120912. /**
  120913. * Launch a ray to try to pick a mesh in the scene
  120914. * @param ray Ray to use
  120915. * @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
  120916. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  120917. * @returns an array of PickingInfo
  120918. */
  120919. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  120920. /**
  120921. * Force the value of meshUnderPointer
  120922. * @param mesh defines the mesh to use
  120923. * @param pointerId optional pointer id when using more than one pointer
  120924. */
  120925. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  120926. /**
  120927. * Gets the mesh under the pointer
  120928. * @returns a Mesh or null if no mesh is under the pointer
  120929. */
  120930. getPointerOverMesh(): Nullable<AbstractMesh>;
  120931. /** @hidden */
  120932. _rebuildGeometries(): void;
  120933. /** @hidden */
  120934. _rebuildTextures(): void;
  120935. private _getByTags;
  120936. /**
  120937. * Get a list of meshes by tags
  120938. * @param tagsQuery defines the tags query to use
  120939. * @param forEach defines a predicate used to filter results
  120940. * @returns an array of Mesh
  120941. */
  120942. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  120943. /**
  120944. * Get a list of cameras by tags
  120945. * @param tagsQuery defines the tags query to use
  120946. * @param forEach defines a predicate used to filter results
  120947. * @returns an array of Camera
  120948. */
  120949. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  120950. /**
  120951. * Get a list of lights by tags
  120952. * @param tagsQuery defines the tags query to use
  120953. * @param forEach defines a predicate used to filter results
  120954. * @returns an array of Light
  120955. */
  120956. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  120957. /**
  120958. * Get a list of materials by tags
  120959. * @param tagsQuery defines the tags query to use
  120960. * @param forEach defines a predicate used to filter results
  120961. * @returns an array of Material
  120962. */
  120963. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  120964. /**
  120965. * Get a list of transform nodes by tags
  120966. * @param tagsQuery defines the tags query to use
  120967. * @param forEach defines a predicate used to filter results
  120968. * @returns an array of TransformNode
  120969. */
  120970. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  120971. /**
  120972. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  120973. * This allowed control for front to back rendering or reversly depending of the special needs.
  120974. *
  120975. * @param renderingGroupId The rendering group id corresponding to its index
  120976. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  120977. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  120978. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  120979. */
  120980. 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;
  120981. /**
  120982. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  120983. *
  120984. * @param renderingGroupId The rendering group id corresponding to its index
  120985. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  120986. * @param depth Automatically clears depth between groups if true and autoClear is true.
  120987. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  120988. */
  120989. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  120990. /**
  120991. * Gets the current auto clear configuration for one rendering group of the rendering
  120992. * manager.
  120993. * @param index the rendering group index to get the information for
  120994. * @returns The auto clear setup for the requested rendering group
  120995. */
  120996. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  120997. private _blockMaterialDirtyMechanism;
  120998. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  120999. get blockMaterialDirtyMechanism(): boolean;
  121000. set blockMaterialDirtyMechanism(value: boolean);
  121001. /**
  121002. * Will flag all materials as dirty to trigger new shader compilation
  121003. * @param flag defines the flag used to specify which material part must be marked as dirty
  121004. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  121005. */
  121006. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  121007. /** @hidden */
  121008. _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;
  121009. /** @hidden */
  121010. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121011. /** @hidden */
  121012. _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;
  121013. /** @hidden */
  121014. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  121015. /** @hidden */
  121016. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  121017. /** @hidden */
  121018. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121019. }
  121020. }
  121021. declare module BABYLON {
  121022. /**
  121023. * Set of assets to keep when moving a scene into an asset container.
  121024. */
  121025. export class KeepAssets extends AbstractScene {
  121026. }
  121027. /**
  121028. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  121029. */
  121030. export class InstantiatedEntries {
  121031. /**
  121032. * List of new root nodes (eg. nodes with no parent)
  121033. */
  121034. rootNodes: TransformNode[];
  121035. /**
  121036. * List of new skeletons
  121037. */
  121038. skeletons: Skeleton[];
  121039. /**
  121040. * List of new animation groups
  121041. */
  121042. animationGroups: AnimationGroup[];
  121043. }
  121044. /**
  121045. * Container with a set of assets that can be added or removed from a scene.
  121046. */
  121047. export class AssetContainer extends AbstractScene {
  121048. private _wasAddedToScene;
  121049. /**
  121050. * The scene the AssetContainer belongs to.
  121051. */
  121052. scene: Scene;
  121053. /**
  121054. * Instantiates an AssetContainer.
  121055. * @param scene The scene the AssetContainer belongs to.
  121056. */
  121057. constructor(scene: Scene);
  121058. /**
  121059. * Instantiate or clone all meshes and add the new ones to the scene.
  121060. * Skeletons and animation groups will all be cloned
  121061. * @param nameFunction defines an optional function used to get new names for clones
  121062. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  121063. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  121064. */
  121065. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  121066. /**
  121067. * Adds all the assets from the container to the scene.
  121068. */
  121069. addAllToScene(): void;
  121070. /**
  121071. * Removes all the assets in the container from the scene
  121072. */
  121073. removeAllFromScene(): void;
  121074. /**
  121075. * Disposes all the assets in the container
  121076. */
  121077. dispose(): void;
  121078. private _moveAssets;
  121079. /**
  121080. * Removes all the assets contained in the scene and adds them to the container.
  121081. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  121082. */
  121083. moveAllFromScene(keepAssets?: KeepAssets): void;
  121084. /**
  121085. * 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.
  121086. * @returns the root mesh
  121087. */
  121088. createRootMesh(): Mesh;
  121089. /**
  121090. * Merge animations (direct and animation groups) from this asset container into a scene
  121091. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  121092. * @param animatables set of animatables to retarget to a node from the scene
  121093. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  121094. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  121095. */
  121096. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  121097. }
  121098. }
  121099. declare module BABYLON {
  121100. /**
  121101. * Defines how the parser contract is defined.
  121102. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  121103. */
  121104. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  121105. /**
  121106. * Defines how the individual parser contract is defined.
  121107. * These parser can parse an individual asset
  121108. */
  121109. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  121110. /**
  121111. * Base class of the scene acting as a container for the different elements composing a scene.
  121112. * This class is dynamically extended by the different components of the scene increasing
  121113. * flexibility and reducing coupling
  121114. */
  121115. export abstract class AbstractScene {
  121116. /**
  121117. * Stores the list of available parsers in the application.
  121118. */
  121119. private static _BabylonFileParsers;
  121120. /**
  121121. * Stores the list of available individual parsers in the application.
  121122. */
  121123. private static _IndividualBabylonFileParsers;
  121124. /**
  121125. * Adds a parser in the list of available ones
  121126. * @param name Defines the name of the parser
  121127. * @param parser Defines the parser to add
  121128. */
  121129. static AddParser(name: string, parser: BabylonFileParser): void;
  121130. /**
  121131. * Gets a general parser from the list of avaialble ones
  121132. * @param name Defines the name of the parser
  121133. * @returns the requested parser or null
  121134. */
  121135. static GetParser(name: string): Nullable<BabylonFileParser>;
  121136. /**
  121137. * Adds n individual parser in the list of available ones
  121138. * @param name Defines the name of the parser
  121139. * @param parser Defines the parser to add
  121140. */
  121141. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  121142. /**
  121143. * Gets an individual parser from the list of avaialble ones
  121144. * @param name Defines the name of the parser
  121145. * @returns the requested parser or null
  121146. */
  121147. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  121148. /**
  121149. * Parser json data and populate both a scene and its associated container object
  121150. * @param jsonData Defines the data to parse
  121151. * @param scene Defines the scene to parse the data for
  121152. * @param container Defines the container attached to the parsing sequence
  121153. * @param rootUrl Defines the root url of the data
  121154. */
  121155. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  121156. /**
  121157. * Gets the list of root nodes (ie. nodes with no parent)
  121158. */
  121159. rootNodes: Node[];
  121160. /** All of the cameras added to this scene
  121161. * @see https://doc.babylonjs.com/babylon101/cameras
  121162. */
  121163. cameras: Camera[];
  121164. /**
  121165. * All of the lights added to this scene
  121166. * @see https://doc.babylonjs.com/babylon101/lights
  121167. */
  121168. lights: Light[];
  121169. /**
  121170. * All of the (abstract) meshes added to this scene
  121171. */
  121172. meshes: AbstractMesh[];
  121173. /**
  121174. * The list of skeletons added to the scene
  121175. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  121176. */
  121177. skeletons: Skeleton[];
  121178. /**
  121179. * All of the particle systems added to this scene
  121180. * @see https://doc.babylonjs.com/babylon101/particles
  121181. */
  121182. particleSystems: IParticleSystem[];
  121183. /**
  121184. * Gets a list of Animations associated with the scene
  121185. */
  121186. animations: Animation[];
  121187. /**
  121188. * All of the animation groups added to this scene
  121189. * @see https://doc.babylonjs.com/how_to/group
  121190. */
  121191. animationGroups: AnimationGroup[];
  121192. /**
  121193. * All of the multi-materials added to this scene
  121194. * @see https://doc.babylonjs.com/how_to/multi_materials
  121195. */
  121196. multiMaterials: MultiMaterial[];
  121197. /**
  121198. * All of the materials added to this scene
  121199. * In the context of a Scene, it is not supposed to be modified manually.
  121200. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  121201. * Note also that the order of the Material within the array is not significant and might change.
  121202. * @see https://doc.babylonjs.com/babylon101/materials
  121203. */
  121204. materials: Material[];
  121205. /**
  121206. * The list of morph target managers added to the scene
  121207. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  121208. */
  121209. morphTargetManagers: MorphTargetManager[];
  121210. /**
  121211. * The list of geometries used in the scene.
  121212. */
  121213. geometries: Geometry[];
  121214. /**
  121215. * All of the tranform nodes added to this scene
  121216. * In the context of a Scene, it is not supposed to be modified manually.
  121217. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  121218. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  121219. * @see https://doc.babylonjs.com/how_to/transformnode
  121220. */
  121221. transformNodes: TransformNode[];
  121222. /**
  121223. * ActionManagers available on the scene.
  121224. */
  121225. actionManagers: AbstractActionManager[];
  121226. /**
  121227. * Textures to keep.
  121228. */
  121229. textures: BaseTexture[];
  121230. /** @hidden */
  121231. protected _environmentTexture: Nullable<BaseTexture>;
  121232. /**
  121233. * Texture used in all pbr material as the reflection texture.
  121234. * As in the majority of the scene they are the same (exception for multi room and so on),
  121235. * this is easier to reference from here than from all the materials.
  121236. */
  121237. get environmentTexture(): Nullable<BaseTexture>;
  121238. set environmentTexture(value: Nullable<BaseTexture>);
  121239. /**
  121240. * The list of postprocesses added to the scene
  121241. */
  121242. postProcesses: PostProcess[];
  121243. /**
  121244. * @returns all meshes, lights, cameras, transformNodes and bones
  121245. */
  121246. getNodes(): Array<Node>;
  121247. }
  121248. }
  121249. declare module BABYLON {
  121250. /**
  121251. * Interface used to define options for Sound class
  121252. */
  121253. export interface ISoundOptions {
  121254. /**
  121255. * Does the sound autoplay once loaded.
  121256. */
  121257. autoplay?: boolean;
  121258. /**
  121259. * Does the sound loop after it finishes playing once.
  121260. */
  121261. loop?: boolean;
  121262. /**
  121263. * Sound's volume
  121264. */
  121265. volume?: number;
  121266. /**
  121267. * Is it a spatial sound?
  121268. */
  121269. spatialSound?: boolean;
  121270. /**
  121271. * Maximum distance to hear that sound
  121272. */
  121273. maxDistance?: number;
  121274. /**
  121275. * Uses user defined attenuation function
  121276. */
  121277. useCustomAttenuation?: boolean;
  121278. /**
  121279. * Define the roll off factor of spatial sounds.
  121280. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121281. */
  121282. rolloffFactor?: number;
  121283. /**
  121284. * Define the reference distance the sound should be heard perfectly.
  121285. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121286. */
  121287. refDistance?: number;
  121288. /**
  121289. * Define the distance attenuation model the sound will follow.
  121290. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121291. */
  121292. distanceModel?: string;
  121293. /**
  121294. * Defines the playback speed (1 by default)
  121295. */
  121296. playbackRate?: number;
  121297. /**
  121298. * Defines if the sound is from a streaming source
  121299. */
  121300. streaming?: boolean;
  121301. /**
  121302. * Defines an optional length (in seconds) inside the sound file
  121303. */
  121304. length?: number;
  121305. /**
  121306. * Defines an optional offset (in seconds) inside the sound file
  121307. */
  121308. offset?: number;
  121309. /**
  121310. * If true, URLs will not be required to state the audio file codec to use.
  121311. */
  121312. skipCodecCheck?: boolean;
  121313. }
  121314. /**
  121315. * Defines a sound that can be played in the application.
  121316. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  121317. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121318. */
  121319. export class Sound {
  121320. /**
  121321. * The name of the sound in the scene.
  121322. */
  121323. name: string;
  121324. /**
  121325. * Does the sound autoplay once loaded.
  121326. */
  121327. autoplay: boolean;
  121328. /**
  121329. * Does the sound loop after it finishes playing once.
  121330. */
  121331. loop: boolean;
  121332. /**
  121333. * Does the sound use a custom attenuation curve to simulate the falloff
  121334. * happening when the source gets further away from the camera.
  121335. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  121336. */
  121337. useCustomAttenuation: boolean;
  121338. /**
  121339. * The sound track id this sound belongs to.
  121340. */
  121341. soundTrackId: number;
  121342. /**
  121343. * Is this sound currently played.
  121344. */
  121345. isPlaying: boolean;
  121346. /**
  121347. * Is this sound currently paused.
  121348. */
  121349. isPaused: boolean;
  121350. /**
  121351. * Does this sound enables spatial sound.
  121352. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121353. */
  121354. spatialSound: boolean;
  121355. /**
  121356. * Define the reference distance the sound should be heard perfectly.
  121357. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121358. */
  121359. refDistance: number;
  121360. /**
  121361. * Define the roll off factor of spatial sounds.
  121362. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121363. */
  121364. rolloffFactor: number;
  121365. /**
  121366. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  121367. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121368. */
  121369. maxDistance: number;
  121370. /**
  121371. * Define the distance attenuation model the sound will follow.
  121372. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121373. */
  121374. distanceModel: string;
  121375. /**
  121376. * @hidden
  121377. * Back Compat
  121378. **/
  121379. onended: () => any;
  121380. /**
  121381. * Gets or sets an object used to store user defined information for the sound.
  121382. */
  121383. metadata: any;
  121384. /**
  121385. * Observable event when the current playing sound finishes.
  121386. */
  121387. onEndedObservable: Observable<Sound>;
  121388. private _panningModel;
  121389. private _playbackRate;
  121390. private _streaming;
  121391. private _startTime;
  121392. private _startOffset;
  121393. private _position;
  121394. /** @hidden */
  121395. _positionInEmitterSpace: boolean;
  121396. private _localDirection;
  121397. private _volume;
  121398. private _isReadyToPlay;
  121399. private _isDirectional;
  121400. private _readyToPlayCallback;
  121401. private _audioBuffer;
  121402. private _soundSource;
  121403. private _streamingSource;
  121404. private _soundPanner;
  121405. private _soundGain;
  121406. private _inputAudioNode;
  121407. private _outputAudioNode;
  121408. private _coneInnerAngle;
  121409. private _coneOuterAngle;
  121410. private _coneOuterGain;
  121411. private _scene;
  121412. private _connectedTransformNode;
  121413. private _customAttenuationFunction;
  121414. private _registerFunc;
  121415. private _isOutputConnected;
  121416. private _htmlAudioElement;
  121417. private _urlType;
  121418. private _length?;
  121419. private _offset?;
  121420. /** @hidden */
  121421. static _SceneComponentInitialization: (scene: Scene) => void;
  121422. /**
  121423. * Create a sound and attach it to a scene
  121424. * @param name Name of your sound
  121425. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  121426. * @param scene defines the scene the sound belongs to
  121427. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  121428. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  121429. */
  121430. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  121431. /**
  121432. * Release the sound and its associated resources
  121433. */
  121434. dispose(): void;
  121435. /**
  121436. * Gets if the sounds is ready to be played or not.
  121437. * @returns true if ready, otherwise false
  121438. */
  121439. isReady(): boolean;
  121440. private _soundLoaded;
  121441. /**
  121442. * Sets the data of the sound from an audiobuffer
  121443. * @param audioBuffer The audioBuffer containing the data
  121444. */
  121445. setAudioBuffer(audioBuffer: AudioBuffer): void;
  121446. /**
  121447. * Updates the current sounds options such as maxdistance, loop...
  121448. * @param options A JSON object containing values named as the object properties
  121449. */
  121450. updateOptions(options: ISoundOptions): void;
  121451. private _createSpatialParameters;
  121452. private _updateSpatialParameters;
  121453. /**
  121454. * Switch the panning model to HRTF:
  121455. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  121456. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121457. */
  121458. switchPanningModelToHRTF(): void;
  121459. /**
  121460. * Switch the panning model to Equal Power:
  121461. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  121462. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121463. */
  121464. switchPanningModelToEqualPower(): void;
  121465. private _switchPanningModel;
  121466. /**
  121467. * Connect this sound to a sound track audio node like gain...
  121468. * @param soundTrackAudioNode the sound track audio node to connect to
  121469. */
  121470. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  121471. /**
  121472. * Transform this sound into a directional source
  121473. * @param coneInnerAngle Size of the inner cone in degree
  121474. * @param coneOuterAngle Size of the outer cone in degree
  121475. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  121476. */
  121477. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  121478. /**
  121479. * Gets or sets the inner angle for the directional cone.
  121480. */
  121481. get directionalConeInnerAngle(): number;
  121482. /**
  121483. * Gets or sets the inner angle for the directional cone.
  121484. */
  121485. set directionalConeInnerAngle(value: number);
  121486. /**
  121487. * Gets or sets the outer angle for the directional cone.
  121488. */
  121489. get directionalConeOuterAngle(): number;
  121490. /**
  121491. * Gets or sets the outer angle for the directional cone.
  121492. */
  121493. set directionalConeOuterAngle(value: number);
  121494. /**
  121495. * Sets the position of the emitter if spatial sound is enabled
  121496. * @param newPosition Defines the new posisiton
  121497. */
  121498. setPosition(newPosition: Vector3): void;
  121499. /**
  121500. * Sets the local direction of the emitter if spatial sound is enabled
  121501. * @param newLocalDirection Defines the new local direction
  121502. */
  121503. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  121504. private _updateDirection;
  121505. /** @hidden */
  121506. updateDistanceFromListener(): void;
  121507. /**
  121508. * Sets a new custom attenuation function for the sound.
  121509. * @param callback Defines the function used for the attenuation
  121510. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  121511. */
  121512. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  121513. /**
  121514. * Play the sound
  121515. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  121516. * @param offset (optional) Start the sound at a specific time in seconds
  121517. * @param length (optional) Sound duration (in seconds)
  121518. */
  121519. play(time?: number, offset?: number, length?: number): void;
  121520. private _onended;
  121521. /**
  121522. * Stop the sound
  121523. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  121524. */
  121525. stop(time?: number): void;
  121526. /**
  121527. * Put the sound in pause
  121528. */
  121529. pause(): void;
  121530. /**
  121531. * Sets a dedicated volume for this sounds
  121532. * @param newVolume Define the new volume of the sound
  121533. * @param time Define time for gradual change to new volume
  121534. */
  121535. setVolume(newVolume: number, time?: number): void;
  121536. /**
  121537. * Set the sound play back rate
  121538. * @param newPlaybackRate Define the playback rate the sound should be played at
  121539. */
  121540. setPlaybackRate(newPlaybackRate: number): void;
  121541. /**
  121542. * Gets the volume of the sound.
  121543. * @returns the volume of the sound
  121544. */
  121545. getVolume(): number;
  121546. /**
  121547. * Attach the sound to a dedicated mesh
  121548. * @param transformNode The transform node to connect the sound with
  121549. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  121550. */
  121551. attachToMesh(transformNode: TransformNode): void;
  121552. /**
  121553. * Detach the sound from the previously attached mesh
  121554. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  121555. */
  121556. detachFromMesh(): void;
  121557. private _onRegisterAfterWorldMatrixUpdate;
  121558. /**
  121559. * Clone the current sound in the scene.
  121560. * @returns the new sound clone
  121561. */
  121562. clone(): Nullable<Sound>;
  121563. /**
  121564. * Gets the current underlying audio buffer containing the data
  121565. * @returns the audio buffer
  121566. */
  121567. getAudioBuffer(): Nullable<AudioBuffer>;
  121568. /**
  121569. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  121570. * @returns the source node
  121571. */
  121572. getSoundSource(): Nullable<AudioBufferSourceNode>;
  121573. /**
  121574. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  121575. * @returns the gain node
  121576. */
  121577. getSoundGain(): Nullable<GainNode>;
  121578. /**
  121579. * Serializes the Sound in a JSON representation
  121580. * @returns the JSON representation of the sound
  121581. */
  121582. serialize(): any;
  121583. /**
  121584. * Parse a JSON representation of a sound to innstantiate in a given scene
  121585. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  121586. * @param scene Define the scene the new parsed sound should be created in
  121587. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  121588. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  121589. * @returns the newly parsed sound
  121590. */
  121591. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  121592. }
  121593. }
  121594. declare module BABYLON {
  121595. /**
  121596. * This defines an action helpful to play a defined sound on a triggered action.
  121597. */
  121598. export class PlaySoundAction extends Action {
  121599. private _sound;
  121600. /**
  121601. * Instantiate the action
  121602. * @param triggerOptions defines the trigger options
  121603. * @param sound defines the sound to play
  121604. * @param condition defines the trigger related conditions
  121605. */
  121606. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  121607. /** @hidden */
  121608. _prepare(): void;
  121609. /**
  121610. * Execute the action and play the sound.
  121611. */
  121612. execute(): void;
  121613. /**
  121614. * Serializes the actions and its related information.
  121615. * @param parent defines the object to serialize in
  121616. * @returns the serialized object
  121617. */
  121618. serialize(parent: any): any;
  121619. }
  121620. /**
  121621. * This defines an action helpful to stop a defined sound on a triggered action.
  121622. */
  121623. export class StopSoundAction extends Action {
  121624. private _sound;
  121625. /**
  121626. * Instantiate the action
  121627. * @param triggerOptions defines the trigger options
  121628. * @param sound defines the sound to stop
  121629. * @param condition defines the trigger related conditions
  121630. */
  121631. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  121632. /** @hidden */
  121633. _prepare(): void;
  121634. /**
  121635. * Execute the action and stop the sound.
  121636. */
  121637. execute(): void;
  121638. /**
  121639. * Serializes the actions and its related information.
  121640. * @param parent defines the object to serialize in
  121641. * @returns the serialized object
  121642. */
  121643. serialize(parent: any): any;
  121644. }
  121645. }
  121646. declare module BABYLON {
  121647. /**
  121648. * This defines an action responsible to change the value of a property
  121649. * by interpolating between its current value and the newly set one once triggered.
  121650. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  121651. */
  121652. export class InterpolateValueAction extends Action {
  121653. /**
  121654. * Defines the path of the property where the value should be interpolated
  121655. */
  121656. propertyPath: string;
  121657. /**
  121658. * Defines the target value at the end of the interpolation.
  121659. */
  121660. value: any;
  121661. /**
  121662. * Defines the time it will take for the property to interpolate to the value.
  121663. */
  121664. duration: number;
  121665. /**
  121666. * Defines if the other scene animations should be stopped when the action has been triggered
  121667. */
  121668. stopOtherAnimations?: boolean;
  121669. /**
  121670. * Defines a callback raised once the interpolation animation has been done.
  121671. */
  121672. onInterpolationDone?: () => void;
  121673. /**
  121674. * Observable triggered once the interpolation animation has been done.
  121675. */
  121676. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  121677. private _target;
  121678. private _effectiveTarget;
  121679. private _property;
  121680. /**
  121681. * Instantiate the action
  121682. * @param triggerOptions defines the trigger options
  121683. * @param target defines the object containing the value to interpolate
  121684. * @param propertyPath defines the path to the property in the target object
  121685. * @param value defines the target value at the end of the interpolation
  121686. * @param duration deines the time it will take for the property to interpolate to the value.
  121687. * @param condition defines the trigger related conditions
  121688. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  121689. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  121690. */
  121691. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  121692. /** @hidden */
  121693. _prepare(): void;
  121694. /**
  121695. * Execute the action starts the value interpolation.
  121696. */
  121697. execute(): void;
  121698. /**
  121699. * Serializes the actions and its related information.
  121700. * @param parent defines the object to serialize in
  121701. * @returns the serialized object
  121702. */
  121703. serialize(parent: any): any;
  121704. }
  121705. }
  121706. declare module BABYLON {
  121707. /**
  121708. * Options allowed during the creation of a sound track.
  121709. */
  121710. export interface ISoundTrackOptions {
  121711. /**
  121712. * The volume the sound track should take during creation
  121713. */
  121714. volume?: number;
  121715. /**
  121716. * Define if the sound track is the main sound track of the scene
  121717. */
  121718. mainTrack?: boolean;
  121719. }
  121720. /**
  121721. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  121722. * It will be also used in a future release to apply effects on a specific track.
  121723. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  121724. */
  121725. export class SoundTrack {
  121726. /**
  121727. * The unique identifier of the sound track in the scene.
  121728. */
  121729. id: number;
  121730. /**
  121731. * The list of sounds included in the sound track.
  121732. */
  121733. soundCollection: Array<Sound>;
  121734. private _outputAudioNode;
  121735. private _scene;
  121736. private _connectedAnalyser;
  121737. private _options;
  121738. private _isInitialized;
  121739. /**
  121740. * Creates a new sound track.
  121741. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  121742. * @param scene Define the scene the sound track belongs to
  121743. * @param options
  121744. */
  121745. constructor(scene: Scene, options?: ISoundTrackOptions);
  121746. private _initializeSoundTrackAudioGraph;
  121747. /**
  121748. * Release the sound track and its associated resources
  121749. */
  121750. dispose(): void;
  121751. /**
  121752. * Adds a sound to this sound track
  121753. * @param sound define the cound to add
  121754. * @ignoreNaming
  121755. */
  121756. AddSound(sound: Sound): void;
  121757. /**
  121758. * Removes a sound to this sound track
  121759. * @param sound define the cound to remove
  121760. * @ignoreNaming
  121761. */
  121762. RemoveSound(sound: Sound): void;
  121763. /**
  121764. * Set a global volume for the full sound track.
  121765. * @param newVolume Define the new volume of the sound track
  121766. */
  121767. setVolume(newVolume: number): void;
  121768. /**
  121769. * Switch the panning model to HRTF:
  121770. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  121771. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121772. */
  121773. switchPanningModelToHRTF(): void;
  121774. /**
  121775. * Switch the panning model to Equal Power:
  121776. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  121777. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121778. */
  121779. switchPanningModelToEqualPower(): void;
  121780. /**
  121781. * Connect the sound track to an audio analyser allowing some amazing
  121782. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  121783. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  121784. * @param analyser The analyser to connect to the engine
  121785. */
  121786. connectToAnalyser(analyser: Analyser): void;
  121787. }
  121788. }
  121789. declare module BABYLON {
  121790. interface AbstractScene {
  121791. /**
  121792. * The list of sounds used in the scene.
  121793. */
  121794. sounds: Nullable<Array<Sound>>;
  121795. }
  121796. interface Scene {
  121797. /**
  121798. * @hidden
  121799. * Backing field
  121800. */
  121801. _mainSoundTrack: SoundTrack;
  121802. /**
  121803. * The main sound track played by the scene.
  121804. * It cotains your primary collection of sounds.
  121805. */
  121806. mainSoundTrack: SoundTrack;
  121807. /**
  121808. * The list of sound tracks added to the scene
  121809. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121810. */
  121811. soundTracks: Nullable<Array<SoundTrack>>;
  121812. /**
  121813. * Gets a sound using a given name
  121814. * @param name defines the name to search for
  121815. * @return the found sound or null if not found at all.
  121816. */
  121817. getSoundByName(name: string): Nullable<Sound>;
  121818. /**
  121819. * Gets or sets if audio support is enabled
  121820. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121821. */
  121822. audioEnabled: boolean;
  121823. /**
  121824. * Gets or sets if audio will be output to headphones
  121825. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121826. */
  121827. headphone: boolean;
  121828. /**
  121829. * Gets or sets custom audio listener position provider
  121830. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121831. */
  121832. audioListenerPositionProvider: Nullable<() => Vector3>;
  121833. /**
  121834. * Gets or sets a refresh rate when using 3D audio positioning
  121835. */
  121836. audioPositioningRefreshRate: number;
  121837. }
  121838. /**
  121839. * Defines the sound scene component responsible to manage any sounds
  121840. * in a given scene.
  121841. */
  121842. export class AudioSceneComponent implements ISceneSerializableComponent {
  121843. private static _CameraDirectionLH;
  121844. private static _CameraDirectionRH;
  121845. /**
  121846. * The component name helpfull to identify the component in the list of scene components.
  121847. */
  121848. readonly name: string;
  121849. /**
  121850. * The scene the component belongs to.
  121851. */
  121852. scene: Scene;
  121853. private _audioEnabled;
  121854. /**
  121855. * Gets whether audio is enabled or not.
  121856. * Please use related enable/disable method to switch state.
  121857. */
  121858. get audioEnabled(): boolean;
  121859. private _headphone;
  121860. /**
  121861. * Gets whether audio is outputing to headphone or not.
  121862. * Please use the according Switch methods to change output.
  121863. */
  121864. get headphone(): boolean;
  121865. /**
  121866. * Gets or sets a refresh rate when using 3D audio positioning
  121867. */
  121868. audioPositioningRefreshRate: number;
  121869. private _audioListenerPositionProvider;
  121870. /**
  121871. * Gets the current audio listener position provider
  121872. */
  121873. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  121874. /**
  121875. * Sets a custom listener position for all sounds in the scene
  121876. * By default, this is the position of the first active camera
  121877. */
  121878. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  121879. /**
  121880. * Creates a new instance of the component for the given scene
  121881. * @param scene Defines the scene to register the component in
  121882. */
  121883. constructor(scene: Scene);
  121884. /**
  121885. * Registers the component in a given scene
  121886. */
  121887. register(): void;
  121888. /**
  121889. * Rebuilds the elements related to this component in case of
  121890. * context lost for instance.
  121891. */
  121892. rebuild(): void;
  121893. /**
  121894. * Serializes the component data to the specified json object
  121895. * @param serializationObject The object to serialize to
  121896. */
  121897. serialize(serializationObject: any): void;
  121898. /**
  121899. * Adds all the elements from the container to the scene
  121900. * @param container the container holding the elements
  121901. */
  121902. addFromContainer(container: AbstractScene): void;
  121903. /**
  121904. * Removes all the elements in the container from the scene
  121905. * @param container contains the elements to remove
  121906. * @param dispose if the removed element should be disposed (default: false)
  121907. */
  121908. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  121909. /**
  121910. * Disposes the component and the associated ressources.
  121911. */
  121912. dispose(): void;
  121913. /**
  121914. * Disables audio in the associated scene.
  121915. */
  121916. disableAudio(): void;
  121917. /**
  121918. * Enables audio in the associated scene.
  121919. */
  121920. enableAudio(): void;
  121921. /**
  121922. * Switch audio to headphone output.
  121923. */
  121924. switchAudioModeForHeadphones(): void;
  121925. /**
  121926. * Switch audio to normal speakers.
  121927. */
  121928. switchAudioModeForNormalSpeakers(): void;
  121929. private _cachedCameraDirection;
  121930. private _cachedCameraPosition;
  121931. private _lastCheck;
  121932. private _afterRender;
  121933. }
  121934. }
  121935. declare module BABYLON {
  121936. /**
  121937. * Wraps one or more Sound objects and selects one with random weight for playback.
  121938. */
  121939. export class WeightedSound {
  121940. /** When true a Sound will be selected and played when the current playing Sound completes. */
  121941. loop: boolean;
  121942. private _coneInnerAngle;
  121943. private _coneOuterAngle;
  121944. private _volume;
  121945. /** A Sound is currently playing. */
  121946. isPlaying: boolean;
  121947. /** A Sound is currently paused. */
  121948. isPaused: boolean;
  121949. private _sounds;
  121950. private _weights;
  121951. private _currentIndex?;
  121952. /**
  121953. * Creates a new WeightedSound from the list of sounds given.
  121954. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  121955. * @param sounds Array of Sounds that will be selected from.
  121956. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  121957. */
  121958. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  121959. /**
  121960. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  121961. */
  121962. get directionalConeInnerAngle(): number;
  121963. /**
  121964. * The size of cone in degress for a directional sound in which there will be no attenuation.
  121965. */
  121966. set directionalConeInnerAngle(value: number);
  121967. /**
  121968. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  121969. * Listener angles between innerAngle and outerAngle will falloff linearly.
  121970. */
  121971. get directionalConeOuterAngle(): number;
  121972. /**
  121973. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  121974. * Listener angles between innerAngle and outerAngle will falloff linearly.
  121975. */
  121976. set directionalConeOuterAngle(value: number);
  121977. /**
  121978. * Playback volume.
  121979. */
  121980. get volume(): number;
  121981. /**
  121982. * Playback volume.
  121983. */
  121984. set volume(value: number);
  121985. private _onended;
  121986. /**
  121987. * Suspend playback
  121988. */
  121989. pause(): void;
  121990. /**
  121991. * Stop playback
  121992. */
  121993. stop(): void;
  121994. /**
  121995. * Start playback.
  121996. * @param startOffset Position the clip head at a specific time in seconds.
  121997. */
  121998. play(startOffset?: number): void;
  121999. }
  122000. }
  122001. declare module BABYLON {
  122002. /**
  122003. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  122004. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  122005. */
  122006. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  122007. /**
  122008. * Gets the name of the behavior.
  122009. */
  122010. get name(): string;
  122011. /**
  122012. * The easing function used by animations
  122013. */
  122014. static EasingFunction: BackEase;
  122015. /**
  122016. * The easing mode used by animations
  122017. */
  122018. static EasingMode: number;
  122019. /**
  122020. * The duration of the animation, in milliseconds
  122021. */
  122022. transitionDuration: number;
  122023. /**
  122024. * Length of the distance animated by the transition when lower radius is reached
  122025. */
  122026. lowerRadiusTransitionRange: number;
  122027. /**
  122028. * Length of the distance animated by the transition when upper radius is reached
  122029. */
  122030. upperRadiusTransitionRange: number;
  122031. private _autoTransitionRange;
  122032. /**
  122033. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  122034. */
  122035. get autoTransitionRange(): boolean;
  122036. /**
  122037. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  122038. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  122039. */
  122040. set autoTransitionRange(value: boolean);
  122041. private _attachedCamera;
  122042. private _onAfterCheckInputsObserver;
  122043. private _onMeshTargetChangedObserver;
  122044. /**
  122045. * Initializes the behavior.
  122046. */
  122047. init(): void;
  122048. /**
  122049. * Attaches the behavior to its arc rotate camera.
  122050. * @param camera Defines the camera to attach the behavior to
  122051. */
  122052. attach(camera: ArcRotateCamera): void;
  122053. /**
  122054. * Detaches the behavior from its current arc rotate camera.
  122055. */
  122056. detach(): void;
  122057. private _radiusIsAnimating;
  122058. private _radiusBounceTransition;
  122059. private _animatables;
  122060. private _cachedWheelPrecision;
  122061. /**
  122062. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  122063. * @param radiusLimit The limit to check against.
  122064. * @return Bool to indicate if at limit.
  122065. */
  122066. private _isRadiusAtLimit;
  122067. /**
  122068. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  122069. * @param radiusDelta The delta by which to animate to. Can be negative.
  122070. */
  122071. private _applyBoundRadiusAnimation;
  122072. /**
  122073. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  122074. */
  122075. protected _clearAnimationLocks(): void;
  122076. /**
  122077. * Stops and removes all animations that have been applied to the camera
  122078. */
  122079. stopAllAnimations(): void;
  122080. }
  122081. }
  122082. declare module BABYLON {
  122083. /**
  122084. * 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.
  122085. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  122086. */
  122087. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  122088. /**
  122089. * Gets the name of the behavior.
  122090. */
  122091. get name(): string;
  122092. private _mode;
  122093. private _radiusScale;
  122094. private _positionScale;
  122095. private _defaultElevation;
  122096. private _elevationReturnTime;
  122097. private _elevationReturnWaitTime;
  122098. private _zoomStopsAnimation;
  122099. private _framingTime;
  122100. /**
  122101. * The easing function used by animations
  122102. */
  122103. static EasingFunction: ExponentialEase;
  122104. /**
  122105. * The easing mode used by animations
  122106. */
  122107. static EasingMode: number;
  122108. /**
  122109. * Sets the current mode used by the behavior
  122110. */
  122111. set mode(mode: number);
  122112. /**
  122113. * Gets current mode used by the behavior.
  122114. */
  122115. get mode(): number;
  122116. /**
  122117. * Sets the scale applied to the radius (1 by default)
  122118. */
  122119. set radiusScale(radius: number);
  122120. /**
  122121. * Gets the scale applied to the radius
  122122. */
  122123. get radiusScale(): number;
  122124. /**
  122125. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  122126. */
  122127. set positionScale(scale: number);
  122128. /**
  122129. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  122130. */
  122131. get positionScale(): number;
  122132. /**
  122133. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  122134. * behaviour is triggered, in radians.
  122135. */
  122136. set defaultElevation(elevation: number);
  122137. /**
  122138. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  122139. * behaviour is triggered, in radians.
  122140. */
  122141. get defaultElevation(): number;
  122142. /**
  122143. * Sets the time (in milliseconds) taken to return to the default beta position.
  122144. * Negative value indicates camera should not return to default.
  122145. */
  122146. set elevationReturnTime(speed: number);
  122147. /**
  122148. * Gets the time (in milliseconds) taken to return to the default beta position.
  122149. * Negative value indicates camera should not return to default.
  122150. */
  122151. get elevationReturnTime(): number;
  122152. /**
  122153. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  122154. */
  122155. set elevationReturnWaitTime(time: number);
  122156. /**
  122157. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  122158. */
  122159. get elevationReturnWaitTime(): number;
  122160. /**
  122161. * Sets the flag that indicates if user zooming should stop animation.
  122162. */
  122163. set zoomStopsAnimation(flag: boolean);
  122164. /**
  122165. * Gets the flag that indicates if user zooming should stop animation.
  122166. */
  122167. get zoomStopsAnimation(): boolean;
  122168. /**
  122169. * Sets the transition time when framing the mesh, in milliseconds
  122170. */
  122171. set framingTime(time: number);
  122172. /**
  122173. * Gets the transition time when framing the mesh, in milliseconds
  122174. */
  122175. get framingTime(): number;
  122176. /**
  122177. * Define if the behavior should automatically change the configured
  122178. * camera limits and sensibilities.
  122179. */
  122180. autoCorrectCameraLimitsAndSensibility: boolean;
  122181. private _onPrePointerObservableObserver;
  122182. private _onAfterCheckInputsObserver;
  122183. private _onMeshTargetChangedObserver;
  122184. private _attachedCamera;
  122185. private _isPointerDown;
  122186. private _lastInteractionTime;
  122187. /**
  122188. * Initializes the behavior.
  122189. */
  122190. init(): void;
  122191. /**
  122192. * Attaches the behavior to its arc rotate camera.
  122193. * @param camera Defines the camera to attach the behavior to
  122194. */
  122195. attach(camera: ArcRotateCamera): void;
  122196. /**
  122197. * Detaches the behavior from its current arc rotate camera.
  122198. */
  122199. detach(): void;
  122200. private _animatables;
  122201. private _betaIsAnimating;
  122202. private _betaTransition;
  122203. private _radiusTransition;
  122204. private _vectorTransition;
  122205. /**
  122206. * Targets the given mesh and updates zoom level accordingly.
  122207. * @param mesh The mesh to target.
  122208. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122209. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122210. */
  122211. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122212. /**
  122213. * Targets the given mesh with its children and updates zoom level accordingly.
  122214. * @param mesh The mesh to target.
  122215. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122216. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122217. */
  122218. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122219. /**
  122220. * Targets the given meshes with their children and updates zoom level accordingly.
  122221. * @param meshes The mesh to target.
  122222. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122223. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122224. */
  122225. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122226. /**
  122227. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  122228. * @param minimumWorld Determines the smaller position of the bounding box extend
  122229. * @param maximumWorld Determines the bigger position of the bounding box extend
  122230. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122231. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122232. */
  122233. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122234. /**
  122235. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  122236. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  122237. * frustum width.
  122238. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  122239. * to fully enclose the mesh in the viewing frustum.
  122240. */
  122241. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  122242. /**
  122243. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  122244. * is automatically returned to its default position (expected to be above ground plane).
  122245. */
  122246. private _maintainCameraAboveGround;
  122247. /**
  122248. * Returns the frustum slope based on the canvas ratio and camera FOV
  122249. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  122250. */
  122251. private _getFrustumSlope;
  122252. /**
  122253. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  122254. */
  122255. private _clearAnimationLocks;
  122256. /**
  122257. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  122258. */
  122259. private _applyUserInteraction;
  122260. /**
  122261. * Stops and removes all animations that have been applied to the camera
  122262. */
  122263. stopAllAnimations(): void;
  122264. /**
  122265. * Gets a value indicating if the user is moving the camera
  122266. */
  122267. get isUserIsMoving(): boolean;
  122268. /**
  122269. * The camera can move all the way towards the mesh.
  122270. */
  122271. static IgnoreBoundsSizeMode: number;
  122272. /**
  122273. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  122274. */
  122275. static FitFrustumSidesMode: number;
  122276. }
  122277. }
  122278. declare module BABYLON {
  122279. /**
  122280. * Base class for Camera Pointer Inputs.
  122281. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  122282. * for example usage.
  122283. */
  122284. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  122285. /**
  122286. * Defines the camera the input is attached to.
  122287. */
  122288. abstract camera: Camera;
  122289. /**
  122290. * Whether keyboard modifier keys are pressed at time of last mouse event.
  122291. */
  122292. protected _altKey: boolean;
  122293. protected _ctrlKey: boolean;
  122294. protected _metaKey: boolean;
  122295. protected _shiftKey: boolean;
  122296. /**
  122297. * Which mouse buttons were pressed at time of last mouse event.
  122298. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  122299. */
  122300. protected _buttonsPressed: number;
  122301. /**
  122302. * Defines the buttons associated with the input to handle camera move.
  122303. */
  122304. buttons: number[];
  122305. /**
  122306. * Attach the input controls to a specific dom element to get the input from.
  122307. * @param element Defines the element the controls should be listened from
  122308. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122309. */
  122310. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122311. /**
  122312. * Detach the current controls from the specified dom element.
  122313. * @param element Defines the element to stop listening the inputs from
  122314. */
  122315. detachControl(element: Nullable<HTMLElement>): void;
  122316. /**
  122317. * Gets the class name of the current input.
  122318. * @returns the class name
  122319. */
  122320. getClassName(): string;
  122321. /**
  122322. * Get the friendly name associated with the input class.
  122323. * @returns the input friendly name
  122324. */
  122325. getSimpleName(): string;
  122326. /**
  122327. * Called on pointer POINTERDOUBLETAP event.
  122328. * Override this method to provide functionality on POINTERDOUBLETAP event.
  122329. */
  122330. protected onDoubleTap(type: string): void;
  122331. /**
  122332. * Called on pointer POINTERMOVE event if only a single touch is active.
  122333. * Override this method to provide functionality.
  122334. */
  122335. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  122336. /**
  122337. * Called on pointer POINTERMOVE event if multiple touches are active.
  122338. * Override this method to provide functionality.
  122339. */
  122340. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  122341. /**
  122342. * Called on JS contextmenu event.
  122343. * Override this method to provide functionality.
  122344. */
  122345. protected onContextMenu(evt: PointerEvent): void;
  122346. /**
  122347. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  122348. * press.
  122349. * Override this method to provide functionality.
  122350. */
  122351. protected onButtonDown(evt: PointerEvent): void;
  122352. /**
  122353. * Called each time a new POINTERUP event occurs. Ie, for each button
  122354. * release.
  122355. * Override this method to provide functionality.
  122356. */
  122357. protected onButtonUp(evt: PointerEvent): void;
  122358. /**
  122359. * Called when window becomes inactive.
  122360. * Override this method to provide functionality.
  122361. */
  122362. protected onLostFocus(): void;
  122363. private _pointerInput;
  122364. private _observer;
  122365. private _onLostFocus;
  122366. private pointA;
  122367. private pointB;
  122368. }
  122369. }
  122370. declare module BABYLON {
  122371. /**
  122372. * Manage the pointers inputs to control an arc rotate camera.
  122373. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122374. */
  122375. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  122376. /**
  122377. * Defines the camera the input is attached to.
  122378. */
  122379. camera: ArcRotateCamera;
  122380. /**
  122381. * Gets the class name of the current input.
  122382. * @returns the class name
  122383. */
  122384. getClassName(): string;
  122385. /**
  122386. * Defines the buttons associated with the input to handle camera move.
  122387. */
  122388. buttons: number[];
  122389. /**
  122390. * Defines the pointer angular sensibility along the X axis or how fast is
  122391. * the camera rotating.
  122392. */
  122393. angularSensibilityX: number;
  122394. /**
  122395. * Defines the pointer angular sensibility along the Y axis or how fast is
  122396. * the camera rotating.
  122397. */
  122398. angularSensibilityY: number;
  122399. /**
  122400. * Defines the pointer pinch precision or how fast is the camera zooming.
  122401. */
  122402. pinchPrecision: number;
  122403. /**
  122404. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  122405. * from 0.
  122406. * It defines the percentage of current camera.radius to use as delta when
  122407. * pinch zoom is used.
  122408. */
  122409. pinchDeltaPercentage: number;
  122410. /**
  122411. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  122412. * that any object in the plane at the camera's target point will scale
  122413. * perfectly with finger motion.
  122414. * Overrides pinchDeltaPercentage and pinchPrecision.
  122415. */
  122416. useNaturalPinchZoom: boolean;
  122417. /**
  122418. * Defines the pointer panning sensibility or how fast is the camera moving.
  122419. */
  122420. panningSensibility: number;
  122421. /**
  122422. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  122423. */
  122424. multiTouchPanning: boolean;
  122425. /**
  122426. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  122427. * zoom (pinch) through multitouch.
  122428. */
  122429. multiTouchPanAndZoom: boolean;
  122430. /**
  122431. * Revers pinch action direction.
  122432. */
  122433. pinchInwards: boolean;
  122434. private _isPanClick;
  122435. private _twoFingerActivityCount;
  122436. private _isPinching;
  122437. /**
  122438. * Called on pointer POINTERMOVE event if only a single touch is active.
  122439. */
  122440. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  122441. /**
  122442. * Called on pointer POINTERDOUBLETAP event.
  122443. */
  122444. protected onDoubleTap(type: string): void;
  122445. /**
  122446. * Called on pointer POINTERMOVE event if multiple touches are active.
  122447. */
  122448. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  122449. /**
  122450. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  122451. * press.
  122452. */
  122453. protected onButtonDown(evt: PointerEvent): void;
  122454. /**
  122455. * Called each time a new POINTERUP event occurs. Ie, for each button
  122456. * release.
  122457. */
  122458. protected onButtonUp(evt: PointerEvent): void;
  122459. /**
  122460. * Called when window becomes inactive.
  122461. */
  122462. protected onLostFocus(): void;
  122463. }
  122464. }
  122465. declare module BABYLON {
  122466. /**
  122467. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  122468. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122469. */
  122470. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  122471. /**
  122472. * Defines the camera the input is attached to.
  122473. */
  122474. camera: ArcRotateCamera;
  122475. /**
  122476. * Defines the list of key codes associated with the up action (increase alpha)
  122477. */
  122478. keysUp: number[];
  122479. /**
  122480. * Defines the list of key codes associated with the down action (decrease alpha)
  122481. */
  122482. keysDown: number[];
  122483. /**
  122484. * Defines the list of key codes associated with the left action (increase beta)
  122485. */
  122486. keysLeft: number[];
  122487. /**
  122488. * Defines the list of key codes associated with the right action (decrease beta)
  122489. */
  122490. keysRight: number[];
  122491. /**
  122492. * Defines the list of key codes associated with the reset action.
  122493. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  122494. */
  122495. keysReset: number[];
  122496. /**
  122497. * Defines the panning sensibility of the inputs.
  122498. * (How fast is the camera panning)
  122499. */
  122500. panningSensibility: number;
  122501. /**
  122502. * Defines the zooming sensibility of the inputs.
  122503. * (How fast is the camera zooming)
  122504. */
  122505. zoomingSensibility: number;
  122506. /**
  122507. * Defines whether maintaining the alt key down switch the movement mode from
  122508. * orientation to zoom.
  122509. */
  122510. useAltToZoom: boolean;
  122511. /**
  122512. * Rotation speed of the camera
  122513. */
  122514. angularSpeed: number;
  122515. private _keys;
  122516. private _ctrlPressed;
  122517. private _altPressed;
  122518. private _onCanvasBlurObserver;
  122519. private _onKeyboardObserver;
  122520. private _engine;
  122521. private _scene;
  122522. /**
  122523. * Attach the input controls to a specific dom element to get the input from.
  122524. * @param element Defines the element the controls should be listened from
  122525. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122526. */
  122527. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122528. /**
  122529. * Detach the current controls from the specified dom element.
  122530. * @param element Defines the element to stop listening the inputs from
  122531. */
  122532. detachControl(element: Nullable<HTMLElement>): void;
  122533. /**
  122534. * Update the current camera state depending on the inputs that have been used this frame.
  122535. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122536. */
  122537. checkInputs(): void;
  122538. /**
  122539. * Gets the class name of the current intput.
  122540. * @returns the class name
  122541. */
  122542. getClassName(): string;
  122543. /**
  122544. * Get the friendly name associated with the input class.
  122545. * @returns the input friendly name
  122546. */
  122547. getSimpleName(): string;
  122548. }
  122549. }
  122550. declare module BABYLON {
  122551. /**
  122552. * Manage the mouse wheel inputs to control an arc rotate camera.
  122553. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122554. */
  122555. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  122556. /**
  122557. * Defines the camera the input is attached to.
  122558. */
  122559. camera: ArcRotateCamera;
  122560. /**
  122561. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  122562. */
  122563. wheelPrecision: number;
  122564. /**
  122565. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  122566. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  122567. */
  122568. wheelDeltaPercentage: number;
  122569. private _wheel;
  122570. private _observer;
  122571. private computeDeltaFromMouseWheelLegacyEvent;
  122572. /**
  122573. * Attach the input controls to a specific dom element to get the input from.
  122574. * @param element Defines the element the controls should be listened from
  122575. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122576. */
  122577. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122578. /**
  122579. * Detach the current controls from the specified dom element.
  122580. * @param element Defines the element to stop listening the inputs from
  122581. */
  122582. detachControl(element: Nullable<HTMLElement>): void;
  122583. /**
  122584. * Gets the class name of the current intput.
  122585. * @returns the class name
  122586. */
  122587. getClassName(): string;
  122588. /**
  122589. * Get the friendly name associated with the input class.
  122590. * @returns the input friendly name
  122591. */
  122592. getSimpleName(): string;
  122593. }
  122594. }
  122595. declare module BABYLON {
  122596. /**
  122597. * Default Inputs manager for the ArcRotateCamera.
  122598. * It groups all the default supported inputs for ease of use.
  122599. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122600. */
  122601. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  122602. /**
  122603. * Instantiates a new ArcRotateCameraInputsManager.
  122604. * @param camera Defines the camera the inputs belong to
  122605. */
  122606. constructor(camera: ArcRotateCamera);
  122607. /**
  122608. * Add mouse wheel input support to the input manager.
  122609. * @returns the current input manager
  122610. */
  122611. addMouseWheel(): ArcRotateCameraInputsManager;
  122612. /**
  122613. * Add pointers input support to the input manager.
  122614. * @returns the current input manager
  122615. */
  122616. addPointers(): ArcRotateCameraInputsManager;
  122617. /**
  122618. * Add keyboard input support to the input manager.
  122619. * @returns the current input manager
  122620. */
  122621. addKeyboard(): ArcRotateCameraInputsManager;
  122622. }
  122623. }
  122624. declare module BABYLON {
  122625. /**
  122626. * This represents an orbital type of camera.
  122627. *
  122628. * 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.
  122629. * 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.
  122630. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  122631. */
  122632. export class ArcRotateCamera extends TargetCamera {
  122633. /**
  122634. * Defines the rotation angle of the camera along the longitudinal axis.
  122635. */
  122636. alpha: number;
  122637. /**
  122638. * Defines the rotation angle of the camera along the latitudinal axis.
  122639. */
  122640. beta: number;
  122641. /**
  122642. * Defines the radius of the camera from it s target point.
  122643. */
  122644. radius: number;
  122645. protected _target: Vector3;
  122646. protected _targetHost: Nullable<AbstractMesh>;
  122647. /**
  122648. * Defines the target point of the camera.
  122649. * The camera looks towards it form the radius distance.
  122650. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  122651. */
  122652. get target(): Vector3;
  122653. set target(value: Vector3);
  122654. /**
  122655. * Define the current local position of the camera in the scene
  122656. */
  122657. get position(): Vector3;
  122658. set position(newPosition: Vector3);
  122659. protected _upToYMatrix: Matrix;
  122660. protected _YToUpMatrix: Matrix;
  122661. /**
  122662. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  122663. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  122664. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  122665. */
  122666. set upVector(vec: Vector3);
  122667. get upVector(): Vector3;
  122668. /**
  122669. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  122670. */
  122671. setMatUp(): void;
  122672. /**
  122673. * Current inertia value on the longitudinal axis.
  122674. * The bigger this number the longer it will take for the camera to stop.
  122675. */
  122676. inertialAlphaOffset: number;
  122677. /**
  122678. * Current inertia value on the latitudinal axis.
  122679. * The bigger this number the longer it will take for the camera to stop.
  122680. */
  122681. inertialBetaOffset: number;
  122682. /**
  122683. * Current inertia value on the radius axis.
  122684. * The bigger this number the longer it will take for the camera to stop.
  122685. */
  122686. inertialRadiusOffset: number;
  122687. /**
  122688. * Minimum allowed angle on the longitudinal axis.
  122689. * This can help limiting how the Camera is able to move in the scene.
  122690. */
  122691. lowerAlphaLimit: Nullable<number>;
  122692. /**
  122693. * Maximum allowed angle on the longitudinal axis.
  122694. * This can help limiting how the Camera is able to move in the scene.
  122695. */
  122696. upperAlphaLimit: Nullable<number>;
  122697. /**
  122698. * Minimum allowed angle on the latitudinal axis.
  122699. * This can help limiting how the Camera is able to move in the scene.
  122700. */
  122701. lowerBetaLimit: number;
  122702. /**
  122703. * Maximum allowed angle on the latitudinal axis.
  122704. * This can help limiting how the Camera is able to move in the scene.
  122705. */
  122706. upperBetaLimit: number;
  122707. /**
  122708. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  122709. * This can help limiting how the Camera is able to move in the scene.
  122710. */
  122711. lowerRadiusLimit: Nullable<number>;
  122712. /**
  122713. * Maximum allowed distance of the camera to the target (The camera can not get further).
  122714. * This can help limiting how the Camera is able to move in the scene.
  122715. */
  122716. upperRadiusLimit: Nullable<number>;
  122717. /**
  122718. * Defines the current inertia value used during panning of the camera along the X axis.
  122719. */
  122720. inertialPanningX: number;
  122721. /**
  122722. * Defines the current inertia value used during panning of the camera along the Y axis.
  122723. */
  122724. inertialPanningY: number;
  122725. /**
  122726. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  122727. * Basically if your fingers moves away from more than this distance you will be considered
  122728. * in pinch mode.
  122729. */
  122730. pinchToPanMaxDistance: number;
  122731. /**
  122732. * Defines the maximum distance the camera can pan.
  122733. * This could help keeping the cammera always in your scene.
  122734. */
  122735. panningDistanceLimit: Nullable<number>;
  122736. /**
  122737. * Defines the target of the camera before paning.
  122738. */
  122739. panningOriginTarget: Vector3;
  122740. /**
  122741. * Defines the value of the inertia used during panning.
  122742. * 0 would mean stop inertia and one would mean no decelleration at all.
  122743. */
  122744. panningInertia: number;
  122745. /**
  122746. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  122747. */
  122748. get angularSensibilityX(): number;
  122749. set angularSensibilityX(value: number);
  122750. /**
  122751. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  122752. */
  122753. get angularSensibilityY(): number;
  122754. set angularSensibilityY(value: number);
  122755. /**
  122756. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  122757. */
  122758. get pinchPrecision(): number;
  122759. set pinchPrecision(value: number);
  122760. /**
  122761. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  122762. * It will be used instead of pinchDeltaPrecision if different from 0.
  122763. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  122764. */
  122765. get pinchDeltaPercentage(): number;
  122766. set pinchDeltaPercentage(value: number);
  122767. /**
  122768. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  122769. * and pinch delta percentage.
  122770. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  122771. * that any object in the plane at the camera's target point will scale
  122772. * perfectly with finger motion.
  122773. */
  122774. get useNaturalPinchZoom(): boolean;
  122775. set useNaturalPinchZoom(value: boolean);
  122776. /**
  122777. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  122778. */
  122779. get panningSensibility(): number;
  122780. set panningSensibility(value: number);
  122781. /**
  122782. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  122783. */
  122784. get keysUp(): number[];
  122785. set keysUp(value: number[]);
  122786. /**
  122787. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  122788. */
  122789. get keysDown(): number[];
  122790. set keysDown(value: number[]);
  122791. /**
  122792. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  122793. */
  122794. get keysLeft(): number[];
  122795. set keysLeft(value: number[]);
  122796. /**
  122797. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  122798. */
  122799. get keysRight(): number[];
  122800. set keysRight(value: number[]);
  122801. /**
  122802. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  122803. */
  122804. get wheelPrecision(): number;
  122805. set wheelPrecision(value: number);
  122806. /**
  122807. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  122808. * It will be used instead of pinchDeltaPrecision if different from 0.
  122809. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  122810. */
  122811. get wheelDeltaPercentage(): number;
  122812. set wheelDeltaPercentage(value: number);
  122813. /**
  122814. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  122815. */
  122816. zoomOnFactor: number;
  122817. /**
  122818. * Defines a screen offset for the camera position.
  122819. */
  122820. targetScreenOffset: Vector2;
  122821. /**
  122822. * Allows the camera to be completely reversed.
  122823. * If false the camera can not arrive upside down.
  122824. */
  122825. allowUpsideDown: boolean;
  122826. /**
  122827. * Define if double tap/click is used to restore the previously saved state of the camera.
  122828. */
  122829. useInputToRestoreState: boolean;
  122830. /** @hidden */
  122831. _viewMatrix: Matrix;
  122832. /** @hidden */
  122833. _useCtrlForPanning: boolean;
  122834. /** @hidden */
  122835. _panningMouseButton: number;
  122836. /**
  122837. * Defines the input associated to the camera.
  122838. */
  122839. inputs: ArcRotateCameraInputsManager;
  122840. /** @hidden */
  122841. _reset: () => void;
  122842. /**
  122843. * Defines the allowed panning axis.
  122844. */
  122845. panningAxis: Vector3;
  122846. protected _localDirection: Vector3;
  122847. protected _transformedDirection: Vector3;
  122848. private _bouncingBehavior;
  122849. /**
  122850. * Gets the bouncing behavior of the camera if it has been enabled.
  122851. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  122852. */
  122853. get bouncingBehavior(): Nullable<BouncingBehavior>;
  122854. /**
  122855. * Defines if the bouncing behavior of the camera is enabled on the camera.
  122856. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  122857. */
  122858. get useBouncingBehavior(): boolean;
  122859. set useBouncingBehavior(value: boolean);
  122860. private _framingBehavior;
  122861. /**
  122862. * Gets the framing behavior of the camera if it has been enabled.
  122863. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  122864. */
  122865. get framingBehavior(): Nullable<FramingBehavior>;
  122866. /**
  122867. * Defines if the framing behavior of the camera is enabled on the camera.
  122868. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  122869. */
  122870. get useFramingBehavior(): boolean;
  122871. set useFramingBehavior(value: boolean);
  122872. private _autoRotationBehavior;
  122873. /**
  122874. * Gets the auto rotation behavior of the camera if it has been enabled.
  122875. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  122876. */
  122877. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  122878. /**
  122879. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  122880. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  122881. */
  122882. get useAutoRotationBehavior(): boolean;
  122883. set useAutoRotationBehavior(value: boolean);
  122884. /**
  122885. * Observable triggered when the mesh target has been changed on the camera.
  122886. */
  122887. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  122888. /**
  122889. * Event raised when the camera is colliding with a mesh.
  122890. */
  122891. onCollide: (collidedMesh: AbstractMesh) => void;
  122892. /**
  122893. * Defines whether the camera should check collision with the objects oh the scene.
  122894. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  122895. */
  122896. checkCollisions: boolean;
  122897. /**
  122898. * Defines the collision radius of the camera.
  122899. * This simulates a sphere around the camera.
  122900. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  122901. */
  122902. collisionRadius: Vector3;
  122903. protected _collider: Collider;
  122904. protected _previousPosition: Vector3;
  122905. protected _collisionVelocity: Vector3;
  122906. protected _newPosition: Vector3;
  122907. protected _previousAlpha: number;
  122908. protected _previousBeta: number;
  122909. protected _previousRadius: number;
  122910. protected _collisionTriggered: boolean;
  122911. protected _targetBoundingCenter: Nullable<Vector3>;
  122912. private _computationVector;
  122913. /**
  122914. * Instantiates a new ArcRotateCamera in a given scene
  122915. * @param name Defines the name of the camera
  122916. * @param alpha Defines the camera rotation along the logitudinal axis
  122917. * @param beta Defines the camera rotation along the latitudinal axis
  122918. * @param radius Defines the camera distance from its target
  122919. * @param target Defines the camera target
  122920. * @param scene Defines the scene the camera belongs to
  122921. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  122922. */
  122923. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  122924. /** @hidden */
  122925. _initCache(): void;
  122926. /** @hidden */
  122927. _updateCache(ignoreParentClass?: boolean): void;
  122928. protected _getTargetPosition(): Vector3;
  122929. private _storedAlpha;
  122930. private _storedBeta;
  122931. private _storedRadius;
  122932. private _storedTarget;
  122933. private _storedTargetScreenOffset;
  122934. /**
  122935. * Stores the current state of the camera (alpha, beta, radius and target)
  122936. * @returns the camera itself
  122937. */
  122938. storeState(): Camera;
  122939. /**
  122940. * @hidden
  122941. * Restored camera state. You must call storeState() first
  122942. */
  122943. _restoreStateValues(): boolean;
  122944. /** @hidden */
  122945. _isSynchronizedViewMatrix(): boolean;
  122946. /**
  122947. * Attached controls to the current camera.
  122948. * @param element Defines the element the controls should be listened from
  122949. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122950. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  122951. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  122952. */
  122953. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  122954. /**
  122955. * Detach the current controls from the camera.
  122956. * The camera will stop reacting to inputs.
  122957. * @param element Defines the element to stop listening the inputs from
  122958. */
  122959. detachControl(element: HTMLElement): void;
  122960. /** @hidden */
  122961. _checkInputs(): void;
  122962. protected _checkLimits(): void;
  122963. /**
  122964. * Rebuilds angles (alpha, beta) and radius from the give position and target
  122965. */
  122966. rebuildAnglesAndRadius(): void;
  122967. /**
  122968. * Use a position to define the current camera related information like alpha, beta and radius
  122969. * @param position Defines the position to set the camera at
  122970. */
  122971. setPosition(position: Vector3): void;
  122972. /**
  122973. * Defines the target the camera should look at.
  122974. * This will automatically adapt alpha beta and radius to fit within the new target.
  122975. * @param target Defines the new target as a Vector or a mesh
  122976. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  122977. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  122978. */
  122979. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  122980. /** @hidden */
  122981. _getViewMatrix(): Matrix;
  122982. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  122983. /**
  122984. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  122985. * @param meshes Defines the mesh to zoom on
  122986. * @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)
  122987. */
  122988. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  122989. /**
  122990. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  122991. * The target will be changed but the radius
  122992. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  122993. * @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)
  122994. */
  122995. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  122996. min: Vector3;
  122997. max: Vector3;
  122998. distance: number;
  122999. }, doNotUpdateMaxZ?: boolean): void;
  123000. /**
  123001. * @override
  123002. * Override Camera.createRigCamera
  123003. */
  123004. createRigCamera(name: string, cameraIndex: number): Camera;
  123005. /**
  123006. * @hidden
  123007. * @override
  123008. * Override Camera._updateRigCameras
  123009. */
  123010. _updateRigCameras(): void;
  123011. /**
  123012. * Destroy the camera and release the current resources hold by it.
  123013. */
  123014. dispose(): void;
  123015. /**
  123016. * Gets the current object class name.
  123017. * @return the class name
  123018. */
  123019. getClassName(): string;
  123020. }
  123021. }
  123022. declare module BABYLON {
  123023. /**
  123024. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  123025. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123026. */
  123027. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  123028. /**
  123029. * Gets the name of the behavior.
  123030. */
  123031. get name(): string;
  123032. private _zoomStopsAnimation;
  123033. private _idleRotationSpeed;
  123034. private _idleRotationWaitTime;
  123035. private _idleRotationSpinupTime;
  123036. /**
  123037. * Sets the flag that indicates if user zooming should stop animation.
  123038. */
  123039. set zoomStopsAnimation(flag: boolean);
  123040. /**
  123041. * Gets the flag that indicates if user zooming should stop animation.
  123042. */
  123043. get zoomStopsAnimation(): boolean;
  123044. /**
  123045. * Sets the default speed at which the camera rotates around the model.
  123046. */
  123047. set idleRotationSpeed(speed: number);
  123048. /**
  123049. * Gets the default speed at which the camera rotates around the model.
  123050. */
  123051. get idleRotationSpeed(): number;
  123052. /**
  123053. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  123054. */
  123055. set idleRotationWaitTime(time: number);
  123056. /**
  123057. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  123058. */
  123059. get idleRotationWaitTime(): number;
  123060. /**
  123061. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  123062. */
  123063. set idleRotationSpinupTime(time: number);
  123064. /**
  123065. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  123066. */
  123067. get idleRotationSpinupTime(): number;
  123068. /**
  123069. * Gets a value indicating if the camera is currently rotating because of this behavior
  123070. */
  123071. get rotationInProgress(): boolean;
  123072. private _onPrePointerObservableObserver;
  123073. private _onAfterCheckInputsObserver;
  123074. private _attachedCamera;
  123075. private _isPointerDown;
  123076. private _lastFrameTime;
  123077. private _lastInteractionTime;
  123078. private _cameraRotationSpeed;
  123079. /**
  123080. * Initializes the behavior.
  123081. */
  123082. init(): void;
  123083. /**
  123084. * Attaches the behavior to its arc rotate camera.
  123085. * @param camera Defines the camera to attach the behavior to
  123086. */
  123087. attach(camera: ArcRotateCamera): void;
  123088. /**
  123089. * Detaches the behavior from its current arc rotate camera.
  123090. */
  123091. detach(): void;
  123092. /**
  123093. * Returns true if user is scrolling.
  123094. * @return true if user is scrolling.
  123095. */
  123096. private _userIsZooming;
  123097. private _lastFrameRadius;
  123098. private _shouldAnimationStopForInteraction;
  123099. /**
  123100. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  123101. */
  123102. private _applyUserInteraction;
  123103. private _userIsMoving;
  123104. }
  123105. }
  123106. declare module BABYLON {
  123107. /**
  123108. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  123109. */
  123110. export class AttachToBoxBehavior implements Behavior<Mesh> {
  123111. private ui;
  123112. /**
  123113. * The name of the behavior
  123114. */
  123115. name: string;
  123116. /**
  123117. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  123118. */
  123119. distanceAwayFromFace: number;
  123120. /**
  123121. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  123122. */
  123123. distanceAwayFromBottomOfFace: number;
  123124. private _faceVectors;
  123125. private _target;
  123126. private _scene;
  123127. private _onRenderObserver;
  123128. private _tmpMatrix;
  123129. private _tmpVector;
  123130. /**
  123131. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  123132. * @param ui The transform node that should be attched to the mesh
  123133. */
  123134. constructor(ui: TransformNode);
  123135. /**
  123136. * Initializes the behavior
  123137. */
  123138. init(): void;
  123139. private _closestFace;
  123140. private _zeroVector;
  123141. private _lookAtTmpMatrix;
  123142. private _lookAtToRef;
  123143. /**
  123144. * Attaches the AttachToBoxBehavior to the passed in mesh
  123145. * @param target The mesh that the specified node will be attached to
  123146. */
  123147. attach(target: Mesh): void;
  123148. /**
  123149. * Detaches the behavior from the mesh
  123150. */
  123151. detach(): void;
  123152. }
  123153. }
  123154. declare module BABYLON {
  123155. /**
  123156. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  123157. */
  123158. export class FadeInOutBehavior implements Behavior<Mesh> {
  123159. /**
  123160. * Time in milliseconds to delay before fading in (Default: 0)
  123161. */
  123162. delay: number;
  123163. /**
  123164. * Time in milliseconds for the mesh to fade in (Default: 300)
  123165. */
  123166. fadeInTime: number;
  123167. private _millisecondsPerFrame;
  123168. private _hovered;
  123169. private _hoverValue;
  123170. private _ownerNode;
  123171. /**
  123172. * Instatiates the FadeInOutBehavior
  123173. */
  123174. constructor();
  123175. /**
  123176. * The name of the behavior
  123177. */
  123178. get name(): string;
  123179. /**
  123180. * Initializes the behavior
  123181. */
  123182. init(): void;
  123183. /**
  123184. * Attaches the fade behavior on the passed in mesh
  123185. * @param ownerNode The mesh that will be faded in/out once attached
  123186. */
  123187. attach(ownerNode: Mesh): void;
  123188. /**
  123189. * Detaches the behavior from the mesh
  123190. */
  123191. detach(): void;
  123192. /**
  123193. * Triggers the mesh to begin fading in or out
  123194. * @param value if the object should fade in or out (true to fade in)
  123195. */
  123196. fadeIn(value: boolean): void;
  123197. private _update;
  123198. private _setAllVisibility;
  123199. }
  123200. }
  123201. declare module BABYLON {
  123202. /**
  123203. * Class containing a set of static utilities functions for managing Pivots
  123204. * @hidden
  123205. */
  123206. export class PivotTools {
  123207. private static _PivotCached;
  123208. private static _OldPivotPoint;
  123209. private static _PivotTranslation;
  123210. private static _PivotTmpVector;
  123211. private static _PivotPostMultiplyPivotMatrix;
  123212. /** @hidden */
  123213. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  123214. /** @hidden */
  123215. static _RestorePivotPoint(mesh: AbstractMesh): void;
  123216. }
  123217. }
  123218. declare module BABYLON {
  123219. /**
  123220. * Class containing static functions to help procedurally build meshes
  123221. */
  123222. export class PlaneBuilder {
  123223. /**
  123224. * Creates a plane mesh
  123225. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  123226. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  123227. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  123228. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123229. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123231. * @param name defines the name of the mesh
  123232. * @param options defines the options used to create the mesh
  123233. * @param scene defines the hosting scene
  123234. * @returns the plane mesh
  123235. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123236. */
  123237. static CreatePlane(name: string, options: {
  123238. size?: number;
  123239. width?: number;
  123240. height?: number;
  123241. sideOrientation?: number;
  123242. frontUVs?: Vector4;
  123243. backUVs?: Vector4;
  123244. updatable?: boolean;
  123245. sourcePlane?: Plane;
  123246. }, scene?: Nullable<Scene>): Mesh;
  123247. }
  123248. }
  123249. declare module BABYLON {
  123250. /**
  123251. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  123252. */
  123253. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  123254. private static _AnyMouseID;
  123255. /**
  123256. * Abstract mesh the behavior is set on
  123257. */
  123258. attachedNode: AbstractMesh;
  123259. private _dragPlane;
  123260. private _scene;
  123261. private _pointerObserver;
  123262. private _beforeRenderObserver;
  123263. private static _planeScene;
  123264. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  123265. /**
  123266. * 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)
  123267. */
  123268. maxDragAngle: number;
  123269. /**
  123270. * @hidden
  123271. */
  123272. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  123273. /**
  123274. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  123275. */
  123276. currentDraggingPointerID: number;
  123277. /**
  123278. * The last position where the pointer hit the drag plane in world space
  123279. */
  123280. lastDragPosition: Vector3;
  123281. /**
  123282. * If the behavior is currently in a dragging state
  123283. */
  123284. dragging: boolean;
  123285. /**
  123286. * 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)
  123287. */
  123288. dragDeltaRatio: number;
  123289. /**
  123290. * If the drag plane orientation should be updated during the dragging (Default: true)
  123291. */
  123292. updateDragPlane: boolean;
  123293. private _debugMode;
  123294. private _moving;
  123295. /**
  123296. * Fires each time the attached mesh is dragged with the pointer
  123297. * * delta between last drag position and current drag position in world space
  123298. * * dragDistance along the drag axis
  123299. * * dragPlaneNormal normal of the current drag plane used during the drag
  123300. * * dragPlanePoint in world space where the drag intersects the drag plane
  123301. */
  123302. onDragObservable: Observable<{
  123303. delta: Vector3;
  123304. dragPlanePoint: Vector3;
  123305. dragPlaneNormal: Vector3;
  123306. dragDistance: number;
  123307. pointerId: number;
  123308. }>;
  123309. /**
  123310. * Fires each time a drag begins (eg. mouse down on mesh)
  123311. */
  123312. onDragStartObservable: Observable<{
  123313. dragPlanePoint: Vector3;
  123314. pointerId: number;
  123315. }>;
  123316. /**
  123317. * Fires each time a drag ends (eg. mouse release after drag)
  123318. */
  123319. onDragEndObservable: Observable<{
  123320. dragPlanePoint: Vector3;
  123321. pointerId: number;
  123322. }>;
  123323. /**
  123324. * If the attached mesh should be moved when dragged
  123325. */
  123326. moveAttached: boolean;
  123327. /**
  123328. * If the drag behavior will react to drag events (Default: true)
  123329. */
  123330. enabled: boolean;
  123331. /**
  123332. * If pointer events should start and release the drag (Default: true)
  123333. */
  123334. startAndReleaseDragOnPointerEvents: boolean;
  123335. /**
  123336. * If camera controls should be detached during the drag
  123337. */
  123338. detachCameraControls: boolean;
  123339. /**
  123340. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  123341. */
  123342. useObjectOrientationForDragging: boolean;
  123343. private _options;
  123344. /**
  123345. * Gets the options used by the behavior
  123346. */
  123347. get options(): {
  123348. dragAxis?: Vector3;
  123349. dragPlaneNormal?: Vector3;
  123350. };
  123351. /**
  123352. * Sets the options used by the behavior
  123353. */
  123354. set options(options: {
  123355. dragAxis?: Vector3;
  123356. dragPlaneNormal?: Vector3;
  123357. });
  123358. /**
  123359. * Creates a pointer drag behavior that can be attached to a mesh
  123360. * @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)
  123361. */
  123362. constructor(options?: {
  123363. dragAxis?: Vector3;
  123364. dragPlaneNormal?: Vector3;
  123365. });
  123366. /**
  123367. * Predicate to determine if it is valid to move the object to a new position when it is moved
  123368. */
  123369. validateDrag: (targetPosition: Vector3) => boolean;
  123370. /**
  123371. * The name of the behavior
  123372. */
  123373. get name(): string;
  123374. /**
  123375. * Initializes the behavior
  123376. */
  123377. init(): void;
  123378. private _tmpVector;
  123379. private _alternatePickedPoint;
  123380. private _worldDragAxis;
  123381. private _targetPosition;
  123382. private _attachedElement;
  123383. /**
  123384. * Attaches the drag behavior the passed in mesh
  123385. * @param ownerNode The mesh that will be dragged around once attached
  123386. * @param predicate Predicate to use for pick filtering
  123387. */
  123388. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  123389. /**
  123390. * Force relase the drag action by code.
  123391. */
  123392. releaseDrag(): void;
  123393. private _startDragRay;
  123394. private _lastPointerRay;
  123395. /**
  123396. * Simulates the start of a pointer drag event on the behavior
  123397. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  123398. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  123399. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  123400. */
  123401. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  123402. private _startDrag;
  123403. private _dragDelta;
  123404. private _moveDrag;
  123405. private _pickWithRayOnDragPlane;
  123406. private _pointA;
  123407. private _pointC;
  123408. private _localAxis;
  123409. private _lookAt;
  123410. private _updateDragPlanePosition;
  123411. /**
  123412. * Detaches the behavior from the mesh
  123413. */
  123414. detach(): void;
  123415. }
  123416. }
  123417. declare module BABYLON {
  123418. /**
  123419. * A behavior that when attached to a mesh will allow the mesh to be scaled
  123420. */
  123421. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  123422. private _dragBehaviorA;
  123423. private _dragBehaviorB;
  123424. private _startDistance;
  123425. private _initialScale;
  123426. private _targetScale;
  123427. private _ownerNode;
  123428. private _sceneRenderObserver;
  123429. /**
  123430. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  123431. */
  123432. constructor();
  123433. /**
  123434. * The name of the behavior
  123435. */
  123436. get name(): string;
  123437. /**
  123438. * Initializes the behavior
  123439. */
  123440. init(): void;
  123441. private _getCurrentDistance;
  123442. /**
  123443. * Attaches the scale behavior the passed in mesh
  123444. * @param ownerNode The mesh that will be scaled around once attached
  123445. */
  123446. attach(ownerNode: Mesh): void;
  123447. /**
  123448. * Detaches the behavior from the mesh
  123449. */
  123450. detach(): void;
  123451. }
  123452. }
  123453. declare module BABYLON {
  123454. /**
  123455. * 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
  123456. */
  123457. export class SixDofDragBehavior implements Behavior<Mesh> {
  123458. private static _virtualScene;
  123459. private _ownerNode;
  123460. private _sceneRenderObserver;
  123461. private _scene;
  123462. private _targetPosition;
  123463. private _virtualOriginMesh;
  123464. private _virtualDragMesh;
  123465. private _pointerObserver;
  123466. private _moving;
  123467. private _startingOrientation;
  123468. private _attachedElement;
  123469. /**
  123470. * 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)
  123471. */
  123472. private zDragFactor;
  123473. /**
  123474. * If the object should rotate to face the drag origin
  123475. */
  123476. rotateDraggedObject: boolean;
  123477. /**
  123478. * If the behavior is currently in a dragging state
  123479. */
  123480. dragging: boolean;
  123481. /**
  123482. * 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)
  123483. */
  123484. dragDeltaRatio: number;
  123485. /**
  123486. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  123487. */
  123488. currentDraggingPointerID: number;
  123489. /**
  123490. * If camera controls should be detached during the drag
  123491. */
  123492. detachCameraControls: boolean;
  123493. /**
  123494. * Fires each time a drag starts
  123495. */
  123496. onDragStartObservable: Observable<{}>;
  123497. /**
  123498. * Fires each time a drag ends (eg. mouse release after drag)
  123499. */
  123500. onDragEndObservable: Observable<{}>;
  123501. /**
  123502. * 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
  123503. */
  123504. constructor();
  123505. /**
  123506. * The name of the behavior
  123507. */
  123508. get name(): string;
  123509. /**
  123510. * Initializes the behavior
  123511. */
  123512. init(): void;
  123513. /**
  123514. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  123515. */
  123516. private get _pointerCamera();
  123517. /**
  123518. * Attaches the scale behavior the passed in mesh
  123519. * @param ownerNode The mesh that will be scaled around once attached
  123520. */
  123521. attach(ownerNode: Mesh): void;
  123522. /**
  123523. * Detaches the behavior from the mesh
  123524. */
  123525. detach(): void;
  123526. }
  123527. }
  123528. declare module BABYLON {
  123529. /**
  123530. * Class used to apply inverse kinematics to bones
  123531. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  123532. */
  123533. export class BoneIKController {
  123534. private static _tmpVecs;
  123535. private static _tmpQuat;
  123536. private static _tmpMats;
  123537. /**
  123538. * Gets or sets the target mesh
  123539. */
  123540. targetMesh: AbstractMesh;
  123541. /** Gets or sets the mesh used as pole */
  123542. poleTargetMesh: AbstractMesh;
  123543. /**
  123544. * Gets or sets the bone used as pole
  123545. */
  123546. poleTargetBone: Nullable<Bone>;
  123547. /**
  123548. * Gets or sets the target position
  123549. */
  123550. targetPosition: Vector3;
  123551. /**
  123552. * Gets or sets the pole target position
  123553. */
  123554. poleTargetPosition: Vector3;
  123555. /**
  123556. * Gets or sets the pole target local offset
  123557. */
  123558. poleTargetLocalOffset: Vector3;
  123559. /**
  123560. * Gets or sets the pole angle
  123561. */
  123562. poleAngle: number;
  123563. /**
  123564. * Gets or sets the mesh associated with the controller
  123565. */
  123566. mesh: AbstractMesh;
  123567. /**
  123568. * 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)
  123569. */
  123570. slerpAmount: number;
  123571. private _bone1Quat;
  123572. private _bone1Mat;
  123573. private _bone2Ang;
  123574. private _bone1;
  123575. private _bone2;
  123576. private _bone1Length;
  123577. private _bone2Length;
  123578. private _maxAngle;
  123579. private _maxReach;
  123580. private _rightHandedSystem;
  123581. private _bendAxis;
  123582. private _slerping;
  123583. private _adjustRoll;
  123584. /**
  123585. * Gets or sets maximum allowed angle
  123586. */
  123587. get maxAngle(): number;
  123588. set maxAngle(value: number);
  123589. /**
  123590. * Creates a new BoneIKController
  123591. * @param mesh defines the mesh to control
  123592. * @param bone defines the bone to control
  123593. * @param options defines options to set up the controller
  123594. */
  123595. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  123596. targetMesh?: AbstractMesh;
  123597. poleTargetMesh?: AbstractMesh;
  123598. poleTargetBone?: Bone;
  123599. poleTargetLocalOffset?: Vector3;
  123600. poleAngle?: number;
  123601. bendAxis?: Vector3;
  123602. maxAngle?: number;
  123603. slerpAmount?: number;
  123604. });
  123605. private _setMaxAngle;
  123606. /**
  123607. * Force the controller to update the bones
  123608. */
  123609. update(): void;
  123610. }
  123611. }
  123612. declare module BABYLON {
  123613. /**
  123614. * Class used to make a bone look toward a point in space
  123615. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  123616. */
  123617. export class BoneLookController {
  123618. private static _tmpVecs;
  123619. private static _tmpQuat;
  123620. private static _tmpMats;
  123621. /**
  123622. * The target Vector3 that the bone will look at
  123623. */
  123624. target: Vector3;
  123625. /**
  123626. * The mesh that the bone is attached to
  123627. */
  123628. mesh: AbstractMesh;
  123629. /**
  123630. * The bone that will be looking to the target
  123631. */
  123632. bone: Bone;
  123633. /**
  123634. * The up axis of the coordinate system that is used when the bone is rotated
  123635. */
  123636. upAxis: Vector3;
  123637. /**
  123638. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  123639. */
  123640. upAxisSpace: Space;
  123641. /**
  123642. * Used to make an adjustment to the yaw of the bone
  123643. */
  123644. adjustYaw: number;
  123645. /**
  123646. * Used to make an adjustment to the pitch of the bone
  123647. */
  123648. adjustPitch: number;
  123649. /**
  123650. * Used to make an adjustment to the roll of the bone
  123651. */
  123652. adjustRoll: number;
  123653. /**
  123654. * 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)
  123655. */
  123656. slerpAmount: number;
  123657. private _minYaw;
  123658. private _maxYaw;
  123659. private _minPitch;
  123660. private _maxPitch;
  123661. private _minYawSin;
  123662. private _minYawCos;
  123663. private _maxYawSin;
  123664. private _maxYawCos;
  123665. private _midYawConstraint;
  123666. private _minPitchTan;
  123667. private _maxPitchTan;
  123668. private _boneQuat;
  123669. private _slerping;
  123670. private _transformYawPitch;
  123671. private _transformYawPitchInv;
  123672. private _firstFrameSkipped;
  123673. private _yawRange;
  123674. private _fowardAxis;
  123675. /**
  123676. * Gets or sets the minimum yaw angle that the bone can look to
  123677. */
  123678. get minYaw(): number;
  123679. set minYaw(value: number);
  123680. /**
  123681. * Gets or sets the maximum yaw angle that the bone can look to
  123682. */
  123683. get maxYaw(): number;
  123684. set maxYaw(value: number);
  123685. /**
  123686. * Gets or sets the minimum pitch angle that the bone can look to
  123687. */
  123688. get minPitch(): number;
  123689. set minPitch(value: number);
  123690. /**
  123691. * Gets or sets the maximum pitch angle that the bone can look to
  123692. */
  123693. get maxPitch(): number;
  123694. set maxPitch(value: number);
  123695. /**
  123696. * Create a BoneLookController
  123697. * @param mesh the mesh that the bone belongs to
  123698. * @param bone the bone that will be looking to the target
  123699. * @param target the target Vector3 to look at
  123700. * @param options optional settings:
  123701. * * maxYaw: the maximum angle the bone will yaw to
  123702. * * minYaw: the minimum angle the bone will yaw to
  123703. * * maxPitch: the maximum angle the bone will pitch to
  123704. * * minPitch: the minimum angle the bone will yaw to
  123705. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  123706. * * upAxis: the up axis of the coordinate system
  123707. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  123708. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  123709. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  123710. * * adjustYaw: used to make an adjustment to the yaw of the bone
  123711. * * adjustPitch: used to make an adjustment to the pitch of the bone
  123712. * * adjustRoll: used to make an adjustment to the roll of the bone
  123713. **/
  123714. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  123715. maxYaw?: number;
  123716. minYaw?: number;
  123717. maxPitch?: number;
  123718. minPitch?: number;
  123719. slerpAmount?: number;
  123720. upAxis?: Vector3;
  123721. upAxisSpace?: Space;
  123722. yawAxis?: Vector3;
  123723. pitchAxis?: Vector3;
  123724. adjustYaw?: number;
  123725. adjustPitch?: number;
  123726. adjustRoll?: number;
  123727. });
  123728. /**
  123729. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  123730. */
  123731. update(): void;
  123732. private _getAngleDiff;
  123733. private _getAngleBetween;
  123734. private _isAngleBetween;
  123735. }
  123736. }
  123737. declare module BABYLON {
  123738. /**
  123739. * Manage the gamepad inputs to control an arc rotate camera.
  123740. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123741. */
  123742. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  123743. /**
  123744. * Defines the camera the input is attached to.
  123745. */
  123746. camera: ArcRotateCamera;
  123747. /**
  123748. * Defines the gamepad the input is gathering event from.
  123749. */
  123750. gamepad: Nullable<Gamepad>;
  123751. /**
  123752. * Defines the gamepad rotation sensiblity.
  123753. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  123754. */
  123755. gamepadRotationSensibility: number;
  123756. /**
  123757. * Defines the gamepad move sensiblity.
  123758. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  123759. */
  123760. gamepadMoveSensibility: number;
  123761. private _yAxisScale;
  123762. /**
  123763. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  123764. */
  123765. get invertYAxis(): boolean;
  123766. set invertYAxis(value: boolean);
  123767. private _onGamepadConnectedObserver;
  123768. private _onGamepadDisconnectedObserver;
  123769. /**
  123770. * Attach the input controls to a specific dom element to get the input from.
  123771. * @param element Defines the element the controls should be listened from
  123772. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123773. */
  123774. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123775. /**
  123776. * Detach the current controls from the specified dom element.
  123777. * @param element Defines the element to stop listening the inputs from
  123778. */
  123779. detachControl(element: Nullable<HTMLElement>): void;
  123780. /**
  123781. * Update the current camera state depending on the inputs that have been used this frame.
  123782. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123783. */
  123784. checkInputs(): void;
  123785. /**
  123786. * Gets the class name of the current intput.
  123787. * @returns the class name
  123788. */
  123789. getClassName(): string;
  123790. /**
  123791. * Get the friendly name associated with the input class.
  123792. * @returns the input friendly name
  123793. */
  123794. getSimpleName(): string;
  123795. }
  123796. }
  123797. declare module BABYLON {
  123798. interface ArcRotateCameraInputsManager {
  123799. /**
  123800. * Add orientation input support to the input manager.
  123801. * @returns the current input manager
  123802. */
  123803. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  123804. }
  123805. /**
  123806. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  123807. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123808. */
  123809. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  123810. /**
  123811. * Defines the camera the input is attached to.
  123812. */
  123813. camera: ArcRotateCamera;
  123814. /**
  123815. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  123816. */
  123817. alphaCorrection: number;
  123818. /**
  123819. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  123820. */
  123821. gammaCorrection: number;
  123822. private _alpha;
  123823. private _gamma;
  123824. private _dirty;
  123825. private _deviceOrientationHandler;
  123826. /**
  123827. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  123828. */
  123829. constructor();
  123830. /**
  123831. * Attach the input controls to a specific dom element to get the input from.
  123832. * @param element Defines the element the controls should be listened from
  123833. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123834. */
  123835. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123836. /** @hidden */
  123837. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  123838. /**
  123839. * Update the current camera state depending on the inputs that have been used this frame.
  123840. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123841. */
  123842. checkInputs(): void;
  123843. /**
  123844. * Detach the current controls from the specified dom element.
  123845. * @param element Defines the element to stop listening the inputs from
  123846. */
  123847. detachControl(element: Nullable<HTMLElement>): void;
  123848. /**
  123849. * Gets the class name of the current intput.
  123850. * @returns the class name
  123851. */
  123852. getClassName(): string;
  123853. /**
  123854. * Get the friendly name associated with the input class.
  123855. * @returns the input friendly name
  123856. */
  123857. getSimpleName(): string;
  123858. }
  123859. }
  123860. declare module BABYLON {
  123861. /**
  123862. * Listen to mouse events to control the camera.
  123863. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123864. */
  123865. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  123866. /**
  123867. * Defines the camera the input is attached to.
  123868. */
  123869. camera: FlyCamera;
  123870. /**
  123871. * Defines if touch is enabled. (Default is true.)
  123872. */
  123873. touchEnabled: boolean;
  123874. /**
  123875. * Defines the buttons associated with the input to handle camera rotation.
  123876. */
  123877. buttons: number[];
  123878. /**
  123879. * Assign buttons for Yaw control.
  123880. */
  123881. buttonsYaw: number[];
  123882. /**
  123883. * Assign buttons for Pitch control.
  123884. */
  123885. buttonsPitch: number[];
  123886. /**
  123887. * Assign buttons for Roll control.
  123888. */
  123889. buttonsRoll: number[];
  123890. /**
  123891. * Detect if any button is being pressed while mouse is moved.
  123892. * -1 = Mouse locked.
  123893. * 0 = Left button.
  123894. * 1 = Middle Button.
  123895. * 2 = Right Button.
  123896. */
  123897. activeButton: number;
  123898. /**
  123899. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  123900. * Higher values reduce its sensitivity.
  123901. */
  123902. angularSensibility: number;
  123903. private _mousemoveCallback;
  123904. private _observer;
  123905. private _rollObserver;
  123906. private previousPosition;
  123907. private noPreventDefault;
  123908. private element;
  123909. /**
  123910. * Listen to mouse events to control the camera.
  123911. * @param touchEnabled Define if touch is enabled. (Default is true.)
  123912. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123913. */
  123914. constructor(touchEnabled?: boolean);
  123915. /**
  123916. * Attach the mouse control to the HTML DOM element.
  123917. * @param element Defines the element that listens to the input events.
  123918. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  123919. */
  123920. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123921. /**
  123922. * Detach the current controls from the specified dom element.
  123923. * @param element Defines the element to stop listening the inputs from
  123924. */
  123925. detachControl(element: Nullable<HTMLElement>): void;
  123926. /**
  123927. * Gets the class name of the current input.
  123928. * @returns the class name.
  123929. */
  123930. getClassName(): string;
  123931. /**
  123932. * Get the friendly name associated with the input class.
  123933. * @returns the input's friendly name.
  123934. */
  123935. getSimpleName(): string;
  123936. private _pointerInput;
  123937. private _onMouseMove;
  123938. /**
  123939. * Rotate camera by mouse offset.
  123940. */
  123941. private rotateCamera;
  123942. }
  123943. }
  123944. declare module BABYLON {
  123945. /**
  123946. * Default Inputs manager for the FlyCamera.
  123947. * It groups all the default supported inputs for ease of use.
  123948. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123949. */
  123950. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  123951. /**
  123952. * Instantiates a new FlyCameraInputsManager.
  123953. * @param camera Defines the camera the inputs belong to.
  123954. */
  123955. constructor(camera: FlyCamera);
  123956. /**
  123957. * Add keyboard input support to the input manager.
  123958. * @returns the new FlyCameraKeyboardMoveInput().
  123959. */
  123960. addKeyboard(): FlyCameraInputsManager;
  123961. /**
  123962. * Add mouse input support to the input manager.
  123963. * @param touchEnabled Enable touch screen support.
  123964. * @returns the new FlyCameraMouseInput().
  123965. */
  123966. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  123967. }
  123968. }
  123969. declare module BABYLON {
  123970. /**
  123971. * This is a flying camera, designed for 3D movement and rotation in all directions,
  123972. * such as in a 3D Space Shooter or a Flight Simulator.
  123973. */
  123974. export class FlyCamera extends TargetCamera {
  123975. /**
  123976. * Define the collision ellipsoid of the camera.
  123977. * This is helpful for simulating a camera body, like a player's body.
  123978. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  123979. */
  123980. ellipsoid: Vector3;
  123981. /**
  123982. * Define an offset for the position of the ellipsoid around the camera.
  123983. * This can be helpful if the camera is attached away from the player's body center,
  123984. * such as at its head.
  123985. */
  123986. ellipsoidOffset: Vector3;
  123987. /**
  123988. * Enable or disable collisions of the camera with the rest of the scene objects.
  123989. */
  123990. checkCollisions: boolean;
  123991. /**
  123992. * Enable or disable gravity on the camera.
  123993. */
  123994. applyGravity: boolean;
  123995. /**
  123996. * Define the current direction the camera is moving to.
  123997. */
  123998. cameraDirection: Vector3;
  123999. /**
  124000. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  124001. * This overrides and empties cameraRotation.
  124002. */
  124003. rotationQuaternion: Quaternion;
  124004. /**
  124005. * Track Roll to maintain the wanted Rolling when looking around.
  124006. */
  124007. _trackRoll: number;
  124008. /**
  124009. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  124010. */
  124011. rollCorrect: number;
  124012. /**
  124013. * Mimic a banked turn, Rolling the camera when Yawing.
  124014. * It's recommended to use rollCorrect = 10 for faster banking correction.
  124015. */
  124016. bankedTurn: boolean;
  124017. /**
  124018. * Limit in radians for how much Roll banking will add. (Default: 90°)
  124019. */
  124020. bankedTurnLimit: number;
  124021. /**
  124022. * Value of 0 disables the banked Roll.
  124023. * Value of 1 is equal to the Yaw angle in radians.
  124024. */
  124025. bankedTurnMultiplier: number;
  124026. /**
  124027. * The inputs manager loads all the input sources, such as keyboard and mouse.
  124028. */
  124029. inputs: FlyCameraInputsManager;
  124030. /**
  124031. * Gets the input sensibility for mouse input.
  124032. * Higher values reduce sensitivity.
  124033. */
  124034. get angularSensibility(): number;
  124035. /**
  124036. * Sets the input sensibility for a mouse input.
  124037. * Higher values reduce sensitivity.
  124038. */
  124039. set angularSensibility(value: number);
  124040. /**
  124041. * Get the keys for camera movement forward.
  124042. */
  124043. get keysForward(): number[];
  124044. /**
  124045. * Set the keys for camera movement forward.
  124046. */
  124047. set keysForward(value: number[]);
  124048. /**
  124049. * Get the keys for camera movement backward.
  124050. */
  124051. get keysBackward(): number[];
  124052. set keysBackward(value: number[]);
  124053. /**
  124054. * Get the keys for camera movement up.
  124055. */
  124056. get keysUp(): number[];
  124057. /**
  124058. * Set the keys for camera movement up.
  124059. */
  124060. set keysUp(value: number[]);
  124061. /**
  124062. * Get the keys for camera movement down.
  124063. */
  124064. get keysDown(): number[];
  124065. /**
  124066. * Set the keys for camera movement down.
  124067. */
  124068. set keysDown(value: number[]);
  124069. /**
  124070. * Get the keys for camera movement left.
  124071. */
  124072. get keysLeft(): number[];
  124073. /**
  124074. * Set the keys for camera movement left.
  124075. */
  124076. set keysLeft(value: number[]);
  124077. /**
  124078. * Set the keys for camera movement right.
  124079. */
  124080. get keysRight(): number[];
  124081. /**
  124082. * Set the keys for camera movement right.
  124083. */
  124084. set keysRight(value: number[]);
  124085. /**
  124086. * Event raised when the camera collides with a mesh in the scene.
  124087. */
  124088. onCollide: (collidedMesh: AbstractMesh) => void;
  124089. private _collider;
  124090. private _needMoveForGravity;
  124091. private _oldPosition;
  124092. private _diffPosition;
  124093. private _newPosition;
  124094. /** @hidden */
  124095. _localDirection: Vector3;
  124096. /** @hidden */
  124097. _transformedDirection: Vector3;
  124098. /**
  124099. * Instantiates a FlyCamera.
  124100. * This is a flying camera, designed for 3D movement and rotation in all directions,
  124101. * such as in a 3D Space Shooter or a Flight Simulator.
  124102. * @param name Define the name of the camera in the scene.
  124103. * @param position Define the starting position of the camera in the scene.
  124104. * @param scene Define the scene the camera belongs to.
  124105. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  124106. */
  124107. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  124108. /**
  124109. * Attach a control to the HTML DOM element.
  124110. * @param element Defines the element that listens to the input events.
  124111. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  124112. */
  124113. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124114. /**
  124115. * Detach a control from the HTML DOM element.
  124116. * The camera will stop reacting to that input.
  124117. * @param element Defines the element that listens to the input events.
  124118. */
  124119. detachControl(element: HTMLElement): void;
  124120. private _collisionMask;
  124121. /**
  124122. * Get the mask that the camera ignores in collision events.
  124123. */
  124124. get collisionMask(): number;
  124125. /**
  124126. * Set the mask that the camera ignores in collision events.
  124127. */
  124128. set collisionMask(mask: number);
  124129. /** @hidden */
  124130. _collideWithWorld(displacement: Vector3): void;
  124131. /** @hidden */
  124132. private _onCollisionPositionChange;
  124133. /** @hidden */
  124134. _checkInputs(): void;
  124135. /** @hidden */
  124136. _decideIfNeedsToMove(): boolean;
  124137. /** @hidden */
  124138. _updatePosition(): void;
  124139. /**
  124140. * Restore the Roll to its target value at the rate specified.
  124141. * @param rate - Higher means slower restoring.
  124142. * @hidden
  124143. */
  124144. restoreRoll(rate: number): void;
  124145. /**
  124146. * Destroy the camera and release the current resources held by it.
  124147. */
  124148. dispose(): void;
  124149. /**
  124150. * Get the current object class name.
  124151. * @returns the class name.
  124152. */
  124153. getClassName(): string;
  124154. }
  124155. }
  124156. declare module BABYLON {
  124157. /**
  124158. * Listen to keyboard events to control the camera.
  124159. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124160. */
  124161. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  124162. /**
  124163. * Defines the camera the input is attached to.
  124164. */
  124165. camera: FlyCamera;
  124166. /**
  124167. * The list of keyboard keys used to control the forward move of the camera.
  124168. */
  124169. keysForward: number[];
  124170. /**
  124171. * The list of keyboard keys used to control the backward move of the camera.
  124172. */
  124173. keysBackward: number[];
  124174. /**
  124175. * The list of keyboard keys used to control the forward move of the camera.
  124176. */
  124177. keysUp: number[];
  124178. /**
  124179. * The list of keyboard keys used to control the backward move of the camera.
  124180. */
  124181. keysDown: number[];
  124182. /**
  124183. * The list of keyboard keys used to control the right strafe move of the camera.
  124184. */
  124185. keysRight: number[];
  124186. /**
  124187. * The list of keyboard keys used to control the left strafe move of the camera.
  124188. */
  124189. keysLeft: number[];
  124190. private _keys;
  124191. private _onCanvasBlurObserver;
  124192. private _onKeyboardObserver;
  124193. private _engine;
  124194. private _scene;
  124195. /**
  124196. * Attach the input controls to a specific dom element to get the input from.
  124197. * @param element Defines the element the controls should be listened from
  124198. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124199. */
  124200. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124201. /**
  124202. * Detach the current controls from the specified dom element.
  124203. * @param element Defines the element to stop listening the inputs from
  124204. */
  124205. detachControl(element: Nullable<HTMLElement>): void;
  124206. /**
  124207. * Gets the class name of the current intput.
  124208. * @returns the class name
  124209. */
  124210. getClassName(): string;
  124211. /** @hidden */
  124212. _onLostFocus(e: FocusEvent): void;
  124213. /**
  124214. * Get the friendly name associated with the input class.
  124215. * @returns the input friendly name
  124216. */
  124217. getSimpleName(): string;
  124218. /**
  124219. * Update the current camera state depending on the inputs that have been used this frame.
  124220. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124221. */
  124222. checkInputs(): void;
  124223. }
  124224. }
  124225. declare module BABYLON {
  124226. /**
  124227. * Manage the mouse wheel inputs to control a follow camera.
  124228. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124229. */
  124230. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  124231. /**
  124232. * Defines the camera the input is attached to.
  124233. */
  124234. camera: FollowCamera;
  124235. /**
  124236. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  124237. */
  124238. axisControlRadius: boolean;
  124239. /**
  124240. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  124241. */
  124242. axisControlHeight: boolean;
  124243. /**
  124244. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  124245. */
  124246. axisControlRotation: boolean;
  124247. /**
  124248. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  124249. * relation to mouseWheel events.
  124250. */
  124251. wheelPrecision: number;
  124252. /**
  124253. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  124254. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  124255. */
  124256. wheelDeltaPercentage: number;
  124257. private _wheel;
  124258. private _observer;
  124259. /**
  124260. * Attach the input controls to a specific dom element to get the input from.
  124261. * @param element Defines the element the controls should be listened from
  124262. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124263. */
  124264. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124265. /**
  124266. * Detach the current controls from the specified dom element.
  124267. * @param element Defines the element to stop listening the inputs from
  124268. */
  124269. detachControl(element: Nullable<HTMLElement>): void;
  124270. /**
  124271. * Gets the class name of the current intput.
  124272. * @returns the class name
  124273. */
  124274. getClassName(): string;
  124275. /**
  124276. * Get the friendly name associated with the input class.
  124277. * @returns the input friendly name
  124278. */
  124279. getSimpleName(): string;
  124280. }
  124281. }
  124282. declare module BABYLON {
  124283. /**
  124284. * Manage the pointers inputs to control an follow camera.
  124285. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124286. */
  124287. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  124288. /**
  124289. * Defines the camera the input is attached to.
  124290. */
  124291. camera: FollowCamera;
  124292. /**
  124293. * Gets the class name of the current input.
  124294. * @returns the class name
  124295. */
  124296. getClassName(): string;
  124297. /**
  124298. * Defines the pointer angular sensibility along the X axis or how fast is
  124299. * the camera rotating.
  124300. * A negative number will reverse the axis direction.
  124301. */
  124302. angularSensibilityX: number;
  124303. /**
  124304. * Defines the pointer angular sensibility along the Y axis or how fast is
  124305. * the camera rotating.
  124306. * A negative number will reverse the axis direction.
  124307. */
  124308. angularSensibilityY: number;
  124309. /**
  124310. * Defines the pointer pinch precision or how fast is the camera zooming.
  124311. * A negative number will reverse the axis direction.
  124312. */
  124313. pinchPrecision: number;
  124314. /**
  124315. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  124316. * from 0.
  124317. * It defines the percentage of current camera.radius to use as delta when
  124318. * pinch zoom is used.
  124319. */
  124320. pinchDeltaPercentage: number;
  124321. /**
  124322. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  124323. */
  124324. axisXControlRadius: boolean;
  124325. /**
  124326. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  124327. */
  124328. axisXControlHeight: boolean;
  124329. /**
  124330. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  124331. */
  124332. axisXControlRotation: boolean;
  124333. /**
  124334. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  124335. */
  124336. axisYControlRadius: boolean;
  124337. /**
  124338. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  124339. */
  124340. axisYControlHeight: boolean;
  124341. /**
  124342. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  124343. */
  124344. axisYControlRotation: boolean;
  124345. /**
  124346. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  124347. */
  124348. axisPinchControlRadius: boolean;
  124349. /**
  124350. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  124351. */
  124352. axisPinchControlHeight: boolean;
  124353. /**
  124354. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  124355. */
  124356. axisPinchControlRotation: boolean;
  124357. /**
  124358. * Log error messages if basic misconfiguration has occurred.
  124359. */
  124360. warningEnable: boolean;
  124361. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  124362. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  124363. private _warningCounter;
  124364. private _warning;
  124365. }
  124366. }
  124367. declare module BABYLON {
  124368. /**
  124369. * Default Inputs manager for the FollowCamera.
  124370. * It groups all the default supported inputs for ease of use.
  124371. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124372. */
  124373. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  124374. /**
  124375. * Instantiates a new FollowCameraInputsManager.
  124376. * @param camera Defines the camera the inputs belong to
  124377. */
  124378. constructor(camera: FollowCamera);
  124379. /**
  124380. * Add keyboard input support to the input manager.
  124381. * @returns the current input manager
  124382. */
  124383. addKeyboard(): FollowCameraInputsManager;
  124384. /**
  124385. * Add mouse wheel input support to the input manager.
  124386. * @returns the current input manager
  124387. */
  124388. addMouseWheel(): FollowCameraInputsManager;
  124389. /**
  124390. * Add pointers input support to the input manager.
  124391. * @returns the current input manager
  124392. */
  124393. addPointers(): FollowCameraInputsManager;
  124394. /**
  124395. * Add orientation input support to the input manager.
  124396. * @returns the current input manager
  124397. */
  124398. addVRDeviceOrientation(): FollowCameraInputsManager;
  124399. }
  124400. }
  124401. declare module BABYLON {
  124402. /**
  124403. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  124404. * an arc rotate version arcFollowCamera are available.
  124405. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124406. */
  124407. export class FollowCamera extends TargetCamera {
  124408. /**
  124409. * Distance the follow camera should follow an object at
  124410. */
  124411. radius: number;
  124412. /**
  124413. * Minimum allowed distance of the camera to the axis of rotation
  124414. * (The camera can not get closer).
  124415. * This can help limiting how the Camera is able to move in the scene.
  124416. */
  124417. lowerRadiusLimit: Nullable<number>;
  124418. /**
  124419. * Maximum allowed distance of the camera to the axis of rotation
  124420. * (The camera can not get further).
  124421. * This can help limiting how the Camera is able to move in the scene.
  124422. */
  124423. upperRadiusLimit: Nullable<number>;
  124424. /**
  124425. * Define a rotation offset between the camera and the object it follows
  124426. */
  124427. rotationOffset: number;
  124428. /**
  124429. * Minimum allowed angle to camera position relative to target object.
  124430. * This can help limiting how the Camera is able to move in the scene.
  124431. */
  124432. lowerRotationOffsetLimit: Nullable<number>;
  124433. /**
  124434. * Maximum allowed angle to camera position relative to target object.
  124435. * This can help limiting how the Camera is able to move in the scene.
  124436. */
  124437. upperRotationOffsetLimit: Nullable<number>;
  124438. /**
  124439. * Define a height offset between the camera and the object it follows.
  124440. * It can help following an object from the top (like a car chaing a plane)
  124441. */
  124442. heightOffset: number;
  124443. /**
  124444. * Minimum allowed height of camera position relative to target object.
  124445. * This can help limiting how the Camera is able to move in the scene.
  124446. */
  124447. lowerHeightOffsetLimit: Nullable<number>;
  124448. /**
  124449. * Maximum allowed height of camera position relative to target object.
  124450. * This can help limiting how the Camera is able to move in the scene.
  124451. */
  124452. upperHeightOffsetLimit: Nullable<number>;
  124453. /**
  124454. * Define how fast the camera can accelerate to follow it s target.
  124455. */
  124456. cameraAcceleration: number;
  124457. /**
  124458. * Define the speed limit of the camera following an object.
  124459. */
  124460. maxCameraSpeed: number;
  124461. /**
  124462. * Define the target of the camera.
  124463. */
  124464. lockedTarget: Nullable<AbstractMesh>;
  124465. /**
  124466. * Defines the input associated with the camera.
  124467. */
  124468. inputs: FollowCameraInputsManager;
  124469. /**
  124470. * Instantiates the follow camera.
  124471. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124472. * @param name Define the name of the camera in the scene
  124473. * @param position Define the position of the camera
  124474. * @param scene Define the scene the camera belong to
  124475. * @param lockedTarget Define the target of the camera
  124476. */
  124477. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  124478. private _follow;
  124479. /**
  124480. * Attached controls to the current camera.
  124481. * @param element Defines the element the controls should be listened from
  124482. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124483. */
  124484. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124485. /**
  124486. * Detach the current controls from the camera.
  124487. * The camera will stop reacting to inputs.
  124488. * @param element Defines the element to stop listening the inputs from
  124489. */
  124490. detachControl(element: HTMLElement): void;
  124491. /** @hidden */
  124492. _checkInputs(): void;
  124493. private _checkLimits;
  124494. /**
  124495. * Gets the camera class name.
  124496. * @returns the class name
  124497. */
  124498. getClassName(): string;
  124499. }
  124500. /**
  124501. * Arc Rotate version of the follow camera.
  124502. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  124503. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124504. */
  124505. export class ArcFollowCamera extends TargetCamera {
  124506. /** The longitudinal angle of the camera */
  124507. alpha: number;
  124508. /** The latitudinal angle of the camera */
  124509. beta: number;
  124510. /** The radius of the camera from its target */
  124511. radius: number;
  124512. private _cartesianCoordinates;
  124513. /** Define the camera target (the mesh it should follow) */
  124514. private _meshTarget;
  124515. /**
  124516. * Instantiates a new ArcFollowCamera
  124517. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124518. * @param name Define the name of the camera
  124519. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  124520. * @param beta Define the rotation angle of the camera around the elevation axis
  124521. * @param radius Define the radius of the camera from its target point
  124522. * @param target Define the target of the camera
  124523. * @param scene Define the scene the camera belongs to
  124524. */
  124525. constructor(name: string,
  124526. /** The longitudinal angle of the camera */
  124527. alpha: number,
  124528. /** The latitudinal angle of the camera */
  124529. beta: number,
  124530. /** The radius of the camera from its target */
  124531. radius: number,
  124532. /** Define the camera target (the mesh it should follow) */
  124533. target: Nullable<AbstractMesh>, scene: Scene);
  124534. private _follow;
  124535. /** @hidden */
  124536. _checkInputs(): void;
  124537. /**
  124538. * Returns the class name of the object.
  124539. * It is mostly used internally for serialization purposes.
  124540. */
  124541. getClassName(): string;
  124542. }
  124543. }
  124544. declare module BABYLON {
  124545. /**
  124546. * Manage the keyboard inputs to control the movement of a follow camera.
  124547. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124548. */
  124549. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  124550. /**
  124551. * Defines the camera the input is attached to.
  124552. */
  124553. camera: FollowCamera;
  124554. /**
  124555. * Defines the list of key codes associated with the up action (increase heightOffset)
  124556. */
  124557. keysHeightOffsetIncr: number[];
  124558. /**
  124559. * Defines the list of key codes associated with the down action (decrease heightOffset)
  124560. */
  124561. keysHeightOffsetDecr: number[];
  124562. /**
  124563. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  124564. */
  124565. keysHeightOffsetModifierAlt: boolean;
  124566. /**
  124567. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  124568. */
  124569. keysHeightOffsetModifierCtrl: boolean;
  124570. /**
  124571. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  124572. */
  124573. keysHeightOffsetModifierShift: boolean;
  124574. /**
  124575. * Defines the list of key codes associated with the left action (increase rotationOffset)
  124576. */
  124577. keysRotationOffsetIncr: number[];
  124578. /**
  124579. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  124580. */
  124581. keysRotationOffsetDecr: number[];
  124582. /**
  124583. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  124584. */
  124585. keysRotationOffsetModifierAlt: boolean;
  124586. /**
  124587. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  124588. */
  124589. keysRotationOffsetModifierCtrl: boolean;
  124590. /**
  124591. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  124592. */
  124593. keysRotationOffsetModifierShift: boolean;
  124594. /**
  124595. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  124596. */
  124597. keysRadiusIncr: number[];
  124598. /**
  124599. * Defines the list of key codes associated with the zoom-out action (increase radius)
  124600. */
  124601. keysRadiusDecr: number[];
  124602. /**
  124603. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  124604. */
  124605. keysRadiusModifierAlt: boolean;
  124606. /**
  124607. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  124608. */
  124609. keysRadiusModifierCtrl: boolean;
  124610. /**
  124611. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  124612. */
  124613. keysRadiusModifierShift: boolean;
  124614. /**
  124615. * Defines the rate of change of heightOffset.
  124616. */
  124617. heightSensibility: number;
  124618. /**
  124619. * Defines the rate of change of rotationOffset.
  124620. */
  124621. rotationSensibility: number;
  124622. /**
  124623. * Defines the rate of change of radius.
  124624. */
  124625. radiusSensibility: number;
  124626. private _keys;
  124627. private _ctrlPressed;
  124628. private _altPressed;
  124629. private _shiftPressed;
  124630. private _onCanvasBlurObserver;
  124631. private _onKeyboardObserver;
  124632. private _engine;
  124633. private _scene;
  124634. /**
  124635. * Attach the input controls to a specific dom element to get the input from.
  124636. * @param element Defines the element the controls should be listened from
  124637. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124638. */
  124639. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124640. /**
  124641. * Detach the current controls from the specified dom element.
  124642. * @param element Defines the element to stop listening the inputs from
  124643. */
  124644. detachControl(element: Nullable<HTMLElement>): void;
  124645. /**
  124646. * Update the current camera state depending on the inputs that have been used this frame.
  124647. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124648. */
  124649. checkInputs(): void;
  124650. /**
  124651. * Gets the class name of the current input.
  124652. * @returns the class name
  124653. */
  124654. getClassName(): string;
  124655. /**
  124656. * Get the friendly name associated with the input class.
  124657. * @returns the input friendly name
  124658. */
  124659. getSimpleName(): string;
  124660. /**
  124661. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  124662. * allow modification of the heightOffset value.
  124663. */
  124664. private _modifierHeightOffset;
  124665. /**
  124666. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  124667. * allow modification of the rotationOffset value.
  124668. */
  124669. private _modifierRotationOffset;
  124670. /**
  124671. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  124672. * allow modification of the radius value.
  124673. */
  124674. private _modifierRadius;
  124675. }
  124676. }
  124677. declare module BABYLON {
  124678. interface FreeCameraInputsManager {
  124679. /**
  124680. * @hidden
  124681. */
  124682. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  124683. /**
  124684. * Add orientation input support to the input manager.
  124685. * @returns the current input manager
  124686. */
  124687. addDeviceOrientation(): FreeCameraInputsManager;
  124688. }
  124689. /**
  124690. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  124691. * Screen rotation is taken into account.
  124692. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124693. */
  124694. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  124695. private _camera;
  124696. private _screenOrientationAngle;
  124697. private _constantTranform;
  124698. private _screenQuaternion;
  124699. private _alpha;
  124700. private _beta;
  124701. private _gamma;
  124702. /**
  124703. * Can be used to detect if a device orientation sensor is available on a device
  124704. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  124705. * @returns a promise that will resolve on orientation change
  124706. */
  124707. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  124708. /**
  124709. * @hidden
  124710. */
  124711. _onDeviceOrientationChangedObservable: Observable<void>;
  124712. /**
  124713. * Instantiates a new input
  124714. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124715. */
  124716. constructor();
  124717. /**
  124718. * Define the camera controlled by the input.
  124719. */
  124720. get camera(): FreeCamera;
  124721. set camera(camera: FreeCamera);
  124722. /**
  124723. * Attach the input controls to a specific dom element to get the input from.
  124724. * @param element Defines the element the controls should be listened from
  124725. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124726. */
  124727. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124728. private _orientationChanged;
  124729. private _deviceOrientation;
  124730. /**
  124731. * Detach the current controls from the specified dom element.
  124732. * @param element Defines the element to stop listening the inputs from
  124733. */
  124734. detachControl(element: Nullable<HTMLElement>): void;
  124735. /**
  124736. * Update the current camera state depending on the inputs that have been used this frame.
  124737. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124738. */
  124739. checkInputs(): void;
  124740. /**
  124741. * Gets the class name of the current intput.
  124742. * @returns the class name
  124743. */
  124744. getClassName(): string;
  124745. /**
  124746. * Get the friendly name associated with the input class.
  124747. * @returns the input friendly name
  124748. */
  124749. getSimpleName(): string;
  124750. }
  124751. }
  124752. declare module BABYLON {
  124753. /**
  124754. * Manage the gamepad inputs to control a free camera.
  124755. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124756. */
  124757. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  124758. /**
  124759. * Define the camera the input is attached to.
  124760. */
  124761. camera: FreeCamera;
  124762. /**
  124763. * Define the Gamepad controlling the input
  124764. */
  124765. gamepad: Nullable<Gamepad>;
  124766. /**
  124767. * Defines the gamepad rotation sensiblity.
  124768. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  124769. */
  124770. gamepadAngularSensibility: number;
  124771. /**
  124772. * Defines the gamepad move sensiblity.
  124773. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  124774. */
  124775. gamepadMoveSensibility: number;
  124776. private _yAxisScale;
  124777. /**
  124778. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  124779. */
  124780. get invertYAxis(): boolean;
  124781. set invertYAxis(value: boolean);
  124782. private _onGamepadConnectedObserver;
  124783. private _onGamepadDisconnectedObserver;
  124784. private _cameraTransform;
  124785. private _deltaTransform;
  124786. private _vector3;
  124787. private _vector2;
  124788. /**
  124789. * Attach the input controls to a specific dom element to get the input from.
  124790. * @param element Defines the element the controls should be listened from
  124791. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124792. */
  124793. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124794. /**
  124795. * Detach the current controls from the specified dom element.
  124796. * @param element Defines the element to stop listening the inputs from
  124797. */
  124798. detachControl(element: Nullable<HTMLElement>): void;
  124799. /**
  124800. * Update the current camera state depending on the inputs that have been used this frame.
  124801. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124802. */
  124803. checkInputs(): void;
  124804. /**
  124805. * Gets the class name of the current intput.
  124806. * @returns the class name
  124807. */
  124808. getClassName(): string;
  124809. /**
  124810. * Get the friendly name associated with the input class.
  124811. * @returns the input friendly name
  124812. */
  124813. getSimpleName(): string;
  124814. }
  124815. }
  124816. declare module BABYLON {
  124817. /**
  124818. * Defines the potential axis of a Joystick
  124819. */
  124820. export enum JoystickAxis {
  124821. /** X axis */
  124822. X = 0,
  124823. /** Y axis */
  124824. Y = 1,
  124825. /** Z axis */
  124826. Z = 2
  124827. }
  124828. /**
  124829. * Represents the different customization options available
  124830. * for VirtualJoystick
  124831. */
  124832. interface VirtualJoystickCustomizations {
  124833. /**
  124834. * Size of the joystick's puck
  124835. */
  124836. puckSize: number;
  124837. /**
  124838. * Size of the joystick's container
  124839. */
  124840. containerSize: number;
  124841. /**
  124842. * Color of the joystick && puck
  124843. */
  124844. color: string;
  124845. /**
  124846. * Image URL for the joystick's puck
  124847. */
  124848. puckImage?: string;
  124849. /**
  124850. * Image URL for the joystick's container
  124851. */
  124852. containerImage?: string;
  124853. /**
  124854. * Defines the unmoving position of the joystick container
  124855. */
  124856. position?: {
  124857. x: number;
  124858. y: number;
  124859. };
  124860. /**
  124861. * Defines whether or not the joystick container is always visible
  124862. */
  124863. alwaysVisible: boolean;
  124864. /**
  124865. * Defines whether or not to limit the movement of the puck to the joystick's container
  124866. */
  124867. limitToContainer: boolean;
  124868. }
  124869. /**
  124870. * Class used to define virtual joystick (used in touch mode)
  124871. */
  124872. export class VirtualJoystick {
  124873. /**
  124874. * Gets or sets a boolean indicating that left and right values must be inverted
  124875. */
  124876. reverseLeftRight: boolean;
  124877. /**
  124878. * Gets or sets a boolean indicating that up and down values must be inverted
  124879. */
  124880. reverseUpDown: boolean;
  124881. /**
  124882. * Gets the offset value for the position (ie. the change of the position value)
  124883. */
  124884. deltaPosition: Vector3;
  124885. /**
  124886. * Gets a boolean indicating if the virtual joystick was pressed
  124887. */
  124888. pressed: boolean;
  124889. /**
  124890. * Canvas the virtual joystick will render onto, default z-index of this is 5
  124891. */
  124892. static Canvas: Nullable<HTMLCanvasElement>;
  124893. /**
  124894. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  124895. */
  124896. limitToContainer: boolean;
  124897. private static _globalJoystickIndex;
  124898. private static _alwaysVisibleSticks;
  124899. private static vjCanvasContext;
  124900. private static vjCanvasWidth;
  124901. private static vjCanvasHeight;
  124902. private static halfWidth;
  124903. private static _GetDefaultOptions;
  124904. private _action;
  124905. private _axisTargetedByLeftAndRight;
  124906. private _axisTargetedByUpAndDown;
  124907. private _joystickSensibility;
  124908. private _inversedSensibility;
  124909. private _joystickPointerID;
  124910. private _joystickColor;
  124911. private _joystickPointerPos;
  124912. private _joystickPreviousPointerPos;
  124913. private _joystickPointerStartPos;
  124914. private _deltaJoystickVector;
  124915. private _leftJoystick;
  124916. private _touches;
  124917. private _joystickPosition;
  124918. private _alwaysVisible;
  124919. private _puckImage;
  124920. private _containerImage;
  124921. private _joystickPuckSize;
  124922. private _joystickContainerSize;
  124923. private _clearPuckSize;
  124924. private _clearContainerSize;
  124925. private _clearPuckSizeOffset;
  124926. private _clearContainerSizeOffset;
  124927. private _onPointerDownHandlerRef;
  124928. private _onPointerMoveHandlerRef;
  124929. private _onPointerUpHandlerRef;
  124930. private _onResize;
  124931. /**
  124932. * Creates a new virtual joystick
  124933. * @param leftJoystick defines that the joystick is for left hand (false by default)
  124934. * @param customizations Defines the options we want to customize the VirtualJoystick
  124935. */
  124936. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  124937. /**
  124938. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  124939. * @param newJoystickSensibility defines the new sensibility
  124940. */
  124941. setJoystickSensibility(newJoystickSensibility: number): void;
  124942. private _onPointerDown;
  124943. private _onPointerMove;
  124944. private _onPointerUp;
  124945. /**
  124946. * Change the color of the virtual joystick
  124947. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  124948. */
  124949. setJoystickColor(newColor: string): void;
  124950. /**
  124951. * Size of the joystick's container
  124952. */
  124953. set containerSize(newSize: number);
  124954. get containerSize(): number;
  124955. /**
  124956. * Size of the joystick's puck
  124957. */
  124958. set puckSize(newSize: number);
  124959. get puckSize(): number;
  124960. /**
  124961. * Clears the set position of the joystick
  124962. */
  124963. clearPosition(): void;
  124964. /**
  124965. * Defines whether or not the joystick container is always visible
  124966. */
  124967. set alwaysVisible(value: boolean);
  124968. get alwaysVisible(): boolean;
  124969. /**
  124970. * Sets the constant position of the Joystick container
  124971. * @param x X axis coordinate
  124972. * @param y Y axis coordinate
  124973. */
  124974. setPosition(x: number, y: number): void;
  124975. /**
  124976. * Defines a callback to call when the joystick is touched
  124977. * @param action defines the callback
  124978. */
  124979. setActionOnTouch(action: () => any): void;
  124980. /**
  124981. * Defines which axis you'd like to control for left & right
  124982. * @param axis defines the axis to use
  124983. */
  124984. setAxisForLeftRight(axis: JoystickAxis): void;
  124985. /**
  124986. * Defines which axis you'd like to control for up & down
  124987. * @param axis defines the axis to use
  124988. */
  124989. setAxisForUpDown(axis: JoystickAxis): void;
  124990. /**
  124991. * Clears the canvas from the previous puck / container draw
  124992. */
  124993. private _clearPreviousDraw;
  124994. /**
  124995. * Loads `urlPath` to be used for the container's image
  124996. * @param urlPath defines the urlPath of an image to use
  124997. */
  124998. setContainerImage(urlPath: string): void;
  124999. /**
  125000. * Loads `urlPath` to be used for the puck's image
  125001. * @param urlPath defines the urlPath of an image to use
  125002. */
  125003. setPuckImage(urlPath: string): void;
  125004. /**
  125005. * Draws the Virtual Joystick's container
  125006. */
  125007. private _drawContainer;
  125008. /**
  125009. * Draws the Virtual Joystick's puck
  125010. */
  125011. private _drawPuck;
  125012. private _drawVirtualJoystick;
  125013. /**
  125014. * Release internal HTML canvas
  125015. */
  125016. releaseCanvas(): void;
  125017. }
  125018. }
  125019. declare module BABYLON {
  125020. interface FreeCameraInputsManager {
  125021. /**
  125022. * Add virtual joystick input support to the input manager.
  125023. * @returns the current input manager
  125024. */
  125025. addVirtualJoystick(): FreeCameraInputsManager;
  125026. }
  125027. /**
  125028. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  125029. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125030. */
  125031. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  125032. /**
  125033. * Defines the camera the input is attached to.
  125034. */
  125035. camera: FreeCamera;
  125036. private _leftjoystick;
  125037. private _rightjoystick;
  125038. /**
  125039. * Gets the left stick of the virtual joystick.
  125040. * @returns The virtual Joystick
  125041. */
  125042. getLeftJoystick(): VirtualJoystick;
  125043. /**
  125044. * Gets the right stick of the virtual joystick.
  125045. * @returns The virtual Joystick
  125046. */
  125047. getRightJoystick(): VirtualJoystick;
  125048. /**
  125049. * Update the current camera state depending on the inputs that have been used this frame.
  125050. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125051. */
  125052. checkInputs(): void;
  125053. /**
  125054. * Attach the input controls to a specific dom element to get the input from.
  125055. * @param element Defines the element the controls should be listened from
  125056. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125057. */
  125058. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125059. /**
  125060. * Detach the current controls from the specified dom element.
  125061. * @param element Defines the element to stop listening the inputs from
  125062. */
  125063. detachControl(element: Nullable<HTMLElement>): void;
  125064. /**
  125065. * Gets the class name of the current intput.
  125066. * @returns the class name
  125067. */
  125068. getClassName(): string;
  125069. /**
  125070. * Get the friendly name associated with the input class.
  125071. * @returns the input friendly name
  125072. */
  125073. getSimpleName(): string;
  125074. }
  125075. }
  125076. declare module BABYLON {
  125077. /**
  125078. * This represents a FPS type of camera controlled by touch.
  125079. * This is like a universal camera minus the Gamepad controls.
  125080. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125081. */
  125082. export class TouchCamera extends FreeCamera {
  125083. /**
  125084. * Defines the touch sensibility for rotation.
  125085. * The higher the faster.
  125086. */
  125087. get touchAngularSensibility(): number;
  125088. set touchAngularSensibility(value: number);
  125089. /**
  125090. * Defines the touch sensibility for move.
  125091. * The higher the faster.
  125092. */
  125093. get touchMoveSensibility(): number;
  125094. set touchMoveSensibility(value: number);
  125095. /**
  125096. * Instantiates a new touch camera.
  125097. * This represents a FPS type of camera controlled by touch.
  125098. * This is like a universal camera minus the Gamepad controls.
  125099. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125100. * @param name Define the name of the camera in the scene
  125101. * @param position Define the start position of the camera in the scene
  125102. * @param scene Define the scene the camera belongs to
  125103. */
  125104. constructor(name: string, position: Vector3, scene: Scene);
  125105. /**
  125106. * Gets the current object class name.
  125107. * @return the class name
  125108. */
  125109. getClassName(): string;
  125110. /** @hidden */
  125111. _setupInputs(): void;
  125112. }
  125113. }
  125114. declare module BABYLON {
  125115. /**
  125116. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  125117. * being tilted forward or back and left or right.
  125118. */
  125119. export class DeviceOrientationCamera extends FreeCamera {
  125120. private _initialQuaternion;
  125121. private _quaternionCache;
  125122. private _tmpDragQuaternion;
  125123. private _disablePointerInputWhenUsingDeviceOrientation;
  125124. /**
  125125. * Creates a new device orientation camera
  125126. * @param name The name of the camera
  125127. * @param position The start position camera
  125128. * @param scene The scene the camera belongs to
  125129. */
  125130. constructor(name: string, position: Vector3, scene: Scene);
  125131. /**
  125132. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  125133. */
  125134. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  125135. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  125136. private _dragFactor;
  125137. /**
  125138. * Enabled turning on the y axis when the orientation sensor is active
  125139. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  125140. */
  125141. enableHorizontalDragging(dragFactor?: number): void;
  125142. /**
  125143. * Gets the current instance class name ("DeviceOrientationCamera").
  125144. * This helps avoiding instanceof at run time.
  125145. * @returns the class name
  125146. */
  125147. getClassName(): string;
  125148. /**
  125149. * @hidden
  125150. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  125151. */
  125152. _checkInputs(): void;
  125153. /**
  125154. * Reset the camera to its default orientation on the specified axis only.
  125155. * @param axis The axis to reset
  125156. */
  125157. resetToCurrentRotation(axis?: Axis): void;
  125158. }
  125159. }
  125160. declare module BABYLON {
  125161. /**
  125162. * Defines supported buttons for XBox360 compatible gamepads
  125163. */
  125164. export enum Xbox360Button {
  125165. /** A */
  125166. A = 0,
  125167. /** B */
  125168. B = 1,
  125169. /** X */
  125170. X = 2,
  125171. /** Y */
  125172. Y = 3,
  125173. /** Left button */
  125174. LB = 4,
  125175. /** Right button */
  125176. RB = 5,
  125177. /** Back */
  125178. Back = 8,
  125179. /** Start */
  125180. Start = 9,
  125181. /** Left stick */
  125182. LeftStick = 10,
  125183. /** Right stick */
  125184. RightStick = 11
  125185. }
  125186. /** Defines values for XBox360 DPad */
  125187. export enum Xbox360Dpad {
  125188. /** Up */
  125189. Up = 12,
  125190. /** Down */
  125191. Down = 13,
  125192. /** Left */
  125193. Left = 14,
  125194. /** Right */
  125195. Right = 15
  125196. }
  125197. /**
  125198. * Defines a XBox360 gamepad
  125199. */
  125200. export class Xbox360Pad extends Gamepad {
  125201. private _leftTrigger;
  125202. private _rightTrigger;
  125203. private _onlefttriggerchanged;
  125204. private _onrighttriggerchanged;
  125205. private _onbuttondown;
  125206. private _onbuttonup;
  125207. private _ondpaddown;
  125208. private _ondpadup;
  125209. /** Observable raised when a button is pressed */
  125210. onButtonDownObservable: Observable<Xbox360Button>;
  125211. /** Observable raised when a button is released */
  125212. onButtonUpObservable: Observable<Xbox360Button>;
  125213. /** Observable raised when a pad is pressed */
  125214. onPadDownObservable: Observable<Xbox360Dpad>;
  125215. /** Observable raised when a pad is released */
  125216. onPadUpObservable: Observable<Xbox360Dpad>;
  125217. private _buttonA;
  125218. private _buttonB;
  125219. private _buttonX;
  125220. private _buttonY;
  125221. private _buttonBack;
  125222. private _buttonStart;
  125223. private _buttonLB;
  125224. private _buttonRB;
  125225. private _buttonLeftStick;
  125226. private _buttonRightStick;
  125227. private _dPadUp;
  125228. private _dPadDown;
  125229. private _dPadLeft;
  125230. private _dPadRight;
  125231. private _isXboxOnePad;
  125232. /**
  125233. * Creates a new XBox360 gamepad object
  125234. * @param id defines the id of this gamepad
  125235. * @param index defines its index
  125236. * @param gamepad defines the internal HTML gamepad object
  125237. * @param xboxOne defines if it is a XBox One gamepad
  125238. */
  125239. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  125240. /**
  125241. * Defines the callback to call when left trigger is pressed
  125242. * @param callback defines the callback to use
  125243. */
  125244. onlefttriggerchanged(callback: (value: number) => void): void;
  125245. /**
  125246. * Defines the callback to call when right trigger is pressed
  125247. * @param callback defines the callback to use
  125248. */
  125249. onrighttriggerchanged(callback: (value: number) => void): void;
  125250. /**
  125251. * Gets the left trigger value
  125252. */
  125253. get leftTrigger(): number;
  125254. /**
  125255. * Sets the left trigger value
  125256. */
  125257. set leftTrigger(newValue: number);
  125258. /**
  125259. * Gets the right trigger value
  125260. */
  125261. get rightTrigger(): number;
  125262. /**
  125263. * Sets the right trigger value
  125264. */
  125265. set rightTrigger(newValue: number);
  125266. /**
  125267. * Defines the callback to call when a button is pressed
  125268. * @param callback defines the callback to use
  125269. */
  125270. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  125271. /**
  125272. * Defines the callback to call when a button is released
  125273. * @param callback defines the callback to use
  125274. */
  125275. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  125276. /**
  125277. * Defines the callback to call when a pad is pressed
  125278. * @param callback defines the callback to use
  125279. */
  125280. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  125281. /**
  125282. * Defines the callback to call when a pad is released
  125283. * @param callback defines the callback to use
  125284. */
  125285. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  125286. private _setButtonValue;
  125287. private _setDPadValue;
  125288. /**
  125289. * Gets the value of the `A` button
  125290. */
  125291. get buttonA(): number;
  125292. /**
  125293. * Sets the value of the `A` button
  125294. */
  125295. set buttonA(value: number);
  125296. /**
  125297. * Gets the value of the `B` button
  125298. */
  125299. get buttonB(): number;
  125300. /**
  125301. * Sets the value of the `B` button
  125302. */
  125303. set buttonB(value: number);
  125304. /**
  125305. * Gets the value of the `X` button
  125306. */
  125307. get buttonX(): number;
  125308. /**
  125309. * Sets the value of the `X` button
  125310. */
  125311. set buttonX(value: number);
  125312. /**
  125313. * Gets the value of the `Y` button
  125314. */
  125315. get buttonY(): number;
  125316. /**
  125317. * Sets the value of the `Y` button
  125318. */
  125319. set buttonY(value: number);
  125320. /**
  125321. * Gets the value of the `Start` button
  125322. */
  125323. get buttonStart(): number;
  125324. /**
  125325. * Sets the value of the `Start` button
  125326. */
  125327. set buttonStart(value: number);
  125328. /**
  125329. * Gets the value of the `Back` button
  125330. */
  125331. get buttonBack(): number;
  125332. /**
  125333. * Sets the value of the `Back` button
  125334. */
  125335. set buttonBack(value: number);
  125336. /**
  125337. * Gets the value of the `Left` button
  125338. */
  125339. get buttonLB(): number;
  125340. /**
  125341. * Sets the value of the `Left` button
  125342. */
  125343. set buttonLB(value: number);
  125344. /**
  125345. * Gets the value of the `Right` button
  125346. */
  125347. get buttonRB(): number;
  125348. /**
  125349. * Sets the value of the `Right` button
  125350. */
  125351. set buttonRB(value: number);
  125352. /**
  125353. * Gets the value of the Left joystick
  125354. */
  125355. get buttonLeftStick(): number;
  125356. /**
  125357. * Sets the value of the Left joystick
  125358. */
  125359. set buttonLeftStick(value: number);
  125360. /**
  125361. * Gets the value of the Right joystick
  125362. */
  125363. get buttonRightStick(): number;
  125364. /**
  125365. * Sets the value of the Right joystick
  125366. */
  125367. set buttonRightStick(value: number);
  125368. /**
  125369. * Gets the value of D-pad up
  125370. */
  125371. get dPadUp(): number;
  125372. /**
  125373. * Sets the value of D-pad up
  125374. */
  125375. set dPadUp(value: number);
  125376. /**
  125377. * Gets the value of D-pad down
  125378. */
  125379. get dPadDown(): number;
  125380. /**
  125381. * Sets the value of D-pad down
  125382. */
  125383. set dPadDown(value: number);
  125384. /**
  125385. * Gets the value of D-pad left
  125386. */
  125387. get dPadLeft(): number;
  125388. /**
  125389. * Sets the value of D-pad left
  125390. */
  125391. set dPadLeft(value: number);
  125392. /**
  125393. * Gets the value of D-pad right
  125394. */
  125395. get dPadRight(): number;
  125396. /**
  125397. * Sets the value of D-pad right
  125398. */
  125399. set dPadRight(value: number);
  125400. /**
  125401. * Force the gamepad to synchronize with device values
  125402. */
  125403. update(): void;
  125404. /**
  125405. * Disposes the gamepad
  125406. */
  125407. dispose(): void;
  125408. }
  125409. }
  125410. declare module BABYLON {
  125411. /**
  125412. * Defines supported buttons for DualShock compatible gamepads
  125413. */
  125414. export enum DualShockButton {
  125415. /** Cross */
  125416. Cross = 0,
  125417. /** Circle */
  125418. Circle = 1,
  125419. /** Square */
  125420. Square = 2,
  125421. /** Triangle */
  125422. Triangle = 3,
  125423. /** L1 */
  125424. L1 = 4,
  125425. /** R1 */
  125426. R1 = 5,
  125427. /** Share */
  125428. Share = 8,
  125429. /** Options */
  125430. Options = 9,
  125431. /** Left stick */
  125432. LeftStick = 10,
  125433. /** Right stick */
  125434. RightStick = 11
  125435. }
  125436. /** Defines values for DualShock DPad */
  125437. export enum DualShockDpad {
  125438. /** Up */
  125439. Up = 12,
  125440. /** Down */
  125441. Down = 13,
  125442. /** Left */
  125443. Left = 14,
  125444. /** Right */
  125445. Right = 15
  125446. }
  125447. /**
  125448. * Defines a DualShock gamepad
  125449. */
  125450. export class DualShockPad extends Gamepad {
  125451. private _leftTrigger;
  125452. private _rightTrigger;
  125453. private _onlefttriggerchanged;
  125454. private _onrighttriggerchanged;
  125455. private _onbuttondown;
  125456. private _onbuttonup;
  125457. private _ondpaddown;
  125458. private _ondpadup;
  125459. /** Observable raised when a button is pressed */
  125460. onButtonDownObservable: Observable<DualShockButton>;
  125461. /** Observable raised when a button is released */
  125462. onButtonUpObservable: Observable<DualShockButton>;
  125463. /** Observable raised when a pad is pressed */
  125464. onPadDownObservable: Observable<DualShockDpad>;
  125465. /** Observable raised when a pad is released */
  125466. onPadUpObservable: Observable<DualShockDpad>;
  125467. private _buttonCross;
  125468. private _buttonCircle;
  125469. private _buttonSquare;
  125470. private _buttonTriangle;
  125471. private _buttonShare;
  125472. private _buttonOptions;
  125473. private _buttonL1;
  125474. private _buttonR1;
  125475. private _buttonLeftStick;
  125476. private _buttonRightStick;
  125477. private _dPadUp;
  125478. private _dPadDown;
  125479. private _dPadLeft;
  125480. private _dPadRight;
  125481. /**
  125482. * Creates a new DualShock gamepad object
  125483. * @param id defines the id of this gamepad
  125484. * @param index defines its index
  125485. * @param gamepad defines the internal HTML gamepad object
  125486. */
  125487. constructor(id: string, index: number, gamepad: any);
  125488. /**
  125489. * Defines the callback to call when left trigger is pressed
  125490. * @param callback defines the callback to use
  125491. */
  125492. onlefttriggerchanged(callback: (value: number) => void): void;
  125493. /**
  125494. * Defines the callback to call when right trigger is pressed
  125495. * @param callback defines the callback to use
  125496. */
  125497. onrighttriggerchanged(callback: (value: number) => void): void;
  125498. /**
  125499. * Gets the left trigger value
  125500. */
  125501. get leftTrigger(): number;
  125502. /**
  125503. * Sets the left trigger value
  125504. */
  125505. set leftTrigger(newValue: number);
  125506. /**
  125507. * Gets the right trigger value
  125508. */
  125509. get rightTrigger(): number;
  125510. /**
  125511. * Sets the right trigger value
  125512. */
  125513. set rightTrigger(newValue: number);
  125514. /**
  125515. * Defines the callback to call when a button is pressed
  125516. * @param callback defines the callback to use
  125517. */
  125518. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  125519. /**
  125520. * Defines the callback to call when a button is released
  125521. * @param callback defines the callback to use
  125522. */
  125523. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  125524. /**
  125525. * Defines the callback to call when a pad is pressed
  125526. * @param callback defines the callback to use
  125527. */
  125528. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  125529. /**
  125530. * Defines the callback to call when a pad is released
  125531. * @param callback defines the callback to use
  125532. */
  125533. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  125534. private _setButtonValue;
  125535. private _setDPadValue;
  125536. /**
  125537. * Gets the value of the `Cross` button
  125538. */
  125539. get buttonCross(): number;
  125540. /**
  125541. * Sets the value of the `Cross` button
  125542. */
  125543. set buttonCross(value: number);
  125544. /**
  125545. * Gets the value of the `Circle` button
  125546. */
  125547. get buttonCircle(): number;
  125548. /**
  125549. * Sets the value of the `Circle` button
  125550. */
  125551. set buttonCircle(value: number);
  125552. /**
  125553. * Gets the value of the `Square` button
  125554. */
  125555. get buttonSquare(): number;
  125556. /**
  125557. * Sets the value of the `Square` button
  125558. */
  125559. set buttonSquare(value: number);
  125560. /**
  125561. * Gets the value of the `Triangle` button
  125562. */
  125563. get buttonTriangle(): number;
  125564. /**
  125565. * Sets the value of the `Triangle` button
  125566. */
  125567. set buttonTriangle(value: number);
  125568. /**
  125569. * Gets the value of the `Options` button
  125570. */
  125571. get buttonOptions(): number;
  125572. /**
  125573. * Sets the value of the `Options` button
  125574. */
  125575. set buttonOptions(value: number);
  125576. /**
  125577. * Gets the value of the `Share` button
  125578. */
  125579. get buttonShare(): number;
  125580. /**
  125581. * Sets the value of the `Share` button
  125582. */
  125583. set buttonShare(value: number);
  125584. /**
  125585. * Gets the value of the `L1` button
  125586. */
  125587. get buttonL1(): number;
  125588. /**
  125589. * Sets the value of the `L1` button
  125590. */
  125591. set buttonL1(value: number);
  125592. /**
  125593. * Gets the value of the `R1` button
  125594. */
  125595. get buttonR1(): number;
  125596. /**
  125597. * Sets the value of the `R1` button
  125598. */
  125599. set buttonR1(value: number);
  125600. /**
  125601. * Gets the value of the Left joystick
  125602. */
  125603. get buttonLeftStick(): number;
  125604. /**
  125605. * Sets the value of the Left joystick
  125606. */
  125607. set buttonLeftStick(value: number);
  125608. /**
  125609. * Gets the value of the Right joystick
  125610. */
  125611. get buttonRightStick(): number;
  125612. /**
  125613. * Sets the value of the Right joystick
  125614. */
  125615. set buttonRightStick(value: number);
  125616. /**
  125617. * Gets the value of D-pad up
  125618. */
  125619. get dPadUp(): number;
  125620. /**
  125621. * Sets the value of D-pad up
  125622. */
  125623. set dPadUp(value: number);
  125624. /**
  125625. * Gets the value of D-pad down
  125626. */
  125627. get dPadDown(): number;
  125628. /**
  125629. * Sets the value of D-pad down
  125630. */
  125631. set dPadDown(value: number);
  125632. /**
  125633. * Gets the value of D-pad left
  125634. */
  125635. get dPadLeft(): number;
  125636. /**
  125637. * Sets the value of D-pad left
  125638. */
  125639. set dPadLeft(value: number);
  125640. /**
  125641. * Gets the value of D-pad right
  125642. */
  125643. get dPadRight(): number;
  125644. /**
  125645. * Sets the value of D-pad right
  125646. */
  125647. set dPadRight(value: number);
  125648. /**
  125649. * Force the gamepad to synchronize with device values
  125650. */
  125651. update(): void;
  125652. /**
  125653. * Disposes the gamepad
  125654. */
  125655. dispose(): void;
  125656. }
  125657. }
  125658. declare module BABYLON {
  125659. /**
  125660. * Manager for handling gamepads
  125661. */
  125662. export class GamepadManager {
  125663. private _scene?;
  125664. private _babylonGamepads;
  125665. private _oneGamepadConnected;
  125666. /** @hidden */
  125667. _isMonitoring: boolean;
  125668. private _gamepadEventSupported;
  125669. private _gamepadSupport?;
  125670. /**
  125671. * observable to be triggered when the gamepad controller has been connected
  125672. */
  125673. onGamepadConnectedObservable: Observable<Gamepad>;
  125674. /**
  125675. * observable to be triggered when the gamepad controller has been disconnected
  125676. */
  125677. onGamepadDisconnectedObservable: Observable<Gamepad>;
  125678. private _onGamepadConnectedEvent;
  125679. private _onGamepadDisconnectedEvent;
  125680. /**
  125681. * Initializes the gamepad manager
  125682. * @param _scene BabylonJS scene
  125683. */
  125684. constructor(_scene?: Scene | undefined);
  125685. /**
  125686. * The gamepads in the game pad manager
  125687. */
  125688. get gamepads(): Gamepad[];
  125689. /**
  125690. * Get the gamepad controllers based on type
  125691. * @param type The type of gamepad controller
  125692. * @returns Nullable gamepad
  125693. */
  125694. getGamepadByType(type?: number): Nullable<Gamepad>;
  125695. /**
  125696. * Disposes the gamepad manager
  125697. */
  125698. dispose(): void;
  125699. private _addNewGamepad;
  125700. private _startMonitoringGamepads;
  125701. private _stopMonitoringGamepads;
  125702. /** @hidden */
  125703. _checkGamepadsStatus(): void;
  125704. private _updateGamepadObjects;
  125705. }
  125706. }
  125707. declare module BABYLON {
  125708. interface Scene {
  125709. /** @hidden */
  125710. _gamepadManager: Nullable<GamepadManager>;
  125711. /**
  125712. * Gets the gamepad manager associated with the scene
  125713. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  125714. */
  125715. gamepadManager: GamepadManager;
  125716. }
  125717. /**
  125718. * Interface representing a free camera inputs manager
  125719. */
  125720. interface FreeCameraInputsManager {
  125721. /**
  125722. * Adds gamepad input support to the FreeCameraInputsManager.
  125723. * @returns the FreeCameraInputsManager
  125724. */
  125725. addGamepad(): FreeCameraInputsManager;
  125726. }
  125727. /**
  125728. * Interface representing an arc rotate camera inputs manager
  125729. */
  125730. interface ArcRotateCameraInputsManager {
  125731. /**
  125732. * Adds gamepad input support to the ArcRotateCamera InputManager.
  125733. * @returns the camera inputs manager
  125734. */
  125735. addGamepad(): ArcRotateCameraInputsManager;
  125736. }
  125737. /**
  125738. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  125739. */
  125740. export class GamepadSystemSceneComponent implements ISceneComponent {
  125741. /**
  125742. * The component name helpfull to identify the component in the list of scene components.
  125743. */
  125744. readonly name: string;
  125745. /**
  125746. * The scene the component belongs to.
  125747. */
  125748. scene: Scene;
  125749. /**
  125750. * Creates a new instance of the component for the given scene
  125751. * @param scene Defines the scene to register the component in
  125752. */
  125753. constructor(scene: Scene);
  125754. /**
  125755. * Registers the component in a given scene
  125756. */
  125757. register(): void;
  125758. /**
  125759. * Rebuilds the elements related to this component in case of
  125760. * context lost for instance.
  125761. */
  125762. rebuild(): void;
  125763. /**
  125764. * Disposes the component and the associated ressources
  125765. */
  125766. dispose(): void;
  125767. private _beforeCameraUpdate;
  125768. }
  125769. }
  125770. declare module BABYLON {
  125771. /**
  125772. * 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,
  125773. * which still works and will still be found in many Playgrounds.
  125774. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125775. */
  125776. export class UniversalCamera extends TouchCamera {
  125777. /**
  125778. * Defines the gamepad rotation sensiblity.
  125779. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  125780. */
  125781. get gamepadAngularSensibility(): number;
  125782. set gamepadAngularSensibility(value: number);
  125783. /**
  125784. * Defines the gamepad move sensiblity.
  125785. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  125786. */
  125787. get gamepadMoveSensibility(): number;
  125788. set gamepadMoveSensibility(value: number);
  125789. /**
  125790. * 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,
  125791. * which still works and will still be found in many Playgrounds.
  125792. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125793. * @param name Define the name of the camera in the scene
  125794. * @param position Define the start position of the camera in the scene
  125795. * @param scene Define the scene the camera belongs to
  125796. */
  125797. constructor(name: string, position: Vector3, scene: Scene);
  125798. /**
  125799. * Gets the current object class name.
  125800. * @return the class name
  125801. */
  125802. getClassName(): string;
  125803. }
  125804. }
  125805. declare module BABYLON {
  125806. /**
  125807. * This represents a FPS type of camera. This is only here for back compat purpose.
  125808. * Please use the UniversalCamera instead as both are identical.
  125809. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125810. */
  125811. export class GamepadCamera extends UniversalCamera {
  125812. /**
  125813. * Instantiates a new Gamepad Camera
  125814. * This represents a FPS type of camera. This is only here for back compat purpose.
  125815. * Please use the UniversalCamera instead as both are identical.
  125816. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125817. * @param name Define the name of the camera in the scene
  125818. * @param position Define the start position of the camera in the scene
  125819. * @param scene Define the scene the camera belongs to
  125820. */
  125821. constructor(name: string, position: Vector3, scene: Scene);
  125822. /**
  125823. * Gets the current object class name.
  125824. * @return the class name
  125825. */
  125826. getClassName(): string;
  125827. }
  125828. }
  125829. declare module BABYLON {
  125830. /** @hidden */
  125831. export var passPixelShader: {
  125832. name: string;
  125833. shader: string;
  125834. };
  125835. }
  125836. declare module BABYLON {
  125837. /** @hidden */
  125838. export var passCubePixelShader: {
  125839. name: string;
  125840. shader: string;
  125841. };
  125842. }
  125843. declare module BABYLON {
  125844. /**
  125845. * PassPostProcess which produces an output the same as it's input
  125846. */
  125847. export class PassPostProcess extends PostProcess {
  125848. /**
  125849. * Gets a string identifying the name of the class
  125850. * @returns "PassPostProcess" string
  125851. */
  125852. getClassName(): string;
  125853. /**
  125854. * Creates the PassPostProcess
  125855. * @param name The name of the effect.
  125856. * @param options The required width/height ratio to downsize to before computing the render pass.
  125857. * @param camera The camera to apply the render pass to.
  125858. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125859. * @param engine The engine which the post process will be applied. (default: current engine)
  125860. * @param reusable If the post process can be reused on the same frame. (default: false)
  125861. * @param textureType The type of texture to be used when performing the post processing.
  125862. * @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)
  125863. */
  125864. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125865. /** @hidden */
  125866. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  125867. }
  125868. /**
  125869. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  125870. */
  125871. export class PassCubePostProcess extends PostProcess {
  125872. private _face;
  125873. /**
  125874. * Gets or sets the cube face to display.
  125875. * * 0 is +X
  125876. * * 1 is -X
  125877. * * 2 is +Y
  125878. * * 3 is -Y
  125879. * * 4 is +Z
  125880. * * 5 is -Z
  125881. */
  125882. get face(): number;
  125883. set face(value: number);
  125884. /**
  125885. * Gets a string identifying the name of the class
  125886. * @returns "PassCubePostProcess" string
  125887. */
  125888. getClassName(): string;
  125889. /**
  125890. * Creates the PassCubePostProcess
  125891. * @param name The name of the effect.
  125892. * @param options The required width/height ratio to downsize to before computing the render pass.
  125893. * @param camera The camera to apply the render pass to.
  125894. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125895. * @param engine The engine which the post process will be applied. (default: current engine)
  125896. * @param reusable If the post process can be reused on the same frame. (default: false)
  125897. * @param textureType The type of texture to be used when performing the post processing.
  125898. * @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)
  125899. */
  125900. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125901. /** @hidden */
  125902. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  125903. }
  125904. }
  125905. declare module BABYLON {
  125906. /** @hidden */
  125907. export var anaglyphPixelShader: {
  125908. name: string;
  125909. shader: string;
  125910. };
  125911. }
  125912. declare module BABYLON {
  125913. /**
  125914. * Postprocess used to generate anaglyphic rendering
  125915. */
  125916. export class AnaglyphPostProcess extends PostProcess {
  125917. private _passedProcess;
  125918. /**
  125919. * Gets a string identifying the name of the class
  125920. * @returns "AnaglyphPostProcess" string
  125921. */
  125922. getClassName(): string;
  125923. /**
  125924. * Creates a new AnaglyphPostProcess
  125925. * @param name defines postprocess name
  125926. * @param options defines creation options or target ratio scale
  125927. * @param rigCameras defines cameras using this postprocess
  125928. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  125929. * @param engine defines hosting engine
  125930. * @param reusable defines if the postprocess will be reused multiple times per frame
  125931. */
  125932. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  125933. }
  125934. }
  125935. declare module BABYLON {
  125936. /**
  125937. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  125938. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125939. */
  125940. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  125941. /**
  125942. * Creates a new AnaglyphArcRotateCamera
  125943. * @param name defines camera name
  125944. * @param alpha defines alpha angle (in radians)
  125945. * @param beta defines beta angle (in radians)
  125946. * @param radius defines radius
  125947. * @param target defines camera target
  125948. * @param interaxialDistance defines distance between each color axis
  125949. * @param scene defines the hosting scene
  125950. */
  125951. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  125952. /**
  125953. * Gets camera class name
  125954. * @returns AnaglyphArcRotateCamera
  125955. */
  125956. getClassName(): string;
  125957. }
  125958. }
  125959. declare module BABYLON {
  125960. /**
  125961. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  125962. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125963. */
  125964. export class AnaglyphFreeCamera extends FreeCamera {
  125965. /**
  125966. * Creates a new AnaglyphFreeCamera
  125967. * @param name defines camera name
  125968. * @param position defines initial position
  125969. * @param interaxialDistance defines distance between each color axis
  125970. * @param scene defines the hosting scene
  125971. */
  125972. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  125973. /**
  125974. * Gets camera class name
  125975. * @returns AnaglyphFreeCamera
  125976. */
  125977. getClassName(): string;
  125978. }
  125979. }
  125980. declare module BABYLON {
  125981. /**
  125982. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  125983. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  125984. */
  125985. export class AnaglyphGamepadCamera extends GamepadCamera {
  125986. /**
  125987. * Creates a new AnaglyphGamepadCamera
  125988. * @param name defines camera name
  125989. * @param position defines initial position
  125990. * @param interaxialDistance defines distance between each color axis
  125991. * @param scene defines the hosting scene
  125992. */
  125993. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  125994. /**
  125995. * Gets camera class name
  125996. * @returns AnaglyphGamepadCamera
  125997. */
  125998. getClassName(): string;
  125999. }
  126000. }
  126001. declare module BABYLON {
  126002. /**
  126003. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  126004. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126005. */
  126006. export class AnaglyphUniversalCamera extends UniversalCamera {
  126007. /**
  126008. * Creates a new AnaglyphUniversalCamera
  126009. * @param name defines camera name
  126010. * @param position defines initial position
  126011. * @param interaxialDistance defines distance between each color axis
  126012. * @param scene defines the hosting scene
  126013. */
  126014. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126015. /**
  126016. * Gets camera class name
  126017. * @returns AnaglyphUniversalCamera
  126018. */
  126019. getClassName(): string;
  126020. }
  126021. }
  126022. declare module BABYLON {
  126023. /**
  126024. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  126025. * @see https://doc.babylonjs.com/features/cameras
  126026. */
  126027. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  126028. /**
  126029. * Creates a new StereoscopicArcRotateCamera
  126030. * @param name defines camera name
  126031. * @param alpha defines alpha angle (in radians)
  126032. * @param beta defines beta angle (in radians)
  126033. * @param radius defines radius
  126034. * @param target defines camera target
  126035. * @param interaxialDistance defines distance between each color axis
  126036. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126037. * @param scene defines the hosting scene
  126038. */
  126039. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126040. /**
  126041. * Gets camera class name
  126042. * @returns StereoscopicArcRotateCamera
  126043. */
  126044. getClassName(): string;
  126045. }
  126046. }
  126047. declare module BABYLON {
  126048. /**
  126049. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  126050. * @see https://doc.babylonjs.com/features/cameras
  126051. */
  126052. export class StereoscopicFreeCamera extends FreeCamera {
  126053. /**
  126054. * Creates a new StereoscopicFreeCamera
  126055. * @param name defines camera name
  126056. * @param position defines initial position
  126057. * @param interaxialDistance defines distance between each color axis
  126058. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126059. * @param scene defines the hosting scene
  126060. */
  126061. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126062. /**
  126063. * Gets camera class name
  126064. * @returns StereoscopicFreeCamera
  126065. */
  126066. getClassName(): string;
  126067. }
  126068. }
  126069. declare module BABYLON {
  126070. /**
  126071. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  126072. * @see https://doc.babylonjs.com/features/cameras
  126073. */
  126074. export class StereoscopicGamepadCamera extends GamepadCamera {
  126075. /**
  126076. * Creates a new StereoscopicGamepadCamera
  126077. * @param name defines camera name
  126078. * @param position defines initial position
  126079. * @param interaxialDistance defines distance between each color axis
  126080. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126081. * @param scene defines the hosting scene
  126082. */
  126083. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126084. /**
  126085. * Gets camera class name
  126086. * @returns StereoscopicGamepadCamera
  126087. */
  126088. getClassName(): string;
  126089. }
  126090. }
  126091. declare module BABYLON {
  126092. /**
  126093. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  126094. * @see https://doc.babylonjs.com/features/cameras
  126095. */
  126096. export class StereoscopicUniversalCamera extends UniversalCamera {
  126097. /**
  126098. * Creates a new StereoscopicUniversalCamera
  126099. * @param name defines camera name
  126100. * @param position defines initial position
  126101. * @param interaxialDistance defines distance between each color axis
  126102. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126103. * @param scene defines the hosting scene
  126104. */
  126105. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126106. /**
  126107. * Gets camera class name
  126108. * @returns StereoscopicUniversalCamera
  126109. */
  126110. getClassName(): string;
  126111. }
  126112. }
  126113. declare module BABYLON {
  126114. /**
  126115. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  126116. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  126117. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  126118. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  126119. */
  126120. export class VirtualJoysticksCamera extends FreeCamera {
  126121. /**
  126122. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  126123. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  126124. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  126125. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  126126. * @param name Define the name of the camera in the scene
  126127. * @param position Define the start position of the camera in the scene
  126128. * @param scene Define the scene the camera belongs to
  126129. */
  126130. constructor(name: string, position: Vector3, scene: Scene);
  126131. /**
  126132. * Gets the current object class name.
  126133. * @return the class name
  126134. */
  126135. getClassName(): string;
  126136. }
  126137. }
  126138. declare module BABYLON {
  126139. /**
  126140. * This represents all the required metrics to create a VR camera.
  126141. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  126142. */
  126143. export class VRCameraMetrics {
  126144. /**
  126145. * Define the horizontal resolution off the screen.
  126146. */
  126147. hResolution: number;
  126148. /**
  126149. * Define the vertical resolution off the screen.
  126150. */
  126151. vResolution: number;
  126152. /**
  126153. * Define the horizontal screen size.
  126154. */
  126155. hScreenSize: number;
  126156. /**
  126157. * Define the vertical screen size.
  126158. */
  126159. vScreenSize: number;
  126160. /**
  126161. * Define the vertical screen center position.
  126162. */
  126163. vScreenCenter: number;
  126164. /**
  126165. * Define the distance of the eyes to the screen.
  126166. */
  126167. eyeToScreenDistance: number;
  126168. /**
  126169. * Define the distance between both lenses
  126170. */
  126171. lensSeparationDistance: number;
  126172. /**
  126173. * Define the distance between both viewer's eyes.
  126174. */
  126175. interpupillaryDistance: number;
  126176. /**
  126177. * Define the distortion factor of the VR postprocess.
  126178. * Please, touch with care.
  126179. */
  126180. distortionK: number[];
  126181. /**
  126182. * Define the chromatic aberration correction factors for the VR post process.
  126183. */
  126184. chromaAbCorrection: number[];
  126185. /**
  126186. * Define the scale factor of the post process.
  126187. * The smaller the better but the slower.
  126188. */
  126189. postProcessScaleFactor: number;
  126190. /**
  126191. * Define an offset for the lens center.
  126192. */
  126193. lensCenterOffset: number;
  126194. /**
  126195. * Define if the current vr camera should compensate the distortion of the lense or not.
  126196. */
  126197. compensateDistortion: boolean;
  126198. /**
  126199. * Defines if multiview should be enabled when rendering (Default: false)
  126200. */
  126201. multiviewEnabled: boolean;
  126202. /**
  126203. * Gets the rendering aspect ratio based on the provided resolutions.
  126204. */
  126205. get aspectRatio(): number;
  126206. /**
  126207. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  126208. */
  126209. get aspectRatioFov(): number;
  126210. /**
  126211. * @hidden
  126212. */
  126213. get leftHMatrix(): Matrix;
  126214. /**
  126215. * @hidden
  126216. */
  126217. get rightHMatrix(): Matrix;
  126218. /**
  126219. * @hidden
  126220. */
  126221. get leftPreViewMatrix(): Matrix;
  126222. /**
  126223. * @hidden
  126224. */
  126225. get rightPreViewMatrix(): Matrix;
  126226. /**
  126227. * Get the default VRMetrics based on the most generic setup.
  126228. * @returns the default vr metrics
  126229. */
  126230. static GetDefault(): VRCameraMetrics;
  126231. }
  126232. }
  126233. declare module BABYLON {
  126234. /** @hidden */
  126235. export var vrDistortionCorrectionPixelShader: {
  126236. name: string;
  126237. shader: string;
  126238. };
  126239. }
  126240. declare module BABYLON {
  126241. /**
  126242. * VRDistortionCorrectionPostProcess used for mobile VR
  126243. */
  126244. export class VRDistortionCorrectionPostProcess extends PostProcess {
  126245. private _isRightEye;
  126246. private _distortionFactors;
  126247. private _postProcessScaleFactor;
  126248. private _lensCenterOffset;
  126249. private _scaleIn;
  126250. private _scaleFactor;
  126251. private _lensCenter;
  126252. /**
  126253. * Gets a string identifying the name of the class
  126254. * @returns "VRDistortionCorrectionPostProcess" string
  126255. */
  126256. getClassName(): string;
  126257. /**
  126258. * Initializes the VRDistortionCorrectionPostProcess
  126259. * @param name The name of the effect.
  126260. * @param camera The camera to apply the render pass to.
  126261. * @param isRightEye If this is for the right eye distortion
  126262. * @param vrMetrics All the required metrics for the VR camera
  126263. */
  126264. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  126265. }
  126266. }
  126267. declare module BABYLON {
  126268. /**
  126269. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  126270. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126271. */
  126272. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  126273. /**
  126274. * Creates a new VRDeviceOrientationArcRotateCamera
  126275. * @param name defines camera name
  126276. * @param alpha defines the camera rotation along the logitudinal axis
  126277. * @param beta defines the camera rotation along the latitudinal axis
  126278. * @param radius defines the camera distance from its target
  126279. * @param target defines the camera target
  126280. * @param scene defines the scene the camera belongs to
  126281. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126282. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126283. */
  126284. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126285. /**
  126286. * Gets camera class name
  126287. * @returns VRDeviceOrientationArcRotateCamera
  126288. */
  126289. getClassName(): string;
  126290. }
  126291. }
  126292. declare module BABYLON {
  126293. /**
  126294. * Camera used to simulate VR rendering (based on FreeCamera)
  126295. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126296. */
  126297. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  126298. /**
  126299. * Creates a new VRDeviceOrientationFreeCamera
  126300. * @param name defines camera name
  126301. * @param position defines the start position of the camera
  126302. * @param scene defines the scene the camera belongs to
  126303. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126304. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126305. */
  126306. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126307. /**
  126308. * Gets camera class name
  126309. * @returns VRDeviceOrientationFreeCamera
  126310. */
  126311. getClassName(): string;
  126312. }
  126313. }
  126314. declare module BABYLON {
  126315. /**
  126316. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  126317. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126318. */
  126319. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  126320. /**
  126321. * Creates a new VRDeviceOrientationGamepadCamera
  126322. * @param name defines camera name
  126323. * @param position defines the start position of the camera
  126324. * @param scene defines the scene the camera belongs to
  126325. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126326. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126327. */
  126328. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126329. /**
  126330. * Gets camera class name
  126331. * @returns VRDeviceOrientationGamepadCamera
  126332. */
  126333. getClassName(): string;
  126334. }
  126335. }
  126336. declare module BABYLON {
  126337. /**
  126338. * A class extending Texture allowing drawing on a texture
  126339. * @see https://doc.babylonjs.com/how_to/dynamictexture
  126340. */
  126341. export class DynamicTexture extends Texture {
  126342. private _generateMipMaps;
  126343. private _canvas;
  126344. private _context;
  126345. /**
  126346. * Creates a DynamicTexture
  126347. * @param name defines the name of the texture
  126348. * @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
  126349. * @param scene defines the scene where you want the texture
  126350. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  126351. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126352. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  126353. */
  126354. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  126355. /**
  126356. * Get the current class name of the texture useful for serialization or dynamic coding.
  126357. * @returns "DynamicTexture"
  126358. */
  126359. getClassName(): string;
  126360. /**
  126361. * Gets the current state of canRescale
  126362. */
  126363. get canRescale(): boolean;
  126364. private _recreate;
  126365. /**
  126366. * Scales the texture
  126367. * @param ratio the scale factor to apply to both width and height
  126368. */
  126369. scale(ratio: number): void;
  126370. /**
  126371. * Resizes the texture
  126372. * @param width the new width
  126373. * @param height the new height
  126374. */
  126375. scaleTo(width: number, height: number): void;
  126376. /**
  126377. * Gets the context of the canvas used by the texture
  126378. * @returns the canvas context of the dynamic texture
  126379. */
  126380. getContext(): CanvasRenderingContext2D;
  126381. /**
  126382. * Clears the texture
  126383. */
  126384. clear(): void;
  126385. /**
  126386. * Updates the texture
  126387. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  126388. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  126389. */
  126390. update(invertY?: boolean, premulAlpha?: boolean): void;
  126391. /**
  126392. * Draws text onto the texture
  126393. * @param text defines the text to be drawn
  126394. * @param x defines the placement of the text from the left
  126395. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  126396. * @param font defines the font to be used with font-style, font-size, font-name
  126397. * @param color defines the color used for the text
  126398. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  126399. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  126400. * @param update defines whether texture is immediately update (default is true)
  126401. */
  126402. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  126403. /**
  126404. * Clones the texture
  126405. * @returns the clone of the texture.
  126406. */
  126407. clone(): DynamicTexture;
  126408. /**
  126409. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  126410. * @returns a serialized dynamic texture object
  126411. */
  126412. serialize(): any;
  126413. private _IsCanvasElement;
  126414. /** @hidden */
  126415. _rebuild(): void;
  126416. }
  126417. }
  126418. declare module BABYLON {
  126419. /**
  126420. * Class containing static functions to help procedurally build meshes
  126421. */
  126422. export class GroundBuilder {
  126423. /**
  126424. * Creates a ground mesh
  126425. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  126426. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  126427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126428. * @param name defines the name of the mesh
  126429. * @param options defines the options used to create the mesh
  126430. * @param scene defines the hosting scene
  126431. * @returns the ground mesh
  126432. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  126433. */
  126434. static CreateGround(name: string, options: {
  126435. width?: number;
  126436. height?: number;
  126437. subdivisions?: number;
  126438. subdivisionsX?: number;
  126439. subdivisionsY?: number;
  126440. updatable?: boolean;
  126441. }, scene: any): Mesh;
  126442. /**
  126443. * Creates a tiled ground mesh
  126444. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  126445. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  126446. * * 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
  126447. * * 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
  126448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126449. * @param name defines the name of the mesh
  126450. * @param options defines the options used to create the mesh
  126451. * @param scene defines the hosting scene
  126452. * @returns the tiled ground mesh
  126453. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  126454. */
  126455. static CreateTiledGround(name: string, options: {
  126456. xmin: number;
  126457. zmin: number;
  126458. xmax: number;
  126459. zmax: number;
  126460. subdivisions?: {
  126461. w: number;
  126462. h: number;
  126463. };
  126464. precision?: {
  126465. w: number;
  126466. h: number;
  126467. };
  126468. updatable?: boolean;
  126469. }, scene?: Nullable<Scene>): Mesh;
  126470. /**
  126471. * Creates a ground mesh from a height map
  126472. * * The parameter `url` sets the URL of the height map image resource.
  126473. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  126474. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  126475. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  126476. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  126477. * * 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.
  126478. * * 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).
  126479. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  126480. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126481. * @param name defines the name of the mesh
  126482. * @param url defines the url to the height map
  126483. * @param options defines the options used to create the mesh
  126484. * @param scene defines the hosting scene
  126485. * @returns the ground mesh
  126486. * @see https://doc.babylonjs.com/babylon101/height_map
  126487. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  126488. */
  126489. static CreateGroundFromHeightMap(name: string, url: string, options: {
  126490. width?: number;
  126491. height?: number;
  126492. subdivisions?: number;
  126493. minHeight?: number;
  126494. maxHeight?: number;
  126495. colorFilter?: Color3;
  126496. alphaFilter?: number;
  126497. updatable?: boolean;
  126498. onReady?: (mesh: GroundMesh) => void;
  126499. }, scene?: Nullable<Scene>): GroundMesh;
  126500. }
  126501. }
  126502. declare module BABYLON {
  126503. /**
  126504. * Class containing static functions to help procedurally build meshes
  126505. */
  126506. export class TorusBuilder {
  126507. /**
  126508. * Creates a torus mesh
  126509. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  126510. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  126511. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  126512. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126513. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126515. * @param name defines the name of the mesh
  126516. * @param options defines the options used to create the mesh
  126517. * @param scene defines the hosting scene
  126518. * @returns the torus mesh
  126519. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  126520. */
  126521. static CreateTorus(name: string, options: {
  126522. diameter?: number;
  126523. thickness?: number;
  126524. tessellation?: number;
  126525. updatable?: boolean;
  126526. sideOrientation?: number;
  126527. frontUVs?: Vector4;
  126528. backUVs?: Vector4;
  126529. }, scene: any): Mesh;
  126530. }
  126531. }
  126532. declare module BABYLON {
  126533. /**
  126534. * Class containing static functions to help procedurally build meshes
  126535. */
  126536. export class CylinderBuilder {
  126537. /**
  126538. * Creates a cylinder or a cone mesh
  126539. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  126540. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  126541. * * 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.
  126542. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  126543. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  126544. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  126545. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  126546. * * 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).
  126547. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  126548. * * 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).
  126549. * * 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
  126550. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  126551. * * 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
  126552. * * 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.
  126553. * * If `enclose` is false, a ring surface is one element.
  126554. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  126555. * * 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
  126556. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126557. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126559. * @param name defines the name of the mesh
  126560. * @param options defines the options used to create the mesh
  126561. * @param scene defines the hosting scene
  126562. * @returns the cylinder mesh
  126563. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  126564. */
  126565. static CreateCylinder(name: string, options: {
  126566. height?: number;
  126567. diameterTop?: number;
  126568. diameterBottom?: number;
  126569. diameter?: number;
  126570. tessellation?: number;
  126571. subdivisions?: number;
  126572. arc?: number;
  126573. faceColors?: Color4[];
  126574. faceUV?: Vector4[];
  126575. updatable?: boolean;
  126576. hasRings?: boolean;
  126577. enclose?: boolean;
  126578. cap?: number;
  126579. sideOrientation?: number;
  126580. frontUVs?: Vector4;
  126581. backUVs?: Vector4;
  126582. }, scene: any): Mesh;
  126583. }
  126584. }
  126585. declare module BABYLON {
  126586. /**
  126587. * States of the webXR experience
  126588. */
  126589. export enum WebXRState {
  126590. /**
  126591. * Transitioning to being in XR mode
  126592. */
  126593. ENTERING_XR = 0,
  126594. /**
  126595. * Transitioning to non XR mode
  126596. */
  126597. EXITING_XR = 1,
  126598. /**
  126599. * In XR mode and presenting
  126600. */
  126601. IN_XR = 2,
  126602. /**
  126603. * Not entered XR mode
  126604. */
  126605. NOT_IN_XR = 3
  126606. }
  126607. /**
  126608. * Abstraction of the XR render target
  126609. */
  126610. export interface WebXRRenderTarget extends IDisposable {
  126611. /**
  126612. * xrpresent context of the canvas which can be used to display/mirror xr content
  126613. */
  126614. canvasContext: WebGLRenderingContext;
  126615. /**
  126616. * xr layer for the canvas
  126617. */
  126618. xrLayer: Nullable<XRWebGLLayer>;
  126619. /**
  126620. * Initializes the xr layer for the session
  126621. * @param xrSession xr session
  126622. * @returns a promise that will resolve once the XR Layer has been created
  126623. */
  126624. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  126625. }
  126626. }
  126627. declare module BABYLON {
  126628. /**
  126629. * COnfiguration object for WebXR output canvas
  126630. */
  126631. export class WebXRManagedOutputCanvasOptions {
  126632. /**
  126633. * An optional canvas in case you wish to create it yourself and provide it here.
  126634. * If not provided, a new canvas will be created
  126635. */
  126636. canvasElement?: HTMLCanvasElement;
  126637. /**
  126638. * Options for this XR Layer output
  126639. */
  126640. canvasOptions?: XRWebGLLayerOptions;
  126641. /**
  126642. * CSS styling for a newly created canvas (if not provided)
  126643. */
  126644. newCanvasCssStyle?: string;
  126645. /**
  126646. * Get the default values of the configuration object
  126647. * @param engine defines the engine to use (can be null)
  126648. * @returns default values of this configuration object
  126649. */
  126650. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  126651. }
  126652. /**
  126653. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  126654. */
  126655. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  126656. private _options;
  126657. private _canvas;
  126658. private _engine;
  126659. private _originalCanvasSize;
  126660. /**
  126661. * Rendering context of the canvas which can be used to display/mirror xr content
  126662. */
  126663. canvasContext: WebGLRenderingContext;
  126664. /**
  126665. * xr layer for the canvas
  126666. */
  126667. xrLayer: Nullable<XRWebGLLayer>;
  126668. /**
  126669. * Obseervers registered here will be triggered when the xr layer was initialized
  126670. */
  126671. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  126672. /**
  126673. * Initializes the canvas to be added/removed upon entering/exiting xr
  126674. * @param _xrSessionManager The XR Session manager
  126675. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  126676. */
  126677. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  126678. /**
  126679. * Disposes of the object
  126680. */
  126681. dispose(): void;
  126682. /**
  126683. * Initializes the xr layer for the session
  126684. * @param xrSession xr session
  126685. * @returns a promise that will resolve once the XR Layer has been created
  126686. */
  126687. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  126688. private _addCanvas;
  126689. private _removeCanvas;
  126690. private _setCanvasSize;
  126691. private _setManagedOutputCanvas;
  126692. }
  126693. }
  126694. declare module BABYLON {
  126695. /**
  126696. * Manages an XRSession to work with Babylon's engine
  126697. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  126698. */
  126699. export class WebXRSessionManager implements IDisposable {
  126700. /** The scene which the session should be created for */
  126701. scene: Scene;
  126702. private _referenceSpace;
  126703. private _rttProvider;
  126704. private _sessionEnded;
  126705. private _xrNavigator;
  126706. private baseLayer;
  126707. /**
  126708. * The base reference space from which the session started. good if you want to reset your
  126709. * reference space
  126710. */
  126711. baseReferenceSpace: XRReferenceSpace;
  126712. /**
  126713. * Current XR frame
  126714. */
  126715. currentFrame: Nullable<XRFrame>;
  126716. /** WebXR timestamp updated every frame */
  126717. currentTimestamp: number;
  126718. /**
  126719. * Used just in case of a failure to initialize an immersive session.
  126720. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  126721. */
  126722. defaultHeightCompensation: number;
  126723. /**
  126724. * Fires every time a new xrFrame arrives which can be used to update the camera
  126725. */
  126726. onXRFrameObservable: Observable<XRFrame>;
  126727. /**
  126728. * Fires when the reference space changed
  126729. */
  126730. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  126731. /**
  126732. * Fires when the xr session is ended either by the device or manually done
  126733. */
  126734. onXRSessionEnded: Observable<any>;
  126735. /**
  126736. * Fires when the xr session is ended either by the device or manually done
  126737. */
  126738. onXRSessionInit: Observable<XRSession>;
  126739. /**
  126740. * Underlying xr session
  126741. */
  126742. session: XRSession;
  126743. /**
  126744. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  126745. * or get the offset the player is currently at.
  126746. */
  126747. viewerReferenceSpace: XRReferenceSpace;
  126748. /**
  126749. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  126750. * @param scene The scene which the session should be created for
  126751. */
  126752. constructor(
  126753. /** The scene which the session should be created for */
  126754. scene: Scene);
  126755. /**
  126756. * The current reference space used in this session. This reference space can constantly change!
  126757. * It is mainly used to offset the camera's position.
  126758. */
  126759. get referenceSpace(): XRReferenceSpace;
  126760. /**
  126761. * Set a new reference space and triggers the observable
  126762. */
  126763. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  126764. /**
  126765. * Disposes of the session manager
  126766. */
  126767. dispose(): void;
  126768. /**
  126769. * Stops the xrSession and restores the render loop
  126770. * @returns Promise which resolves after it exits XR
  126771. */
  126772. exitXRAsync(): Promise<void>;
  126773. /**
  126774. * Gets the correct render target texture to be rendered this frame for this eye
  126775. * @param eye the eye for which to get the render target
  126776. * @returns the render target for the specified eye
  126777. */
  126778. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  126779. /**
  126780. * Creates a WebXRRenderTarget object for the XR session
  126781. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  126782. * @param options optional options to provide when creating a new render target
  126783. * @returns a WebXR render target to which the session can render
  126784. */
  126785. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  126786. /**
  126787. * Initializes the manager
  126788. * After initialization enterXR can be called to start an XR session
  126789. * @returns Promise which resolves after it is initialized
  126790. */
  126791. initializeAsync(): Promise<void>;
  126792. /**
  126793. * Initializes an xr session
  126794. * @param xrSessionMode mode to initialize
  126795. * @param xrSessionInit defines optional and required values to pass to the session builder
  126796. * @returns a promise which will resolve once the session has been initialized
  126797. */
  126798. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  126799. /**
  126800. * Checks if a session would be supported for the creation options specified
  126801. * @param sessionMode session mode to check if supported eg. immersive-vr
  126802. * @returns A Promise that resolves to true if supported and false if not
  126803. */
  126804. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  126805. /**
  126806. * Resets the reference space to the one started the session
  126807. */
  126808. resetReferenceSpace(): void;
  126809. /**
  126810. * Starts rendering to the xr layer
  126811. */
  126812. runXRRenderLoop(): void;
  126813. /**
  126814. * Sets the reference space on the xr session
  126815. * @param referenceSpaceType space to set
  126816. * @returns a promise that will resolve once the reference space has been set
  126817. */
  126818. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  126819. /**
  126820. * Updates the render state of the session
  126821. * @param state state to set
  126822. * @returns a promise that resolves once the render state has been updated
  126823. */
  126824. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  126825. /**
  126826. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  126827. * @param sessionMode defines the session to test
  126828. * @returns a promise with boolean as final value
  126829. */
  126830. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  126831. private _createRenderTargetTexture;
  126832. }
  126833. }
  126834. declare module BABYLON {
  126835. /**
  126836. * WebXR Camera which holds the views for the xrSession
  126837. * @see https://doc.babylonjs.com/how_to/webxr_camera
  126838. */
  126839. export class WebXRCamera extends FreeCamera {
  126840. private _xrSessionManager;
  126841. private _firstFrame;
  126842. private _referenceQuaternion;
  126843. private _referencedPosition;
  126844. private _xrInvPositionCache;
  126845. private _xrInvQuaternionCache;
  126846. /**
  126847. * Observable raised before camera teleportation
  126848. */
  126849. onBeforeCameraTeleport: Observable<Vector3>;
  126850. /**
  126851. * Observable raised after camera teleportation
  126852. */
  126853. onAfterCameraTeleport: Observable<Vector3>;
  126854. /**
  126855. * Should position compensation execute on first frame.
  126856. * This is used when copying the position from a native (non XR) camera
  126857. */
  126858. compensateOnFirstFrame: boolean;
  126859. /**
  126860. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  126861. * @param name the name of the camera
  126862. * @param scene the scene to add the camera to
  126863. * @param _xrSessionManager a constructed xr session manager
  126864. */
  126865. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  126866. /**
  126867. * Return the user's height, unrelated to the current ground.
  126868. * This will be the y position of this camera, when ground level is 0.
  126869. */
  126870. get realWorldHeight(): number;
  126871. /** @hidden */
  126872. _updateForDualEyeDebugging(): void;
  126873. /**
  126874. * Sets this camera's transformation based on a non-vr camera
  126875. * @param otherCamera the non-vr camera to copy the transformation from
  126876. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  126877. */
  126878. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  126879. /**
  126880. * Gets the current instance class name ("WebXRCamera").
  126881. * @returns the class name
  126882. */
  126883. getClassName(): string;
  126884. private _rotate180;
  126885. private _updateFromXRSession;
  126886. private _updateNumberOfRigCameras;
  126887. private _updateReferenceSpace;
  126888. private _updateReferenceSpaceOffset;
  126889. }
  126890. }
  126891. declare module BABYLON {
  126892. /**
  126893. * Defining the interface required for a (webxr) feature
  126894. */
  126895. export interface IWebXRFeature extends IDisposable {
  126896. /**
  126897. * Is this feature attached
  126898. */
  126899. attached: boolean;
  126900. /**
  126901. * Should auto-attach be disabled?
  126902. */
  126903. disableAutoAttach: boolean;
  126904. /**
  126905. * Attach the feature to the session
  126906. * Will usually be called by the features manager
  126907. *
  126908. * @param force should attachment be forced (even when already attached)
  126909. * @returns true if successful.
  126910. */
  126911. attach(force?: boolean): boolean;
  126912. /**
  126913. * Detach the feature from the session
  126914. * Will usually be called by the features manager
  126915. *
  126916. * @returns true if successful.
  126917. */
  126918. detach(): boolean;
  126919. /**
  126920. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  126921. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  126922. *
  126923. * @returns whether or not the feature is compatible in this environment
  126924. */
  126925. isCompatible(): boolean;
  126926. /**
  126927. * Was this feature disposed;
  126928. */
  126929. isDisposed: boolean;
  126930. /**
  126931. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  126932. */
  126933. xrNativeFeatureName?: string;
  126934. /**
  126935. * A list of (Babylon WebXR) features this feature depends on
  126936. */
  126937. dependsOn?: string[];
  126938. }
  126939. /**
  126940. * A list of the currently available features without referencing them
  126941. */
  126942. export class WebXRFeatureName {
  126943. /**
  126944. * The name of the anchor system feature
  126945. */
  126946. static readonly ANCHOR_SYSTEM: string;
  126947. /**
  126948. * The name of the background remover feature
  126949. */
  126950. static readonly BACKGROUND_REMOVER: string;
  126951. /**
  126952. * The name of the hit test feature
  126953. */
  126954. static readonly HIT_TEST: string;
  126955. /**
  126956. * physics impostors for xr controllers feature
  126957. */
  126958. static readonly PHYSICS_CONTROLLERS: string;
  126959. /**
  126960. * The name of the plane detection feature
  126961. */
  126962. static readonly PLANE_DETECTION: string;
  126963. /**
  126964. * The name of the pointer selection feature
  126965. */
  126966. static readonly POINTER_SELECTION: string;
  126967. /**
  126968. * The name of the teleportation feature
  126969. */
  126970. static readonly TELEPORTATION: string;
  126971. /**
  126972. * The name of the feature points feature.
  126973. */
  126974. static readonly FEATURE_POINTS: string;
  126975. /**
  126976. * The name of the hand tracking feature.
  126977. */
  126978. static readonly HAND_TRACKING: string;
  126979. }
  126980. /**
  126981. * Defining the constructor of a feature. Used to register the modules.
  126982. */
  126983. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  126984. /**
  126985. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  126986. * It is mainly used in AR sessions.
  126987. *
  126988. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  126989. */
  126990. export class WebXRFeaturesManager implements IDisposable {
  126991. private _xrSessionManager;
  126992. private static readonly _AvailableFeatures;
  126993. private _features;
  126994. /**
  126995. * constructs a new features manages.
  126996. *
  126997. * @param _xrSessionManager an instance of WebXRSessionManager
  126998. */
  126999. constructor(_xrSessionManager: WebXRSessionManager);
  127000. /**
  127001. * Used to register a module. After calling this function a developer can use this feature in the scene.
  127002. * Mainly used internally.
  127003. *
  127004. * @param featureName the name of the feature to register
  127005. * @param constructorFunction the function used to construct the module
  127006. * @param version the (babylon) version of the module
  127007. * @param stable is that a stable version of this module
  127008. */
  127009. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  127010. /**
  127011. * Returns a constructor of a specific feature.
  127012. *
  127013. * @param featureName the name of the feature to construct
  127014. * @param version the version of the feature to load
  127015. * @param xrSessionManager the xrSessionManager. Used to construct the module
  127016. * @param options optional options provided to the module.
  127017. * @returns a function that, when called, will return a new instance of this feature
  127018. */
  127019. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  127020. /**
  127021. * Can be used to return the list of features currently registered
  127022. *
  127023. * @returns an Array of available features
  127024. */
  127025. static GetAvailableFeatures(): string[];
  127026. /**
  127027. * Gets the versions available for a specific feature
  127028. * @param featureName the name of the feature
  127029. * @returns an array with the available versions
  127030. */
  127031. static GetAvailableVersions(featureName: string): string[];
  127032. /**
  127033. * Return the latest unstable version of this feature
  127034. * @param featureName the name of the feature to search
  127035. * @returns the version number. if not found will return -1
  127036. */
  127037. static GetLatestVersionOfFeature(featureName: string): number;
  127038. /**
  127039. * Return the latest stable version of this feature
  127040. * @param featureName the name of the feature to search
  127041. * @returns the version number. if not found will return -1
  127042. */
  127043. static GetStableVersionOfFeature(featureName: string): number;
  127044. /**
  127045. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  127046. * Can be used during a session to start a feature
  127047. * @param featureName the name of feature to attach
  127048. */
  127049. attachFeature(featureName: string): void;
  127050. /**
  127051. * Can be used inside a session or when the session ends to detach a specific feature
  127052. * @param featureName the name of the feature to detach
  127053. */
  127054. detachFeature(featureName: string): void;
  127055. /**
  127056. * Used to disable an already-enabled feature
  127057. * The feature will be disposed and will be recreated once enabled.
  127058. * @param featureName the feature to disable
  127059. * @returns true if disable was successful
  127060. */
  127061. disableFeature(featureName: string | {
  127062. Name: string;
  127063. }): boolean;
  127064. /**
  127065. * dispose this features manager
  127066. */
  127067. dispose(): void;
  127068. /**
  127069. * 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.
  127070. * 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.
  127071. *
  127072. * @param featureName the name of the feature to load or the class of the feature
  127073. * @param version optional version to load. if not provided the latest version will be enabled
  127074. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  127075. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  127076. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  127077. * @returns a new constructed feature or throws an error if feature not found.
  127078. */
  127079. enableFeature(featureName: string | {
  127080. Name: string;
  127081. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  127082. /**
  127083. * get the implementation of an enabled feature.
  127084. * @param featureName the name of the feature to load
  127085. * @returns the feature class, if found
  127086. */
  127087. getEnabledFeature(featureName: string): IWebXRFeature;
  127088. /**
  127089. * Get the list of enabled features
  127090. * @returns an array of enabled features
  127091. */
  127092. getEnabledFeatures(): string[];
  127093. /**
  127094. * This function will exten the session creation configuration object with enabled features.
  127095. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  127096. * according to the defined "required" variable, provided during enableFeature call
  127097. * @param xrSessionInit the xr Session init object to extend
  127098. *
  127099. * @returns an extended XRSessionInit object
  127100. */
  127101. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  127102. }
  127103. }
  127104. declare module BABYLON {
  127105. /**
  127106. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  127107. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  127108. */
  127109. export class WebXRExperienceHelper implements IDisposable {
  127110. private scene;
  127111. private _nonVRCamera;
  127112. private _originalSceneAutoClear;
  127113. private _supported;
  127114. /**
  127115. * Camera used to render xr content
  127116. */
  127117. camera: WebXRCamera;
  127118. /** A features manager for this xr session */
  127119. featuresManager: WebXRFeaturesManager;
  127120. /**
  127121. * Observers registered here will be triggered after the camera's initial transformation is set
  127122. * This can be used to set a different ground level or an extra rotation.
  127123. *
  127124. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  127125. * to the position set after this observable is done executing.
  127126. */
  127127. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  127128. /**
  127129. * Fires when the state of the experience helper has changed
  127130. */
  127131. onStateChangedObservable: Observable<WebXRState>;
  127132. /** Session manager used to keep track of xr session */
  127133. sessionManager: WebXRSessionManager;
  127134. /**
  127135. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  127136. */
  127137. state: WebXRState;
  127138. /**
  127139. * Creates a WebXRExperienceHelper
  127140. * @param scene The scene the helper should be created in
  127141. */
  127142. private constructor();
  127143. /**
  127144. * Creates the experience helper
  127145. * @param scene the scene to attach the experience helper to
  127146. * @returns a promise for the experience helper
  127147. */
  127148. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  127149. /**
  127150. * Disposes of the experience helper
  127151. */
  127152. dispose(): void;
  127153. /**
  127154. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  127155. * @param sessionMode options for the XR session
  127156. * @param referenceSpaceType frame of reference of the XR session
  127157. * @param renderTarget the output canvas that will be used to enter XR mode
  127158. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  127159. * @returns promise that resolves after xr mode has entered
  127160. */
  127161. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  127162. /**
  127163. * Exits XR mode and returns the scene to its original state
  127164. * @returns promise that resolves after xr mode has exited
  127165. */
  127166. exitXRAsync(): Promise<void>;
  127167. private _nonXRToXRCamera;
  127168. private _setState;
  127169. }
  127170. }
  127171. declare module BABYLON {
  127172. /**
  127173. * X-Y values for axes in WebXR
  127174. */
  127175. export interface IWebXRMotionControllerAxesValue {
  127176. /**
  127177. * The value of the x axis
  127178. */
  127179. x: number;
  127180. /**
  127181. * The value of the y-axis
  127182. */
  127183. y: number;
  127184. }
  127185. /**
  127186. * changed / previous values for the values of this component
  127187. */
  127188. export interface IWebXRMotionControllerComponentChangesValues<T> {
  127189. /**
  127190. * current (this frame) value
  127191. */
  127192. current: T;
  127193. /**
  127194. * previous (last change) value
  127195. */
  127196. previous: T;
  127197. }
  127198. /**
  127199. * Represents changes in the component between current frame and last values recorded
  127200. */
  127201. export interface IWebXRMotionControllerComponentChanges {
  127202. /**
  127203. * will be populated with previous and current values if axes changed
  127204. */
  127205. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  127206. /**
  127207. * will be populated with previous and current values if pressed changed
  127208. */
  127209. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  127210. /**
  127211. * will be populated with previous and current values if touched changed
  127212. */
  127213. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  127214. /**
  127215. * will be populated with previous and current values if value changed
  127216. */
  127217. value?: IWebXRMotionControllerComponentChangesValues<number>;
  127218. }
  127219. /**
  127220. * This class represents a single component (for example button or thumbstick) of a motion controller
  127221. */
  127222. export class WebXRControllerComponent implements IDisposable {
  127223. /**
  127224. * the id of this component
  127225. */
  127226. id: string;
  127227. /**
  127228. * the type of the component
  127229. */
  127230. type: MotionControllerComponentType;
  127231. private _buttonIndex;
  127232. private _axesIndices;
  127233. private _axes;
  127234. private _changes;
  127235. private _currentValue;
  127236. private _hasChanges;
  127237. private _pressed;
  127238. private _touched;
  127239. /**
  127240. * button component type
  127241. */
  127242. static BUTTON_TYPE: MotionControllerComponentType;
  127243. /**
  127244. * squeeze component type
  127245. */
  127246. static SQUEEZE_TYPE: MotionControllerComponentType;
  127247. /**
  127248. * Thumbstick component type
  127249. */
  127250. static THUMBSTICK_TYPE: MotionControllerComponentType;
  127251. /**
  127252. * Touchpad component type
  127253. */
  127254. static TOUCHPAD_TYPE: MotionControllerComponentType;
  127255. /**
  127256. * trigger component type
  127257. */
  127258. static TRIGGER_TYPE: MotionControllerComponentType;
  127259. /**
  127260. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  127261. * the axes data changes
  127262. */
  127263. onAxisValueChangedObservable: Observable<{
  127264. x: number;
  127265. y: number;
  127266. }>;
  127267. /**
  127268. * Observers registered here will be triggered when the state of a button changes
  127269. * State change is either pressed / touched / value
  127270. */
  127271. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  127272. /**
  127273. * Creates a new component for a motion controller.
  127274. * It is created by the motion controller itself
  127275. *
  127276. * @param id the id of this component
  127277. * @param type the type of the component
  127278. * @param _buttonIndex index in the buttons array of the gamepad
  127279. * @param _axesIndices indices of the values in the axes array of the gamepad
  127280. */
  127281. constructor(
  127282. /**
  127283. * the id of this component
  127284. */
  127285. id: string,
  127286. /**
  127287. * the type of the component
  127288. */
  127289. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  127290. /**
  127291. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  127292. */
  127293. get axes(): IWebXRMotionControllerAxesValue;
  127294. /**
  127295. * Get the changes. Elements will be populated only if they changed with their previous and current value
  127296. */
  127297. get changes(): IWebXRMotionControllerComponentChanges;
  127298. /**
  127299. * Return whether or not the component changed the last frame
  127300. */
  127301. get hasChanges(): boolean;
  127302. /**
  127303. * is the button currently pressed
  127304. */
  127305. get pressed(): boolean;
  127306. /**
  127307. * is the button currently touched
  127308. */
  127309. get touched(): boolean;
  127310. /**
  127311. * Get the current value of this component
  127312. */
  127313. get value(): number;
  127314. /**
  127315. * Dispose this component
  127316. */
  127317. dispose(): void;
  127318. /**
  127319. * Are there axes correlating to this component
  127320. * @return true is axes data is available
  127321. */
  127322. isAxes(): boolean;
  127323. /**
  127324. * Is this component a button (hence - pressable)
  127325. * @returns true if can be pressed
  127326. */
  127327. isButton(): boolean;
  127328. /**
  127329. * update this component using the gamepad object it is in. Called on every frame
  127330. * @param nativeController the native gamepad controller object
  127331. */
  127332. update(nativeController: IMinimalMotionControllerObject): void;
  127333. }
  127334. }
  127335. declare module BABYLON {
  127336. /**
  127337. * Interface used to represent data loading progression
  127338. */
  127339. export interface ISceneLoaderProgressEvent {
  127340. /**
  127341. * Defines if data length to load can be evaluated
  127342. */
  127343. readonly lengthComputable: boolean;
  127344. /**
  127345. * Defines the loaded data length
  127346. */
  127347. readonly loaded: number;
  127348. /**
  127349. * Defines the data length to load
  127350. */
  127351. readonly total: number;
  127352. }
  127353. /**
  127354. * Interface used by SceneLoader plugins to define supported file extensions
  127355. */
  127356. export interface ISceneLoaderPluginExtensions {
  127357. /**
  127358. * Defines the list of supported extensions
  127359. */
  127360. [extension: string]: {
  127361. isBinary: boolean;
  127362. };
  127363. }
  127364. /**
  127365. * Interface used by SceneLoader plugin factory
  127366. */
  127367. export interface ISceneLoaderPluginFactory {
  127368. /**
  127369. * Defines the name of the factory
  127370. */
  127371. name: string;
  127372. /**
  127373. * Function called to create a new plugin
  127374. * @return the new plugin
  127375. */
  127376. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  127377. /**
  127378. * The callback that returns true if the data can be directly loaded.
  127379. * @param data string containing the file data
  127380. * @returns if the data can be loaded directly
  127381. */
  127382. canDirectLoad?(data: string): boolean;
  127383. }
  127384. /**
  127385. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  127386. */
  127387. export interface ISceneLoaderPluginBase {
  127388. /**
  127389. * The friendly name of this plugin.
  127390. */
  127391. name: string;
  127392. /**
  127393. * The file extensions supported by this plugin.
  127394. */
  127395. extensions: string | ISceneLoaderPluginExtensions;
  127396. /**
  127397. * The callback called when loading from a url.
  127398. * @param scene scene loading this url
  127399. * @param url url to load
  127400. * @param onSuccess callback called when the file successfully loads
  127401. * @param onProgress callback called while file is loading (if the server supports this mode)
  127402. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  127403. * @param onError callback called when the file fails to load
  127404. * @returns a file request object
  127405. */
  127406. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  127407. /**
  127408. * The callback called when loading from a file object.
  127409. * @param scene scene loading this file
  127410. * @param file defines the file to load
  127411. * @param onSuccess defines the callback to call when data is loaded
  127412. * @param onProgress defines the callback to call during loading process
  127413. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  127414. * @param onError defines the callback to call when an error occurs
  127415. * @returns a file request object
  127416. */
  127417. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  127418. /**
  127419. * The callback that returns true if the data can be directly loaded.
  127420. * @param data string containing the file data
  127421. * @returns if the data can be loaded directly
  127422. */
  127423. canDirectLoad?(data: string): boolean;
  127424. /**
  127425. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  127426. * @param scene scene loading this data
  127427. * @param data string containing the data
  127428. * @returns data to pass to the plugin
  127429. */
  127430. directLoad?(scene: Scene, data: string): any;
  127431. /**
  127432. * The callback that allows custom handling of the root url based on the response url.
  127433. * @param rootUrl the original root url
  127434. * @param responseURL the response url if available
  127435. * @returns the new root url
  127436. */
  127437. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  127438. }
  127439. /**
  127440. * Interface used to define a SceneLoader plugin
  127441. */
  127442. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  127443. /**
  127444. * Import meshes into a scene.
  127445. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127446. * @param scene The scene to import into
  127447. * @param data The data to import
  127448. * @param rootUrl The root url for scene and resources
  127449. * @param meshes The meshes array to import into
  127450. * @param particleSystems The particle systems array to import into
  127451. * @param skeletons The skeletons array to import into
  127452. * @param onError The callback when import fails
  127453. * @returns True if successful or false otherwise
  127454. */
  127455. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  127456. /**
  127457. * Load into a scene.
  127458. * @param scene The scene to load into
  127459. * @param data The data to import
  127460. * @param rootUrl The root url for scene and resources
  127461. * @param onError The callback when import fails
  127462. * @returns True if successful or false otherwise
  127463. */
  127464. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  127465. /**
  127466. * Load into an asset container.
  127467. * @param scene The scene to load into
  127468. * @param data The data to import
  127469. * @param rootUrl The root url for scene and resources
  127470. * @param onError The callback when import fails
  127471. * @returns The loaded asset container
  127472. */
  127473. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  127474. }
  127475. /**
  127476. * Interface used to define an async SceneLoader plugin
  127477. */
  127478. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  127479. /**
  127480. * Import meshes into a scene.
  127481. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127482. * @param scene The scene to import into
  127483. * @param data The data to import
  127484. * @param rootUrl The root url for scene and resources
  127485. * @param onProgress The callback when the load progresses
  127486. * @param fileName Defines the name of the file to load
  127487. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  127488. */
  127489. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  127490. meshes: AbstractMesh[];
  127491. particleSystems: IParticleSystem[];
  127492. skeletons: Skeleton[];
  127493. animationGroups: AnimationGroup[];
  127494. }>;
  127495. /**
  127496. * Load into a scene.
  127497. * @param scene The scene to load into
  127498. * @param data The data to import
  127499. * @param rootUrl The root url for scene and resources
  127500. * @param onProgress The callback when the load progresses
  127501. * @param fileName Defines the name of the file to load
  127502. * @returns Nothing
  127503. */
  127504. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  127505. /**
  127506. * Load into an asset container.
  127507. * @param scene The scene to load into
  127508. * @param data The data to import
  127509. * @param rootUrl The root url for scene and resources
  127510. * @param onProgress The callback when the load progresses
  127511. * @param fileName Defines the name of the file to load
  127512. * @returns The loaded asset container
  127513. */
  127514. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  127515. }
  127516. /**
  127517. * Mode that determines how to handle old animation groups before loading new ones.
  127518. */
  127519. export enum SceneLoaderAnimationGroupLoadingMode {
  127520. /**
  127521. * Reset all old animations to initial state then dispose them.
  127522. */
  127523. Clean = 0,
  127524. /**
  127525. * Stop all old animations.
  127526. */
  127527. Stop = 1,
  127528. /**
  127529. * Restart old animations from first frame.
  127530. */
  127531. Sync = 2,
  127532. /**
  127533. * Old animations remains untouched.
  127534. */
  127535. NoSync = 3
  127536. }
  127537. /**
  127538. * Defines a plugin registered by the SceneLoader
  127539. */
  127540. interface IRegisteredPlugin {
  127541. /**
  127542. * Defines the plugin to use
  127543. */
  127544. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  127545. /**
  127546. * Defines if the plugin supports binary data
  127547. */
  127548. isBinary: boolean;
  127549. }
  127550. /**
  127551. * Class used to load scene from various file formats using registered plugins
  127552. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  127553. */
  127554. export class SceneLoader {
  127555. /**
  127556. * No logging while loading
  127557. */
  127558. static readonly NO_LOGGING: number;
  127559. /**
  127560. * Minimal logging while loading
  127561. */
  127562. static readonly MINIMAL_LOGGING: number;
  127563. /**
  127564. * Summary logging while loading
  127565. */
  127566. static readonly SUMMARY_LOGGING: number;
  127567. /**
  127568. * Detailled logging while loading
  127569. */
  127570. static readonly DETAILED_LOGGING: number;
  127571. /**
  127572. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  127573. */
  127574. static get ForceFullSceneLoadingForIncremental(): boolean;
  127575. static set ForceFullSceneLoadingForIncremental(value: boolean);
  127576. /**
  127577. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  127578. */
  127579. static get ShowLoadingScreen(): boolean;
  127580. static set ShowLoadingScreen(value: boolean);
  127581. /**
  127582. * Defines the current logging level (while loading the scene)
  127583. * @ignorenaming
  127584. */
  127585. static get loggingLevel(): number;
  127586. static set loggingLevel(value: number);
  127587. /**
  127588. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  127589. */
  127590. static get CleanBoneMatrixWeights(): boolean;
  127591. static set CleanBoneMatrixWeights(value: boolean);
  127592. /**
  127593. * Event raised when a plugin is used to load a scene
  127594. */
  127595. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  127596. private static _registeredPlugins;
  127597. private static _showingLoadingScreen;
  127598. /**
  127599. * Gets the default plugin (used to load Babylon files)
  127600. * @returns the .babylon plugin
  127601. */
  127602. static GetDefaultPlugin(): IRegisteredPlugin;
  127603. private static _GetPluginForExtension;
  127604. private static _GetPluginForDirectLoad;
  127605. private static _GetPluginForFilename;
  127606. private static _GetDirectLoad;
  127607. private static _LoadData;
  127608. private static _GetFileInfo;
  127609. /**
  127610. * Gets a plugin that can load the given extension
  127611. * @param extension defines the extension to load
  127612. * @returns a plugin or null if none works
  127613. */
  127614. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  127615. /**
  127616. * Gets a boolean indicating that the given extension can be loaded
  127617. * @param extension defines the extension to load
  127618. * @returns true if the extension is supported
  127619. */
  127620. static IsPluginForExtensionAvailable(extension: string): boolean;
  127621. /**
  127622. * Adds a new plugin to the list of registered plugins
  127623. * @param plugin defines the plugin to add
  127624. */
  127625. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  127626. /**
  127627. * Import meshes into a scene
  127628. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127629. * @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)
  127630. * @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)
  127631. * @param scene the instance of BABYLON.Scene to append to
  127632. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  127633. * @param onProgress a callback with a progress event for each file being loaded
  127634. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127635. * @param pluginExtension the extension used to determine the plugin
  127636. * @returns The loaded plugin
  127637. */
  127638. 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>;
  127639. /**
  127640. * Import meshes into a scene
  127641. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  127642. * @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)
  127643. * @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)
  127644. * @param scene the instance of BABYLON.Scene to append to
  127645. * @param onProgress a callback with a progress event for each file being loaded
  127646. * @param pluginExtension the extension used to determine the plugin
  127647. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  127648. */
  127649. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  127650. meshes: AbstractMesh[];
  127651. particleSystems: IParticleSystem[];
  127652. skeletons: Skeleton[];
  127653. animationGroups: AnimationGroup[];
  127654. }>;
  127655. /**
  127656. * Load a scene
  127657. * @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)
  127658. * @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)
  127659. * @param engine is the instance of BABYLON.Engine to use to create the scene
  127660. * @param onSuccess a callback with the scene when import succeeds
  127661. * @param onProgress a callback with a progress event for each file being loaded
  127662. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127663. * @param pluginExtension the extension used to determine the plugin
  127664. * @returns The loaded plugin
  127665. */
  127666. 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>;
  127667. /**
  127668. * Load a scene
  127669. * @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)
  127670. * @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)
  127671. * @param engine is the instance of BABYLON.Engine to use to create the scene
  127672. * @param onProgress a callback with a progress event for each file being loaded
  127673. * @param pluginExtension the extension used to determine the plugin
  127674. * @returns The loaded scene
  127675. */
  127676. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  127677. /**
  127678. * Append a scene
  127679. * @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)
  127680. * @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)
  127681. * @param scene is the instance of BABYLON.Scene to append to
  127682. * @param onSuccess a callback with the scene when import succeeds
  127683. * @param onProgress a callback with a progress event for each file being loaded
  127684. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127685. * @param pluginExtension the extension used to determine the plugin
  127686. * @returns The loaded plugin
  127687. */
  127688. 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>;
  127689. /**
  127690. * Append a scene
  127691. * @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)
  127692. * @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)
  127693. * @param scene is the instance of BABYLON.Scene to append to
  127694. * @param onProgress a callback with a progress event for each file being loaded
  127695. * @param pluginExtension the extension used to determine the plugin
  127696. * @returns The given scene
  127697. */
  127698. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  127699. /**
  127700. * Load a scene into an asset container
  127701. * @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)
  127702. * @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)
  127703. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  127704. * @param onSuccess a callback with the scene when import succeeds
  127705. * @param onProgress a callback with a progress event for each file being loaded
  127706. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127707. * @param pluginExtension the extension used to determine the plugin
  127708. * @returns The loaded plugin
  127709. */
  127710. 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>;
  127711. /**
  127712. * Load a scene into an asset container
  127713. * @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)
  127714. * @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)
  127715. * @param scene is the instance of Scene to append to
  127716. * @param onProgress a callback with a progress event for each file being loaded
  127717. * @param pluginExtension the extension used to determine the plugin
  127718. * @returns The loaded asset container
  127719. */
  127720. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  127721. /**
  127722. * Import animations from a file into a scene
  127723. * @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)
  127724. * @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)
  127725. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  127726. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  127727. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  127728. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  127729. * @param onSuccess a callback with the scene when import succeeds
  127730. * @param onProgress a callback with a progress event for each file being loaded
  127731. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127732. * @param pluginExtension the extension used to determine the plugin
  127733. */
  127734. 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;
  127735. /**
  127736. * Import animations from a file into a scene
  127737. * @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)
  127738. * @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)
  127739. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  127740. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  127741. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  127742. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  127743. * @param onSuccess a callback with the scene when import succeeds
  127744. * @param onProgress a callback with a progress event for each file being loaded
  127745. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  127746. * @param pluginExtension the extension used to determine the plugin
  127747. * @returns the updated scene with imported animations
  127748. */
  127749. 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>;
  127750. }
  127751. }
  127752. declare module BABYLON {
  127753. /**
  127754. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  127755. */
  127756. export type MotionControllerHandedness = "none" | "left" | "right";
  127757. /**
  127758. * The type of components available in motion controllers.
  127759. * This is not the name of the component.
  127760. */
  127761. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  127762. /**
  127763. * The state of a controller component
  127764. */
  127765. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  127766. /**
  127767. * The schema of motion controller layout.
  127768. * No object will be initialized using this interface
  127769. * This is used just to define the profile.
  127770. */
  127771. export interface IMotionControllerLayout {
  127772. /**
  127773. * Path to load the assets. Usually relative to the base path
  127774. */
  127775. assetPath: string;
  127776. /**
  127777. * Available components (unsorted)
  127778. */
  127779. components: {
  127780. /**
  127781. * A map of component Ids
  127782. */
  127783. [componentId: string]: {
  127784. /**
  127785. * The type of input the component outputs
  127786. */
  127787. type: MotionControllerComponentType;
  127788. /**
  127789. * The indices of this component in the gamepad object
  127790. */
  127791. gamepadIndices: {
  127792. /**
  127793. * Index of button
  127794. */
  127795. button?: number;
  127796. /**
  127797. * If available, index of x-axis
  127798. */
  127799. xAxis?: number;
  127800. /**
  127801. * If available, index of y-axis
  127802. */
  127803. yAxis?: number;
  127804. };
  127805. /**
  127806. * The mesh's root node name
  127807. */
  127808. rootNodeName: string;
  127809. /**
  127810. * Animation definitions for this model
  127811. */
  127812. visualResponses: {
  127813. [stateKey: string]: {
  127814. /**
  127815. * What property will be animated
  127816. */
  127817. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  127818. /**
  127819. * What states influence this visual response
  127820. */
  127821. states: MotionControllerComponentStateType[];
  127822. /**
  127823. * Type of animation - movement or visibility
  127824. */
  127825. valueNodeProperty: "transform" | "visibility";
  127826. /**
  127827. * Base node name to move. Its position will be calculated according to the min and max nodes
  127828. */
  127829. valueNodeName?: string;
  127830. /**
  127831. * Minimum movement node
  127832. */
  127833. minNodeName?: string;
  127834. /**
  127835. * Max movement node
  127836. */
  127837. maxNodeName?: string;
  127838. };
  127839. };
  127840. /**
  127841. * If touch enabled, what is the name of node to display user feedback
  127842. */
  127843. touchPointNodeName?: string;
  127844. };
  127845. };
  127846. /**
  127847. * Is it xr standard mapping or not
  127848. */
  127849. gamepadMapping: "" | "xr-standard";
  127850. /**
  127851. * Base root node of this entire model
  127852. */
  127853. rootNodeName: string;
  127854. /**
  127855. * Defines the main button component id
  127856. */
  127857. selectComponentId: string;
  127858. }
  127859. /**
  127860. * A definition for the layout map in the input profile
  127861. */
  127862. export interface IMotionControllerLayoutMap {
  127863. /**
  127864. * Layouts with handedness type as a key
  127865. */
  127866. [handedness: string]: IMotionControllerLayout;
  127867. }
  127868. /**
  127869. * The XR Input profile schema
  127870. * Profiles can be found here:
  127871. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  127872. */
  127873. export interface IMotionControllerProfile {
  127874. /**
  127875. * fallback profiles for this profileId
  127876. */
  127877. fallbackProfileIds: string[];
  127878. /**
  127879. * The layout map, with handedness as key
  127880. */
  127881. layouts: IMotionControllerLayoutMap;
  127882. /**
  127883. * The id of this profile
  127884. * correlates to the profile(s) in the xrInput.profiles array
  127885. */
  127886. profileId: string;
  127887. }
  127888. /**
  127889. * A helper-interface for the 3 meshes needed for controller button animation
  127890. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  127891. */
  127892. export interface IMotionControllerButtonMeshMap {
  127893. /**
  127894. * the mesh that defines the pressed value mesh position.
  127895. * This is used to find the max-position of this button
  127896. */
  127897. pressedMesh: AbstractMesh;
  127898. /**
  127899. * the mesh that defines the unpressed value mesh position.
  127900. * This is used to find the min (or initial) position of this button
  127901. */
  127902. unpressedMesh: AbstractMesh;
  127903. /**
  127904. * The mesh that will be changed when value changes
  127905. */
  127906. valueMesh: AbstractMesh;
  127907. }
  127908. /**
  127909. * A helper-interface for the 3 meshes needed for controller axis animation.
  127910. * This will be expanded when touchpad animations are fully supported
  127911. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  127912. */
  127913. export interface IMotionControllerMeshMap {
  127914. /**
  127915. * the mesh that defines the maximum value mesh position.
  127916. */
  127917. maxMesh?: AbstractMesh;
  127918. /**
  127919. * the mesh that defines the minimum value mesh position.
  127920. */
  127921. minMesh?: AbstractMesh;
  127922. /**
  127923. * The mesh that will be changed when axis value changes
  127924. */
  127925. valueMesh?: AbstractMesh;
  127926. }
  127927. /**
  127928. * The elements needed for change-detection of the gamepad objects in motion controllers
  127929. */
  127930. export interface IMinimalMotionControllerObject {
  127931. /**
  127932. * Available axes of this controller
  127933. */
  127934. axes: number[];
  127935. /**
  127936. * An array of available buttons
  127937. */
  127938. buttons: Array<{
  127939. /**
  127940. * Value of the button/trigger
  127941. */
  127942. value: number;
  127943. /**
  127944. * If the button/trigger is currently touched
  127945. */
  127946. touched: boolean;
  127947. /**
  127948. * If the button/trigger is currently pressed
  127949. */
  127950. pressed: boolean;
  127951. }>;
  127952. /**
  127953. * EXPERIMENTAL haptic support.
  127954. */
  127955. hapticActuators?: Array<{
  127956. pulse: (value: number, duration: number) => Promise<boolean>;
  127957. }>;
  127958. }
  127959. /**
  127960. * An Abstract Motion controller
  127961. * This class receives an xrInput and a profile layout and uses those to initialize the components
  127962. * Each component has an observable to check for changes in value and state
  127963. */
  127964. export abstract class WebXRAbstractMotionController implements IDisposable {
  127965. protected scene: Scene;
  127966. protected layout: IMotionControllerLayout;
  127967. /**
  127968. * The gamepad object correlating to this controller
  127969. */
  127970. gamepadObject: IMinimalMotionControllerObject;
  127971. /**
  127972. * handedness (left/right/none) of this controller
  127973. */
  127974. handedness: MotionControllerHandedness;
  127975. private _initComponent;
  127976. private _modelReady;
  127977. /**
  127978. * A map of components (WebXRControllerComponent) in this motion controller
  127979. * Components have a ComponentType and can also have both button and axis definitions
  127980. */
  127981. readonly components: {
  127982. [id: string]: WebXRControllerComponent;
  127983. };
  127984. /**
  127985. * Disable the model's animation. Can be set at any time.
  127986. */
  127987. disableAnimation: boolean;
  127988. /**
  127989. * Observers registered here will be triggered when the model of this controller is done loading
  127990. */
  127991. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  127992. /**
  127993. * The profile id of this motion controller
  127994. */
  127995. abstract profileId: string;
  127996. /**
  127997. * The root mesh of the model. It is null if the model was not yet initialized
  127998. */
  127999. rootMesh: Nullable<AbstractMesh>;
  128000. /**
  128001. * constructs a new abstract motion controller
  128002. * @param scene the scene to which the model of the controller will be added
  128003. * @param layout The profile layout to load
  128004. * @param gamepadObject The gamepad object correlating to this controller
  128005. * @param handedness handedness (left/right/none) of this controller
  128006. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  128007. */
  128008. constructor(scene: Scene, layout: IMotionControllerLayout,
  128009. /**
  128010. * The gamepad object correlating to this controller
  128011. */
  128012. gamepadObject: IMinimalMotionControllerObject,
  128013. /**
  128014. * handedness (left/right/none) of this controller
  128015. */
  128016. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  128017. /**
  128018. * Dispose this controller, the model mesh and all its components
  128019. */
  128020. dispose(): void;
  128021. /**
  128022. * Returns all components of specific type
  128023. * @param type the type to search for
  128024. * @return an array of components with this type
  128025. */
  128026. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  128027. /**
  128028. * get a component based an its component id as defined in layout.components
  128029. * @param id the id of the component
  128030. * @returns the component correlates to the id or undefined if not found
  128031. */
  128032. getComponent(id: string): WebXRControllerComponent;
  128033. /**
  128034. * Get the list of components available in this motion controller
  128035. * @returns an array of strings correlating to available components
  128036. */
  128037. getComponentIds(): string[];
  128038. /**
  128039. * Get the first component of specific type
  128040. * @param type type of component to find
  128041. * @return a controller component or null if not found
  128042. */
  128043. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  128044. /**
  128045. * Get the main (Select) component of this controller as defined in the layout
  128046. * @returns the main component of this controller
  128047. */
  128048. getMainComponent(): WebXRControllerComponent;
  128049. /**
  128050. * Loads the model correlating to this controller
  128051. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  128052. * @returns A promise fulfilled with the result of the model loading
  128053. */
  128054. loadModel(): Promise<boolean>;
  128055. /**
  128056. * Update this model using the current XRFrame
  128057. * @param xrFrame the current xr frame to use and update the model
  128058. */
  128059. updateFromXRFrame(xrFrame: XRFrame): void;
  128060. /**
  128061. * Backwards compatibility due to a deeply-integrated typo
  128062. */
  128063. get handness(): XREye;
  128064. /**
  128065. * Pulse (vibrate) this controller
  128066. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  128067. * Consecutive calls to this function will cancel the last pulse call
  128068. *
  128069. * @param value the strength of the pulse in 0.0...1.0 range
  128070. * @param duration Duration of the pulse in milliseconds
  128071. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  128072. * @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
  128073. */
  128074. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  128075. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  128076. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  128077. /**
  128078. * Moves the axis on the controller mesh based on its current state
  128079. * @param axis the index of the axis
  128080. * @param axisValue the value of the axis which determines the meshes new position
  128081. * @hidden
  128082. */
  128083. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  128084. /**
  128085. * Update the model itself with the current frame data
  128086. * @param xrFrame the frame to use for updating the model mesh
  128087. */
  128088. protected updateModel(xrFrame: XRFrame): void;
  128089. /**
  128090. * Get the filename and path for this controller's model
  128091. * @returns a map of filename and path
  128092. */
  128093. protected abstract _getFilenameAndPath(): {
  128094. filename: string;
  128095. path: string;
  128096. };
  128097. /**
  128098. * This function is called before the mesh is loaded. It checks for loading constraints.
  128099. * For example, this function can check if the GLB loader is available
  128100. * If this function returns false, the generic controller will be loaded instead
  128101. * @returns Is the client ready to load the mesh
  128102. */
  128103. protected abstract _getModelLoadingConstraints(): boolean;
  128104. /**
  128105. * This function will be called after the model was successfully loaded and can be used
  128106. * for mesh transformations before it is available for the user
  128107. * @param meshes the loaded meshes
  128108. */
  128109. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  128110. /**
  128111. * Set the root mesh for this controller. Important for the WebXR controller class
  128112. * @param meshes the loaded meshes
  128113. */
  128114. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  128115. /**
  128116. * A function executed each frame that updates the mesh (if needed)
  128117. * @param xrFrame the current xrFrame
  128118. */
  128119. protected abstract _updateModel(xrFrame: XRFrame): void;
  128120. private _getGenericFilenameAndPath;
  128121. private _getGenericParentMesh;
  128122. }
  128123. }
  128124. declare module BABYLON {
  128125. /**
  128126. * A generic trigger-only motion controller for WebXR
  128127. */
  128128. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  128129. /**
  128130. * Static version of the profile id of this controller
  128131. */
  128132. static ProfileId: string;
  128133. profileId: string;
  128134. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  128135. protected _getFilenameAndPath(): {
  128136. filename: string;
  128137. path: string;
  128138. };
  128139. protected _getModelLoadingConstraints(): boolean;
  128140. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  128141. protected _setRootMesh(meshes: AbstractMesh[]): void;
  128142. protected _updateModel(): void;
  128143. }
  128144. }
  128145. declare module BABYLON {
  128146. /**
  128147. * Class containing static functions to help procedurally build meshes
  128148. */
  128149. export class SphereBuilder {
  128150. /**
  128151. * Creates a sphere mesh
  128152. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  128153. * * 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`)
  128154. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  128155. * * 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
  128156. * * 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)
  128157. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128158. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128160. * @param name defines the name of the mesh
  128161. * @param options defines the options used to create the mesh
  128162. * @param scene defines the hosting scene
  128163. * @returns the sphere mesh
  128164. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  128165. */
  128166. static CreateSphere(name: string, options: {
  128167. segments?: number;
  128168. diameter?: number;
  128169. diameterX?: number;
  128170. diameterY?: number;
  128171. diameterZ?: number;
  128172. arc?: number;
  128173. slice?: number;
  128174. sideOrientation?: number;
  128175. frontUVs?: Vector4;
  128176. backUVs?: Vector4;
  128177. updatable?: boolean;
  128178. }, scene?: Nullable<Scene>): Mesh;
  128179. }
  128180. }
  128181. declare module BABYLON {
  128182. /**
  128183. * A profiled motion controller has its profile loaded from an online repository.
  128184. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  128185. */
  128186. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  128187. private _repositoryUrl;
  128188. private _buttonMeshMapping;
  128189. private _touchDots;
  128190. /**
  128191. * The profile ID of this controller. Will be populated when the controller initializes.
  128192. */
  128193. profileId: string;
  128194. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  128195. dispose(): void;
  128196. protected _getFilenameAndPath(): {
  128197. filename: string;
  128198. path: string;
  128199. };
  128200. protected _getModelLoadingConstraints(): boolean;
  128201. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  128202. protected _setRootMesh(meshes: AbstractMesh[]): void;
  128203. protected _updateModel(_xrFrame: XRFrame): void;
  128204. }
  128205. }
  128206. declare module BABYLON {
  128207. /**
  128208. * A construction function type to create a new controller based on an xrInput object
  128209. */
  128210. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  128211. /**
  128212. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  128213. *
  128214. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  128215. * it should be replaced with auto-loaded controllers.
  128216. *
  128217. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  128218. */
  128219. export class WebXRMotionControllerManager {
  128220. private static _AvailableControllers;
  128221. private static _Fallbacks;
  128222. private static _ProfileLoadingPromises;
  128223. private static _ProfilesList;
  128224. /**
  128225. * The base URL of the online controller repository. Can be changed at any time.
  128226. */
  128227. static BaseRepositoryUrl: string;
  128228. /**
  128229. * Which repository gets priority - local or online
  128230. */
  128231. static PrioritizeOnlineRepository: boolean;
  128232. /**
  128233. * Use the online repository, or use only locally-defined controllers
  128234. */
  128235. static UseOnlineRepository: boolean;
  128236. /**
  128237. * Clear the cache used for profile loading and reload when requested again
  128238. */
  128239. static ClearProfilesCache(): void;
  128240. /**
  128241. * Register the default fallbacks.
  128242. * This function is called automatically when this file is imported.
  128243. */
  128244. static DefaultFallbacks(): void;
  128245. /**
  128246. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  128247. * @param profileId the profile to which a fallback needs to be found
  128248. * @return an array with corresponding fallback profiles
  128249. */
  128250. static FindFallbackWithProfileId(profileId: string): string[];
  128251. /**
  128252. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  128253. * The order of search:
  128254. *
  128255. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  128256. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  128257. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  128258. * 4) return the generic trigger controller if none were found
  128259. *
  128260. * @param xrInput the xrInput to which a new controller is initialized
  128261. * @param scene the scene to which the model will be added
  128262. * @param forceProfile force a certain profile for this controller
  128263. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  128264. */
  128265. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  128266. /**
  128267. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  128268. *
  128269. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  128270. *
  128271. * @param type the profile type to register
  128272. * @param constructFunction the function to be called when loading this profile
  128273. */
  128274. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  128275. /**
  128276. * Register a fallback to a specific profile.
  128277. * @param profileId the profileId that will receive the fallbacks
  128278. * @param fallbacks A list of fallback profiles
  128279. */
  128280. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  128281. /**
  128282. * Will update the list of profiles available in the repository
  128283. * @return a promise that resolves to a map of profiles available online
  128284. */
  128285. static UpdateProfilesList(): Promise<{
  128286. [profile: string]: string;
  128287. }>;
  128288. private static _LoadProfileFromRepository;
  128289. private static _LoadProfilesFromAvailableControllers;
  128290. }
  128291. }
  128292. declare module BABYLON {
  128293. /**
  128294. * Configuration options for the WebXR controller creation
  128295. */
  128296. export interface IWebXRControllerOptions {
  128297. /**
  128298. * Should the controller mesh be animated when a user interacts with it
  128299. * The pressed buttons / thumbstick and touchpad animations will be disabled
  128300. */
  128301. disableMotionControllerAnimation?: boolean;
  128302. /**
  128303. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  128304. */
  128305. doNotLoadControllerMesh?: boolean;
  128306. /**
  128307. * Force a specific controller type for this controller.
  128308. * This can be used when creating your own profile or when testing different controllers
  128309. */
  128310. forceControllerProfile?: string;
  128311. /**
  128312. * Defines a rendering group ID for meshes that will be loaded.
  128313. * This is for the default controllers only.
  128314. */
  128315. renderingGroupId?: number;
  128316. }
  128317. /**
  128318. * Represents an XR controller
  128319. */
  128320. export class WebXRInputSource {
  128321. private _scene;
  128322. /** The underlying input source for the controller */
  128323. inputSource: XRInputSource;
  128324. private _options;
  128325. private _tmpVector;
  128326. private _uniqueId;
  128327. private _disposed;
  128328. /**
  128329. * 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
  128330. */
  128331. grip?: AbstractMesh;
  128332. /**
  128333. * If available, this is the gamepad object related to this controller.
  128334. * Using this object it is possible to get click events and trackpad changes of the
  128335. * webxr controller that is currently being used.
  128336. */
  128337. motionController?: WebXRAbstractMotionController;
  128338. /**
  128339. * Event that fires when the controller is removed/disposed.
  128340. * The object provided as event data is this controller, after associated assets were disposed.
  128341. * uniqueId is still available.
  128342. */
  128343. onDisposeObservable: Observable<WebXRInputSource>;
  128344. /**
  128345. * Will be triggered when the mesh associated with the motion controller is done loading.
  128346. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  128347. * A shortened version of controller -> motion controller -> on mesh loaded.
  128348. */
  128349. onMeshLoadedObservable: Observable<AbstractMesh>;
  128350. /**
  128351. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  128352. */
  128353. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  128354. /**
  128355. * Pointer which can be used to select objects or attach a visible laser to
  128356. */
  128357. pointer: AbstractMesh;
  128358. /**
  128359. * Creates the input source object
  128360. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  128361. * @param _scene the scene which the controller should be associated to
  128362. * @param inputSource the underlying input source for the controller
  128363. * @param _options options for this controller creation
  128364. */
  128365. constructor(_scene: Scene,
  128366. /** The underlying input source for the controller */
  128367. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  128368. /**
  128369. * Get this controllers unique id
  128370. */
  128371. get uniqueId(): string;
  128372. /**
  128373. * Disposes of the object
  128374. */
  128375. dispose(): void;
  128376. /**
  128377. * Gets a world space ray coming from the pointer or grip
  128378. * @param result the resulting ray
  128379. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  128380. */
  128381. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  128382. /**
  128383. * Updates the controller pose based on the given XRFrame
  128384. * @param xrFrame xr frame to update the pose with
  128385. * @param referenceSpace reference space to use
  128386. */
  128387. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  128388. }
  128389. }
  128390. declare module BABYLON {
  128391. /**
  128392. * The schema for initialization options of the XR Input class
  128393. */
  128394. export interface IWebXRInputOptions {
  128395. /**
  128396. * If set to true no model will be automatically loaded
  128397. */
  128398. doNotLoadControllerMeshes?: boolean;
  128399. /**
  128400. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  128401. * If not found, the xr input profile data will be used.
  128402. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  128403. */
  128404. forceInputProfile?: string;
  128405. /**
  128406. * Do not send a request to the controller repository to load the profile.
  128407. *
  128408. * Instead, use the controllers available in babylon itself.
  128409. */
  128410. disableOnlineControllerRepository?: boolean;
  128411. /**
  128412. * A custom URL for the controllers repository
  128413. */
  128414. customControllersRepositoryURL?: string;
  128415. /**
  128416. * Should the controller model's components not move according to the user input
  128417. */
  128418. disableControllerAnimation?: boolean;
  128419. /**
  128420. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  128421. */
  128422. controllerOptions?: IWebXRControllerOptions;
  128423. }
  128424. /**
  128425. * XR input used to track XR inputs such as controllers/rays
  128426. */
  128427. export class WebXRInput implements IDisposable {
  128428. /**
  128429. * the xr session manager for this session
  128430. */
  128431. xrSessionManager: WebXRSessionManager;
  128432. /**
  128433. * the WebXR camera for this session. Mainly used for teleportation
  128434. */
  128435. xrCamera: WebXRCamera;
  128436. private readonly options;
  128437. /**
  128438. * XR controllers being tracked
  128439. */
  128440. controllers: Array<WebXRInputSource>;
  128441. private _frameObserver;
  128442. private _sessionEndedObserver;
  128443. private _sessionInitObserver;
  128444. /**
  128445. * Event when a controller has been connected/added
  128446. */
  128447. onControllerAddedObservable: Observable<WebXRInputSource>;
  128448. /**
  128449. * Event when a controller has been removed/disconnected
  128450. */
  128451. onControllerRemovedObservable: Observable<WebXRInputSource>;
  128452. /**
  128453. * Initializes the WebXRInput
  128454. * @param xrSessionManager the xr session manager for this session
  128455. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  128456. * @param options = initialization options for this xr input
  128457. */
  128458. constructor(
  128459. /**
  128460. * the xr session manager for this session
  128461. */
  128462. xrSessionManager: WebXRSessionManager,
  128463. /**
  128464. * the WebXR camera for this session. Mainly used for teleportation
  128465. */
  128466. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  128467. private _onInputSourcesChange;
  128468. private _addAndRemoveControllers;
  128469. /**
  128470. * Disposes of the object
  128471. */
  128472. dispose(): void;
  128473. }
  128474. }
  128475. declare module BABYLON {
  128476. /**
  128477. * This is the base class for all WebXR features.
  128478. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  128479. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  128480. */
  128481. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  128482. protected _xrSessionManager: WebXRSessionManager;
  128483. private _attached;
  128484. private _removeOnDetach;
  128485. /**
  128486. * Is this feature disposed?
  128487. */
  128488. isDisposed: boolean;
  128489. /**
  128490. * Should auto-attach be disabled?
  128491. */
  128492. disableAutoAttach: boolean;
  128493. /**
  128494. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  128495. */
  128496. xrNativeFeatureName: string;
  128497. /**
  128498. * Construct a new (abstract) WebXR feature
  128499. * @param _xrSessionManager the xr session manager for this feature
  128500. */
  128501. constructor(_xrSessionManager: WebXRSessionManager);
  128502. /**
  128503. * Is this feature attached
  128504. */
  128505. get attached(): boolean;
  128506. /**
  128507. * attach this feature
  128508. *
  128509. * @param force should attachment be forced (even when already attached)
  128510. * @returns true if successful, false is failed or already attached
  128511. */
  128512. attach(force?: boolean): boolean;
  128513. /**
  128514. * detach this feature.
  128515. *
  128516. * @returns true if successful, false if failed or already detached
  128517. */
  128518. detach(): boolean;
  128519. /**
  128520. * Dispose this feature and all of the resources attached
  128521. */
  128522. dispose(): void;
  128523. /**
  128524. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  128525. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  128526. *
  128527. * @returns whether or not the feature is compatible in this environment
  128528. */
  128529. isCompatible(): boolean;
  128530. /**
  128531. * This is used to register callbacks that will automatically be removed when detach is called.
  128532. * @param observable the observable to which the observer will be attached
  128533. * @param callback the callback to register
  128534. */
  128535. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  128536. /**
  128537. * Code in this function will be executed on each xrFrame received from the browser.
  128538. * This function will not execute after the feature is detached.
  128539. * @param _xrFrame the current frame
  128540. */
  128541. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  128542. }
  128543. }
  128544. declare module BABYLON {
  128545. /**
  128546. * Renders a layer on top of an existing scene
  128547. */
  128548. export class UtilityLayerRenderer implements IDisposable {
  128549. /** the original scene that will be rendered on top of */
  128550. originalScene: Scene;
  128551. private _pointerCaptures;
  128552. private _lastPointerEvents;
  128553. private static _DefaultUtilityLayer;
  128554. private static _DefaultKeepDepthUtilityLayer;
  128555. private _sharedGizmoLight;
  128556. private _renderCamera;
  128557. /**
  128558. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  128559. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  128560. * @returns the camera that is used when rendering the utility layer
  128561. */
  128562. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  128563. /**
  128564. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  128565. * @param cam the camera that should be used when rendering the utility layer
  128566. */
  128567. setRenderCamera(cam: Nullable<Camera>): void;
  128568. /**
  128569. * @hidden
  128570. * Light which used by gizmos to get light shading
  128571. */
  128572. _getSharedGizmoLight(): HemisphericLight;
  128573. /**
  128574. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  128575. */
  128576. pickUtilitySceneFirst: boolean;
  128577. /**
  128578. * 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)
  128579. */
  128580. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  128581. /**
  128582. * 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)
  128583. */
  128584. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  128585. /**
  128586. * The scene that is rendered on top of the original scene
  128587. */
  128588. utilityLayerScene: Scene;
  128589. /**
  128590. * If the utility layer should automatically be rendered on top of existing scene
  128591. */
  128592. shouldRender: boolean;
  128593. /**
  128594. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  128595. */
  128596. onlyCheckPointerDownEvents: boolean;
  128597. /**
  128598. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  128599. */
  128600. processAllEvents: boolean;
  128601. /**
  128602. * Observable raised when the pointer move from the utility layer scene to the main scene
  128603. */
  128604. onPointerOutObservable: Observable<number>;
  128605. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  128606. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  128607. private _afterRenderObserver;
  128608. private _sceneDisposeObserver;
  128609. private _originalPointerObserver;
  128610. /**
  128611. * Instantiates a UtilityLayerRenderer
  128612. * @param originalScene the original scene that will be rendered on top of
  128613. * @param handleEvents boolean indicating if the utility layer should handle events
  128614. */
  128615. constructor(
  128616. /** the original scene that will be rendered on top of */
  128617. originalScene: Scene, handleEvents?: boolean);
  128618. private _notifyObservers;
  128619. /**
  128620. * Renders the utility layers scene on top of the original scene
  128621. */
  128622. render(): void;
  128623. /**
  128624. * Disposes of the renderer
  128625. */
  128626. dispose(): void;
  128627. private _updateCamera;
  128628. }
  128629. }
  128630. declare module BABYLON {
  128631. /**
  128632. * Options interface for the pointer selection module
  128633. */
  128634. export interface IWebXRControllerPointerSelectionOptions {
  128635. /**
  128636. * if provided, this scene will be used to render meshes.
  128637. */
  128638. customUtilityLayerScene?: Scene;
  128639. /**
  128640. * 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)
  128641. * If not disabled, the last picked point will be used to execute a pointer up event
  128642. * If disabled, pointer up event will be triggered right after the pointer down event.
  128643. * Used in screen and gaze target ray mode only
  128644. */
  128645. disablePointerUpOnTouchOut: boolean;
  128646. /**
  128647. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  128648. */
  128649. forceGazeMode: boolean;
  128650. /**
  128651. * 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
  128652. * to start a new countdown to the pointer down event.
  128653. * Defaults to 1.
  128654. */
  128655. gazeModePointerMovedFactor?: number;
  128656. /**
  128657. * Different button type to use instead of the main component
  128658. */
  128659. overrideButtonId?: string;
  128660. /**
  128661. * use this rendering group id for the meshes (optional)
  128662. */
  128663. renderingGroupId?: number;
  128664. /**
  128665. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  128666. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  128667. * 3000 means 3 seconds between pointing at something and selecting it
  128668. */
  128669. timeToSelect?: number;
  128670. /**
  128671. * Should meshes created here be added to a utility layer or the main scene
  128672. */
  128673. useUtilityLayer?: boolean;
  128674. /**
  128675. * Optional WebXR camera to be used for gaze selection
  128676. */
  128677. gazeCamera?: WebXRCamera;
  128678. /**
  128679. * the xr input to use with this pointer selection
  128680. */
  128681. xrInput: WebXRInput;
  128682. }
  128683. /**
  128684. * A module that will enable pointer selection for motion controllers of XR Input Sources
  128685. */
  128686. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  128687. private readonly _options;
  128688. private static _idCounter;
  128689. private _attachController;
  128690. private _controllers;
  128691. private _scene;
  128692. private _tmpVectorForPickCompare;
  128693. /**
  128694. * The module's name
  128695. */
  128696. static readonly Name: string;
  128697. /**
  128698. * The (Babylon) version of this module.
  128699. * This is an integer representing the implementation version.
  128700. * This number does not correspond to the WebXR specs version
  128701. */
  128702. static readonly Version: number;
  128703. /**
  128704. * Disable lighting on the laser pointer (so it will always be visible)
  128705. */
  128706. disablePointerLighting: boolean;
  128707. /**
  128708. * Disable lighting on the selection mesh (so it will always be visible)
  128709. */
  128710. disableSelectionMeshLighting: boolean;
  128711. /**
  128712. * Should the laser pointer be displayed
  128713. */
  128714. displayLaserPointer: boolean;
  128715. /**
  128716. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  128717. */
  128718. displaySelectionMesh: boolean;
  128719. /**
  128720. * This color will be set to the laser pointer when selection is triggered
  128721. */
  128722. laserPointerPickedColor: Color3;
  128723. /**
  128724. * Default color of the laser pointer
  128725. */
  128726. laserPointerDefaultColor: Color3;
  128727. /**
  128728. * default color of the selection ring
  128729. */
  128730. selectionMeshDefaultColor: Color3;
  128731. /**
  128732. * This color will be applied to the selection ring when selection is triggered
  128733. */
  128734. selectionMeshPickedColor: Color3;
  128735. /**
  128736. * Optional filter to be used for ray selection. This predicate shares behavior with
  128737. * scene.pointerMovePredicate which takes priority if it is also assigned.
  128738. */
  128739. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  128740. /**
  128741. * constructs a new background remover module
  128742. * @param _xrSessionManager the session manager for this module
  128743. * @param _options read-only options to be used in this module
  128744. */
  128745. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  128746. /**
  128747. * attach this feature
  128748. * Will usually be called by the features manager
  128749. *
  128750. * @returns true if successful.
  128751. */
  128752. attach(): boolean;
  128753. /**
  128754. * detach this feature.
  128755. * Will usually be called by the features manager
  128756. *
  128757. * @returns true if successful.
  128758. */
  128759. detach(): boolean;
  128760. /**
  128761. * Will get the mesh under a specific pointer.
  128762. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  128763. * @param controllerId the controllerId to check
  128764. * @returns The mesh under pointer or null if no mesh is under the pointer
  128765. */
  128766. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  128767. /**
  128768. * Get the xr controller that correlates to the pointer id in the pointer event
  128769. *
  128770. * @param id the pointer id to search for
  128771. * @returns the controller that correlates to this id or null if not found
  128772. */
  128773. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  128774. protected _onXRFrame(_xrFrame: XRFrame): void;
  128775. private _attachGazeMode;
  128776. private _attachScreenRayMode;
  128777. private _attachTrackedPointerRayMode;
  128778. private _convertNormalToDirectionOfRay;
  128779. private _detachController;
  128780. private _generateNewMeshPair;
  128781. private _pickingMoved;
  128782. private _updatePointerDistance;
  128783. /** @hidden */
  128784. get lasterPointerDefaultColor(): Color3;
  128785. }
  128786. }
  128787. declare module BABYLON {
  128788. /**
  128789. * Button which can be used to enter a different mode of XR
  128790. */
  128791. export class WebXREnterExitUIButton {
  128792. /** button element */
  128793. element: HTMLElement;
  128794. /** XR initialization options for the button */
  128795. sessionMode: XRSessionMode;
  128796. /** Reference space type */
  128797. referenceSpaceType: XRReferenceSpaceType;
  128798. /**
  128799. * Creates a WebXREnterExitUIButton
  128800. * @param element button element
  128801. * @param sessionMode XR initialization session mode
  128802. * @param referenceSpaceType the type of reference space to be used
  128803. */
  128804. constructor(
  128805. /** button element */
  128806. element: HTMLElement,
  128807. /** XR initialization options for the button */
  128808. sessionMode: XRSessionMode,
  128809. /** Reference space type */
  128810. referenceSpaceType: XRReferenceSpaceType);
  128811. /**
  128812. * Extendable function which can be used to update the button's visuals when the state changes
  128813. * @param activeButton the current active button in the UI
  128814. */
  128815. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  128816. }
  128817. /**
  128818. * Options to create the webXR UI
  128819. */
  128820. export class WebXREnterExitUIOptions {
  128821. /**
  128822. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  128823. */
  128824. customButtons?: Array<WebXREnterExitUIButton>;
  128825. /**
  128826. * A reference space type to use when creating the default button.
  128827. * Default is local-floor
  128828. */
  128829. referenceSpaceType?: XRReferenceSpaceType;
  128830. /**
  128831. * Context to enter xr with
  128832. */
  128833. renderTarget?: Nullable<WebXRRenderTarget>;
  128834. /**
  128835. * A session mode to use when creating the default button.
  128836. * Default is immersive-vr
  128837. */
  128838. sessionMode?: XRSessionMode;
  128839. /**
  128840. * A list of optional features to init the session with
  128841. */
  128842. optionalFeatures?: string[];
  128843. /**
  128844. * A list of optional features to init the session with
  128845. */
  128846. requiredFeatures?: string[];
  128847. }
  128848. /**
  128849. * UI to allow the user to enter/exit XR mode
  128850. */
  128851. export class WebXREnterExitUI implements IDisposable {
  128852. private scene;
  128853. /** version of the options passed to this UI */
  128854. options: WebXREnterExitUIOptions;
  128855. private _activeButton;
  128856. private _buttons;
  128857. /**
  128858. * The HTML Div Element to which buttons are added.
  128859. */
  128860. readonly overlay: HTMLDivElement;
  128861. /**
  128862. * Fired every time the active button is changed.
  128863. *
  128864. * When xr is entered via a button that launches xr that button will be the callback parameter
  128865. *
  128866. * When exiting xr the callback parameter will be null)
  128867. */
  128868. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  128869. /**
  128870. *
  128871. * @param scene babylon scene object to use
  128872. * @param options (read-only) version of the options passed to this UI
  128873. */
  128874. private constructor();
  128875. /**
  128876. * Creates UI to allow the user to enter/exit XR mode
  128877. * @param scene the scene to add the ui to
  128878. * @param helper the xr experience helper to enter/exit xr with
  128879. * @param options options to configure the UI
  128880. * @returns the created ui
  128881. */
  128882. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  128883. /**
  128884. * Disposes of the XR UI component
  128885. */
  128886. dispose(): void;
  128887. private _updateButtons;
  128888. }
  128889. }
  128890. declare module BABYLON {
  128891. /**
  128892. * Class containing static functions to help procedurally build meshes
  128893. */
  128894. export class LinesBuilder {
  128895. /**
  128896. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  128897. * * 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
  128898. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  128899. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  128900. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  128901. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  128902. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  128903. * * 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
  128904. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  128905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128906. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  128907. * @param name defines the name of the new line system
  128908. * @param options defines the options used to create the line system
  128909. * @param scene defines the hosting scene
  128910. * @returns a new line system mesh
  128911. */
  128912. static CreateLineSystem(name: string, options: {
  128913. lines: Vector3[][];
  128914. updatable?: boolean;
  128915. instance?: Nullable<LinesMesh>;
  128916. colors?: Nullable<Color4[][]>;
  128917. useVertexAlpha?: boolean;
  128918. }, scene: Nullable<Scene>): LinesMesh;
  128919. /**
  128920. * Creates a line mesh
  128921. * 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
  128922. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  128923. * * The parameter `points` is an array successive Vector3
  128924. * * 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
  128925. * * The optional parameter `colors` is an array of successive Color4, one per line point
  128926. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  128927. * * When updating an instance, remember that only point positions can change, not the number of points
  128928. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128929. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  128930. * @param name defines the name of the new line system
  128931. * @param options defines the options used to create the line system
  128932. * @param scene defines the hosting scene
  128933. * @returns a new line mesh
  128934. */
  128935. static CreateLines(name: string, options: {
  128936. points: Vector3[];
  128937. updatable?: boolean;
  128938. instance?: Nullable<LinesMesh>;
  128939. colors?: Color4[];
  128940. useVertexAlpha?: boolean;
  128941. }, scene?: Nullable<Scene>): LinesMesh;
  128942. /**
  128943. * Creates a dashed line mesh
  128944. * * 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
  128945. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  128946. * * The parameter `points` is an array successive Vector3
  128947. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  128948. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  128949. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  128950. * * 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
  128951. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  128952. * * When updating an instance, remember that only point positions can change, not the number of points
  128953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128954. * @param name defines the name of the mesh
  128955. * @param options defines the options used to create the mesh
  128956. * @param scene defines the hosting scene
  128957. * @returns the dashed line mesh
  128958. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  128959. */
  128960. static CreateDashedLines(name: string, options: {
  128961. points: Vector3[];
  128962. dashSize?: number;
  128963. gapSize?: number;
  128964. dashNb?: number;
  128965. updatable?: boolean;
  128966. instance?: LinesMesh;
  128967. useVertexAlpha?: boolean;
  128968. }, scene?: Nullable<Scene>): LinesMesh;
  128969. }
  128970. }
  128971. declare module BABYLON {
  128972. /**
  128973. * Construction options for a timer
  128974. */
  128975. export interface ITimerOptions<T> {
  128976. /**
  128977. * Time-to-end
  128978. */
  128979. timeout: number;
  128980. /**
  128981. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  128982. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  128983. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  128984. */
  128985. contextObservable: Observable<T>;
  128986. /**
  128987. * Optional parameters when adding an observer to the observable
  128988. */
  128989. observableParameters?: {
  128990. mask?: number;
  128991. insertFirst?: boolean;
  128992. scope?: any;
  128993. };
  128994. /**
  128995. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  128996. */
  128997. breakCondition?: (data?: ITimerData<T>) => boolean;
  128998. /**
  128999. * Will be triggered when the time condition has met
  129000. */
  129001. onEnded?: (data: ITimerData<any>) => void;
  129002. /**
  129003. * Will be triggered when the break condition has met (prematurely ended)
  129004. */
  129005. onAborted?: (data: ITimerData<any>) => void;
  129006. /**
  129007. * Optional function to execute on each tick (or count)
  129008. */
  129009. onTick?: (data: ITimerData<any>) => void;
  129010. }
  129011. /**
  129012. * An interface defining the data sent by the timer
  129013. */
  129014. export interface ITimerData<T> {
  129015. /**
  129016. * When did it start
  129017. */
  129018. startTime: number;
  129019. /**
  129020. * Time now
  129021. */
  129022. currentTime: number;
  129023. /**
  129024. * Time passed since started
  129025. */
  129026. deltaTime: number;
  129027. /**
  129028. * How much is completed, in [0.0...1.0].
  129029. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  129030. */
  129031. completeRate: number;
  129032. /**
  129033. * What the registered observable sent in the last count
  129034. */
  129035. payload: T;
  129036. }
  129037. /**
  129038. * The current state of the timer
  129039. */
  129040. export enum TimerState {
  129041. /**
  129042. * Timer initialized, not yet started
  129043. */
  129044. INIT = 0,
  129045. /**
  129046. * Timer started and counting
  129047. */
  129048. STARTED = 1,
  129049. /**
  129050. * Timer ended (whether aborted or time reached)
  129051. */
  129052. ENDED = 2
  129053. }
  129054. /**
  129055. * A simple version of the timer. Will take options and start the timer immediately after calling it
  129056. *
  129057. * @param options options with which to initialize this timer
  129058. */
  129059. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  129060. /**
  129061. * An advanced implementation of a timer class
  129062. */
  129063. export class AdvancedTimer<T = any> implements IDisposable {
  129064. /**
  129065. * Will notify each time the timer calculates the remaining time
  129066. */
  129067. onEachCountObservable: Observable<ITimerData<T>>;
  129068. /**
  129069. * Will trigger when the timer was aborted due to the break condition
  129070. */
  129071. onTimerAbortedObservable: Observable<ITimerData<T>>;
  129072. /**
  129073. * Will trigger when the timer ended successfully
  129074. */
  129075. onTimerEndedObservable: Observable<ITimerData<T>>;
  129076. /**
  129077. * Will trigger when the timer state has changed
  129078. */
  129079. onStateChangedObservable: Observable<TimerState>;
  129080. private _observer;
  129081. private _contextObservable;
  129082. private _observableParameters;
  129083. private _startTime;
  129084. private _timer;
  129085. private _state;
  129086. private _breakCondition;
  129087. private _timeToEnd;
  129088. private _breakOnNextTick;
  129089. /**
  129090. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  129091. * @param options construction options for this advanced timer
  129092. */
  129093. constructor(options: ITimerOptions<T>);
  129094. /**
  129095. * set a breaking condition for this timer. Default is to never break during count
  129096. * @param predicate the new break condition. Returns true to break, false otherwise
  129097. */
  129098. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  129099. /**
  129100. * Reset ALL associated observables in this advanced timer
  129101. */
  129102. clearObservables(): void;
  129103. /**
  129104. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  129105. *
  129106. * @param timeToEnd how much time to measure until timer ended
  129107. */
  129108. start(timeToEnd?: number): void;
  129109. /**
  129110. * Will force a stop on the next tick.
  129111. */
  129112. stop(): void;
  129113. /**
  129114. * Dispose this timer, clearing all resources
  129115. */
  129116. dispose(): void;
  129117. private _setState;
  129118. private _tick;
  129119. private _stop;
  129120. }
  129121. }
  129122. declare module BABYLON {
  129123. /**
  129124. * The options container for the teleportation module
  129125. */
  129126. export interface IWebXRTeleportationOptions {
  129127. /**
  129128. * if provided, this scene will be used to render meshes.
  129129. */
  129130. customUtilityLayerScene?: Scene;
  129131. /**
  129132. * Values to configure the default target mesh
  129133. */
  129134. defaultTargetMeshOptions?: {
  129135. /**
  129136. * Fill color of the teleportation area
  129137. */
  129138. teleportationFillColor?: string;
  129139. /**
  129140. * Border color for the teleportation area
  129141. */
  129142. teleportationBorderColor?: string;
  129143. /**
  129144. * Disable the mesh's animation sequence
  129145. */
  129146. disableAnimation?: boolean;
  129147. /**
  129148. * Disable lighting on the material or the ring and arrow
  129149. */
  129150. disableLighting?: boolean;
  129151. /**
  129152. * Override the default material of the torus and arrow
  129153. */
  129154. torusArrowMaterial?: Material;
  129155. };
  129156. /**
  129157. * A list of meshes to use as floor meshes.
  129158. * Meshes can be added and removed after initializing the feature using the
  129159. * addFloorMesh and removeFloorMesh functions
  129160. * If empty, rotation will still work
  129161. */
  129162. floorMeshes?: AbstractMesh[];
  129163. /**
  129164. * use this rendering group id for the meshes (optional)
  129165. */
  129166. renderingGroupId?: number;
  129167. /**
  129168. * Should teleportation move only to snap points
  129169. */
  129170. snapPointsOnly?: boolean;
  129171. /**
  129172. * An array of points to which the teleportation will snap to.
  129173. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  129174. */
  129175. snapPositions?: Vector3[];
  129176. /**
  129177. * How close should the teleportation ray be in order to snap to position.
  129178. * Default to 0.8 units (meters)
  129179. */
  129180. snapToPositionRadius?: number;
  129181. /**
  129182. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  129183. * If you want to support rotation, make sure your mesh has a direction indicator.
  129184. *
  129185. * When left untouched, the default mesh will be initialized.
  129186. */
  129187. teleportationTargetMesh?: AbstractMesh;
  129188. /**
  129189. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  129190. */
  129191. timeToTeleport?: number;
  129192. /**
  129193. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  129194. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  129195. */
  129196. useMainComponentOnly?: boolean;
  129197. /**
  129198. * Should meshes created here be added to a utility layer or the main scene
  129199. */
  129200. useUtilityLayer?: boolean;
  129201. /**
  129202. * Babylon XR Input class for controller
  129203. */
  129204. xrInput: WebXRInput;
  129205. /**
  129206. * Meshes that the teleportation ray cannot go through
  129207. */
  129208. pickBlockerMeshes?: AbstractMesh[];
  129209. }
  129210. /**
  129211. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  129212. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  129213. * the input of the attached controllers.
  129214. */
  129215. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  129216. private _options;
  129217. private _controllers;
  129218. private _currentTeleportationControllerId;
  129219. private _floorMeshes;
  129220. private _quadraticBezierCurve;
  129221. private _selectionFeature;
  129222. private _snapToPositions;
  129223. private _snappedToPoint;
  129224. private _teleportationRingMaterial?;
  129225. private _tmpRay;
  129226. private _tmpVector;
  129227. private _tmpQuaternion;
  129228. /**
  129229. * The module's name
  129230. */
  129231. static readonly Name: string;
  129232. /**
  129233. * The (Babylon) version of this module.
  129234. * This is an integer representing the implementation version.
  129235. * This number does not correspond to the webxr specs version
  129236. */
  129237. static readonly Version: number;
  129238. /**
  129239. * Is movement backwards enabled
  129240. */
  129241. backwardsMovementEnabled: boolean;
  129242. /**
  129243. * Distance to travel when moving backwards
  129244. */
  129245. backwardsTeleportationDistance: number;
  129246. /**
  129247. * The distance from the user to the inspection point in the direction of the controller
  129248. * A higher number will allow the user to move further
  129249. * defaults to 5 (meters, in xr units)
  129250. */
  129251. parabolicCheckRadius: number;
  129252. /**
  129253. * Should the module support parabolic ray on top of direct ray
  129254. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  129255. * Very helpful when moving between floors / different heights
  129256. */
  129257. parabolicRayEnabled: boolean;
  129258. /**
  129259. * How much rotation should be applied when rotating right and left
  129260. */
  129261. rotationAngle: number;
  129262. /**
  129263. * Is rotation enabled when moving forward?
  129264. * Disabling this feature will prevent the user from deciding the direction when teleporting
  129265. */
  129266. rotationEnabled: boolean;
  129267. /**
  129268. * constructs a new anchor system
  129269. * @param _xrSessionManager an instance of WebXRSessionManager
  129270. * @param _options configuration object for this feature
  129271. */
  129272. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  129273. /**
  129274. * Get the snapPointsOnly flag
  129275. */
  129276. get snapPointsOnly(): boolean;
  129277. /**
  129278. * Sets the snapPointsOnly flag
  129279. * @param snapToPoints should teleportation be exclusively to snap points
  129280. */
  129281. set snapPointsOnly(snapToPoints: boolean);
  129282. /**
  129283. * Add a new mesh to the floor meshes array
  129284. * @param mesh the mesh to use as floor mesh
  129285. */
  129286. addFloorMesh(mesh: AbstractMesh): void;
  129287. /**
  129288. * Add a new snap-to point to fix teleportation to this position
  129289. * @param newSnapPoint The new Snap-To point
  129290. */
  129291. addSnapPoint(newSnapPoint: Vector3): void;
  129292. attach(): boolean;
  129293. detach(): boolean;
  129294. dispose(): void;
  129295. /**
  129296. * Remove a mesh from the floor meshes array
  129297. * @param mesh the mesh to remove
  129298. */
  129299. removeFloorMesh(mesh: AbstractMesh): void;
  129300. /**
  129301. * Remove a mesh from the floor meshes array using its name
  129302. * @param name the mesh name to remove
  129303. */
  129304. removeFloorMeshByName(name: string): void;
  129305. /**
  129306. * 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
  129307. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  129308. * @returns was the point found and removed or not
  129309. */
  129310. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  129311. /**
  129312. * This function sets a selection feature that will be disabled when
  129313. * the forward ray is shown and will be reattached when hidden.
  129314. * This is used to remove the selection rays when moving.
  129315. * @param selectionFeature the feature to disable when forward movement is enabled
  129316. */
  129317. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  129318. protected _onXRFrame(_xrFrame: XRFrame): void;
  129319. private _attachController;
  129320. private _createDefaultTargetMesh;
  129321. private _detachController;
  129322. private _findClosestSnapPointWithRadius;
  129323. private _setTargetMeshPosition;
  129324. private _setTargetMeshVisibility;
  129325. private _showParabolicPath;
  129326. private _teleportForward;
  129327. }
  129328. }
  129329. declare module BABYLON {
  129330. /**
  129331. * Options for the default xr helper
  129332. */
  129333. export class WebXRDefaultExperienceOptions {
  129334. /**
  129335. * Enable or disable default UI to enter XR
  129336. */
  129337. disableDefaultUI?: boolean;
  129338. /**
  129339. * Should teleportation not initialize. defaults to false.
  129340. */
  129341. disableTeleportation?: boolean;
  129342. /**
  129343. * Floor meshes that will be used for teleport
  129344. */
  129345. floorMeshes?: Array<AbstractMesh>;
  129346. /**
  129347. * If set to true, the first frame will not be used to reset position
  129348. * The first frame is mainly used when copying transformation from the old camera
  129349. * Mainly used in AR
  129350. */
  129351. ignoreNativeCameraTransformation?: boolean;
  129352. /**
  129353. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  129354. */
  129355. inputOptions?: IWebXRInputOptions;
  129356. /**
  129357. * optional configuration for the output canvas
  129358. */
  129359. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  129360. /**
  129361. * optional UI options. This can be used among other to change session mode and reference space type
  129362. */
  129363. uiOptions?: WebXREnterExitUIOptions;
  129364. /**
  129365. * When loading teleportation and pointer select, use stable versions instead of latest.
  129366. */
  129367. useStablePlugins?: boolean;
  129368. /**
  129369. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  129370. */
  129371. renderingGroupId?: number;
  129372. /**
  129373. * A list of optional features to init the session with
  129374. * If set to true, all features we support will be added
  129375. */
  129376. optionalFeatures?: boolean | string[];
  129377. }
  129378. /**
  129379. * Default experience which provides a similar setup to the previous webVRExperience
  129380. */
  129381. export class WebXRDefaultExperience {
  129382. /**
  129383. * Base experience
  129384. */
  129385. baseExperience: WebXRExperienceHelper;
  129386. /**
  129387. * Enables ui for entering/exiting xr
  129388. */
  129389. enterExitUI: WebXREnterExitUI;
  129390. /**
  129391. * Input experience extension
  129392. */
  129393. input: WebXRInput;
  129394. /**
  129395. * Enables laser pointer and selection
  129396. */
  129397. pointerSelection: WebXRControllerPointerSelection;
  129398. /**
  129399. * Default target xr should render to
  129400. */
  129401. renderTarget: WebXRRenderTarget;
  129402. /**
  129403. * Enables teleportation
  129404. */
  129405. teleportation: WebXRMotionControllerTeleportation;
  129406. private constructor();
  129407. /**
  129408. * Creates the default xr experience
  129409. * @param scene scene
  129410. * @param options options for basic configuration
  129411. * @returns resulting WebXRDefaultExperience
  129412. */
  129413. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  129414. /**
  129415. * DIsposes of the experience helper
  129416. */
  129417. dispose(): void;
  129418. }
  129419. }
  129420. declare module BABYLON {
  129421. /**
  129422. * Options to modify the vr teleportation behavior.
  129423. */
  129424. export interface VRTeleportationOptions {
  129425. /**
  129426. * The name of the mesh which should be used as the teleportation floor. (default: null)
  129427. */
  129428. floorMeshName?: string;
  129429. /**
  129430. * A list of meshes to be used as the teleportation floor. (default: empty)
  129431. */
  129432. floorMeshes?: Mesh[];
  129433. /**
  129434. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  129435. */
  129436. teleportationMode?: number;
  129437. /**
  129438. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  129439. */
  129440. teleportationTime?: number;
  129441. /**
  129442. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  129443. */
  129444. teleportationSpeed?: number;
  129445. /**
  129446. * The easing function used in the animation or null for Linear. (default CircleEase)
  129447. */
  129448. easingFunction?: EasingFunction;
  129449. }
  129450. /**
  129451. * Options to modify the vr experience helper's behavior.
  129452. */
  129453. export interface VRExperienceHelperOptions extends WebVROptions {
  129454. /**
  129455. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  129456. */
  129457. createDeviceOrientationCamera?: boolean;
  129458. /**
  129459. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  129460. */
  129461. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  129462. /**
  129463. * Uses the main button on the controller to toggle the laser casted. (default: true)
  129464. */
  129465. laserToggle?: boolean;
  129466. /**
  129467. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  129468. */
  129469. floorMeshes?: Mesh[];
  129470. /**
  129471. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  129472. */
  129473. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  129474. /**
  129475. * Defines if WebXR should be used instead of WebVR (if available)
  129476. */
  129477. useXR?: boolean;
  129478. }
  129479. /**
  129480. * Event containing information after VR has been entered
  129481. */
  129482. export class OnAfterEnteringVRObservableEvent {
  129483. /**
  129484. * If entering vr was successful
  129485. */
  129486. success: boolean;
  129487. }
  129488. /**
  129489. * Helps to quickly add VR support to an existing scene.
  129490. * See https://doc.babylonjs.com/how_to/webvr_helper
  129491. */
  129492. export class VRExperienceHelper {
  129493. /** Options to modify the vr experience helper's behavior. */
  129494. webVROptions: VRExperienceHelperOptions;
  129495. private _scene;
  129496. private _position;
  129497. private _btnVR;
  129498. private _btnVRDisplayed;
  129499. private _webVRsupported;
  129500. private _webVRready;
  129501. private _webVRrequesting;
  129502. private _webVRpresenting;
  129503. private _hasEnteredVR;
  129504. private _fullscreenVRpresenting;
  129505. private _inputElement;
  129506. private _webVRCamera;
  129507. private _vrDeviceOrientationCamera;
  129508. private _deviceOrientationCamera;
  129509. private _existingCamera;
  129510. private _onKeyDown;
  129511. private _onVrDisplayPresentChange;
  129512. private _onVRDisplayChanged;
  129513. private _onVRRequestPresentStart;
  129514. private _onVRRequestPresentComplete;
  129515. /**
  129516. * 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)
  129517. */
  129518. enableGazeEvenWhenNoPointerLock: boolean;
  129519. /**
  129520. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  129521. */
  129522. exitVROnDoubleTap: boolean;
  129523. /**
  129524. * Observable raised right before entering VR.
  129525. */
  129526. onEnteringVRObservable: Observable<VRExperienceHelper>;
  129527. /**
  129528. * Observable raised when entering VR has completed.
  129529. */
  129530. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  129531. /**
  129532. * Observable raised when exiting VR.
  129533. */
  129534. onExitingVRObservable: Observable<VRExperienceHelper>;
  129535. /**
  129536. * Observable raised when controller mesh is loaded.
  129537. */
  129538. onControllerMeshLoadedObservable: Observable<WebVRController>;
  129539. /** Return this.onEnteringVRObservable
  129540. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  129541. */
  129542. get onEnteringVR(): Observable<VRExperienceHelper>;
  129543. /** Return this.onExitingVRObservable
  129544. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  129545. */
  129546. get onExitingVR(): Observable<VRExperienceHelper>;
  129547. /** Return this.onControllerMeshLoadedObservable
  129548. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  129549. */
  129550. get onControllerMeshLoaded(): Observable<WebVRController>;
  129551. private _rayLength;
  129552. private _useCustomVRButton;
  129553. private _teleportationRequested;
  129554. private _teleportActive;
  129555. private _floorMeshName;
  129556. private _floorMeshesCollection;
  129557. private _teleportationMode;
  129558. private _teleportationTime;
  129559. private _teleportationSpeed;
  129560. private _teleportationEasing;
  129561. private _rotationAllowed;
  129562. private _teleportBackwardsVector;
  129563. private _teleportationTarget;
  129564. private _isDefaultTeleportationTarget;
  129565. private _postProcessMove;
  129566. private _teleportationFillColor;
  129567. private _teleportationBorderColor;
  129568. private _rotationAngle;
  129569. private _haloCenter;
  129570. private _cameraGazer;
  129571. private _padSensibilityUp;
  129572. private _padSensibilityDown;
  129573. private _leftController;
  129574. private _rightController;
  129575. private _gazeColor;
  129576. private _laserColor;
  129577. private _pickedLaserColor;
  129578. private _pickedGazeColor;
  129579. /**
  129580. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  129581. */
  129582. onNewMeshSelected: Observable<AbstractMesh>;
  129583. /**
  129584. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  129585. * This observable will provide the mesh and the controller used to select the mesh
  129586. */
  129587. onMeshSelectedWithController: Observable<{
  129588. mesh: AbstractMesh;
  129589. controller: WebVRController;
  129590. }>;
  129591. /**
  129592. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  129593. */
  129594. onNewMeshPicked: Observable<PickingInfo>;
  129595. private _circleEase;
  129596. /**
  129597. * Observable raised before camera teleportation
  129598. */
  129599. onBeforeCameraTeleport: Observable<Vector3>;
  129600. /**
  129601. * Observable raised after camera teleportation
  129602. */
  129603. onAfterCameraTeleport: Observable<Vector3>;
  129604. /**
  129605. * Observable raised when current selected mesh gets unselected
  129606. */
  129607. onSelectedMeshUnselected: Observable<AbstractMesh>;
  129608. private _raySelectionPredicate;
  129609. /**
  129610. * To be optionaly changed by user to define custom ray selection
  129611. */
  129612. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  129613. /**
  129614. * To be optionaly changed by user to define custom selection logic (after ray selection)
  129615. */
  129616. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  129617. /**
  129618. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  129619. */
  129620. teleportationEnabled: boolean;
  129621. private _defaultHeight;
  129622. private _teleportationInitialized;
  129623. private _interactionsEnabled;
  129624. private _interactionsRequested;
  129625. private _displayGaze;
  129626. private _displayLaserPointer;
  129627. /**
  129628. * The mesh used to display where the user is going to teleport.
  129629. */
  129630. get teleportationTarget(): Mesh;
  129631. /**
  129632. * Sets the mesh to be used to display where the user is going to teleport.
  129633. */
  129634. set teleportationTarget(value: Mesh);
  129635. /**
  129636. * 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
  129637. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  129638. * See https://doc.babylonjs.com/resources/baking_transformations
  129639. */
  129640. get gazeTrackerMesh(): Mesh;
  129641. set gazeTrackerMesh(value: Mesh);
  129642. /**
  129643. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  129644. */
  129645. updateGazeTrackerScale: boolean;
  129646. /**
  129647. * If the gaze trackers color should be updated when selecting meshes
  129648. */
  129649. updateGazeTrackerColor: boolean;
  129650. /**
  129651. * If the controller laser color should be updated when selecting meshes
  129652. */
  129653. updateControllerLaserColor: boolean;
  129654. /**
  129655. * The gaze tracking mesh corresponding to the left controller
  129656. */
  129657. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  129658. /**
  129659. * The gaze tracking mesh corresponding to the right controller
  129660. */
  129661. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  129662. /**
  129663. * If the ray of the gaze should be displayed.
  129664. */
  129665. get displayGaze(): boolean;
  129666. /**
  129667. * Sets if the ray of the gaze should be displayed.
  129668. */
  129669. set displayGaze(value: boolean);
  129670. /**
  129671. * If the ray of the LaserPointer should be displayed.
  129672. */
  129673. get displayLaserPointer(): boolean;
  129674. /**
  129675. * Sets if the ray of the LaserPointer should be displayed.
  129676. */
  129677. set displayLaserPointer(value: boolean);
  129678. /**
  129679. * The deviceOrientationCamera used as the camera when not in VR.
  129680. */
  129681. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  129682. /**
  129683. * Based on the current WebVR support, returns the current VR camera used.
  129684. */
  129685. get currentVRCamera(): Nullable<Camera>;
  129686. /**
  129687. * The webVRCamera which is used when in VR.
  129688. */
  129689. get webVRCamera(): WebVRFreeCamera;
  129690. /**
  129691. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  129692. */
  129693. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  129694. /**
  129695. * The html button that is used to trigger entering into VR.
  129696. */
  129697. get vrButton(): Nullable<HTMLButtonElement>;
  129698. private get _teleportationRequestInitiated();
  129699. /**
  129700. * Defines whether or not Pointer lock should be requested when switching to
  129701. * full screen.
  129702. */
  129703. requestPointerLockOnFullScreen: boolean;
  129704. /**
  129705. * If asking to force XR, this will be populated with the default xr experience
  129706. */
  129707. xr: WebXRDefaultExperience;
  129708. /**
  129709. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  129710. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  129711. */
  129712. xrTestDone: boolean;
  129713. /**
  129714. * Instantiates a VRExperienceHelper.
  129715. * Helps to quickly add VR support to an existing scene.
  129716. * @param scene The scene the VRExperienceHelper belongs to.
  129717. * @param webVROptions Options to modify the vr experience helper's behavior.
  129718. */
  129719. constructor(scene: Scene,
  129720. /** Options to modify the vr experience helper's behavior. */
  129721. webVROptions?: VRExperienceHelperOptions);
  129722. private completeVRInit;
  129723. private _onDefaultMeshLoaded;
  129724. private _onResize;
  129725. private _onFullscreenChange;
  129726. /**
  129727. * Gets a value indicating if we are currently in VR mode.
  129728. */
  129729. get isInVRMode(): boolean;
  129730. private onVrDisplayPresentChange;
  129731. private onVRDisplayChanged;
  129732. private moveButtonToBottomRight;
  129733. private displayVRButton;
  129734. private updateButtonVisibility;
  129735. private _cachedAngularSensibility;
  129736. /**
  129737. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  129738. * Otherwise, will use the fullscreen API.
  129739. */
  129740. enterVR(): void;
  129741. /**
  129742. * Attempt to exit VR, or fullscreen.
  129743. */
  129744. exitVR(): void;
  129745. /**
  129746. * The position of the vr experience helper.
  129747. */
  129748. get position(): Vector3;
  129749. /**
  129750. * Sets the position of the vr experience helper.
  129751. */
  129752. set position(value: Vector3);
  129753. /**
  129754. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  129755. */
  129756. enableInteractions(): void;
  129757. private get _noControllerIsActive();
  129758. private beforeRender;
  129759. private _isTeleportationFloor;
  129760. /**
  129761. * Adds a floor mesh to be used for teleportation.
  129762. * @param floorMesh the mesh to be used for teleportation.
  129763. */
  129764. addFloorMesh(floorMesh: Mesh): void;
  129765. /**
  129766. * Removes a floor mesh from being used for teleportation.
  129767. * @param floorMesh the mesh to be removed.
  129768. */
  129769. removeFloorMesh(floorMesh: Mesh): void;
  129770. /**
  129771. * Enables interactions and teleportation using the VR controllers and gaze.
  129772. * @param vrTeleportationOptions options to modify teleportation behavior.
  129773. */
  129774. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  129775. private _onNewGamepadConnected;
  129776. private _tryEnableInteractionOnController;
  129777. private _onNewGamepadDisconnected;
  129778. private _enableInteractionOnController;
  129779. private _checkTeleportWithRay;
  129780. private _checkRotate;
  129781. private _checkTeleportBackwards;
  129782. private _enableTeleportationOnController;
  129783. private _createTeleportationCircles;
  129784. private _displayTeleportationTarget;
  129785. private _hideTeleportationTarget;
  129786. private _rotateCamera;
  129787. private _moveTeleportationSelectorTo;
  129788. private _workingVector;
  129789. private _workingQuaternion;
  129790. private _workingMatrix;
  129791. /**
  129792. * Time Constant Teleportation Mode
  129793. */
  129794. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  129795. /**
  129796. * Speed Constant Teleportation Mode
  129797. */
  129798. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  129799. /**
  129800. * Teleports the users feet to the desired location
  129801. * @param location The location where the user's feet should be placed
  129802. */
  129803. teleportCamera(location: Vector3): void;
  129804. private _convertNormalToDirectionOfRay;
  129805. private _castRayAndSelectObject;
  129806. private _notifySelectedMeshUnselected;
  129807. /**
  129808. * Permanently set new colors for the laser pointer
  129809. * @param color the new laser color
  129810. * @param pickedColor the new laser color when picked mesh detected
  129811. */
  129812. setLaserColor(color: Color3, pickedColor?: Color3): void;
  129813. /**
  129814. * Set lighting enabled / disabled on the laser pointer of both controllers
  129815. * @param enabled should the lighting be enabled on the laser pointer
  129816. */
  129817. setLaserLightingState(enabled?: boolean): void;
  129818. /**
  129819. * Permanently set new colors for the gaze pointer
  129820. * @param color the new gaze color
  129821. * @param pickedColor the new gaze color when picked mesh detected
  129822. */
  129823. setGazeColor(color: Color3, pickedColor?: Color3): void;
  129824. /**
  129825. * Sets the color of the laser ray from the vr controllers.
  129826. * @param color new color for the ray.
  129827. */
  129828. changeLaserColor(color: Color3): void;
  129829. /**
  129830. * Sets the color of the ray from the vr headsets gaze.
  129831. * @param color new color for the ray.
  129832. */
  129833. changeGazeColor(color: Color3): void;
  129834. /**
  129835. * Exits VR and disposes of the vr experience helper
  129836. */
  129837. dispose(): void;
  129838. /**
  129839. * Gets the name of the VRExperienceHelper class
  129840. * @returns "VRExperienceHelper"
  129841. */
  129842. getClassName(): string;
  129843. }
  129844. }
  129845. declare module BABYLON {
  129846. /**
  129847. * Contains an array of blocks representing the octree
  129848. */
  129849. export interface IOctreeContainer<T> {
  129850. /**
  129851. * Blocks within the octree
  129852. */
  129853. blocks: Array<OctreeBlock<T>>;
  129854. }
  129855. /**
  129856. * Class used to store a cell in an octree
  129857. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129858. */
  129859. export class OctreeBlock<T> {
  129860. /**
  129861. * Gets the content of the current block
  129862. */
  129863. entries: T[];
  129864. /**
  129865. * Gets the list of block children
  129866. */
  129867. blocks: Array<OctreeBlock<T>>;
  129868. private _depth;
  129869. private _maxDepth;
  129870. private _capacity;
  129871. private _minPoint;
  129872. private _maxPoint;
  129873. private _boundingVectors;
  129874. private _creationFunc;
  129875. /**
  129876. * Creates a new block
  129877. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  129878. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  129879. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  129880. * @param depth defines the current depth of this block in the octree
  129881. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  129882. * @param creationFunc defines a callback to call when an element is added to the block
  129883. */
  129884. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  129885. /**
  129886. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  129887. */
  129888. get capacity(): number;
  129889. /**
  129890. * Gets the minimum vector (in world space) of the block's bounding box
  129891. */
  129892. get minPoint(): Vector3;
  129893. /**
  129894. * Gets the maximum vector (in world space) of the block's bounding box
  129895. */
  129896. get maxPoint(): Vector3;
  129897. /**
  129898. * Add a new element to this block
  129899. * @param entry defines the element to add
  129900. */
  129901. addEntry(entry: T): void;
  129902. /**
  129903. * Remove an element from this block
  129904. * @param entry defines the element to remove
  129905. */
  129906. removeEntry(entry: T): void;
  129907. /**
  129908. * Add an array of elements to this block
  129909. * @param entries defines the array of elements to add
  129910. */
  129911. addEntries(entries: T[]): void;
  129912. /**
  129913. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  129914. * @param frustumPlanes defines the frustum planes to test
  129915. * @param selection defines the array to store current content if selection is positive
  129916. * @param allowDuplicate defines if the selection array can contains duplicated entries
  129917. */
  129918. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  129919. /**
  129920. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  129921. * @param sphereCenter defines the bounding sphere center
  129922. * @param sphereRadius defines the bounding sphere radius
  129923. * @param selection defines the array to store current content if selection is positive
  129924. * @param allowDuplicate defines if the selection array can contains duplicated entries
  129925. */
  129926. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  129927. /**
  129928. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  129929. * @param ray defines the ray to test with
  129930. * @param selection defines the array to store current content if selection is positive
  129931. */
  129932. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  129933. /**
  129934. * Subdivide the content into child blocks (this block will then be empty)
  129935. */
  129936. createInnerBlocks(): void;
  129937. /**
  129938. * @hidden
  129939. */
  129940. 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;
  129941. }
  129942. }
  129943. declare module BABYLON {
  129944. /**
  129945. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  129946. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129947. */
  129948. export class Octree<T> {
  129949. /** 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.) */
  129950. maxDepth: number;
  129951. /**
  129952. * Blocks within the octree containing objects
  129953. */
  129954. blocks: Array<OctreeBlock<T>>;
  129955. /**
  129956. * Content stored in the octree
  129957. */
  129958. dynamicContent: T[];
  129959. private _maxBlockCapacity;
  129960. private _selectionContent;
  129961. private _creationFunc;
  129962. /**
  129963. * Creates a octree
  129964. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  129965. * @param creationFunc function to be used to instatiate the octree
  129966. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  129967. * @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.)
  129968. */
  129969. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  129970. /** 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.) */
  129971. maxDepth?: number);
  129972. /**
  129973. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  129974. * @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);
  129975. * @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);
  129976. * @param entries meshes to be added to the octree blocks
  129977. */
  129978. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  129979. /**
  129980. * Adds a mesh to the octree
  129981. * @param entry Mesh to add to the octree
  129982. */
  129983. addMesh(entry: T): void;
  129984. /**
  129985. * Remove an element from the octree
  129986. * @param entry defines the element to remove
  129987. */
  129988. removeMesh(entry: T): void;
  129989. /**
  129990. * Selects an array of meshes within the frustum
  129991. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  129992. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  129993. * @returns array of meshes within the frustum
  129994. */
  129995. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  129996. /**
  129997. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  129998. * @param sphereCenter defines the bounding sphere center
  129999. * @param sphereRadius defines the bounding sphere radius
  130000. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130001. * @returns an array of objects that intersect the sphere
  130002. */
  130003. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  130004. /**
  130005. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  130006. * @param ray defines the ray to test with
  130007. * @returns array of intersected objects
  130008. */
  130009. intersectsRay(ray: Ray): SmartArray<T>;
  130010. /**
  130011. * Adds a mesh into the octree block if it intersects the block
  130012. */
  130013. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  130014. /**
  130015. * Adds a submesh into the octree block if it intersects the block
  130016. */
  130017. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  130018. }
  130019. }
  130020. declare module BABYLON {
  130021. interface Scene {
  130022. /**
  130023. * @hidden
  130024. * Backing Filed
  130025. */
  130026. _selectionOctree: Octree<AbstractMesh>;
  130027. /**
  130028. * Gets the octree used to boost mesh selection (picking)
  130029. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130030. */
  130031. selectionOctree: Octree<AbstractMesh>;
  130032. /**
  130033. * Creates or updates the octree used to boost selection (picking)
  130034. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130035. * @param maxCapacity defines the maximum capacity per leaf
  130036. * @param maxDepth defines the maximum depth of the octree
  130037. * @returns an octree of AbstractMesh
  130038. */
  130039. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  130040. }
  130041. interface AbstractMesh {
  130042. /**
  130043. * @hidden
  130044. * Backing Field
  130045. */
  130046. _submeshesOctree: Octree<SubMesh>;
  130047. /**
  130048. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  130049. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  130050. * @param maxCapacity defines the maximum size of each block (64 by default)
  130051. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  130052. * @returns the new octree
  130053. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  130054. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130055. */
  130056. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  130057. }
  130058. /**
  130059. * Defines the octree scene component responsible to manage any octrees
  130060. * in a given scene.
  130061. */
  130062. export class OctreeSceneComponent {
  130063. /**
  130064. * The component name help to identify the component in the list of scene components.
  130065. */
  130066. readonly name: string;
  130067. /**
  130068. * The scene the component belongs to.
  130069. */
  130070. scene: Scene;
  130071. /**
  130072. * Indicates if the meshes have been checked to make sure they are isEnabled()
  130073. */
  130074. readonly checksIsEnabled: boolean;
  130075. /**
  130076. * Creates a new instance of the component for the given scene
  130077. * @param scene Defines the scene to register the component in
  130078. */
  130079. constructor(scene: Scene);
  130080. /**
  130081. * Registers the component in a given scene
  130082. */
  130083. register(): void;
  130084. /**
  130085. * Return the list of active meshes
  130086. * @returns the list of active meshes
  130087. */
  130088. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  130089. /**
  130090. * Return the list of active sub meshes
  130091. * @param mesh The mesh to get the candidates sub meshes from
  130092. * @returns the list of active sub meshes
  130093. */
  130094. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  130095. private _tempRay;
  130096. /**
  130097. * Return the list of sub meshes intersecting with a given local ray
  130098. * @param mesh defines the mesh to find the submesh for
  130099. * @param localRay defines the ray in local space
  130100. * @returns the list of intersecting sub meshes
  130101. */
  130102. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  130103. /**
  130104. * Return the list of sub meshes colliding with a collider
  130105. * @param mesh defines the mesh to find the submesh for
  130106. * @param collider defines the collider to evaluate the collision against
  130107. * @returns the list of colliding sub meshes
  130108. */
  130109. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  130110. /**
  130111. * Rebuilds the elements related to this component in case of
  130112. * context lost for instance.
  130113. */
  130114. rebuild(): void;
  130115. /**
  130116. * Disposes the component and the associated ressources.
  130117. */
  130118. dispose(): void;
  130119. }
  130120. }
  130121. declare module BABYLON {
  130122. /**
  130123. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  130124. */
  130125. export class Gizmo implements IDisposable {
  130126. /** The utility layer the gizmo will be added to */
  130127. gizmoLayer: UtilityLayerRenderer;
  130128. /**
  130129. * The root mesh of the gizmo
  130130. */
  130131. _rootMesh: Mesh;
  130132. private _attachedMesh;
  130133. private _attachedNode;
  130134. /**
  130135. * Ratio for the scale of the gizmo (Default: 1)
  130136. */
  130137. protected _scaleRatio: number;
  130138. /**
  130139. * Ratio for the scale of the gizmo (Default: 1)
  130140. */
  130141. set scaleRatio(value: number);
  130142. get scaleRatio(): number;
  130143. /**
  130144. * If a custom mesh has been set (Default: false)
  130145. */
  130146. protected _customMeshSet: boolean;
  130147. /**
  130148. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  130149. * * When set, interactions will be enabled
  130150. */
  130151. get attachedMesh(): Nullable<AbstractMesh>;
  130152. set attachedMesh(value: Nullable<AbstractMesh>);
  130153. /**
  130154. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  130155. * * When set, interactions will be enabled
  130156. */
  130157. get attachedNode(): Nullable<Node>;
  130158. set attachedNode(value: Nullable<Node>);
  130159. /**
  130160. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  130161. * @param mesh The mesh to replace the default mesh of the gizmo
  130162. */
  130163. setCustomMesh(mesh: Mesh): void;
  130164. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  130165. /**
  130166. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  130167. */
  130168. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130169. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130170. /**
  130171. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  130172. */
  130173. updateGizmoPositionToMatchAttachedMesh: boolean;
  130174. /**
  130175. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  130176. */
  130177. updateScale: boolean;
  130178. protected _interactionsEnabled: boolean;
  130179. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130180. private _beforeRenderObserver;
  130181. private _tempQuaternion;
  130182. private _tempVector;
  130183. private _tempVector2;
  130184. private _tempMatrix1;
  130185. private _tempMatrix2;
  130186. private _rightHandtoLeftHandMatrix;
  130187. /**
  130188. * Creates a gizmo
  130189. * @param gizmoLayer The utility layer the gizmo will be added to
  130190. */
  130191. constructor(
  130192. /** The utility layer the gizmo will be added to */
  130193. gizmoLayer?: UtilityLayerRenderer);
  130194. /**
  130195. * Updates the gizmo to match the attached mesh's position/rotation
  130196. */
  130197. protected _update(): void;
  130198. /**
  130199. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  130200. * @param value Node, TransformNode or mesh
  130201. */
  130202. protected _matrixChanged(): void;
  130203. /**
  130204. * Disposes of the gizmo
  130205. */
  130206. dispose(): void;
  130207. }
  130208. }
  130209. declare module BABYLON {
  130210. /**
  130211. * Single plane drag gizmo
  130212. */
  130213. export class PlaneDragGizmo extends Gizmo {
  130214. /**
  130215. * Drag behavior responsible for the gizmos dragging interactions
  130216. */
  130217. dragBehavior: PointerDragBehavior;
  130218. private _pointerObserver;
  130219. /**
  130220. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130221. */
  130222. snapDistance: number;
  130223. /**
  130224. * Event that fires each time the gizmo snaps to a new location.
  130225. * * snapDistance is the the change in distance
  130226. */
  130227. onSnapObservable: Observable<{
  130228. snapDistance: number;
  130229. }>;
  130230. private _plane;
  130231. private _coloredMaterial;
  130232. private _hoverMaterial;
  130233. private _isEnabled;
  130234. private _parent;
  130235. /** @hidden */
  130236. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  130237. /** @hidden */
  130238. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  130239. /**
  130240. * Creates a PlaneDragGizmo
  130241. * @param gizmoLayer The utility layer the gizmo will be added to
  130242. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  130243. * @param color The color of the gizmo
  130244. */
  130245. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  130246. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130247. /**
  130248. * If the gizmo is enabled
  130249. */
  130250. set isEnabled(value: boolean);
  130251. get isEnabled(): boolean;
  130252. /**
  130253. * Disposes of the gizmo
  130254. */
  130255. dispose(): void;
  130256. }
  130257. }
  130258. declare module BABYLON {
  130259. /**
  130260. * Gizmo that enables dragging a mesh along 3 axis
  130261. */
  130262. export class PositionGizmo extends Gizmo {
  130263. /**
  130264. * Internal gizmo used for interactions on the x axis
  130265. */
  130266. xGizmo: AxisDragGizmo;
  130267. /**
  130268. * Internal gizmo used for interactions on the y axis
  130269. */
  130270. yGizmo: AxisDragGizmo;
  130271. /**
  130272. * Internal gizmo used for interactions on the z axis
  130273. */
  130274. zGizmo: AxisDragGizmo;
  130275. /**
  130276. * Internal gizmo used for interactions on the yz plane
  130277. */
  130278. xPlaneGizmo: PlaneDragGizmo;
  130279. /**
  130280. * Internal gizmo used for interactions on the xz plane
  130281. */
  130282. yPlaneGizmo: PlaneDragGizmo;
  130283. /**
  130284. * Internal gizmo used for interactions on the xy plane
  130285. */
  130286. zPlaneGizmo: PlaneDragGizmo;
  130287. /**
  130288. * private variables
  130289. */
  130290. private _meshAttached;
  130291. private _nodeAttached;
  130292. private _snapDistance;
  130293. /** Fires an event when any of it's sub gizmos are dragged */
  130294. onDragStartObservable: Observable<unknown>;
  130295. /** Fires an event when any of it's sub gizmos are released from dragging */
  130296. onDragEndObservable: Observable<unknown>;
  130297. /**
  130298. * If set to true, planar drag is enabled
  130299. */
  130300. private _planarGizmoEnabled;
  130301. get attachedMesh(): Nullable<AbstractMesh>;
  130302. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130303. get attachedNode(): Nullable<Node>;
  130304. set attachedNode(node: Nullable<Node>);
  130305. /**
  130306. * Creates a PositionGizmo
  130307. * @param gizmoLayer The utility layer the gizmo will be added to
  130308. @param thickness display gizmo axis thickness
  130309. */
  130310. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  130311. /**
  130312. * If the planar drag gizmo is enabled
  130313. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  130314. */
  130315. set planarGizmoEnabled(value: boolean);
  130316. get planarGizmoEnabled(): boolean;
  130317. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130318. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130319. /**
  130320. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130321. */
  130322. set snapDistance(value: number);
  130323. get snapDistance(): number;
  130324. /**
  130325. * Ratio for the scale of the gizmo (Default: 1)
  130326. */
  130327. set scaleRatio(value: number);
  130328. get scaleRatio(): number;
  130329. /**
  130330. * Disposes of the gizmo
  130331. */
  130332. dispose(): void;
  130333. /**
  130334. * CustomMeshes are not supported by this gizmo
  130335. * @param mesh The mesh to replace the default mesh of the gizmo
  130336. */
  130337. setCustomMesh(mesh: Mesh): void;
  130338. }
  130339. }
  130340. declare module BABYLON {
  130341. /**
  130342. * Single axis drag gizmo
  130343. */
  130344. export class AxisDragGizmo extends Gizmo {
  130345. /**
  130346. * Drag behavior responsible for the gizmos dragging interactions
  130347. */
  130348. dragBehavior: PointerDragBehavior;
  130349. private _pointerObserver;
  130350. /**
  130351. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130352. */
  130353. snapDistance: number;
  130354. /**
  130355. * Event that fires each time the gizmo snaps to a new location.
  130356. * * snapDistance is the the change in distance
  130357. */
  130358. onSnapObservable: Observable<{
  130359. snapDistance: number;
  130360. }>;
  130361. private _isEnabled;
  130362. private _parent;
  130363. private _arrow;
  130364. private _coloredMaterial;
  130365. private _hoverMaterial;
  130366. /** @hidden */
  130367. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  130368. /** @hidden */
  130369. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  130370. /**
  130371. * Creates an AxisDragGizmo
  130372. * @param gizmoLayer The utility layer the gizmo will be added to
  130373. * @param dragAxis The axis which the gizmo will be able to drag on
  130374. * @param color The color of the gizmo
  130375. * @param thickness display gizmo axis thickness
  130376. */
  130377. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  130378. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130379. /**
  130380. * If the gizmo is enabled
  130381. */
  130382. set isEnabled(value: boolean);
  130383. get isEnabled(): boolean;
  130384. /**
  130385. * Disposes of the gizmo
  130386. */
  130387. dispose(): void;
  130388. }
  130389. }
  130390. declare module BABYLON.Debug {
  130391. /**
  130392. * The Axes viewer will show 3 axes in a specific point in space
  130393. */
  130394. export class AxesViewer {
  130395. private _xAxis;
  130396. private _yAxis;
  130397. private _zAxis;
  130398. private _scaleLinesFactor;
  130399. private _instanced;
  130400. /**
  130401. * Gets the hosting scene
  130402. */
  130403. scene: Nullable<Scene>;
  130404. /**
  130405. * Gets or sets a number used to scale line length
  130406. */
  130407. scaleLines: number;
  130408. /** Gets the node hierarchy used to render x-axis */
  130409. get xAxis(): TransformNode;
  130410. /** Gets the node hierarchy used to render y-axis */
  130411. get yAxis(): TransformNode;
  130412. /** Gets the node hierarchy used to render z-axis */
  130413. get zAxis(): TransformNode;
  130414. /**
  130415. * Creates a new AxesViewer
  130416. * @param scene defines the hosting scene
  130417. * @param scaleLines defines a number used to scale line length (1 by default)
  130418. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  130419. * @param xAxis defines the node hierarchy used to render the x-axis
  130420. * @param yAxis defines the node hierarchy used to render the y-axis
  130421. * @param zAxis defines the node hierarchy used to render the z-axis
  130422. */
  130423. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  130424. /**
  130425. * Force the viewer to update
  130426. * @param position defines the position of the viewer
  130427. * @param xaxis defines the x axis of the viewer
  130428. * @param yaxis defines the y axis of the viewer
  130429. * @param zaxis defines the z axis of the viewer
  130430. */
  130431. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  130432. /**
  130433. * Creates an instance of this axes viewer.
  130434. * @returns a new axes viewer with instanced meshes
  130435. */
  130436. createInstance(): AxesViewer;
  130437. /** Releases resources */
  130438. dispose(): void;
  130439. private static _SetRenderingGroupId;
  130440. }
  130441. }
  130442. declare module BABYLON.Debug {
  130443. /**
  130444. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  130445. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  130446. */
  130447. export class BoneAxesViewer extends AxesViewer {
  130448. /**
  130449. * Gets or sets the target mesh where to display the axes viewer
  130450. */
  130451. mesh: Nullable<Mesh>;
  130452. /**
  130453. * Gets or sets the target bone where to display the axes viewer
  130454. */
  130455. bone: Nullable<Bone>;
  130456. /** Gets current position */
  130457. pos: Vector3;
  130458. /** Gets direction of X axis */
  130459. xaxis: Vector3;
  130460. /** Gets direction of Y axis */
  130461. yaxis: Vector3;
  130462. /** Gets direction of Z axis */
  130463. zaxis: Vector3;
  130464. /**
  130465. * Creates a new BoneAxesViewer
  130466. * @param scene defines the hosting scene
  130467. * @param bone defines the target bone
  130468. * @param mesh defines the target mesh
  130469. * @param scaleLines defines a scaling factor for line length (1 by default)
  130470. */
  130471. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  130472. /**
  130473. * Force the viewer to update
  130474. */
  130475. update(): void;
  130476. /** Releases resources */
  130477. dispose(): void;
  130478. }
  130479. }
  130480. declare module BABYLON {
  130481. /**
  130482. * Interface used to define scene explorer extensibility option
  130483. */
  130484. export interface IExplorerExtensibilityOption {
  130485. /**
  130486. * Define the option label
  130487. */
  130488. label: string;
  130489. /**
  130490. * Defines the action to execute on click
  130491. */
  130492. action: (entity: any) => void;
  130493. }
  130494. /**
  130495. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  130496. */
  130497. export interface IExplorerExtensibilityGroup {
  130498. /**
  130499. * Defines a predicate to test if a given type mut be extended
  130500. */
  130501. predicate: (entity: any) => boolean;
  130502. /**
  130503. * Gets the list of options added to a type
  130504. */
  130505. entries: IExplorerExtensibilityOption[];
  130506. }
  130507. /**
  130508. * Interface used to define the options to use to create the Inspector
  130509. */
  130510. export interface IInspectorOptions {
  130511. /**
  130512. * Display in overlay mode (default: false)
  130513. */
  130514. overlay?: boolean;
  130515. /**
  130516. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  130517. */
  130518. globalRoot?: HTMLElement;
  130519. /**
  130520. * Display the Scene explorer
  130521. */
  130522. showExplorer?: boolean;
  130523. /**
  130524. * Display the property inspector
  130525. */
  130526. showInspector?: boolean;
  130527. /**
  130528. * Display in embed mode (both panes on the right)
  130529. */
  130530. embedMode?: boolean;
  130531. /**
  130532. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  130533. */
  130534. handleResize?: boolean;
  130535. /**
  130536. * Allow the panes to popup (default: true)
  130537. */
  130538. enablePopup?: boolean;
  130539. /**
  130540. * Allow the panes to be closed by users (default: true)
  130541. */
  130542. enableClose?: boolean;
  130543. /**
  130544. * Optional list of extensibility entries
  130545. */
  130546. explorerExtensibility?: IExplorerExtensibilityGroup[];
  130547. /**
  130548. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  130549. */
  130550. inspectorURL?: string;
  130551. /**
  130552. * Optional initial tab (default to DebugLayerTab.Properties)
  130553. */
  130554. initialTab?: DebugLayerTab;
  130555. }
  130556. interface Scene {
  130557. /**
  130558. * @hidden
  130559. * Backing field
  130560. */
  130561. _debugLayer: DebugLayer;
  130562. /**
  130563. * Gets the debug layer (aka Inspector) associated with the scene
  130564. * @see https://doc.babylonjs.com/features/playground_debuglayer
  130565. */
  130566. debugLayer: DebugLayer;
  130567. }
  130568. /**
  130569. * Enum of inspector action tab
  130570. */
  130571. export enum DebugLayerTab {
  130572. /**
  130573. * Properties tag (default)
  130574. */
  130575. Properties = 0,
  130576. /**
  130577. * Debug tab
  130578. */
  130579. Debug = 1,
  130580. /**
  130581. * Statistics tab
  130582. */
  130583. Statistics = 2,
  130584. /**
  130585. * Tools tab
  130586. */
  130587. Tools = 3,
  130588. /**
  130589. * Settings tab
  130590. */
  130591. Settings = 4
  130592. }
  130593. /**
  130594. * The debug layer (aka Inspector) is the go to tool in order to better understand
  130595. * what is happening in your scene
  130596. * @see https://doc.babylonjs.com/features/playground_debuglayer
  130597. */
  130598. export class DebugLayer {
  130599. /**
  130600. * Define the url to get the inspector script from.
  130601. * By default it uses the babylonjs CDN.
  130602. * @ignoreNaming
  130603. */
  130604. static InspectorURL: string;
  130605. private _scene;
  130606. private BJSINSPECTOR;
  130607. private _onPropertyChangedObservable?;
  130608. /**
  130609. * Observable triggered when a property is changed through the inspector.
  130610. */
  130611. get onPropertyChangedObservable(): any;
  130612. /**
  130613. * Instantiates a new debug layer.
  130614. * The debug layer (aka Inspector) is the go to tool in order to better understand
  130615. * what is happening in your scene
  130616. * @see https://doc.babylonjs.com/features/playground_debuglayer
  130617. * @param scene Defines the scene to inspect
  130618. */
  130619. constructor(scene: Scene);
  130620. /** Creates the inspector window. */
  130621. private _createInspector;
  130622. /**
  130623. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  130624. * @param entity defines the entity to select
  130625. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  130626. */
  130627. select(entity: any, lineContainerTitles?: string | string[]): void;
  130628. /** Get the inspector from bundle or global */
  130629. private _getGlobalInspector;
  130630. /**
  130631. * Get if the inspector is visible or not.
  130632. * @returns true if visible otherwise, false
  130633. */
  130634. isVisible(): boolean;
  130635. /**
  130636. * Hide the inspector and close its window.
  130637. */
  130638. hide(): void;
  130639. /**
  130640. * Update the scene in the inspector
  130641. */
  130642. setAsActiveScene(): void;
  130643. /**
  130644. * Launch the debugLayer.
  130645. * @param config Define the configuration of the inspector
  130646. * @return a promise fulfilled when the debug layer is visible
  130647. */
  130648. show(config?: IInspectorOptions): Promise<DebugLayer>;
  130649. }
  130650. }
  130651. declare module BABYLON {
  130652. /**
  130653. * Class containing static functions to help procedurally build meshes
  130654. */
  130655. export class BoxBuilder {
  130656. /**
  130657. * Creates a box mesh
  130658. * * The parameter `size` sets the size (float) of each box side (default 1)
  130659. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  130660. * * 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)
  130661. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  130662. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130663. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130665. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  130666. * @param name defines the name of the mesh
  130667. * @param options defines the options used to create the mesh
  130668. * @param scene defines the hosting scene
  130669. * @returns the box mesh
  130670. */
  130671. static CreateBox(name: string, options: {
  130672. size?: number;
  130673. width?: number;
  130674. height?: number;
  130675. depth?: number;
  130676. faceUV?: Vector4[];
  130677. faceColors?: Color4[];
  130678. sideOrientation?: number;
  130679. frontUVs?: Vector4;
  130680. backUVs?: Vector4;
  130681. wrap?: boolean;
  130682. topBaseAt?: number;
  130683. bottomBaseAt?: number;
  130684. updatable?: boolean;
  130685. }, scene?: Nullable<Scene>): Mesh;
  130686. }
  130687. }
  130688. declare module BABYLON.Debug {
  130689. /**
  130690. * Used to show the physics impostor around the specific mesh
  130691. */
  130692. export class PhysicsViewer {
  130693. /** @hidden */
  130694. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  130695. /** @hidden */
  130696. protected _meshes: Array<Nullable<AbstractMesh>>;
  130697. /** @hidden */
  130698. protected _scene: Nullable<Scene>;
  130699. /** @hidden */
  130700. protected _numMeshes: number;
  130701. /** @hidden */
  130702. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  130703. private _renderFunction;
  130704. private _utilityLayer;
  130705. private _debugBoxMesh;
  130706. private _debugSphereMesh;
  130707. private _debugCylinderMesh;
  130708. private _debugMaterial;
  130709. private _debugMeshMeshes;
  130710. /**
  130711. * Creates a new PhysicsViewer
  130712. * @param scene defines the hosting scene
  130713. */
  130714. constructor(scene: Scene);
  130715. /** @hidden */
  130716. protected _updateDebugMeshes(): void;
  130717. /**
  130718. * Renders a specified physic impostor
  130719. * @param impostor defines the impostor to render
  130720. * @param targetMesh defines the mesh represented by the impostor
  130721. * @returns the new debug mesh used to render the impostor
  130722. */
  130723. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  130724. /**
  130725. * Hides a specified physic impostor
  130726. * @param impostor defines the impostor to hide
  130727. */
  130728. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  130729. private _getDebugMaterial;
  130730. private _getDebugBoxMesh;
  130731. private _getDebugSphereMesh;
  130732. private _getDebugCylinderMesh;
  130733. private _getDebugMeshMesh;
  130734. private _getDebugMesh;
  130735. /** Releases all resources */
  130736. dispose(): void;
  130737. }
  130738. }
  130739. declare module BABYLON {
  130740. /**
  130741. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  130742. * in order to better appreciate the issue one might have.
  130743. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  130744. */
  130745. export class RayHelper {
  130746. /**
  130747. * Defines the ray we are currently tryin to visualize.
  130748. */
  130749. ray: Nullable<Ray>;
  130750. private _renderPoints;
  130751. private _renderLine;
  130752. private _renderFunction;
  130753. private _scene;
  130754. private _onAfterRenderObserver;
  130755. private _onAfterStepObserver;
  130756. private _attachedToMesh;
  130757. private _meshSpaceDirection;
  130758. private _meshSpaceOrigin;
  130759. /**
  130760. * Helper function to create a colored helper in a scene in one line.
  130761. * @param ray Defines the ray we are currently tryin to visualize
  130762. * @param scene Defines the scene the ray is used in
  130763. * @param color Defines the color we want to see the ray in
  130764. * @returns The newly created ray helper.
  130765. */
  130766. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  130767. /**
  130768. * Instantiate a new ray helper.
  130769. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  130770. * in order to better appreciate the issue one might have.
  130771. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  130772. * @param ray Defines the ray we are currently tryin to visualize
  130773. */
  130774. constructor(ray: Ray);
  130775. /**
  130776. * Shows the ray we are willing to debug.
  130777. * @param scene Defines the scene the ray needs to be rendered in
  130778. * @param color Defines the color the ray needs to be rendered in
  130779. */
  130780. show(scene: Scene, color?: Color3): void;
  130781. /**
  130782. * Hides the ray we are debugging.
  130783. */
  130784. hide(): void;
  130785. private _render;
  130786. /**
  130787. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  130788. * @param mesh Defines the mesh we want the helper attached to
  130789. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  130790. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  130791. * @param length Defines the length of the ray
  130792. */
  130793. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  130794. /**
  130795. * Detach the ray helper from the mesh it has previously been attached to.
  130796. */
  130797. detachFromMesh(): void;
  130798. private _updateToMesh;
  130799. /**
  130800. * Dispose the helper and release its associated resources.
  130801. */
  130802. dispose(): void;
  130803. }
  130804. }
  130805. declare module BABYLON {
  130806. /**
  130807. * Defines the options associated with the creation of a SkeletonViewer.
  130808. */
  130809. export interface ISkeletonViewerOptions {
  130810. /** Should the system pause animations before building the Viewer? */
  130811. pauseAnimations: boolean;
  130812. /** Should the system return the skeleton to rest before building? */
  130813. returnToRest: boolean;
  130814. /** public Display Mode of the Viewer */
  130815. displayMode: number;
  130816. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  130817. displayOptions: ISkeletonViewerDisplayOptions;
  130818. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  130819. computeBonesUsingShaders: boolean;
  130820. /** Flag ignore non weighted bones */
  130821. useAllBones: boolean;
  130822. }
  130823. /**
  130824. * Defines how to display the various bone meshes for the viewer.
  130825. */
  130826. export interface ISkeletonViewerDisplayOptions {
  130827. /** How far down to start tapering the bone spurs */
  130828. midStep?: number;
  130829. /** How big is the midStep? */
  130830. midStepFactor?: number;
  130831. /** Base for the Sphere Size */
  130832. sphereBaseSize?: number;
  130833. /** The ratio of the sphere to the longest bone in units */
  130834. sphereScaleUnit?: number;
  130835. /** Ratio for the Sphere Size */
  130836. sphereFactor?: number;
  130837. }
  130838. /**
  130839. * Defines the constructor options for the BoneWeight Shader.
  130840. */
  130841. export interface IBoneWeightShaderOptions {
  130842. /** Skeleton to Map */
  130843. skeleton: Skeleton;
  130844. /** Colors for Uninfluenced bones */
  130845. colorBase?: Color3;
  130846. /** Colors for 0.0-0.25 Weight bones */
  130847. colorZero?: Color3;
  130848. /** Color for 0.25-0.5 Weight Influence */
  130849. colorQuarter?: Color3;
  130850. /** Color for 0.5-0.75 Weight Influence */
  130851. colorHalf?: Color3;
  130852. /** Color for 0.75-1 Weight Influence */
  130853. colorFull?: Color3;
  130854. /** Color for Zero Weight Influence */
  130855. targetBoneIndex?: number;
  130856. }
  130857. /**
  130858. * Simple structure of the gradient steps for the Color Map.
  130859. */
  130860. export interface ISkeletonMapShaderColorMapKnot {
  130861. /** Color of the Knot */
  130862. color: Color3;
  130863. /** Location of the Knot */
  130864. location: number;
  130865. }
  130866. /**
  130867. * Defines the constructor options for the SkeletonMap Shader.
  130868. */
  130869. export interface ISkeletonMapShaderOptions {
  130870. /** Skeleton to Map */
  130871. skeleton: Skeleton;
  130872. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  130873. colorMap?: ISkeletonMapShaderColorMapKnot[];
  130874. }
  130875. }
  130876. declare module BABYLON {
  130877. /**
  130878. * Class containing static functions to help procedurally build meshes
  130879. */
  130880. export class RibbonBuilder {
  130881. /**
  130882. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  130883. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  130884. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  130885. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  130886. * * 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
  130887. * * 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
  130888. * * 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
  130889. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130890. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130891. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130892. * * 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
  130893. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  130894. * * 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
  130895. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  130896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130897. * @param name defines the name of the mesh
  130898. * @param options defines the options used to create the mesh
  130899. * @param scene defines the hosting scene
  130900. * @returns the ribbon mesh
  130901. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  130902. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130903. */
  130904. static CreateRibbon(name: string, options: {
  130905. pathArray: Vector3[][];
  130906. closeArray?: boolean;
  130907. closePath?: boolean;
  130908. offset?: number;
  130909. updatable?: boolean;
  130910. sideOrientation?: number;
  130911. frontUVs?: Vector4;
  130912. backUVs?: Vector4;
  130913. instance?: Mesh;
  130914. invertUV?: boolean;
  130915. uvs?: Vector2[];
  130916. colors?: Color4[];
  130917. }, scene?: Nullable<Scene>): Mesh;
  130918. }
  130919. }
  130920. declare module BABYLON {
  130921. /**
  130922. * Class containing static functions to help procedurally build meshes
  130923. */
  130924. export class ShapeBuilder {
  130925. /**
  130926. * 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.
  130927. * * 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.
  130928. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130929. * * 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.
  130930. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  130931. * * 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
  130932. * * 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
  130933. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  130934. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130935. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130936. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  130937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130938. * @param name defines the name of the mesh
  130939. * @param options defines the options used to create the mesh
  130940. * @param scene defines the hosting scene
  130941. * @returns the extruded shape mesh
  130942. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130943. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130944. */
  130945. static ExtrudeShape(name: string, options: {
  130946. shape: Vector3[];
  130947. path: Vector3[];
  130948. scale?: number;
  130949. rotation?: number;
  130950. cap?: number;
  130951. updatable?: boolean;
  130952. sideOrientation?: number;
  130953. frontUVs?: Vector4;
  130954. backUVs?: Vector4;
  130955. instance?: Mesh;
  130956. invertUV?: boolean;
  130957. }, scene?: Nullable<Scene>): Mesh;
  130958. /**
  130959. * Creates an custom extruded shape mesh.
  130960. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  130961. * * 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.
  130962. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  130963. * * 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
  130964. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  130965. * * 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
  130966. * * It must returns a float value that will be the scale value applied to the shape on each path point
  130967. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  130968. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  130969. * * 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
  130970. * * 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
  130971. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  130972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130973. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130974. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  130975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130976. * @param name defines the name of the mesh
  130977. * @param options defines the options used to create the mesh
  130978. * @param scene defines the hosting scene
  130979. * @returns the custom extruded shape mesh
  130980. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  130981. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  130982. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  130983. */
  130984. static ExtrudeShapeCustom(name: string, options: {
  130985. shape: Vector3[];
  130986. path: Vector3[];
  130987. scaleFunction?: any;
  130988. rotationFunction?: any;
  130989. ribbonCloseArray?: boolean;
  130990. ribbonClosePath?: boolean;
  130991. cap?: number;
  130992. updatable?: boolean;
  130993. sideOrientation?: number;
  130994. frontUVs?: Vector4;
  130995. backUVs?: Vector4;
  130996. instance?: Mesh;
  130997. invertUV?: boolean;
  130998. }, scene?: Nullable<Scene>): Mesh;
  130999. private static _ExtrudeShapeGeneric;
  131000. }
  131001. }
  131002. declare module BABYLON.Debug {
  131003. /**
  131004. * Class used to render a debug view of a given skeleton
  131005. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  131006. */
  131007. export class SkeletonViewer {
  131008. /** defines the skeleton to render */
  131009. skeleton: Skeleton;
  131010. /** defines the mesh attached to the skeleton */
  131011. mesh: AbstractMesh;
  131012. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  131013. autoUpdateBonesMatrices: boolean;
  131014. /** defines the rendering group id to use with the viewer */
  131015. renderingGroupId: number;
  131016. /** is the options for the viewer */
  131017. options: Partial<ISkeletonViewerOptions>;
  131018. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  131019. static readonly DISPLAY_LINES: number;
  131020. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  131021. static readonly DISPLAY_SPHERES: number;
  131022. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  131023. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  131024. /** public static method to create a BoneWeight Shader
  131025. * @param options The constructor options
  131026. * @param scene The scene that the shader is scoped to
  131027. * @returns The created ShaderMaterial
  131028. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  131029. */
  131030. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  131031. /** public static method to create a BoneWeight Shader
  131032. * @param options The constructor options
  131033. * @param scene The scene that the shader is scoped to
  131034. * @returns The created ShaderMaterial
  131035. */
  131036. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  131037. /** private static method to create a BoneWeight Shader
  131038. * @param size The size of the buffer to create (usually the bone count)
  131039. * @param colorMap The gradient data to generate
  131040. * @param scene The scene that the shader is scoped to
  131041. * @returns an Array of floats from the color gradient values
  131042. */
  131043. private static _CreateBoneMapColorBuffer;
  131044. /** If SkeletonViewer scene scope. */
  131045. private _scene;
  131046. /** Gets or sets the color used to render the skeleton */
  131047. color: Color3;
  131048. /** Array of the points of the skeleton fo the line view. */
  131049. private _debugLines;
  131050. /** The SkeletonViewers Mesh. */
  131051. private _debugMesh;
  131052. /** If SkeletonViewer is enabled. */
  131053. private _isEnabled;
  131054. /** If SkeletonViewer is ready. */
  131055. private _ready;
  131056. /** SkeletonViewer render observable. */
  131057. private _obs;
  131058. /** The Utility Layer to render the gizmos in. */
  131059. private _utilityLayer;
  131060. private _boneIndices;
  131061. /** Gets the Scene. */
  131062. get scene(): Scene;
  131063. /** Gets the utilityLayer. */
  131064. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  131065. /** Checks Ready Status. */
  131066. get isReady(): Boolean;
  131067. /** Sets Ready Status. */
  131068. set ready(value: boolean);
  131069. /** Gets the debugMesh */
  131070. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  131071. /** Sets the debugMesh */
  131072. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  131073. /** Gets the displayMode */
  131074. get displayMode(): number;
  131075. /** Sets the displayMode */
  131076. set displayMode(value: number);
  131077. /**
  131078. * Creates a new SkeletonViewer
  131079. * @param skeleton defines the skeleton to render
  131080. * @param mesh defines the mesh attached to the skeleton
  131081. * @param scene defines the hosting scene
  131082. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  131083. * @param renderingGroupId defines the rendering group id to use with the viewer
  131084. * @param options All of the extra constructor options for the SkeletonViewer
  131085. */
  131086. constructor(
  131087. /** defines the skeleton to render */
  131088. skeleton: Skeleton,
  131089. /** defines the mesh attached to the skeleton */
  131090. mesh: AbstractMesh,
  131091. /** The Scene scope*/
  131092. scene: Scene,
  131093. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  131094. autoUpdateBonesMatrices?: boolean,
  131095. /** defines the rendering group id to use with the viewer */
  131096. renderingGroupId?: number,
  131097. /** is the options for the viewer */
  131098. options?: Partial<ISkeletonViewerOptions>);
  131099. /** The Dynamic bindings for the update functions */
  131100. private _bindObs;
  131101. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  131102. update(): void;
  131103. /** Gets or sets a boolean indicating if the viewer is enabled */
  131104. set isEnabled(value: boolean);
  131105. get isEnabled(): boolean;
  131106. private _getBonePosition;
  131107. private _getLinesForBonesWithLength;
  131108. private _getLinesForBonesNoLength;
  131109. /** function to revert the mesh and scene back to the initial state. */
  131110. private _revert;
  131111. /** function to build and bind sphere joint points and spur bone representations. */
  131112. private _buildSpheresAndSpurs;
  131113. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  131114. private _displayLinesUpdate;
  131115. /** Changes the displayMode of the skeleton viewer
  131116. * @param mode The displayMode numerical value
  131117. */
  131118. changeDisplayMode(mode: number): void;
  131119. /** Changes the displayMode of the skeleton viewer
  131120. * @param option String of the option name
  131121. * @param value The numerical option value
  131122. */
  131123. changeDisplayOptions(option: string, value: number): void;
  131124. /** Release associated resources */
  131125. dispose(): void;
  131126. }
  131127. }
  131128. declare module BABYLON {
  131129. /**
  131130. * Enum for Device Types
  131131. */
  131132. export enum DeviceType {
  131133. /** Generic */
  131134. Generic = 0,
  131135. /** Keyboard */
  131136. Keyboard = 1,
  131137. /** Mouse */
  131138. Mouse = 2,
  131139. /** Touch Pointers */
  131140. Touch = 3,
  131141. /** PS4 Dual Shock */
  131142. DualShock = 4,
  131143. /** Xbox */
  131144. Xbox = 5,
  131145. /** Switch Controller */
  131146. Switch = 6
  131147. }
  131148. /**
  131149. * Enum for All Pointers (Touch/Mouse)
  131150. */
  131151. export enum PointerInput {
  131152. /** Horizontal Axis */
  131153. Horizontal = 0,
  131154. /** Vertical Axis */
  131155. Vertical = 1,
  131156. /** Left Click or Touch */
  131157. LeftClick = 2,
  131158. /** Middle Click */
  131159. MiddleClick = 3,
  131160. /** Right Click */
  131161. RightClick = 4,
  131162. /** Browser Back */
  131163. BrowserBack = 5,
  131164. /** Browser Forward */
  131165. BrowserForward = 6
  131166. }
  131167. /**
  131168. * Enum for Dual Shock Gamepad
  131169. */
  131170. export enum DualShockInput {
  131171. /** Cross */
  131172. Cross = 0,
  131173. /** Circle */
  131174. Circle = 1,
  131175. /** Square */
  131176. Square = 2,
  131177. /** Triangle */
  131178. Triangle = 3,
  131179. /** L1 */
  131180. L1 = 4,
  131181. /** R1 */
  131182. R1 = 5,
  131183. /** L2 */
  131184. L2 = 6,
  131185. /** R2 */
  131186. R2 = 7,
  131187. /** Share */
  131188. Share = 8,
  131189. /** Options */
  131190. Options = 9,
  131191. /** L3 */
  131192. L3 = 10,
  131193. /** R3 */
  131194. R3 = 11,
  131195. /** DPadUp */
  131196. DPadUp = 12,
  131197. /** DPadDown */
  131198. DPadDown = 13,
  131199. /** DPadLeft */
  131200. DPadLeft = 14,
  131201. /** DRight */
  131202. DPadRight = 15,
  131203. /** Home */
  131204. Home = 16,
  131205. /** TouchPad */
  131206. TouchPad = 17,
  131207. /** LStickXAxis */
  131208. LStickXAxis = 18,
  131209. /** LStickYAxis */
  131210. LStickYAxis = 19,
  131211. /** RStickXAxis */
  131212. RStickXAxis = 20,
  131213. /** RStickYAxis */
  131214. RStickYAxis = 21
  131215. }
  131216. /**
  131217. * Enum for Xbox Gamepad
  131218. */
  131219. export enum XboxInput {
  131220. /** A */
  131221. A = 0,
  131222. /** B */
  131223. B = 1,
  131224. /** X */
  131225. X = 2,
  131226. /** Y */
  131227. Y = 3,
  131228. /** LB */
  131229. LB = 4,
  131230. /** RB */
  131231. RB = 5,
  131232. /** LT */
  131233. LT = 6,
  131234. /** RT */
  131235. RT = 7,
  131236. /** Back */
  131237. Back = 8,
  131238. /** Start */
  131239. Start = 9,
  131240. /** LS */
  131241. LS = 10,
  131242. /** RS */
  131243. RS = 11,
  131244. /** DPadUp */
  131245. DPadUp = 12,
  131246. /** DPadDown */
  131247. DPadDown = 13,
  131248. /** DPadLeft */
  131249. DPadLeft = 14,
  131250. /** DRight */
  131251. DPadRight = 15,
  131252. /** Home */
  131253. Home = 16,
  131254. /** LStickXAxis */
  131255. LStickXAxis = 17,
  131256. /** LStickYAxis */
  131257. LStickYAxis = 18,
  131258. /** RStickXAxis */
  131259. RStickXAxis = 19,
  131260. /** RStickYAxis */
  131261. RStickYAxis = 20
  131262. }
  131263. /**
  131264. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  131265. */
  131266. export enum SwitchInput {
  131267. /** B */
  131268. B = 0,
  131269. /** A */
  131270. A = 1,
  131271. /** Y */
  131272. Y = 2,
  131273. /** X */
  131274. X = 3,
  131275. /** L */
  131276. L = 4,
  131277. /** R */
  131278. R = 5,
  131279. /** ZL */
  131280. ZL = 6,
  131281. /** ZR */
  131282. ZR = 7,
  131283. /** Minus */
  131284. Minus = 8,
  131285. /** Plus */
  131286. Plus = 9,
  131287. /** LS */
  131288. LS = 10,
  131289. /** RS */
  131290. RS = 11,
  131291. /** DPadUp */
  131292. DPadUp = 12,
  131293. /** DPadDown */
  131294. DPadDown = 13,
  131295. /** DPadLeft */
  131296. DPadLeft = 14,
  131297. /** DRight */
  131298. DPadRight = 15,
  131299. /** Home */
  131300. Home = 16,
  131301. /** Capture */
  131302. Capture = 17,
  131303. /** LStickXAxis */
  131304. LStickXAxis = 18,
  131305. /** LStickYAxis */
  131306. LStickYAxis = 19,
  131307. /** RStickXAxis */
  131308. RStickXAxis = 20,
  131309. /** RStickYAxis */
  131310. RStickYAxis = 21
  131311. }
  131312. }
  131313. declare module BABYLON {
  131314. /**
  131315. * This class will take all inputs from Keyboard, Pointer, and
  131316. * any Gamepads and provide a polling system that all devices
  131317. * will use. This class assumes that there will only be one
  131318. * pointer device and one keyboard.
  131319. */
  131320. export class DeviceInputSystem implements IDisposable {
  131321. /**
  131322. * Callback to be triggered when a device is connected
  131323. */
  131324. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  131325. /**
  131326. * Callback to be triggered when a device is disconnected
  131327. */
  131328. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  131329. /**
  131330. * Callback to be triggered when event driven input is updated
  131331. */
  131332. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  131333. private _inputs;
  131334. private _gamepads;
  131335. private _keyboardActive;
  131336. private _pointerActive;
  131337. private _elementToAttachTo;
  131338. private _keyboardDownEvent;
  131339. private _keyboardUpEvent;
  131340. private _pointerMoveEvent;
  131341. private _pointerDownEvent;
  131342. private _pointerUpEvent;
  131343. private _gamepadConnectedEvent;
  131344. private _gamepadDisconnectedEvent;
  131345. private static _MAX_KEYCODES;
  131346. private static _MAX_POINTER_INPUTS;
  131347. private constructor();
  131348. /**
  131349. * Creates a new DeviceInputSystem instance
  131350. * @param engine Engine to pull input element from
  131351. * @returns The new instance
  131352. */
  131353. static Create(engine: Engine): DeviceInputSystem;
  131354. /**
  131355. * Checks for current device input value, given an id and input index
  131356. * @param deviceName Id of connected device
  131357. * @param inputIndex Index of device input
  131358. * @returns Current value of input
  131359. */
  131360. /**
  131361. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  131362. * @param deviceType Enum specifiying device type
  131363. * @param deviceSlot "Slot" or index that device is referenced in
  131364. * @param inputIndex Id of input to be checked
  131365. * @returns Current value of input
  131366. */
  131367. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  131368. /**
  131369. * Dispose of all the eventlisteners
  131370. */
  131371. dispose(): void;
  131372. /**
  131373. * Add device and inputs to device array
  131374. * @param deviceType Enum specifiying device type
  131375. * @param deviceSlot "Slot" or index that device is referenced in
  131376. * @param numberOfInputs Number of input entries to create for given device
  131377. */
  131378. private _registerDevice;
  131379. /**
  131380. * Given a specific device name, remove that device from the device map
  131381. * @param deviceType Enum specifiying device type
  131382. * @param deviceSlot "Slot" or index that device is referenced in
  131383. */
  131384. private _unregisterDevice;
  131385. /**
  131386. * Handle all actions that come from keyboard interaction
  131387. */
  131388. private _handleKeyActions;
  131389. /**
  131390. * Handle all actions that come from pointer interaction
  131391. */
  131392. private _handlePointerActions;
  131393. /**
  131394. * Handle all actions that come from gamepad interaction
  131395. */
  131396. private _handleGamepadActions;
  131397. /**
  131398. * Update all non-event based devices with each frame
  131399. * @param deviceType Enum specifiying device type
  131400. * @param deviceSlot "Slot" or index that device is referenced in
  131401. * @param inputIndex Id of input to be checked
  131402. */
  131403. private _updateDevice;
  131404. /**
  131405. * Gets DeviceType from the device name
  131406. * @param deviceName Name of Device from DeviceInputSystem
  131407. * @returns DeviceType enum value
  131408. */
  131409. private _getGamepadDeviceType;
  131410. }
  131411. }
  131412. declare module BABYLON {
  131413. /**
  131414. * Type to handle enforcement of inputs
  131415. */
  131416. 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;
  131417. }
  131418. declare module BABYLON {
  131419. /**
  131420. * Class that handles all input for a specific device
  131421. */
  131422. export class DeviceSource<T extends DeviceType> {
  131423. /** Type of device */
  131424. readonly deviceType: DeviceType;
  131425. /** "Slot" or index that device is referenced in */
  131426. readonly deviceSlot: number;
  131427. /**
  131428. * Observable to handle device input changes per device
  131429. */
  131430. readonly onInputChangedObservable: Observable<{
  131431. inputIndex: DeviceInput<T>;
  131432. previousState: Nullable<number>;
  131433. currentState: Nullable<number>;
  131434. }>;
  131435. private readonly _deviceInputSystem;
  131436. /**
  131437. * Default Constructor
  131438. * @param deviceInputSystem Reference to DeviceInputSystem
  131439. * @param deviceType Type of device
  131440. * @param deviceSlot "Slot" or index that device is referenced in
  131441. */
  131442. constructor(deviceInputSystem: DeviceInputSystem,
  131443. /** Type of device */
  131444. deviceType: DeviceType,
  131445. /** "Slot" or index that device is referenced in */
  131446. deviceSlot?: number);
  131447. /**
  131448. * Get input for specific input
  131449. * @param inputIndex index of specific input on device
  131450. * @returns Input value from DeviceInputSystem
  131451. */
  131452. getInput(inputIndex: DeviceInput<T>): number;
  131453. }
  131454. /**
  131455. * Class to keep track of devices
  131456. */
  131457. export class DeviceSourceManager implements IDisposable {
  131458. /**
  131459. * Observable to be triggered when before a device is connected
  131460. */
  131461. readonly onBeforeDeviceConnectedObservable: Observable<{
  131462. deviceType: DeviceType;
  131463. deviceSlot: number;
  131464. }>;
  131465. /**
  131466. * Observable to be triggered when before a device is disconnected
  131467. */
  131468. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  131469. deviceType: DeviceType;
  131470. deviceSlot: number;
  131471. }>;
  131472. /**
  131473. * Observable to be triggered when after a device is connected
  131474. */
  131475. readonly onAfterDeviceConnectedObservable: Observable<{
  131476. deviceType: DeviceType;
  131477. deviceSlot: number;
  131478. }>;
  131479. /**
  131480. * Observable to be triggered when after a device is disconnected
  131481. */
  131482. readonly onAfterDeviceDisconnectedObservable: Observable<{
  131483. deviceType: DeviceType;
  131484. deviceSlot: number;
  131485. }>;
  131486. private readonly _devices;
  131487. private readonly _firstDevice;
  131488. private readonly _deviceInputSystem;
  131489. /**
  131490. * Default Constructor
  131491. * @param engine engine to pull input element from
  131492. */
  131493. constructor(engine: Engine);
  131494. /**
  131495. * Gets a DeviceSource, given a type and slot
  131496. * @param deviceType Enum specifying device type
  131497. * @param deviceSlot "Slot" or index that device is referenced in
  131498. * @returns DeviceSource object
  131499. */
  131500. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  131501. /**
  131502. * Gets an array of DeviceSource objects for a given device type
  131503. * @param deviceType Enum specifying device type
  131504. * @returns Array of DeviceSource objects
  131505. */
  131506. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  131507. /**
  131508. * Dispose of DeviceInputSystem and other parts
  131509. */
  131510. dispose(): void;
  131511. /**
  131512. * Function to add device name to device list
  131513. * @param deviceType Enum specifying device type
  131514. * @param deviceSlot "Slot" or index that device is referenced in
  131515. */
  131516. private _addDevice;
  131517. /**
  131518. * Function to remove device name to device list
  131519. * @param deviceType Enum specifying device type
  131520. * @param deviceSlot "Slot" or index that device is referenced in
  131521. */
  131522. private _removeDevice;
  131523. /**
  131524. * Updates array storing first connected device of each type
  131525. * @param type Type of Device
  131526. */
  131527. private _updateFirstDevices;
  131528. }
  131529. }
  131530. declare module BABYLON {
  131531. /**
  131532. * Options to create the null engine
  131533. */
  131534. export class NullEngineOptions {
  131535. /**
  131536. * Render width (Default: 512)
  131537. */
  131538. renderWidth: number;
  131539. /**
  131540. * Render height (Default: 256)
  131541. */
  131542. renderHeight: number;
  131543. /**
  131544. * Texture size (Default: 512)
  131545. */
  131546. textureSize: number;
  131547. /**
  131548. * If delta time between frames should be constant
  131549. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131550. */
  131551. deterministicLockstep: boolean;
  131552. /**
  131553. * Maximum about of steps between frames (Default: 4)
  131554. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131555. */
  131556. lockstepMaxSteps: number;
  131557. /**
  131558. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  131559. */
  131560. useHighPrecisionMatrix?: boolean;
  131561. }
  131562. /**
  131563. * The null engine class provides support for headless version of babylon.js.
  131564. * This can be used in server side scenario or for testing purposes
  131565. */
  131566. export class NullEngine extends Engine {
  131567. private _options;
  131568. /**
  131569. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  131570. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131571. * @returns true if engine is in deterministic lock step mode
  131572. */
  131573. isDeterministicLockStep(): boolean;
  131574. /**
  131575. * Gets the max steps when engine is running in deterministic lock step
  131576. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  131577. * @returns the max steps
  131578. */
  131579. getLockstepMaxSteps(): number;
  131580. /**
  131581. * Gets the current hardware scaling level.
  131582. * By default the hardware scaling level is computed from the window device ratio.
  131583. * 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.
  131584. * @returns a number indicating the current hardware scaling level
  131585. */
  131586. getHardwareScalingLevel(): number;
  131587. constructor(options?: NullEngineOptions);
  131588. /**
  131589. * Creates a vertex buffer
  131590. * @param vertices the data for the vertex buffer
  131591. * @returns the new WebGL static buffer
  131592. */
  131593. createVertexBuffer(vertices: FloatArray): DataBuffer;
  131594. /**
  131595. * Creates a new index buffer
  131596. * @param indices defines the content of the index buffer
  131597. * @param updatable defines if the index buffer must be updatable
  131598. * @returns a new webGL buffer
  131599. */
  131600. createIndexBuffer(indices: IndicesArray): DataBuffer;
  131601. /**
  131602. * Clear the current render buffer or the current render target (if any is set up)
  131603. * @param color defines the color to use
  131604. * @param backBuffer defines if the back buffer must be cleared
  131605. * @param depth defines if the depth buffer must be cleared
  131606. * @param stencil defines if the stencil buffer must be cleared
  131607. */
  131608. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  131609. /**
  131610. * Gets the current render width
  131611. * @param useScreen defines if screen size must be used (or the current render target if any)
  131612. * @returns a number defining the current render width
  131613. */
  131614. getRenderWidth(useScreen?: boolean): number;
  131615. /**
  131616. * Gets the current render height
  131617. * @param useScreen defines if screen size must be used (or the current render target if any)
  131618. * @returns a number defining the current render height
  131619. */
  131620. getRenderHeight(useScreen?: boolean): number;
  131621. /**
  131622. * Set the WebGL's viewport
  131623. * @param viewport defines the viewport element to be used
  131624. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  131625. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  131626. */
  131627. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  131628. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  131629. /**
  131630. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  131631. * @param pipelineContext defines the pipeline context to use
  131632. * @param uniformsNames defines the list of uniform names
  131633. * @returns an array of webGL uniform locations
  131634. */
  131635. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  131636. /**
  131637. * Gets the lsit of active attributes for a given webGL program
  131638. * @param pipelineContext defines the pipeline context to use
  131639. * @param attributesNames defines the list of attribute names to get
  131640. * @returns an array of indices indicating the offset of each attribute
  131641. */
  131642. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  131643. /**
  131644. * Binds an effect to the webGL context
  131645. * @param effect defines the effect to bind
  131646. */
  131647. bindSamplers(effect: Effect): void;
  131648. /**
  131649. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  131650. * @param effect defines the effect to activate
  131651. */
  131652. enableEffect(effect: Effect): void;
  131653. /**
  131654. * Set various states to the webGL context
  131655. * @param culling defines backface culling state
  131656. * @param zOffset defines the value to apply to zOffset (0 by default)
  131657. * @param force defines if states must be applied even if cache is up to date
  131658. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  131659. */
  131660. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  131661. /**
  131662. * Set the value of an uniform to an array of int32
  131663. * @param uniform defines the webGL uniform location where to store the value
  131664. * @param array defines the array of int32 to store
  131665. */
  131666. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  131667. /**
  131668. * Set the value of an uniform to an array of int32 (stored as vec2)
  131669. * @param uniform defines the webGL uniform location where to store the value
  131670. * @param array defines the array of int32 to store
  131671. */
  131672. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  131673. /**
  131674. * Set the value of an uniform to an array of int32 (stored as vec3)
  131675. * @param uniform defines the webGL uniform location where to store the value
  131676. * @param array defines the array of int32 to store
  131677. */
  131678. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  131679. /**
  131680. * Set the value of an uniform to an array of int32 (stored as vec4)
  131681. * @param uniform defines the webGL uniform location where to store the value
  131682. * @param array defines the array of int32 to store
  131683. */
  131684. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  131685. /**
  131686. * Set the value of an uniform to an array of float32
  131687. * @param uniform defines the webGL uniform location where to store the value
  131688. * @param array defines the array of float32 to store
  131689. */
  131690. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  131691. /**
  131692. * Set the value of an uniform to an array of float32 (stored as vec2)
  131693. * @param uniform defines the webGL uniform location where to store the value
  131694. * @param array defines the array of float32 to store
  131695. */
  131696. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  131697. /**
  131698. * Set the value of an uniform to an array of float32 (stored as vec3)
  131699. * @param uniform defines the webGL uniform location where to store the value
  131700. * @param array defines the array of float32 to store
  131701. */
  131702. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  131703. /**
  131704. * Set the value of an uniform to an array of float32 (stored as vec4)
  131705. * @param uniform defines the webGL uniform location where to store the value
  131706. * @param array defines the array of float32 to store
  131707. */
  131708. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  131709. /**
  131710. * Set the value of an uniform to an array of number
  131711. * @param uniform defines the webGL uniform location where to store the value
  131712. * @param array defines the array of number to store
  131713. */
  131714. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  131715. /**
  131716. * Set the value of an uniform to an array of number (stored as vec2)
  131717. * @param uniform defines the webGL uniform location where to store the value
  131718. * @param array defines the array of number to store
  131719. */
  131720. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  131721. /**
  131722. * Set the value of an uniform to an array of number (stored as vec3)
  131723. * @param uniform defines the webGL uniform location where to store the value
  131724. * @param array defines the array of number to store
  131725. */
  131726. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  131727. /**
  131728. * Set the value of an uniform to an array of number (stored as vec4)
  131729. * @param uniform defines the webGL uniform location where to store the value
  131730. * @param array defines the array of number to store
  131731. */
  131732. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  131733. /**
  131734. * Set the value of an uniform to an array of float32 (stored as matrices)
  131735. * @param uniform defines the webGL uniform location where to store the value
  131736. * @param matrices defines the array of float32 to store
  131737. */
  131738. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  131739. /**
  131740. * Set the value of an uniform to a matrix (3x3)
  131741. * @param uniform defines the webGL uniform location where to store the value
  131742. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  131743. */
  131744. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131745. /**
  131746. * Set the value of an uniform to a matrix (2x2)
  131747. * @param uniform defines the webGL uniform location where to store the value
  131748. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  131749. */
  131750. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  131751. /**
  131752. * Set the value of an uniform to a number (float)
  131753. * @param uniform defines the webGL uniform location where to store the value
  131754. * @param value defines the float number to store
  131755. */
  131756. setFloat(uniform: WebGLUniformLocation, value: number): void;
  131757. /**
  131758. * Set the value of an uniform to a vec2
  131759. * @param uniform defines the webGL uniform location where to store the value
  131760. * @param x defines the 1st component of the value
  131761. * @param y defines the 2nd component of the value
  131762. */
  131763. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  131764. /**
  131765. * Set the value of an uniform to a vec3
  131766. * @param uniform defines the webGL uniform location where to store the value
  131767. * @param x defines the 1st component of the value
  131768. * @param y defines the 2nd component of the value
  131769. * @param z defines the 3rd component of the value
  131770. */
  131771. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  131772. /**
  131773. * Set the value of an uniform to a boolean
  131774. * @param uniform defines the webGL uniform location where to store the value
  131775. * @param bool defines the boolean to store
  131776. */
  131777. setBool(uniform: WebGLUniformLocation, bool: number): void;
  131778. /**
  131779. * Set the value of an uniform to a vec4
  131780. * @param uniform defines the webGL uniform location where to store the value
  131781. * @param x defines the 1st component of the value
  131782. * @param y defines the 2nd component of the value
  131783. * @param z defines the 3rd component of the value
  131784. * @param w defines the 4th component of the value
  131785. */
  131786. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  131787. /**
  131788. * Sets the current alpha mode
  131789. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  131790. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  131791. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  131792. */
  131793. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  131794. /**
  131795. * Bind webGl buffers directly to the webGL context
  131796. * @param vertexBuffers defines the vertex buffer to bind
  131797. * @param indexBuffer defines the index buffer to bind
  131798. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  131799. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  131800. * @param effect defines the effect associated with the vertex buffer
  131801. */
  131802. bindBuffers(vertexBuffers: {
  131803. [key: string]: VertexBuffer;
  131804. }, indexBuffer: DataBuffer, effect: Effect): void;
  131805. /**
  131806. * Force the entire cache to be cleared
  131807. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  131808. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  131809. */
  131810. wipeCaches(bruteForce?: boolean): void;
  131811. /**
  131812. * Send a draw order
  131813. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  131814. * @param indexStart defines the starting index
  131815. * @param indexCount defines the number of index to draw
  131816. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131817. */
  131818. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  131819. /**
  131820. * Draw a list of indexed primitives
  131821. * @param fillMode defines the primitive to use
  131822. * @param indexStart defines the starting index
  131823. * @param indexCount defines the number of index to draw
  131824. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131825. */
  131826. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  131827. /**
  131828. * Draw a list of unindexed primitives
  131829. * @param fillMode defines the primitive to use
  131830. * @param verticesStart defines the index of first vertex to draw
  131831. * @param verticesCount defines the count of vertices to draw
  131832. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  131833. */
  131834. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  131835. /** @hidden */
  131836. _createTexture(): WebGLTexture;
  131837. /** @hidden */
  131838. _releaseTexture(texture: InternalTexture): void;
  131839. /**
  131840. * Usually called from Texture.ts.
  131841. * Passed information to create a WebGLTexture
  131842. * @param urlArg defines a value which contains one of the following:
  131843. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  131844. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  131845. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  131846. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  131847. * @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)
  131848. * @param scene needed for loading to the correct scene
  131849. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  131850. * @param onLoad optional callback to be called upon successful completion
  131851. * @param onError optional callback to be called upon failure
  131852. * @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
  131853. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  131854. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  131855. * @param forcedExtension defines the extension to use to pick the right loader
  131856. * @param mimeType defines an optional mime type
  131857. * @returns a InternalTexture for assignment back into BABYLON.Texture
  131858. */
  131859. 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;
  131860. /**
  131861. * Creates a new render target texture
  131862. * @param size defines the size of the texture
  131863. * @param options defines the options used to create the texture
  131864. * @returns a new render target texture stored in an InternalTexture
  131865. */
  131866. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  131867. /**
  131868. * Update the sampling mode of a given texture
  131869. * @param samplingMode defines the required sampling mode
  131870. * @param texture defines the texture to update
  131871. */
  131872. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  131873. /**
  131874. * Binds the frame buffer to the specified texture.
  131875. * @param texture The texture to render to or null for the default canvas
  131876. * @param faceIndex The face of the texture to render to in case of cube texture
  131877. * @param requiredWidth The width of the target to render to
  131878. * @param requiredHeight The height of the target to render to
  131879. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  131880. * @param lodLevel defines le lod level to bind to the frame buffer
  131881. */
  131882. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  131883. /**
  131884. * Unbind the current render target texture from the webGL context
  131885. * @param texture defines the render target texture to unbind
  131886. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  131887. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  131888. */
  131889. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  131890. /**
  131891. * Creates a dynamic vertex buffer
  131892. * @param vertices the data for the dynamic vertex buffer
  131893. * @returns the new WebGL dynamic buffer
  131894. */
  131895. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  131896. /**
  131897. * Update the content of a dynamic texture
  131898. * @param texture defines the texture to update
  131899. * @param canvas defines the canvas containing the source
  131900. * @param invertY defines if data must be stored with Y axis inverted
  131901. * @param premulAlpha defines if alpha is stored as premultiplied
  131902. * @param format defines the format of the data
  131903. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  131904. */
  131905. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  131906. /**
  131907. * Gets a boolean indicating if all created effects are ready
  131908. * @returns true if all effects are ready
  131909. */
  131910. areAllEffectsReady(): boolean;
  131911. /**
  131912. * @hidden
  131913. * Get the current error code of the webGL context
  131914. * @returns the error code
  131915. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  131916. */
  131917. getError(): number;
  131918. /** @hidden */
  131919. _getUnpackAlignement(): number;
  131920. /** @hidden */
  131921. _unpackFlipY(value: boolean): void;
  131922. /**
  131923. * Update a dynamic index buffer
  131924. * @param indexBuffer defines the target index buffer
  131925. * @param indices defines the data to update
  131926. * @param offset defines the offset in the target index buffer where update should start
  131927. */
  131928. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  131929. /**
  131930. * Updates a dynamic vertex buffer.
  131931. * @param vertexBuffer the vertex buffer to update
  131932. * @param vertices the data used to update the vertex buffer
  131933. * @param byteOffset the byte offset of the data (optional)
  131934. * @param byteLength the byte length of the data (optional)
  131935. */
  131936. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  131937. /** @hidden */
  131938. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  131939. /** @hidden */
  131940. _bindTexture(channel: number, texture: InternalTexture): void;
  131941. protected _deleteBuffer(buffer: WebGLBuffer): void;
  131942. /**
  131943. * 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
  131944. */
  131945. releaseEffects(): void;
  131946. displayLoadingUI(): void;
  131947. hideLoadingUI(): void;
  131948. /** @hidden */
  131949. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131950. /** @hidden */
  131951. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131952. /** @hidden */
  131953. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  131954. /** @hidden */
  131955. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  131956. }
  131957. }
  131958. declare module BABYLON {
  131959. /**
  131960. * @hidden
  131961. **/
  131962. export class _TimeToken {
  131963. _startTimeQuery: Nullable<WebGLQuery>;
  131964. _endTimeQuery: Nullable<WebGLQuery>;
  131965. _timeElapsedQuery: Nullable<WebGLQuery>;
  131966. _timeElapsedQueryEnded: boolean;
  131967. }
  131968. }
  131969. declare module BABYLON {
  131970. /** @hidden */
  131971. export class _OcclusionDataStorage {
  131972. /** @hidden */
  131973. occlusionInternalRetryCounter: number;
  131974. /** @hidden */
  131975. isOcclusionQueryInProgress: boolean;
  131976. /** @hidden */
  131977. isOccluded: boolean;
  131978. /** @hidden */
  131979. occlusionRetryCount: number;
  131980. /** @hidden */
  131981. occlusionType: number;
  131982. /** @hidden */
  131983. occlusionQueryAlgorithmType: number;
  131984. }
  131985. interface Engine {
  131986. /**
  131987. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  131988. * @return the new query
  131989. */
  131990. createQuery(): WebGLQuery;
  131991. /**
  131992. * Delete and release a webGL query
  131993. * @param query defines the query to delete
  131994. * @return the current engine
  131995. */
  131996. deleteQuery(query: WebGLQuery): Engine;
  131997. /**
  131998. * Check if a given query has resolved and got its value
  131999. * @param query defines the query to check
  132000. * @returns true if the query got its value
  132001. */
  132002. isQueryResultAvailable(query: WebGLQuery): boolean;
  132003. /**
  132004. * Gets the value of a given query
  132005. * @param query defines the query to check
  132006. * @returns the value of the query
  132007. */
  132008. getQueryResult(query: WebGLQuery): number;
  132009. /**
  132010. * Initiates an occlusion query
  132011. * @param algorithmType defines the algorithm to use
  132012. * @param query defines the query to use
  132013. * @returns the current engine
  132014. * @see https://doc.babylonjs.com/features/occlusionquery
  132015. */
  132016. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  132017. /**
  132018. * Ends an occlusion query
  132019. * @see https://doc.babylonjs.com/features/occlusionquery
  132020. * @param algorithmType defines the algorithm to use
  132021. * @returns the current engine
  132022. */
  132023. endOcclusionQuery(algorithmType: number): Engine;
  132024. /**
  132025. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  132026. * Please note that only one query can be issued at a time
  132027. * @returns a time token used to track the time span
  132028. */
  132029. startTimeQuery(): Nullable<_TimeToken>;
  132030. /**
  132031. * Ends a time query
  132032. * @param token defines the token used to measure the time span
  132033. * @returns the time spent (in ns)
  132034. */
  132035. endTimeQuery(token: _TimeToken): int;
  132036. /** @hidden */
  132037. _currentNonTimestampToken: Nullable<_TimeToken>;
  132038. /** @hidden */
  132039. _createTimeQuery(): WebGLQuery;
  132040. /** @hidden */
  132041. _deleteTimeQuery(query: WebGLQuery): void;
  132042. /** @hidden */
  132043. _getGlAlgorithmType(algorithmType: number): number;
  132044. /** @hidden */
  132045. _getTimeQueryResult(query: WebGLQuery): any;
  132046. /** @hidden */
  132047. _getTimeQueryAvailability(query: WebGLQuery): any;
  132048. }
  132049. interface AbstractMesh {
  132050. /**
  132051. * Backing filed
  132052. * @hidden
  132053. */
  132054. __occlusionDataStorage: _OcclusionDataStorage;
  132055. /**
  132056. * Access property
  132057. * @hidden
  132058. */
  132059. _occlusionDataStorage: _OcclusionDataStorage;
  132060. /**
  132061. * 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.
  132062. * The default value is -1 which means don't break the query and wait till the result
  132063. * @see https://doc.babylonjs.com/features/occlusionquery
  132064. */
  132065. occlusionRetryCount: number;
  132066. /**
  132067. * 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:
  132068. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  132069. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  132070. * * 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.
  132071. * @see https://doc.babylonjs.com/features/occlusionquery
  132072. */
  132073. occlusionType: number;
  132074. /**
  132075. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  132076. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  132077. * * 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.
  132078. * @see https://doc.babylonjs.com/features/occlusionquery
  132079. */
  132080. occlusionQueryAlgorithmType: number;
  132081. /**
  132082. * 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
  132083. * @see https://doc.babylonjs.com/features/occlusionquery
  132084. */
  132085. isOccluded: boolean;
  132086. /**
  132087. * Flag to check the progress status of the query
  132088. * @see https://doc.babylonjs.com/features/occlusionquery
  132089. */
  132090. isOcclusionQueryInProgress: boolean;
  132091. }
  132092. }
  132093. declare module BABYLON {
  132094. /** @hidden */
  132095. export var _forceTransformFeedbackToBundle: boolean;
  132096. interface Engine {
  132097. /**
  132098. * Creates a webGL transform feedback object
  132099. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  132100. * @returns the webGL transform feedback object
  132101. */
  132102. createTransformFeedback(): WebGLTransformFeedback;
  132103. /**
  132104. * Delete a webGL transform feedback object
  132105. * @param value defines the webGL transform feedback object to delete
  132106. */
  132107. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  132108. /**
  132109. * Bind a webGL transform feedback object to the webgl context
  132110. * @param value defines the webGL transform feedback object to bind
  132111. */
  132112. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  132113. /**
  132114. * Begins a transform feedback operation
  132115. * @param usePoints defines if points or triangles must be used
  132116. */
  132117. beginTransformFeedback(usePoints: boolean): void;
  132118. /**
  132119. * Ends a transform feedback operation
  132120. */
  132121. endTransformFeedback(): void;
  132122. /**
  132123. * Specify the varyings to use with transform feedback
  132124. * @param program defines the associated webGL program
  132125. * @param value defines the list of strings representing the varying names
  132126. */
  132127. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  132128. /**
  132129. * Bind a webGL buffer for a transform feedback operation
  132130. * @param value defines the webGL buffer to bind
  132131. */
  132132. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  132133. }
  132134. }
  132135. declare module BABYLON {
  132136. /**
  132137. * Class used to define an additional view for the engine
  132138. * @see https://doc.babylonjs.com/how_to/multi_canvases
  132139. */
  132140. export class EngineView {
  132141. /** Defines the canvas where to render the view */
  132142. target: HTMLCanvasElement;
  132143. /** Defines an optional camera used to render the view (will use active camera else) */
  132144. camera?: Camera;
  132145. }
  132146. interface Engine {
  132147. /**
  132148. * Gets or sets the HTML element to use for attaching events
  132149. */
  132150. inputElement: Nullable<HTMLElement>;
  132151. /**
  132152. * Gets the current engine view
  132153. * @see https://doc.babylonjs.com/how_to/multi_canvases
  132154. */
  132155. activeView: Nullable<EngineView>;
  132156. /** Gets or sets the list of views */
  132157. views: EngineView[];
  132158. /**
  132159. * Register a new child canvas
  132160. * @param canvas defines the canvas to register
  132161. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  132162. * @returns the associated view
  132163. */
  132164. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  132165. /**
  132166. * Remove a registered child canvas
  132167. * @param canvas defines the canvas to remove
  132168. * @returns the current engine
  132169. */
  132170. unRegisterView(canvas: HTMLCanvasElement): Engine;
  132171. }
  132172. }
  132173. declare module BABYLON {
  132174. interface Engine {
  132175. /** @hidden */
  132176. _excludedCompressedTextures: string[];
  132177. /** @hidden */
  132178. _textureFormatInUse: string;
  132179. /**
  132180. * Gets the list of texture formats supported
  132181. */
  132182. readonly texturesSupported: Array<string>;
  132183. /**
  132184. * Gets the texture format in use
  132185. */
  132186. readonly textureFormatInUse: Nullable<string>;
  132187. /**
  132188. * Set the compressed texture extensions or file names to skip.
  132189. *
  132190. * @param skippedFiles defines the list of those texture files you want to skip
  132191. * Example: [".dds", ".env", "myfile.png"]
  132192. */
  132193. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  132194. /**
  132195. * Set the compressed texture format to use, based on the formats you have, and the formats
  132196. * supported by the hardware / browser.
  132197. *
  132198. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  132199. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  132200. * to API arguments needed to compressed textures. This puts the burden on the container
  132201. * generator to house the arcane code for determining these for current & future formats.
  132202. *
  132203. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  132204. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  132205. *
  132206. * Note: The result of this call is not taken into account when a texture is base64.
  132207. *
  132208. * @param formatsAvailable defines the list of those format families you have created
  132209. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  132210. *
  132211. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  132212. * @returns The extension selected.
  132213. */
  132214. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  132215. }
  132216. }
  132217. declare module BABYLON {
  132218. /**
  132219. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  132220. */
  132221. export interface CubeMapInfo {
  132222. /**
  132223. * The pixel array for the front face.
  132224. * This is stored in format, left to right, up to down format.
  132225. */
  132226. front: Nullable<ArrayBufferView>;
  132227. /**
  132228. * The pixel array for the back face.
  132229. * This is stored in format, left to right, up to down format.
  132230. */
  132231. back: Nullable<ArrayBufferView>;
  132232. /**
  132233. * The pixel array for the left face.
  132234. * This is stored in format, left to right, up to down format.
  132235. */
  132236. left: Nullable<ArrayBufferView>;
  132237. /**
  132238. * The pixel array for the right face.
  132239. * This is stored in format, left to right, up to down format.
  132240. */
  132241. right: Nullable<ArrayBufferView>;
  132242. /**
  132243. * The pixel array for the up face.
  132244. * This is stored in format, left to right, up to down format.
  132245. */
  132246. up: Nullable<ArrayBufferView>;
  132247. /**
  132248. * The pixel array for the down face.
  132249. * This is stored in format, left to right, up to down format.
  132250. */
  132251. down: Nullable<ArrayBufferView>;
  132252. /**
  132253. * The size of the cubemap stored.
  132254. *
  132255. * Each faces will be size * size pixels.
  132256. */
  132257. size: number;
  132258. /**
  132259. * The format of the texture.
  132260. *
  132261. * RGBA, RGB.
  132262. */
  132263. format: number;
  132264. /**
  132265. * The type of the texture data.
  132266. *
  132267. * UNSIGNED_INT, FLOAT.
  132268. */
  132269. type: number;
  132270. /**
  132271. * Specifies whether the texture is in gamma space.
  132272. */
  132273. gammaSpace: boolean;
  132274. }
  132275. /**
  132276. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  132277. */
  132278. export class PanoramaToCubeMapTools {
  132279. private static FACE_LEFT;
  132280. private static FACE_RIGHT;
  132281. private static FACE_FRONT;
  132282. private static FACE_BACK;
  132283. private static FACE_DOWN;
  132284. private static FACE_UP;
  132285. /**
  132286. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  132287. *
  132288. * @param float32Array The source data.
  132289. * @param inputWidth The width of the input panorama.
  132290. * @param inputHeight The height of the input panorama.
  132291. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  132292. * @return The cubemap data
  132293. */
  132294. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  132295. private static CreateCubemapTexture;
  132296. private static CalcProjectionSpherical;
  132297. }
  132298. }
  132299. declare module BABYLON {
  132300. /**
  132301. * Helper class dealing with the extraction of spherical polynomial dataArray
  132302. * from a cube map.
  132303. */
  132304. export class CubeMapToSphericalPolynomialTools {
  132305. private static FileFaces;
  132306. /**
  132307. * Converts a texture to the according Spherical Polynomial data.
  132308. * This extracts the first 3 orders only as they are the only one used in the lighting.
  132309. *
  132310. * @param texture The texture to extract the information from.
  132311. * @return The Spherical Polynomial data.
  132312. */
  132313. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  132314. /**
  132315. * Converts a cubemap to the according Spherical Polynomial data.
  132316. * This extracts the first 3 orders only as they are the only one used in the lighting.
  132317. *
  132318. * @param cubeInfo The Cube map to extract the information from.
  132319. * @return The Spherical Polynomial data.
  132320. */
  132321. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  132322. }
  132323. }
  132324. declare module BABYLON {
  132325. interface BaseTexture {
  132326. /**
  132327. * Get the polynomial representation of the texture data.
  132328. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  132329. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  132330. */
  132331. sphericalPolynomial: Nullable<SphericalPolynomial>;
  132332. }
  132333. }
  132334. declare module BABYLON {
  132335. /** @hidden */
  132336. export var rgbdEncodePixelShader: {
  132337. name: string;
  132338. shader: string;
  132339. };
  132340. }
  132341. declare module BABYLON {
  132342. /** @hidden */
  132343. export var rgbdDecodePixelShader: {
  132344. name: string;
  132345. shader: string;
  132346. };
  132347. }
  132348. declare module BABYLON {
  132349. /**
  132350. * Raw texture data and descriptor sufficient for WebGL texture upload
  132351. */
  132352. export interface EnvironmentTextureInfo {
  132353. /**
  132354. * Version of the environment map
  132355. */
  132356. version: number;
  132357. /**
  132358. * Width of image
  132359. */
  132360. width: number;
  132361. /**
  132362. * Irradiance information stored in the file.
  132363. */
  132364. irradiance: any;
  132365. /**
  132366. * Specular information stored in the file.
  132367. */
  132368. specular: any;
  132369. }
  132370. /**
  132371. * Defines One Image in the file. It requires only the position in the file
  132372. * as well as the length.
  132373. */
  132374. interface BufferImageData {
  132375. /**
  132376. * Length of the image data.
  132377. */
  132378. length: number;
  132379. /**
  132380. * Position of the data from the null terminator delimiting the end of the JSON.
  132381. */
  132382. position: number;
  132383. }
  132384. /**
  132385. * Defines the specular data enclosed in the file.
  132386. * This corresponds to the version 1 of the data.
  132387. */
  132388. export interface EnvironmentTextureSpecularInfoV1 {
  132389. /**
  132390. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  132391. */
  132392. specularDataPosition?: number;
  132393. /**
  132394. * This contains all the images data needed to reconstruct the cubemap.
  132395. */
  132396. mipmaps: Array<BufferImageData>;
  132397. /**
  132398. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  132399. */
  132400. lodGenerationScale: number;
  132401. }
  132402. /**
  132403. * Sets of helpers addressing the serialization and deserialization of environment texture
  132404. * stored in a BabylonJS env file.
  132405. * Those files are usually stored as .env files.
  132406. */
  132407. export class EnvironmentTextureTools {
  132408. /**
  132409. * Magic number identifying the env file.
  132410. */
  132411. private static _MagicBytes;
  132412. /**
  132413. * Gets the environment info from an env file.
  132414. * @param data The array buffer containing the .env bytes.
  132415. * @returns the environment file info (the json header) if successfully parsed.
  132416. */
  132417. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  132418. /**
  132419. * Creates an environment texture from a loaded cube texture.
  132420. * @param texture defines the cube texture to convert in env file
  132421. * @return a promise containing the environment data if succesfull.
  132422. */
  132423. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  132424. /**
  132425. * Creates a JSON representation of the spherical data.
  132426. * @param texture defines the texture containing the polynomials
  132427. * @return the JSON representation of the spherical info
  132428. */
  132429. private static _CreateEnvTextureIrradiance;
  132430. /**
  132431. * Creates the ArrayBufferViews used for initializing environment texture image data.
  132432. * @param data the image data
  132433. * @param info parameters that determine what views will be created for accessing the underlying buffer
  132434. * @return the views described by info providing access to the underlying buffer
  132435. */
  132436. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  132437. /**
  132438. * Uploads the texture info contained in the env file to the GPU.
  132439. * @param texture defines the internal texture to upload to
  132440. * @param data defines the data to load
  132441. * @param info defines the texture info retrieved through the GetEnvInfo method
  132442. * @returns a promise
  132443. */
  132444. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  132445. private static _OnImageReadyAsync;
  132446. /**
  132447. * Uploads the levels of image data to the GPU.
  132448. * @param texture defines the internal texture to upload to
  132449. * @param imageData defines the array buffer views of image data [mipmap][face]
  132450. * @returns a promise
  132451. */
  132452. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  132453. /**
  132454. * Uploads spherical polynomials information to the texture.
  132455. * @param texture defines the texture we are trying to upload the information to
  132456. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  132457. */
  132458. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  132459. /** @hidden */
  132460. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  132461. }
  132462. }
  132463. declare module BABYLON {
  132464. /**
  132465. * Class used to inline functions in shader code
  132466. */
  132467. export class ShaderCodeInliner {
  132468. private static readonly _RegexpFindFunctionNameAndType;
  132469. private _sourceCode;
  132470. private _functionDescr;
  132471. private _numMaxIterations;
  132472. /** Gets or sets the token used to mark the functions to inline */
  132473. inlineToken: string;
  132474. /** Gets or sets the debug mode */
  132475. debug: boolean;
  132476. /** Gets the code after the inlining process */
  132477. get code(): string;
  132478. /**
  132479. * Initializes the inliner
  132480. * @param sourceCode shader code source to inline
  132481. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  132482. */
  132483. constructor(sourceCode: string, numMaxIterations?: number);
  132484. /**
  132485. * Start the processing of the shader code
  132486. */
  132487. processCode(): void;
  132488. private _collectFunctions;
  132489. private _processInlining;
  132490. private _extractBetweenMarkers;
  132491. private _skipWhitespaces;
  132492. private _removeComments;
  132493. private _replaceFunctionCallsByCode;
  132494. private _findBackward;
  132495. private _escapeRegExp;
  132496. private _replaceNames;
  132497. }
  132498. }
  132499. declare module BABYLON {
  132500. /**
  132501. * Container for accessors for natively-stored mesh data buffers.
  132502. */
  132503. class NativeDataBuffer extends DataBuffer {
  132504. /**
  132505. * Accessor value used to identify/retrieve a natively-stored index buffer.
  132506. */
  132507. nativeIndexBuffer?: any;
  132508. /**
  132509. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  132510. */
  132511. nativeVertexBuffer?: any;
  132512. }
  132513. /** @hidden */
  132514. class NativeTexture extends InternalTexture {
  132515. getInternalTexture(): InternalTexture;
  132516. getViewCount(): number;
  132517. }
  132518. /** @hidden */
  132519. export class NativeEngine extends Engine {
  132520. private readonly _native;
  132521. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  132522. private readonly INVALID_HANDLE;
  132523. private _boundBuffersVertexArray;
  132524. getHardwareScalingLevel(): number;
  132525. constructor();
  132526. dispose(): void;
  132527. /**
  132528. * Can be used to override the current requestAnimationFrame requester.
  132529. * @hidden
  132530. */
  132531. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  132532. /**
  132533. * Override default engine behavior.
  132534. * @param color
  132535. * @param backBuffer
  132536. * @param depth
  132537. * @param stencil
  132538. */
  132539. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  132540. /**
  132541. * Gets host document
  132542. * @returns the host document object
  132543. */
  132544. getHostDocument(): Nullable<Document>;
  132545. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  132546. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  132547. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  132548. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  132549. [key: string]: VertexBuffer;
  132550. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  132551. bindBuffers(vertexBuffers: {
  132552. [key: string]: VertexBuffer;
  132553. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  132554. recordVertexArrayObject(vertexBuffers: {
  132555. [key: string]: VertexBuffer;
  132556. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  132557. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  132558. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  132559. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  132560. /**
  132561. * Draw a list of indexed primitives
  132562. * @param fillMode defines the primitive to use
  132563. * @param indexStart defines the starting index
  132564. * @param indexCount defines the number of index to draw
  132565. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132566. */
  132567. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  132568. /**
  132569. * Draw a list of unindexed primitives
  132570. * @param fillMode defines the primitive to use
  132571. * @param verticesStart defines the index of first vertex to draw
  132572. * @param verticesCount defines the count of vertices to draw
  132573. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132574. */
  132575. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  132576. createPipelineContext(): IPipelineContext;
  132577. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  132578. /** @hidden */
  132579. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  132580. /** @hidden */
  132581. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  132582. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  132583. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  132584. protected _setProgram(program: WebGLProgram): void;
  132585. _releaseEffect(effect: Effect): void;
  132586. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  132587. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  132588. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  132589. bindSamplers(effect: Effect): void;
  132590. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  132591. getRenderWidth(useScreen?: boolean): number;
  132592. getRenderHeight(useScreen?: boolean): number;
  132593. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  132594. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  132595. /**
  132596. * Set the z offset to apply to current rendering
  132597. * @param value defines the offset to apply
  132598. */
  132599. setZOffset(value: number): void;
  132600. /**
  132601. * Gets the current value of the zOffset
  132602. * @returns the current zOffset state
  132603. */
  132604. getZOffset(): number;
  132605. /**
  132606. * Enable or disable depth buffering
  132607. * @param enable defines the state to set
  132608. */
  132609. setDepthBuffer(enable: boolean): void;
  132610. /**
  132611. * Gets a boolean indicating if depth writing is enabled
  132612. * @returns the current depth writing state
  132613. */
  132614. getDepthWrite(): boolean;
  132615. /**
  132616. * Enable or disable depth writing
  132617. * @param enable defines the state to set
  132618. */
  132619. setDepthWrite(enable: boolean): void;
  132620. /**
  132621. * Enable or disable color writing
  132622. * @param enable defines the state to set
  132623. */
  132624. setColorWrite(enable: boolean): void;
  132625. /**
  132626. * Gets a boolean indicating if color writing is enabled
  132627. * @returns the current color writing state
  132628. */
  132629. getColorWrite(): boolean;
  132630. /**
  132631. * Sets alpha constants used by some alpha blending modes
  132632. * @param r defines the red component
  132633. * @param g defines the green component
  132634. * @param b defines the blue component
  132635. * @param a defines the alpha component
  132636. */
  132637. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  132638. /**
  132639. * Sets the current alpha mode
  132640. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  132641. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  132642. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  132643. */
  132644. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  132645. /**
  132646. * Gets the current alpha mode
  132647. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  132648. * @returns the current alpha mode
  132649. */
  132650. getAlphaMode(): number;
  132651. setInt(uniform: WebGLUniformLocation, int: number): void;
  132652. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  132653. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  132654. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  132655. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  132656. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  132657. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  132658. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  132659. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  132660. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  132661. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  132662. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  132663. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  132664. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  132665. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  132666. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  132667. setFloat(uniform: WebGLUniformLocation, value: number): void;
  132668. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  132669. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  132670. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  132671. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  132672. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  132673. wipeCaches(bruteForce?: boolean): void;
  132674. _createTexture(): WebGLTexture;
  132675. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  132676. /**
  132677. * Usually called from Texture.ts.
  132678. * Passed information to create a WebGLTexture
  132679. * @param url defines a value which contains one of the following:
  132680. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  132681. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  132682. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  132683. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  132684. * @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)
  132685. * @param scene needed for loading to the correct scene
  132686. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  132687. * @param onLoad optional callback to be called upon successful completion
  132688. * @param onError optional callback to be called upon failure
  132689. * @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
  132690. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  132691. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  132692. * @param forcedExtension defines the extension to use to pick the right loader
  132693. * @param mimeType defines an optional mime type
  132694. * @returns a InternalTexture for assignment back into BABYLON.Texture
  132695. */
  132696. 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;
  132697. /**
  132698. * Creates a cube texture
  132699. * @param rootUrl defines the url where the files to load is located
  132700. * @param scene defines the current scene
  132701. * @param files defines the list of files to load (1 per face)
  132702. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  132703. * @param onLoad defines an optional callback raised when the texture is loaded
  132704. * @param onError defines an optional callback raised if there is an issue to load the texture
  132705. * @param format defines the format of the data
  132706. * @param forcedExtension defines the extension to use to pick the right loader
  132707. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  132708. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  132709. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  132710. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  132711. * @returns the cube texture as an InternalTexture
  132712. */
  132713. 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;
  132714. private _getSamplingFilter;
  132715. private static _GetNativeTextureFormat;
  132716. createRenderTargetTexture(size: number | {
  132717. width: number;
  132718. height: number;
  132719. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  132720. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  132721. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  132722. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  132723. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  132724. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  132725. /**
  132726. * Updates a dynamic vertex buffer.
  132727. * @param vertexBuffer the vertex buffer to update
  132728. * @param data the data used to update the vertex buffer
  132729. * @param byteOffset the byte offset of the data (optional)
  132730. * @param byteLength the byte length of the data (optional)
  132731. */
  132732. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  132733. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  132734. private _updateAnisotropicLevel;
  132735. private _getAddressMode;
  132736. /** @hidden */
  132737. _bindTexture(channel: number, texture: InternalTexture): void;
  132738. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  132739. releaseEffects(): void;
  132740. /** @hidden */
  132741. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132742. /** @hidden */
  132743. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132744. /** @hidden */
  132745. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132746. /** @hidden */
  132747. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  132748. }
  132749. }
  132750. declare module BABYLON {
  132751. /**
  132752. * Gather the list of clipboard event types as constants.
  132753. */
  132754. export class ClipboardEventTypes {
  132755. /**
  132756. * The clipboard event is fired when a copy command is active (pressed).
  132757. */
  132758. static readonly COPY: number;
  132759. /**
  132760. * The clipboard event is fired when a cut command is active (pressed).
  132761. */
  132762. static readonly CUT: number;
  132763. /**
  132764. * The clipboard event is fired when a paste command is active (pressed).
  132765. */
  132766. static readonly PASTE: number;
  132767. }
  132768. /**
  132769. * This class is used to store clipboard related info for the onClipboardObservable event.
  132770. */
  132771. export class ClipboardInfo {
  132772. /**
  132773. * Defines the type of event (BABYLON.ClipboardEventTypes)
  132774. */
  132775. type: number;
  132776. /**
  132777. * Defines the related dom event
  132778. */
  132779. event: ClipboardEvent;
  132780. /**
  132781. *Creates an instance of ClipboardInfo.
  132782. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  132783. * @param event Defines the related dom event
  132784. */
  132785. constructor(
  132786. /**
  132787. * Defines the type of event (BABYLON.ClipboardEventTypes)
  132788. */
  132789. type: number,
  132790. /**
  132791. * Defines the related dom event
  132792. */
  132793. event: ClipboardEvent);
  132794. /**
  132795. * Get the clipboard event's type from the keycode.
  132796. * @param keyCode Defines the keyCode for the current keyboard event.
  132797. * @return {number}
  132798. */
  132799. static GetTypeFromCharacter(keyCode: number): number;
  132800. }
  132801. }
  132802. declare module BABYLON {
  132803. /**
  132804. * Google Daydream controller
  132805. */
  132806. export class DaydreamController extends WebVRController {
  132807. /**
  132808. * Base Url for the controller model.
  132809. */
  132810. static MODEL_BASE_URL: string;
  132811. /**
  132812. * File name for the controller model.
  132813. */
  132814. static MODEL_FILENAME: string;
  132815. /**
  132816. * Gamepad Id prefix used to identify Daydream Controller.
  132817. */
  132818. static readonly GAMEPAD_ID_PREFIX: string;
  132819. /**
  132820. * Creates a new DaydreamController from a gamepad
  132821. * @param vrGamepad the gamepad that the controller should be created from
  132822. */
  132823. constructor(vrGamepad: any);
  132824. /**
  132825. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132826. * @param scene scene in which to add meshes
  132827. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132828. */
  132829. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132830. /**
  132831. * Called once for each button that changed state since the last frame
  132832. * @param buttonIdx Which button index changed
  132833. * @param state New state of the button
  132834. * @param changes Which properties on the state changed since last frame
  132835. */
  132836. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132837. }
  132838. }
  132839. declare module BABYLON {
  132840. /**
  132841. * Gear VR Controller
  132842. */
  132843. export class GearVRController extends WebVRController {
  132844. /**
  132845. * Base Url for the controller model.
  132846. */
  132847. static MODEL_BASE_URL: string;
  132848. /**
  132849. * File name for the controller model.
  132850. */
  132851. static MODEL_FILENAME: string;
  132852. /**
  132853. * Gamepad Id prefix used to identify this controller.
  132854. */
  132855. static readonly GAMEPAD_ID_PREFIX: string;
  132856. private readonly _buttonIndexToObservableNameMap;
  132857. /**
  132858. * Creates a new GearVRController from a gamepad
  132859. * @param vrGamepad the gamepad that the controller should be created from
  132860. */
  132861. constructor(vrGamepad: any);
  132862. /**
  132863. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132864. * @param scene scene in which to add meshes
  132865. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132866. */
  132867. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132868. /**
  132869. * Called once for each button that changed state since the last frame
  132870. * @param buttonIdx Which button index changed
  132871. * @param state New state of the button
  132872. * @param changes Which properties on the state changed since last frame
  132873. */
  132874. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132875. }
  132876. }
  132877. declare module BABYLON {
  132878. /**
  132879. * Generic Controller
  132880. */
  132881. export class GenericController extends WebVRController {
  132882. /**
  132883. * Base Url for the controller model.
  132884. */
  132885. static readonly MODEL_BASE_URL: string;
  132886. /**
  132887. * File name for the controller model.
  132888. */
  132889. static readonly MODEL_FILENAME: string;
  132890. /**
  132891. * Creates a new GenericController from a gamepad
  132892. * @param vrGamepad the gamepad that the controller should be created from
  132893. */
  132894. constructor(vrGamepad: any);
  132895. /**
  132896. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132897. * @param scene scene in which to add meshes
  132898. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132899. */
  132900. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132901. /**
  132902. * Called once for each button that changed state since the last frame
  132903. * @param buttonIdx Which button index changed
  132904. * @param state New state of the button
  132905. * @param changes Which properties on the state changed since last frame
  132906. */
  132907. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132908. }
  132909. }
  132910. declare module BABYLON {
  132911. /**
  132912. * Oculus Touch Controller
  132913. */
  132914. export class OculusTouchController extends WebVRController {
  132915. /**
  132916. * Base Url for the controller model.
  132917. */
  132918. static MODEL_BASE_URL: string;
  132919. /**
  132920. * File name for the left controller model.
  132921. */
  132922. static MODEL_LEFT_FILENAME: string;
  132923. /**
  132924. * File name for the right controller model.
  132925. */
  132926. static MODEL_RIGHT_FILENAME: string;
  132927. /**
  132928. * Base Url for the Quest controller model.
  132929. */
  132930. static QUEST_MODEL_BASE_URL: string;
  132931. /**
  132932. * @hidden
  132933. * If the controllers are running on a device that needs the updated Quest controller models
  132934. */
  132935. static _IsQuest: boolean;
  132936. /**
  132937. * Fired when the secondary trigger on this controller is modified
  132938. */
  132939. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  132940. /**
  132941. * Fired when the thumb rest on this controller is modified
  132942. */
  132943. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  132944. /**
  132945. * Creates a new OculusTouchController from a gamepad
  132946. * @param vrGamepad the gamepad that the controller should be created from
  132947. */
  132948. constructor(vrGamepad: any);
  132949. /**
  132950. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  132951. * @param scene scene in which to add meshes
  132952. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  132953. */
  132954. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  132955. /**
  132956. * Fired when the A button on this controller is modified
  132957. */
  132958. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132959. /**
  132960. * Fired when the B button on this controller is modified
  132961. */
  132962. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132963. /**
  132964. * Fired when the X button on this controller is modified
  132965. */
  132966. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132967. /**
  132968. * Fired when the Y button on this controller is modified
  132969. */
  132970. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  132971. /**
  132972. * Called once for each button that changed state since the last frame
  132973. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  132974. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  132975. * 2) secondary trigger (same)
  132976. * 3) A (right) X (left), touch, pressed = value
  132977. * 4) B / Y
  132978. * 5) thumb rest
  132979. * @param buttonIdx Which button index changed
  132980. * @param state New state of the button
  132981. * @param changes Which properties on the state changed since last frame
  132982. */
  132983. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  132984. }
  132985. }
  132986. declare module BABYLON {
  132987. /**
  132988. * Vive Controller
  132989. */
  132990. export class ViveController extends WebVRController {
  132991. /**
  132992. * Base Url for the controller model.
  132993. */
  132994. static MODEL_BASE_URL: string;
  132995. /**
  132996. * File name for the controller model.
  132997. */
  132998. static MODEL_FILENAME: string;
  132999. /**
  133000. * Creates a new ViveController from a gamepad
  133001. * @param vrGamepad the gamepad that the controller should be created from
  133002. */
  133003. constructor(vrGamepad: any);
  133004. /**
  133005. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133006. * @param scene scene in which to add meshes
  133007. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133008. */
  133009. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133010. /**
  133011. * Fired when the left button on this controller is modified
  133012. */
  133013. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133014. /**
  133015. * Fired when the right button on this controller is modified
  133016. */
  133017. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133018. /**
  133019. * Fired when the menu button on this controller is modified
  133020. */
  133021. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133022. /**
  133023. * Called once for each button that changed state since the last frame
  133024. * Vive mapping:
  133025. * 0: touchpad
  133026. * 1: trigger
  133027. * 2: left AND right buttons
  133028. * 3: menu button
  133029. * @param buttonIdx Which button index changed
  133030. * @param state New state of the button
  133031. * @param changes Which properties on the state changed since last frame
  133032. */
  133033. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133034. }
  133035. }
  133036. declare module BABYLON {
  133037. /**
  133038. * Defines the WindowsMotionController object that the state of the windows motion controller
  133039. */
  133040. export class WindowsMotionController extends WebVRController {
  133041. /**
  133042. * The base url used to load the left and right controller models
  133043. */
  133044. static MODEL_BASE_URL: string;
  133045. /**
  133046. * The name of the left controller model file
  133047. */
  133048. static MODEL_LEFT_FILENAME: string;
  133049. /**
  133050. * The name of the right controller model file
  133051. */
  133052. static MODEL_RIGHT_FILENAME: string;
  133053. /**
  133054. * The controller name prefix for this controller type
  133055. */
  133056. static readonly GAMEPAD_ID_PREFIX: string;
  133057. /**
  133058. * The controller id pattern for this controller type
  133059. */
  133060. private static readonly GAMEPAD_ID_PATTERN;
  133061. private _loadedMeshInfo;
  133062. protected readonly _mapping: {
  133063. buttons: string[];
  133064. buttonMeshNames: {
  133065. trigger: string;
  133066. menu: string;
  133067. grip: string;
  133068. thumbstick: string;
  133069. trackpad: string;
  133070. };
  133071. buttonObservableNames: {
  133072. trigger: string;
  133073. menu: string;
  133074. grip: string;
  133075. thumbstick: string;
  133076. trackpad: string;
  133077. };
  133078. axisMeshNames: string[];
  133079. pointingPoseMeshName: string;
  133080. };
  133081. /**
  133082. * Fired when the trackpad on this controller is clicked
  133083. */
  133084. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  133085. /**
  133086. * Fired when the trackpad on this controller is modified
  133087. */
  133088. onTrackpadValuesChangedObservable: Observable<StickValues>;
  133089. /**
  133090. * The current x and y values of this controller's trackpad
  133091. */
  133092. trackpad: StickValues;
  133093. /**
  133094. * Creates a new WindowsMotionController from a gamepad
  133095. * @param vrGamepad the gamepad that the controller should be created from
  133096. */
  133097. constructor(vrGamepad: any);
  133098. /**
  133099. * Fired when the trigger on this controller is modified
  133100. */
  133101. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133102. /**
  133103. * Fired when the menu button on this controller is modified
  133104. */
  133105. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133106. /**
  133107. * Fired when the grip button on this controller is modified
  133108. */
  133109. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133110. /**
  133111. * Fired when the thumbstick button on this controller is modified
  133112. */
  133113. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133114. /**
  133115. * Fired when the touchpad button on this controller is modified
  133116. */
  133117. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133118. /**
  133119. * Fired when the touchpad values on this controller are modified
  133120. */
  133121. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  133122. protected _updateTrackpad(): void;
  133123. /**
  133124. * Called once per frame by the engine.
  133125. */
  133126. update(): void;
  133127. /**
  133128. * Called once for each button that changed state since the last frame
  133129. * @param buttonIdx Which button index changed
  133130. * @param state New state of the button
  133131. * @param changes Which properties on the state changed since last frame
  133132. */
  133133. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133134. /**
  133135. * Moves the buttons on the controller mesh based on their current state
  133136. * @param buttonName the name of the button to move
  133137. * @param buttonValue the value of the button which determines the buttons new position
  133138. */
  133139. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  133140. /**
  133141. * Moves the axis on the controller mesh based on its current state
  133142. * @param axis the index of the axis
  133143. * @param axisValue the value of the axis which determines the meshes new position
  133144. * @hidden
  133145. */
  133146. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  133147. /**
  133148. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133149. * @param scene scene in which to add meshes
  133150. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133151. */
  133152. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  133153. /**
  133154. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  133155. * can be transformed by button presses and axes values, based on this._mapping.
  133156. *
  133157. * @param scene scene in which the meshes exist
  133158. * @param meshes list of meshes that make up the controller model to process
  133159. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  133160. */
  133161. private processModel;
  133162. private createMeshInfo;
  133163. /**
  133164. * Gets the ray of the controller in the direction the controller is pointing
  133165. * @param length the length the resulting ray should be
  133166. * @returns a ray in the direction the controller is pointing
  133167. */
  133168. getForwardRay(length?: number): Ray;
  133169. /**
  133170. * Disposes of the controller
  133171. */
  133172. dispose(): void;
  133173. }
  133174. /**
  133175. * This class represents a new windows motion controller in XR.
  133176. */
  133177. export class XRWindowsMotionController extends WindowsMotionController {
  133178. /**
  133179. * Changing the original WIndowsMotionController mapping to fir the new mapping
  133180. */
  133181. protected readonly _mapping: {
  133182. buttons: string[];
  133183. buttonMeshNames: {
  133184. trigger: string;
  133185. menu: string;
  133186. grip: string;
  133187. thumbstick: string;
  133188. trackpad: string;
  133189. };
  133190. buttonObservableNames: {
  133191. trigger: string;
  133192. menu: string;
  133193. grip: string;
  133194. thumbstick: string;
  133195. trackpad: string;
  133196. };
  133197. axisMeshNames: string[];
  133198. pointingPoseMeshName: string;
  133199. };
  133200. /**
  133201. * Construct a new XR-Based windows motion controller
  133202. *
  133203. * @param gamepadInfo the gamepad object from the browser
  133204. */
  133205. constructor(gamepadInfo: any);
  133206. /**
  133207. * holds the thumbstick values (X,Y)
  133208. */
  133209. thumbstickValues: StickValues;
  133210. /**
  133211. * Fired when the thumbstick on this controller is clicked
  133212. */
  133213. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  133214. /**
  133215. * Fired when the thumbstick on this controller is modified
  133216. */
  133217. onThumbstickValuesChangedObservable: Observable<StickValues>;
  133218. /**
  133219. * Fired when the touchpad button on this controller is modified
  133220. */
  133221. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  133222. /**
  133223. * Fired when the touchpad values on this controller are modified
  133224. */
  133225. onTrackpadValuesChangedObservable: Observable<StickValues>;
  133226. /**
  133227. * Fired when the thumbstick button on this controller is modified
  133228. * here to prevent breaking changes
  133229. */
  133230. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133231. /**
  133232. * updating the thumbstick(!) and not the trackpad.
  133233. * This is named this way due to the difference between WebVR and XR and to avoid
  133234. * changing the parent class.
  133235. */
  133236. protected _updateTrackpad(): void;
  133237. /**
  133238. * Disposes the class with joy
  133239. */
  133240. dispose(): void;
  133241. }
  133242. }
  133243. declare module BABYLON {
  133244. /**
  133245. * Class containing static functions to help procedurally build meshes
  133246. */
  133247. export class PolyhedronBuilder {
  133248. /**
  133249. * Creates a polyhedron mesh
  133250. * * 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
  133251. * * The parameter `size` (positive float, default 1) sets the polygon size
  133252. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  133253. * * 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`
  133254. * * 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
  133255. * * 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)`)
  133256. * * 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
  133257. * * 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
  133258. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133259. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133261. * @param name defines the name of the mesh
  133262. * @param options defines the options used to create the mesh
  133263. * @param scene defines the hosting scene
  133264. * @returns the polyhedron mesh
  133265. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  133266. */
  133267. static CreatePolyhedron(name: string, options: {
  133268. type?: number;
  133269. size?: number;
  133270. sizeX?: number;
  133271. sizeY?: number;
  133272. sizeZ?: number;
  133273. custom?: any;
  133274. faceUV?: Vector4[];
  133275. faceColors?: Color4[];
  133276. flat?: boolean;
  133277. updatable?: boolean;
  133278. sideOrientation?: number;
  133279. frontUVs?: Vector4;
  133280. backUVs?: Vector4;
  133281. }, scene?: Nullable<Scene>): Mesh;
  133282. }
  133283. }
  133284. declare module BABYLON {
  133285. /**
  133286. * Gizmo that enables scaling a mesh along 3 axis
  133287. */
  133288. export class ScaleGizmo extends Gizmo {
  133289. /**
  133290. * Internal gizmo used for interactions on the x axis
  133291. */
  133292. xGizmo: AxisScaleGizmo;
  133293. /**
  133294. * Internal gizmo used for interactions on the y axis
  133295. */
  133296. yGizmo: AxisScaleGizmo;
  133297. /**
  133298. * Internal gizmo used for interactions on the z axis
  133299. */
  133300. zGizmo: AxisScaleGizmo;
  133301. /**
  133302. * Internal gizmo used to scale all axis equally
  133303. */
  133304. uniformScaleGizmo: AxisScaleGizmo;
  133305. private _meshAttached;
  133306. private _nodeAttached;
  133307. private _snapDistance;
  133308. private _uniformScalingMesh;
  133309. private _octahedron;
  133310. private _sensitivity;
  133311. /** Fires an event when any of it's sub gizmos are dragged */
  133312. onDragStartObservable: Observable<unknown>;
  133313. /** Fires an event when any of it's sub gizmos are released from dragging */
  133314. onDragEndObservable: Observable<unknown>;
  133315. get attachedMesh(): Nullable<AbstractMesh>;
  133316. set attachedMesh(mesh: Nullable<AbstractMesh>);
  133317. get attachedNode(): Nullable<Node>;
  133318. set attachedNode(node: Nullable<Node>);
  133319. /**
  133320. * Creates a ScaleGizmo
  133321. * @param gizmoLayer The utility layer the gizmo will be added to
  133322. * @param thickness display gizmo axis thickness
  133323. */
  133324. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  133325. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  133326. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  133327. /**
  133328. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  133329. */
  133330. set snapDistance(value: number);
  133331. get snapDistance(): number;
  133332. /**
  133333. * Ratio for the scale of the gizmo (Default: 1)
  133334. */
  133335. set scaleRatio(value: number);
  133336. get scaleRatio(): number;
  133337. /**
  133338. * Sensitivity factor for dragging (Default: 1)
  133339. */
  133340. set sensitivity(value: number);
  133341. get sensitivity(): number;
  133342. /**
  133343. * Disposes of the gizmo
  133344. */
  133345. dispose(): void;
  133346. }
  133347. }
  133348. declare module BABYLON {
  133349. /**
  133350. * Single axis scale gizmo
  133351. */
  133352. export class AxisScaleGizmo extends Gizmo {
  133353. /**
  133354. * Drag behavior responsible for the gizmos dragging interactions
  133355. */
  133356. dragBehavior: PointerDragBehavior;
  133357. private _pointerObserver;
  133358. /**
  133359. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  133360. */
  133361. snapDistance: number;
  133362. /**
  133363. * Event that fires each time the gizmo snaps to a new location.
  133364. * * snapDistance is the the change in distance
  133365. */
  133366. onSnapObservable: Observable<{
  133367. snapDistance: number;
  133368. }>;
  133369. /**
  133370. * If the scaling operation should be done on all axis (default: false)
  133371. */
  133372. uniformScaling: boolean;
  133373. /**
  133374. * Custom sensitivity value for the drag strength
  133375. */
  133376. sensitivity: number;
  133377. private _isEnabled;
  133378. private _parent;
  133379. private _arrow;
  133380. private _coloredMaterial;
  133381. private _hoverMaterial;
  133382. /**
  133383. * Creates an AxisScaleGizmo
  133384. * @param gizmoLayer The utility layer the gizmo will be added to
  133385. * @param dragAxis The axis which the gizmo will be able to scale on
  133386. * @param color The color of the gizmo
  133387. * @param thickness display gizmo axis thickness
  133388. */
  133389. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  133390. protected _attachedNodeChanged(value: Nullable<Node>): void;
  133391. /**
  133392. * If the gizmo is enabled
  133393. */
  133394. set isEnabled(value: boolean);
  133395. get isEnabled(): boolean;
  133396. /**
  133397. * Disposes of the gizmo
  133398. */
  133399. dispose(): void;
  133400. /**
  133401. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  133402. * @param mesh The mesh to replace the default mesh of the gizmo
  133403. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  133404. */
  133405. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  133406. }
  133407. }
  133408. declare module BABYLON {
  133409. /**
  133410. * Bounding box gizmo
  133411. */
  133412. export class BoundingBoxGizmo extends Gizmo {
  133413. private _lineBoundingBox;
  133414. private _rotateSpheresParent;
  133415. private _scaleBoxesParent;
  133416. private _boundingDimensions;
  133417. private _renderObserver;
  133418. private _pointerObserver;
  133419. private _scaleDragSpeed;
  133420. private _tmpQuaternion;
  133421. private _tmpVector;
  133422. private _tmpRotationMatrix;
  133423. /**
  133424. * 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)
  133425. */
  133426. ignoreChildren: boolean;
  133427. /**
  133428. * 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)
  133429. */
  133430. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  133431. /**
  133432. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  133433. */
  133434. rotationSphereSize: number;
  133435. /**
  133436. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  133437. */
  133438. scaleBoxSize: number;
  133439. /**
  133440. * 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)
  133441. */
  133442. fixedDragMeshScreenSize: boolean;
  133443. /**
  133444. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  133445. */
  133446. fixedDragMeshScreenSizeDistanceFactor: number;
  133447. /**
  133448. * Fired when a rotation sphere or scale box is dragged
  133449. */
  133450. onDragStartObservable: Observable<{}>;
  133451. /**
  133452. * Fired when a scale box is dragged
  133453. */
  133454. onScaleBoxDragObservable: Observable<{}>;
  133455. /**
  133456. * Fired when a scale box drag is ended
  133457. */
  133458. onScaleBoxDragEndObservable: Observable<{}>;
  133459. /**
  133460. * Fired when a rotation sphere is dragged
  133461. */
  133462. onRotationSphereDragObservable: Observable<{}>;
  133463. /**
  133464. * Fired when a rotation sphere drag is ended
  133465. */
  133466. onRotationSphereDragEndObservable: Observable<{}>;
  133467. /**
  133468. * 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)
  133469. */
  133470. scalePivot: Nullable<Vector3>;
  133471. /**
  133472. * Mesh used as a pivot to rotate the attached node
  133473. */
  133474. private _anchorMesh;
  133475. private _existingMeshScale;
  133476. private _dragMesh;
  133477. private pointerDragBehavior;
  133478. private coloredMaterial;
  133479. private hoverColoredMaterial;
  133480. /**
  133481. * Sets the color of the bounding box gizmo
  133482. * @param color the color to set
  133483. */
  133484. setColor(color: Color3): void;
  133485. /**
  133486. * Creates an BoundingBoxGizmo
  133487. * @param gizmoLayer The utility layer the gizmo will be added to
  133488. * @param color The color of the gizmo
  133489. */
  133490. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  133491. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  133492. private _selectNode;
  133493. /**
  133494. * Updates the bounding box information for the Gizmo
  133495. */
  133496. updateBoundingBox(): void;
  133497. private _updateRotationSpheres;
  133498. private _updateScaleBoxes;
  133499. /**
  133500. * Enables rotation on the specified axis and disables rotation on the others
  133501. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  133502. */
  133503. setEnabledRotationAxis(axis: string): void;
  133504. /**
  133505. * Enables/disables scaling
  133506. * @param enable if scaling should be enabled
  133507. * @param homogeneousScaling defines if scaling should only be homogeneous
  133508. */
  133509. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  133510. private _updateDummy;
  133511. /**
  133512. * Enables a pointer drag behavior on the bounding box of the gizmo
  133513. */
  133514. enableDragBehavior(): void;
  133515. /**
  133516. * Disposes of the gizmo
  133517. */
  133518. dispose(): void;
  133519. /**
  133520. * 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)
  133521. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  133522. * @returns the bounding box mesh with the passed in mesh as a child
  133523. */
  133524. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  133525. /**
  133526. * CustomMeshes are not supported by this gizmo
  133527. * @param mesh The mesh to replace the default mesh of the gizmo
  133528. */
  133529. setCustomMesh(mesh: Mesh): void;
  133530. }
  133531. }
  133532. declare module BABYLON {
  133533. /**
  133534. * Single plane rotation gizmo
  133535. */
  133536. export class PlaneRotationGizmo extends Gizmo {
  133537. /**
  133538. * Drag behavior responsible for the gizmos dragging interactions
  133539. */
  133540. dragBehavior: PointerDragBehavior;
  133541. private _pointerObserver;
  133542. /**
  133543. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  133544. */
  133545. snapDistance: number;
  133546. /**
  133547. * Event that fires each time the gizmo snaps to a new location.
  133548. * * snapDistance is the the change in distance
  133549. */
  133550. onSnapObservable: Observable<{
  133551. snapDistance: number;
  133552. }>;
  133553. private _isEnabled;
  133554. private _parent;
  133555. /**
  133556. * Creates a PlaneRotationGizmo
  133557. * @param gizmoLayer The utility layer the gizmo will be added to
  133558. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  133559. * @param color The color of the gizmo
  133560. * @param tessellation Amount of tessellation to be used when creating rotation circles
  133561. * @param useEulerRotation Use and update Euler angle instead of quaternion
  133562. * @param thickness display gizmo axis thickness
  133563. */
  133564. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  133565. protected _attachedNodeChanged(value: Nullable<Node>): void;
  133566. /**
  133567. * If the gizmo is enabled
  133568. */
  133569. set isEnabled(value: boolean);
  133570. get isEnabled(): boolean;
  133571. /**
  133572. * Disposes of the gizmo
  133573. */
  133574. dispose(): void;
  133575. }
  133576. }
  133577. declare module BABYLON {
  133578. /**
  133579. * Gizmo that enables rotating a mesh along 3 axis
  133580. */
  133581. export class RotationGizmo extends Gizmo {
  133582. /**
  133583. * Internal gizmo used for interactions on the x axis
  133584. */
  133585. xGizmo: PlaneRotationGizmo;
  133586. /**
  133587. * Internal gizmo used for interactions on the y axis
  133588. */
  133589. yGizmo: PlaneRotationGizmo;
  133590. /**
  133591. * Internal gizmo used for interactions on the z axis
  133592. */
  133593. zGizmo: PlaneRotationGizmo;
  133594. /** Fires an event when any of it's sub gizmos are dragged */
  133595. onDragStartObservable: Observable<unknown>;
  133596. /** Fires an event when any of it's sub gizmos are released from dragging */
  133597. onDragEndObservable: Observable<unknown>;
  133598. private _meshAttached;
  133599. private _nodeAttached;
  133600. get attachedMesh(): Nullable<AbstractMesh>;
  133601. set attachedMesh(mesh: Nullable<AbstractMesh>);
  133602. get attachedNode(): Nullable<Node>;
  133603. set attachedNode(node: Nullable<Node>);
  133604. /**
  133605. * Creates a RotationGizmo
  133606. * @param gizmoLayer The utility layer the gizmo will be added to
  133607. * @param tessellation Amount of tessellation to be used when creating rotation circles
  133608. * @param useEulerRotation Use and update Euler angle instead of quaternion
  133609. * @param thickness display gizmo axis thickness
  133610. */
  133611. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  133612. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  133613. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  133614. /**
  133615. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  133616. */
  133617. set snapDistance(value: number);
  133618. get snapDistance(): number;
  133619. /**
  133620. * Ratio for the scale of the gizmo (Default: 1)
  133621. */
  133622. set scaleRatio(value: number);
  133623. get scaleRatio(): number;
  133624. /**
  133625. * Disposes of the gizmo
  133626. */
  133627. dispose(): void;
  133628. /**
  133629. * CustomMeshes are not supported by this gizmo
  133630. * @param mesh The mesh to replace the default mesh of the gizmo
  133631. */
  133632. setCustomMesh(mesh: Mesh): void;
  133633. }
  133634. }
  133635. declare module BABYLON {
  133636. /**
  133637. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  133638. */
  133639. export class GizmoManager implements IDisposable {
  133640. private scene;
  133641. /**
  133642. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  133643. */
  133644. gizmos: {
  133645. positionGizmo: Nullable<PositionGizmo>;
  133646. rotationGizmo: Nullable<RotationGizmo>;
  133647. scaleGizmo: Nullable<ScaleGizmo>;
  133648. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  133649. };
  133650. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  133651. clearGizmoOnEmptyPointerEvent: boolean;
  133652. /** Fires an event when the manager is attached to a mesh */
  133653. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  133654. /** Fires an event when the manager is attached to a node */
  133655. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  133656. private _gizmosEnabled;
  133657. private _pointerObserver;
  133658. private _attachedMesh;
  133659. private _attachedNode;
  133660. private _boundingBoxColor;
  133661. private _defaultUtilityLayer;
  133662. private _defaultKeepDepthUtilityLayer;
  133663. private _thickness;
  133664. /**
  133665. * When bounding box gizmo is enabled, this can be used to track drag/end events
  133666. */
  133667. boundingBoxDragBehavior: SixDofDragBehavior;
  133668. /**
  133669. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  133670. */
  133671. attachableMeshes: Nullable<Array<AbstractMesh>>;
  133672. /**
  133673. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  133674. */
  133675. attachableNodes: Nullable<Array<Node>>;
  133676. /**
  133677. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  133678. */
  133679. usePointerToAttachGizmos: boolean;
  133680. /**
  133681. * Utility layer that the bounding box gizmo belongs to
  133682. */
  133683. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  133684. /**
  133685. * Utility layer that all gizmos besides bounding box belong to
  133686. */
  133687. get utilityLayer(): UtilityLayerRenderer;
  133688. /**
  133689. * Instatiates a gizmo manager
  133690. * @param scene the scene to overlay the gizmos on top of
  133691. * @param thickness display gizmo axis thickness
  133692. */
  133693. constructor(scene: Scene, thickness?: number);
  133694. /**
  133695. * Attaches a set of gizmos to the specified mesh
  133696. * @param mesh The mesh the gizmo's should be attached to
  133697. */
  133698. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  133699. /**
  133700. * Attaches a set of gizmos to the specified node
  133701. * @param node The node the gizmo's should be attached to
  133702. */
  133703. attachToNode(node: Nullable<Node>): void;
  133704. /**
  133705. * If the position gizmo is enabled
  133706. */
  133707. set positionGizmoEnabled(value: boolean);
  133708. get positionGizmoEnabled(): boolean;
  133709. /**
  133710. * If the rotation gizmo is enabled
  133711. */
  133712. set rotationGizmoEnabled(value: boolean);
  133713. get rotationGizmoEnabled(): boolean;
  133714. /**
  133715. * If the scale gizmo is enabled
  133716. */
  133717. set scaleGizmoEnabled(value: boolean);
  133718. get scaleGizmoEnabled(): boolean;
  133719. /**
  133720. * If the boundingBox gizmo is enabled
  133721. */
  133722. set boundingBoxGizmoEnabled(value: boolean);
  133723. get boundingBoxGizmoEnabled(): boolean;
  133724. /**
  133725. * Disposes of the gizmo manager
  133726. */
  133727. dispose(): void;
  133728. }
  133729. }
  133730. declare module BABYLON {
  133731. /**
  133732. * A directional light is defined by a direction (what a surprise!).
  133733. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  133734. * 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.
  133735. * Documentation: https://doc.babylonjs.com/babylon101/lights
  133736. */
  133737. export class DirectionalLight extends ShadowLight {
  133738. private _shadowFrustumSize;
  133739. /**
  133740. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  133741. */
  133742. get shadowFrustumSize(): number;
  133743. /**
  133744. * Specifies a fix frustum size for the shadow generation.
  133745. */
  133746. set shadowFrustumSize(value: number);
  133747. private _shadowOrthoScale;
  133748. /**
  133749. * Gets the shadow projection scale against the optimal computed one.
  133750. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  133751. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  133752. */
  133753. get shadowOrthoScale(): number;
  133754. /**
  133755. * Sets the shadow projection scale against the optimal computed one.
  133756. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  133757. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  133758. */
  133759. set shadowOrthoScale(value: number);
  133760. /**
  133761. * Automatically compute the projection matrix to best fit (including all the casters)
  133762. * on each frame.
  133763. */
  133764. autoUpdateExtends: boolean;
  133765. /**
  133766. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  133767. * on each frame. autoUpdateExtends must be set to true for this to work
  133768. */
  133769. autoCalcShadowZBounds: boolean;
  133770. private _orthoLeft;
  133771. private _orthoRight;
  133772. private _orthoTop;
  133773. private _orthoBottom;
  133774. /**
  133775. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  133776. * The directional light is emitted from everywhere in the given direction.
  133777. * It can cast shadows.
  133778. * Documentation : https://doc.babylonjs.com/babylon101/lights
  133779. * @param name The friendly name of the light
  133780. * @param direction The direction of the light
  133781. * @param scene The scene the light belongs to
  133782. */
  133783. constructor(name: string, direction: Vector3, scene: Scene);
  133784. /**
  133785. * Returns the string "DirectionalLight".
  133786. * @return The class name
  133787. */
  133788. getClassName(): string;
  133789. /**
  133790. * Returns the integer 1.
  133791. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  133792. */
  133793. getTypeID(): number;
  133794. /**
  133795. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  133796. * Returns the DirectionalLight Shadow projection matrix.
  133797. */
  133798. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  133799. /**
  133800. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  133801. * Returns the DirectionalLight Shadow projection matrix.
  133802. */
  133803. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  133804. /**
  133805. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  133806. * Returns the DirectionalLight Shadow projection matrix.
  133807. */
  133808. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  133809. protected _buildUniformLayout(): void;
  133810. /**
  133811. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  133812. * @param effect The effect to update
  133813. * @param lightIndex The index of the light in the effect to update
  133814. * @returns The directional light
  133815. */
  133816. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  133817. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  133818. /**
  133819. * Gets the minZ used for shadow according to both the scene and the light.
  133820. *
  133821. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  133822. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  133823. * @param activeCamera The camera we are returning the min for
  133824. * @returns the depth min z
  133825. */
  133826. getDepthMinZ(activeCamera: Camera): number;
  133827. /**
  133828. * Gets the maxZ used for shadow according to both the scene and the light.
  133829. *
  133830. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  133831. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  133832. * @param activeCamera The camera we are returning the max for
  133833. * @returns the depth max z
  133834. */
  133835. getDepthMaxZ(activeCamera: Camera): number;
  133836. /**
  133837. * Prepares the list of defines specific to the light type.
  133838. * @param defines the list of defines
  133839. * @param lightIndex defines the index of the light for the effect
  133840. */
  133841. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  133842. }
  133843. }
  133844. declare module BABYLON {
  133845. /**
  133846. * Class containing static functions to help procedurally build meshes
  133847. */
  133848. export class HemisphereBuilder {
  133849. /**
  133850. * Creates a hemisphere mesh
  133851. * @param name defines the name of the mesh
  133852. * @param options defines the options used to create the mesh
  133853. * @param scene defines the hosting scene
  133854. * @returns the hemisphere mesh
  133855. */
  133856. static CreateHemisphere(name: string, options: {
  133857. segments?: number;
  133858. diameter?: number;
  133859. sideOrientation?: number;
  133860. }, scene: any): Mesh;
  133861. }
  133862. }
  133863. declare module BABYLON {
  133864. /**
  133865. * A spot light is defined by a position, a direction, an angle, and an exponent.
  133866. * These values define a cone of light starting from the position, emitting toward the direction.
  133867. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  133868. * and the exponent defines the speed of the decay of the light with distance (reach).
  133869. * Documentation: https://doc.babylonjs.com/babylon101/lights
  133870. */
  133871. export class SpotLight extends ShadowLight {
  133872. private _angle;
  133873. private _innerAngle;
  133874. private _cosHalfAngle;
  133875. private _lightAngleScale;
  133876. private _lightAngleOffset;
  133877. /**
  133878. * Gets the cone angle of the spot light in Radians.
  133879. */
  133880. get angle(): number;
  133881. /**
  133882. * Sets the cone angle of the spot light in Radians.
  133883. */
  133884. set angle(value: number);
  133885. /**
  133886. * Only used in gltf falloff mode, this defines the angle where
  133887. * the directional falloff will start before cutting at angle which could be seen
  133888. * as outer angle.
  133889. */
  133890. get innerAngle(): number;
  133891. /**
  133892. * Only used in gltf falloff mode, this defines the angle where
  133893. * the directional falloff will start before cutting at angle which could be seen
  133894. * as outer angle.
  133895. */
  133896. set innerAngle(value: number);
  133897. private _shadowAngleScale;
  133898. /**
  133899. * Allows scaling the angle of the light for shadow generation only.
  133900. */
  133901. get shadowAngleScale(): number;
  133902. /**
  133903. * Allows scaling the angle of the light for shadow generation only.
  133904. */
  133905. set shadowAngleScale(value: number);
  133906. /**
  133907. * The light decay speed with the distance from the emission spot.
  133908. */
  133909. exponent: number;
  133910. private _projectionTextureMatrix;
  133911. /**
  133912. * Allows reading the projecton texture
  133913. */
  133914. get projectionTextureMatrix(): Matrix;
  133915. protected _projectionTextureLightNear: number;
  133916. /**
  133917. * Gets the near clip of the Spotlight for texture projection.
  133918. */
  133919. get projectionTextureLightNear(): number;
  133920. /**
  133921. * Sets the near clip of the Spotlight for texture projection.
  133922. */
  133923. set projectionTextureLightNear(value: number);
  133924. protected _projectionTextureLightFar: number;
  133925. /**
  133926. * Gets the far clip of the Spotlight for texture projection.
  133927. */
  133928. get projectionTextureLightFar(): number;
  133929. /**
  133930. * Sets the far clip of the Spotlight for texture projection.
  133931. */
  133932. set projectionTextureLightFar(value: number);
  133933. protected _projectionTextureUpDirection: Vector3;
  133934. /**
  133935. * Gets the Up vector of the Spotlight for texture projection.
  133936. */
  133937. get projectionTextureUpDirection(): Vector3;
  133938. /**
  133939. * Sets the Up vector of the Spotlight for texture projection.
  133940. */
  133941. set projectionTextureUpDirection(value: Vector3);
  133942. private _projectionTexture;
  133943. /**
  133944. * Gets the projection texture of the light.
  133945. */
  133946. get projectionTexture(): Nullable<BaseTexture>;
  133947. /**
  133948. * Sets the projection texture of the light.
  133949. */
  133950. set projectionTexture(value: Nullable<BaseTexture>);
  133951. private _projectionTextureViewLightDirty;
  133952. private _projectionTextureProjectionLightDirty;
  133953. private _projectionTextureDirty;
  133954. private _projectionTextureViewTargetVector;
  133955. private _projectionTextureViewLightMatrix;
  133956. private _projectionTextureProjectionLightMatrix;
  133957. private _projectionTextureScalingMatrix;
  133958. /**
  133959. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  133960. * It can cast shadows.
  133961. * Documentation : https://doc.babylonjs.com/babylon101/lights
  133962. * @param name The light friendly name
  133963. * @param position The position of the spot light in the scene
  133964. * @param direction The direction of the light in the scene
  133965. * @param angle The cone angle of the light in Radians
  133966. * @param exponent The light decay speed with the distance from the emission spot
  133967. * @param scene The scene the lights belongs to
  133968. */
  133969. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  133970. /**
  133971. * Returns the string "SpotLight".
  133972. * @returns the class name
  133973. */
  133974. getClassName(): string;
  133975. /**
  133976. * Returns the integer 2.
  133977. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  133978. */
  133979. getTypeID(): number;
  133980. /**
  133981. * Overrides the direction setter to recompute the projection texture view light Matrix.
  133982. */
  133983. protected _setDirection(value: Vector3): void;
  133984. /**
  133985. * Overrides the position setter to recompute the projection texture view light Matrix.
  133986. */
  133987. protected _setPosition(value: Vector3): void;
  133988. /**
  133989. * 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.
  133990. * Returns the SpotLight.
  133991. */
  133992. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  133993. protected _computeProjectionTextureViewLightMatrix(): void;
  133994. protected _computeProjectionTextureProjectionLightMatrix(): void;
  133995. /**
  133996. * Main function for light texture projection matrix computing.
  133997. */
  133998. protected _computeProjectionTextureMatrix(): void;
  133999. protected _buildUniformLayout(): void;
  134000. private _computeAngleValues;
  134001. /**
  134002. * Sets the passed Effect "effect" with the Light textures.
  134003. * @param effect The effect to update
  134004. * @param lightIndex The index of the light in the effect to update
  134005. * @returns The light
  134006. */
  134007. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  134008. /**
  134009. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  134010. * @param effect The effect to update
  134011. * @param lightIndex The index of the light in the effect to update
  134012. * @returns The spot light
  134013. */
  134014. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  134015. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  134016. /**
  134017. * Disposes the light and the associated resources.
  134018. */
  134019. dispose(): void;
  134020. /**
  134021. * Prepares the list of defines specific to the light type.
  134022. * @param defines the list of defines
  134023. * @param lightIndex defines the index of the light for the effect
  134024. */
  134025. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  134026. }
  134027. }
  134028. declare module BABYLON {
  134029. /**
  134030. * Gizmo that enables viewing a light
  134031. */
  134032. export class LightGizmo extends Gizmo {
  134033. private _lightMesh;
  134034. private _material;
  134035. private _cachedPosition;
  134036. private _cachedForward;
  134037. private _attachedMeshParent;
  134038. private _pointerObserver;
  134039. /**
  134040. * Event that fires each time the gizmo is clicked
  134041. */
  134042. onClickedObservable: Observable<Light>;
  134043. /**
  134044. * Creates a LightGizmo
  134045. * @param gizmoLayer The utility layer the gizmo will be added to
  134046. */
  134047. constructor(gizmoLayer?: UtilityLayerRenderer);
  134048. private _light;
  134049. /**
  134050. * The light that the gizmo is attached to
  134051. */
  134052. set light(light: Nullable<Light>);
  134053. get light(): Nullable<Light>;
  134054. /**
  134055. * Gets the material used to render the light gizmo
  134056. */
  134057. get material(): StandardMaterial;
  134058. /**
  134059. * @hidden
  134060. * Updates the gizmo to match the attached mesh's position/rotation
  134061. */
  134062. protected _update(): void;
  134063. private static _Scale;
  134064. /**
  134065. * Creates the lines for a light mesh
  134066. */
  134067. private static _CreateLightLines;
  134068. /**
  134069. * Disposes of the light gizmo
  134070. */
  134071. dispose(): void;
  134072. private static _CreateHemisphericLightMesh;
  134073. private static _CreatePointLightMesh;
  134074. private static _CreateSpotLightMesh;
  134075. private static _CreateDirectionalLightMesh;
  134076. }
  134077. }
  134078. declare module BABYLON {
  134079. /**
  134080. * Gizmo that enables viewing a camera
  134081. */
  134082. export class CameraGizmo extends Gizmo {
  134083. private _cameraMesh;
  134084. private _cameraLinesMesh;
  134085. private _material;
  134086. private _pointerObserver;
  134087. /**
  134088. * Event that fires each time the gizmo is clicked
  134089. */
  134090. onClickedObservable: Observable<Camera>;
  134091. /**
  134092. * Creates a CameraGizmo
  134093. * @param gizmoLayer The utility layer the gizmo will be added to
  134094. */
  134095. constructor(gizmoLayer?: UtilityLayerRenderer);
  134096. private _camera;
  134097. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  134098. get displayFrustum(): boolean;
  134099. set displayFrustum(value: boolean);
  134100. /**
  134101. * The camera that the gizmo is attached to
  134102. */
  134103. set camera(camera: Nullable<Camera>);
  134104. get camera(): Nullable<Camera>;
  134105. /**
  134106. * Gets the material used to render the camera gizmo
  134107. */
  134108. get material(): StandardMaterial;
  134109. /**
  134110. * @hidden
  134111. * Updates the gizmo to match the attached mesh's position/rotation
  134112. */
  134113. protected _update(): void;
  134114. private static _Scale;
  134115. private _invProjection;
  134116. /**
  134117. * Disposes of the camera gizmo
  134118. */
  134119. dispose(): void;
  134120. private static _CreateCameraMesh;
  134121. private static _CreateCameraFrustum;
  134122. }
  134123. }
  134124. declare module BABYLON {
  134125. /** @hidden */
  134126. export var backgroundFragmentDeclaration: {
  134127. name: string;
  134128. shader: string;
  134129. };
  134130. }
  134131. declare module BABYLON {
  134132. /** @hidden */
  134133. export var backgroundUboDeclaration: {
  134134. name: string;
  134135. shader: string;
  134136. };
  134137. }
  134138. declare module BABYLON {
  134139. /** @hidden */
  134140. export var backgroundPixelShader: {
  134141. name: string;
  134142. shader: string;
  134143. };
  134144. }
  134145. declare module BABYLON {
  134146. /** @hidden */
  134147. export var backgroundVertexDeclaration: {
  134148. name: string;
  134149. shader: string;
  134150. };
  134151. }
  134152. declare module BABYLON {
  134153. /** @hidden */
  134154. export var backgroundVertexShader: {
  134155. name: string;
  134156. shader: string;
  134157. };
  134158. }
  134159. declare module BABYLON {
  134160. /**
  134161. * Background material used to create an efficient environement around your scene.
  134162. */
  134163. export class BackgroundMaterial extends PushMaterial {
  134164. /**
  134165. * Standard reflectance value at parallel view angle.
  134166. */
  134167. static StandardReflectance0: number;
  134168. /**
  134169. * Standard reflectance value at grazing angle.
  134170. */
  134171. static StandardReflectance90: number;
  134172. protected _primaryColor: Color3;
  134173. /**
  134174. * Key light Color (multiply against the environement texture)
  134175. */
  134176. primaryColor: Color3;
  134177. protected __perceptualColor: Nullable<Color3>;
  134178. /**
  134179. * Experimental Internal Use Only.
  134180. *
  134181. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  134182. * This acts as a helper to set the primary color to a more "human friendly" value.
  134183. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  134184. * output color as close as possible from the chosen value.
  134185. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  134186. * part of lighting setup.)
  134187. */
  134188. get _perceptualColor(): Nullable<Color3>;
  134189. set _perceptualColor(value: Nullable<Color3>);
  134190. protected _primaryColorShadowLevel: float;
  134191. /**
  134192. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  134193. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  134194. */
  134195. get primaryColorShadowLevel(): float;
  134196. set primaryColorShadowLevel(value: float);
  134197. protected _primaryColorHighlightLevel: float;
  134198. /**
  134199. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  134200. * The primary color is used at the level chosen to define what the white area would look.
  134201. */
  134202. get primaryColorHighlightLevel(): float;
  134203. set primaryColorHighlightLevel(value: float);
  134204. protected _reflectionTexture: Nullable<BaseTexture>;
  134205. /**
  134206. * Reflection Texture used in the material.
  134207. * Should be author in a specific way for the best result (refer to the documentation).
  134208. */
  134209. reflectionTexture: Nullable<BaseTexture>;
  134210. protected _reflectionBlur: float;
  134211. /**
  134212. * Reflection Texture level of blur.
  134213. *
  134214. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  134215. * texture twice.
  134216. */
  134217. reflectionBlur: float;
  134218. protected _diffuseTexture: Nullable<BaseTexture>;
  134219. /**
  134220. * Diffuse Texture used in the material.
  134221. * Should be author in a specific way for the best result (refer to the documentation).
  134222. */
  134223. diffuseTexture: Nullable<BaseTexture>;
  134224. protected _shadowLights: Nullable<IShadowLight[]>;
  134225. /**
  134226. * Specify the list of lights casting shadow on the material.
  134227. * All scene shadow lights will be included if null.
  134228. */
  134229. shadowLights: Nullable<IShadowLight[]>;
  134230. protected _shadowLevel: float;
  134231. /**
  134232. * Helps adjusting the shadow to a softer level if required.
  134233. * 0 means black shadows and 1 means no shadows.
  134234. */
  134235. shadowLevel: float;
  134236. protected _sceneCenter: Vector3;
  134237. /**
  134238. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  134239. * It is usually zero but might be interesting to modify according to your setup.
  134240. */
  134241. sceneCenter: Vector3;
  134242. protected _opacityFresnel: boolean;
  134243. /**
  134244. * This helps specifying that the material is falling off to the sky box at grazing angle.
  134245. * This helps ensuring a nice transition when the camera goes under the ground.
  134246. */
  134247. opacityFresnel: boolean;
  134248. protected _reflectionFresnel: boolean;
  134249. /**
  134250. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  134251. * This helps adding a mirror texture on the ground.
  134252. */
  134253. reflectionFresnel: boolean;
  134254. protected _reflectionFalloffDistance: number;
  134255. /**
  134256. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  134257. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  134258. */
  134259. reflectionFalloffDistance: number;
  134260. protected _reflectionAmount: number;
  134261. /**
  134262. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  134263. */
  134264. reflectionAmount: number;
  134265. protected _reflectionReflectance0: number;
  134266. /**
  134267. * This specifies the weight of the reflection at grazing angle.
  134268. */
  134269. reflectionReflectance0: number;
  134270. protected _reflectionReflectance90: number;
  134271. /**
  134272. * This specifies the weight of the reflection at a perpendicular point of view.
  134273. */
  134274. reflectionReflectance90: number;
  134275. /**
  134276. * Sets the reflection reflectance fresnel values according to the default standard
  134277. * empirically know to work well :-)
  134278. */
  134279. set reflectionStandardFresnelWeight(value: number);
  134280. protected _useRGBColor: boolean;
  134281. /**
  134282. * Helps to directly use the maps channels instead of their level.
  134283. */
  134284. useRGBColor: boolean;
  134285. protected _enableNoise: boolean;
  134286. /**
  134287. * This helps reducing the banding effect that could occur on the background.
  134288. */
  134289. enableNoise: boolean;
  134290. /**
  134291. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  134292. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  134293. * Recommended to be keep at 1.0 except for special cases.
  134294. */
  134295. get fovMultiplier(): number;
  134296. set fovMultiplier(value: number);
  134297. private _fovMultiplier;
  134298. /**
  134299. * Enable the FOV adjustment feature controlled by fovMultiplier.
  134300. */
  134301. useEquirectangularFOV: boolean;
  134302. private _maxSimultaneousLights;
  134303. /**
  134304. * Number of Simultaneous lights allowed on the material.
  134305. */
  134306. maxSimultaneousLights: int;
  134307. private _shadowOnly;
  134308. /**
  134309. * Make the material only render shadows
  134310. */
  134311. shadowOnly: boolean;
  134312. /**
  134313. * Default configuration related to image processing available in the Background Material.
  134314. */
  134315. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  134316. /**
  134317. * Keep track of the image processing observer to allow dispose and replace.
  134318. */
  134319. private _imageProcessingObserver;
  134320. /**
  134321. * Attaches a new image processing configuration to the PBR Material.
  134322. * @param configuration (if null the scene configuration will be use)
  134323. */
  134324. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  134325. /**
  134326. * Gets the image processing configuration used either in this material.
  134327. */
  134328. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  134329. /**
  134330. * Sets the Default image processing configuration used either in the this material.
  134331. *
  134332. * If sets to null, the scene one is in use.
  134333. */
  134334. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  134335. /**
  134336. * Gets wether the color curves effect is enabled.
  134337. */
  134338. get cameraColorCurvesEnabled(): boolean;
  134339. /**
  134340. * Sets wether the color curves effect is enabled.
  134341. */
  134342. set cameraColorCurvesEnabled(value: boolean);
  134343. /**
  134344. * Gets wether the color grading effect is enabled.
  134345. */
  134346. get cameraColorGradingEnabled(): boolean;
  134347. /**
  134348. * Gets wether the color grading effect is enabled.
  134349. */
  134350. set cameraColorGradingEnabled(value: boolean);
  134351. /**
  134352. * Gets wether tonemapping is enabled or not.
  134353. */
  134354. get cameraToneMappingEnabled(): boolean;
  134355. /**
  134356. * Sets wether tonemapping is enabled or not
  134357. */
  134358. set cameraToneMappingEnabled(value: boolean);
  134359. /**
  134360. * The camera exposure used on this material.
  134361. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134362. * This corresponds to a photographic exposure.
  134363. */
  134364. get cameraExposure(): float;
  134365. /**
  134366. * The camera exposure used on this material.
  134367. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134368. * This corresponds to a photographic exposure.
  134369. */
  134370. set cameraExposure(value: float);
  134371. /**
  134372. * Gets The camera contrast used on this material.
  134373. */
  134374. get cameraContrast(): float;
  134375. /**
  134376. * Sets The camera contrast used on this material.
  134377. */
  134378. set cameraContrast(value: float);
  134379. /**
  134380. * Gets the Color Grading 2D Lookup Texture.
  134381. */
  134382. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  134383. /**
  134384. * Sets the Color Grading 2D Lookup Texture.
  134385. */
  134386. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  134387. /**
  134388. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134389. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134390. * 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;
  134391. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134392. */
  134393. get cameraColorCurves(): Nullable<ColorCurves>;
  134394. /**
  134395. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134396. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134397. * 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;
  134398. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134399. */
  134400. set cameraColorCurves(value: Nullable<ColorCurves>);
  134401. /**
  134402. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  134403. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  134404. */
  134405. switchToBGR: boolean;
  134406. private _renderTargets;
  134407. private _reflectionControls;
  134408. private _white;
  134409. private _primaryShadowColor;
  134410. private _primaryHighlightColor;
  134411. /**
  134412. * Instantiates a Background Material in the given scene
  134413. * @param name The friendly name of the material
  134414. * @param scene The scene to add the material to
  134415. */
  134416. constructor(name: string, scene: Scene);
  134417. /**
  134418. * Gets a boolean indicating that current material needs to register RTT
  134419. */
  134420. get hasRenderTargetTextures(): boolean;
  134421. /**
  134422. * The entire material has been created in order to prevent overdraw.
  134423. * @returns false
  134424. */
  134425. needAlphaTesting(): boolean;
  134426. /**
  134427. * The entire material has been created in order to prevent overdraw.
  134428. * @returns true if blending is enable
  134429. */
  134430. needAlphaBlending(): boolean;
  134431. /**
  134432. * Checks wether the material is ready to be rendered for a given mesh.
  134433. * @param mesh The mesh to render
  134434. * @param subMesh The submesh to check against
  134435. * @param useInstances Specify wether or not the material is used with instances
  134436. * @returns true if all the dependencies are ready (Textures, Effects...)
  134437. */
  134438. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  134439. /**
  134440. * Compute the primary color according to the chosen perceptual color.
  134441. */
  134442. private _computePrimaryColorFromPerceptualColor;
  134443. /**
  134444. * Compute the highlights and shadow colors according to their chosen levels.
  134445. */
  134446. private _computePrimaryColors;
  134447. /**
  134448. * Build the uniform buffer used in the material.
  134449. */
  134450. buildUniformLayout(): void;
  134451. /**
  134452. * Unbind the material.
  134453. */
  134454. unbind(): void;
  134455. /**
  134456. * Bind only the world matrix to the material.
  134457. * @param world The world matrix to bind.
  134458. */
  134459. bindOnlyWorldMatrix(world: Matrix): void;
  134460. /**
  134461. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  134462. * @param world The world matrix to bind.
  134463. * @param subMesh The submesh to bind for.
  134464. */
  134465. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  134466. /**
  134467. * Checks to see if a texture is used in the material.
  134468. * @param texture - Base texture to use.
  134469. * @returns - Boolean specifying if a texture is used in the material.
  134470. */
  134471. hasTexture(texture: BaseTexture): boolean;
  134472. /**
  134473. * Dispose the material.
  134474. * @param forceDisposeEffect Force disposal of the associated effect.
  134475. * @param forceDisposeTextures Force disposal of the associated textures.
  134476. */
  134477. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  134478. /**
  134479. * Clones the material.
  134480. * @param name The cloned name.
  134481. * @returns The cloned material.
  134482. */
  134483. clone(name: string): BackgroundMaterial;
  134484. /**
  134485. * Serializes the current material to its JSON representation.
  134486. * @returns The JSON representation.
  134487. */
  134488. serialize(): any;
  134489. /**
  134490. * Gets the class name of the material
  134491. * @returns "BackgroundMaterial"
  134492. */
  134493. getClassName(): string;
  134494. /**
  134495. * Parse a JSON input to create back a background material.
  134496. * @param source The JSON data to parse
  134497. * @param scene The scene to create the parsed material in
  134498. * @param rootUrl The root url of the assets the material depends upon
  134499. * @returns the instantiated BackgroundMaterial.
  134500. */
  134501. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  134502. }
  134503. }
  134504. declare module BABYLON {
  134505. /**
  134506. * Represents the different options available during the creation of
  134507. * a Environment helper.
  134508. *
  134509. * This can control the default ground, skybox and image processing setup of your scene.
  134510. */
  134511. export interface IEnvironmentHelperOptions {
  134512. /**
  134513. * Specifies whether or not to create a ground.
  134514. * True by default.
  134515. */
  134516. createGround: boolean;
  134517. /**
  134518. * Specifies the ground size.
  134519. * 15 by default.
  134520. */
  134521. groundSize: number;
  134522. /**
  134523. * The texture used on the ground for the main color.
  134524. * Comes from the BabylonJS CDN by default.
  134525. *
  134526. * Remarks: Can be either a texture or a url.
  134527. */
  134528. groundTexture: string | BaseTexture;
  134529. /**
  134530. * The color mixed in the ground texture by default.
  134531. * BabylonJS clearColor by default.
  134532. */
  134533. groundColor: Color3;
  134534. /**
  134535. * Specifies the ground opacity.
  134536. * 1 by default.
  134537. */
  134538. groundOpacity: number;
  134539. /**
  134540. * Enables the ground to receive shadows.
  134541. * True by default.
  134542. */
  134543. enableGroundShadow: boolean;
  134544. /**
  134545. * Helps preventing the shadow to be fully black on the ground.
  134546. * 0.5 by default.
  134547. */
  134548. groundShadowLevel: number;
  134549. /**
  134550. * Creates a mirror texture attach to the ground.
  134551. * false by default.
  134552. */
  134553. enableGroundMirror: boolean;
  134554. /**
  134555. * Specifies the ground mirror size ratio.
  134556. * 0.3 by default as the default kernel is 64.
  134557. */
  134558. groundMirrorSizeRatio: number;
  134559. /**
  134560. * Specifies the ground mirror blur kernel size.
  134561. * 64 by default.
  134562. */
  134563. groundMirrorBlurKernel: number;
  134564. /**
  134565. * Specifies the ground mirror visibility amount.
  134566. * 1 by default
  134567. */
  134568. groundMirrorAmount: number;
  134569. /**
  134570. * Specifies the ground mirror reflectance weight.
  134571. * This uses the standard weight of the background material to setup the fresnel effect
  134572. * of the mirror.
  134573. * 1 by default.
  134574. */
  134575. groundMirrorFresnelWeight: number;
  134576. /**
  134577. * Specifies the ground mirror Falloff distance.
  134578. * This can helps reducing the size of the reflection.
  134579. * 0 by Default.
  134580. */
  134581. groundMirrorFallOffDistance: number;
  134582. /**
  134583. * Specifies the ground mirror texture type.
  134584. * Unsigned Int by Default.
  134585. */
  134586. groundMirrorTextureType: number;
  134587. /**
  134588. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  134589. * the shown objects.
  134590. */
  134591. groundYBias: number;
  134592. /**
  134593. * Specifies whether or not to create a skybox.
  134594. * True by default.
  134595. */
  134596. createSkybox: boolean;
  134597. /**
  134598. * Specifies the skybox size.
  134599. * 20 by default.
  134600. */
  134601. skyboxSize: number;
  134602. /**
  134603. * The texture used on the skybox for the main color.
  134604. * Comes from the BabylonJS CDN by default.
  134605. *
  134606. * Remarks: Can be either a texture or a url.
  134607. */
  134608. skyboxTexture: string | BaseTexture;
  134609. /**
  134610. * The color mixed in the skybox texture by default.
  134611. * BabylonJS clearColor by default.
  134612. */
  134613. skyboxColor: Color3;
  134614. /**
  134615. * The background rotation around the Y axis of the scene.
  134616. * This helps aligning the key lights of your scene with the background.
  134617. * 0 by default.
  134618. */
  134619. backgroundYRotation: number;
  134620. /**
  134621. * Compute automatically the size of the elements to best fit with the scene.
  134622. */
  134623. sizeAuto: boolean;
  134624. /**
  134625. * Default position of the rootMesh if autoSize is not true.
  134626. */
  134627. rootPosition: Vector3;
  134628. /**
  134629. * Sets up the image processing in the scene.
  134630. * true by default.
  134631. */
  134632. setupImageProcessing: boolean;
  134633. /**
  134634. * The texture used as your environment texture in the scene.
  134635. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  134636. *
  134637. * Remarks: Can be either a texture or a url.
  134638. */
  134639. environmentTexture: string | BaseTexture;
  134640. /**
  134641. * The value of the exposure to apply to the scene.
  134642. * 0.6 by default if setupImageProcessing is true.
  134643. */
  134644. cameraExposure: number;
  134645. /**
  134646. * The value of the contrast to apply to the scene.
  134647. * 1.6 by default if setupImageProcessing is true.
  134648. */
  134649. cameraContrast: number;
  134650. /**
  134651. * Specifies whether or not tonemapping should be enabled in the scene.
  134652. * true by default if setupImageProcessing is true.
  134653. */
  134654. toneMappingEnabled: boolean;
  134655. }
  134656. /**
  134657. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  134658. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  134659. * It also helps with the default setup of your imageProcessing configuration.
  134660. */
  134661. export class EnvironmentHelper {
  134662. /**
  134663. * Default ground texture URL.
  134664. */
  134665. private static _groundTextureCDNUrl;
  134666. /**
  134667. * Default skybox texture URL.
  134668. */
  134669. private static _skyboxTextureCDNUrl;
  134670. /**
  134671. * Default environment texture URL.
  134672. */
  134673. private static _environmentTextureCDNUrl;
  134674. /**
  134675. * Creates the default options for the helper.
  134676. */
  134677. private static _getDefaultOptions;
  134678. private _rootMesh;
  134679. /**
  134680. * Gets the root mesh created by the helper.
  134681. */
  134682. get rootMesh(): Mesh;
  134683. private _skybox;
  134684. /**
  134685. * Gets the skybox created by the helper.
  134686. */
  134687. get skybox(): Nullable<Mesh>;
  134688. private _skyboxTexture;
  134689. /**
  134690. * Gets the skybox texture created by the helper.
  134691. */
  134692. get skyboxTexture(): Nullable<BaseTexture>;
  134693. private _skyboxMaterial;
  134694. /**
  134695. * Gets the skybox material created by the helper.
  134696. */
  134697. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  134698. private _ground;
  134699. /**
  134700. * Gets the ground mesh created by the helper.
  134701. */
  134702. get ground(): Nullable<Mesh>;
  134703. private _groundTexture;
  134704. /**
  134705. * Gets the ground texture created by the helper.
  134706. */
  134707. get groundTexture(): Nullable<BaseTexture>;
  134708. private _groundMirror;
  134709. /**
  134710. * Gets the ground mirror created by the helper.
  134711. */
  134712. get groundMirror(): Nullable<MirrorTexture>;
  134713. /**
  134714. * Gets the ground mirror render list to helps pushing the meshes
  134715. * you wish in the ground reflection.
  134716. */
  134717. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  134718. private _groundMaterial;
  134719. /**
  134720. * Gets the ground material created by the helper.
  134721. */
  134722. get groundMaterial(): Nullable<BackgroundMaterial>;
  134723. /**
  134724. * Stores the creation options.
  134725. */
  134726. private readonly _scene;
  134727. private _options;
  134728. /**
  134729. * This observable will be notified with any error during the creation of the environment,
  134730. * mainly texture creation errors.
  134731. */
  134732. onErrorObservable: Observable<{
  134733. message?: string;
  134734. exception?: any;
  134735. }>;
  134736. /**
  134737. * constructor
  134738. * @param options Defines the options we want to customize the helper
  134739. * @param scene The scene to add the material to
  134740. */
  134741. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  134742. /**
  134743. * Updates the background according to the new options
  134744. * @param options
  134745. */
  134746. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  134747. /**
  134748. * Sets the primary color of all the available elements.
  134749. * @param color the main color to affect to the ground and the background
  134750. */
  134751. setMainColor(color: Color3): void;
  134752. /**
  134753. * Setup the image processing according to the specified options.
  134754. */
  134755. private _setupImageProcessing;
  134756. /**
  134757. * Setup the environment texture according to the specified options.
  134758. */
  134759. private _setupEnvironmentTexture;
  134760. /**
  134761. * Setup the background according to the specified options.
  134762. */
  134763. private _setupBackground;
  134764. /**
  134765. * Get the scene sizes according to the setup.
  134766. */
  134767. private _getSceneSize;
  134768. /**
  134769. * Setup the ground according to the specified options.
  134770. */
  134771. private _setupGround;
  134772. /**
  134773. * Setup the ground material according to the specified options.
  134774. */
  134775. private _setupGroundMaterial;
  134776. /**
  134777. * Setup the ground diffuse texture according to the specified options.
  134778. */
  134779. private _setupGroundDiffuseTexture;
  134780. /**
  134781. * Setup the ground mirror texture according to the specified options.
  134782. */
  134783. private _setupGroundMirrorTexture;
  134784. /**
  134785. * Setup the ground to receive the mirror texture.
  134786. */
  134787. private _setupMirrorInGroundMaterial;
  134788. /**
  134789. * Setup the skybox according to the specified options.
  134790. */
  134791. private _setupSkybox;
  134792. /**
  134793. * Setup the skybox material according to the specified options.
  134794. */
  134795. private _setupSkyboxMaterial;
  134796. /**
  134797. * Setup the skybox reflection texture according to the specified options.
  134798. */
  134799. private _setupSkyboxReflectionTexture;
  134800. private _errorHandler;
  134801. /**
  134802. * Dispose all the elements created by the Helper.
  134803. */
  134804. dispose(): void;
  134805. }
  134806. }
  134807. declare module BABYLON {
  134808. /**
  134809. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  134810. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  134811. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  134812. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  134813. */
  134814. export abstract class TextureDome<T extends Texture> extends TransformNode {
  134815. protected onError: Nullable<(message?: string, exception?: any) => void>;
  134816. /**
  134817. * Define the source as a Monoscopic panoramic 360/180.
  134818. */
  134819. static readonly MODE_MONOSCOPIC: number;
  134820. /**
  134821. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  134822. */
  134823. static readonly MODE_TOPBOTTOM: number;
  134824. /**
  134825. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  134826. */
  134827. static readonly MODE_SIDEBYSIDE: number;
  134828. private _halfDome;
  134829. protected _useDirectMapping: boolean;
  134830. /**
  134831. * The texture being displayed on the sphere
  134832. */
  134833. protected _texture: T;
  134834. /**
  134835. * Gets the texture being displayed on the sphere
  134836. */
  134837. get texture(): T;
  134838. /**
  134839. * Sets the texture being displayed on the sphere
  134840. */
  134841. set texture(newTexture: T);
  134842. /**
  134843. * The skybox material
  134844. */
  134845. protected _material: BackgroundMaterial;
  134846. /**
  134847. * The surface used for the dome
  134848. */
  134849. protected _mesh: Mesh;
  134850. /**
  134851. * Gets the mesh used for the dome.
  134852. */
  134853. get mesh(): Mesh;
  134854. /**
  134855. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  134856. */
  134857. private _halfDomeMask;
  134858. /**
  134859. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  134860. * Also see the options.resolution property.
  134861. */
  134862. get fovMultiplier(): number;
  134863. set fovMultiplier(value: number);
  134864. protected _textureMode: number;
  134865. /**
  134866. * Gets or set the current texture mode for the texture. It can be:
  134867. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  134868. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  134869. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  134870. */
  134871. get textureMode(): number;
  134872. /**
  134873. * Sets the current texture mode for the texture. It can be:
  134874. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  134875. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  134876. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  134877. */
  134878. set textureMode(value: number);
  134879. /**
  134880. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  134881. */
  134882. get halfDome(): boolean;
  134883. /**
  134884. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  134885. */
  134886. set halfDome(enabled: boolean);
  134887. /**
  134888. * Oberserver used in Stereoscopic VR Mode.
  134889. */
  134890. private _onBeforeCameraRenderObserver;
  134891. /**
  134892. * Observable raised when an error occured while loading the 360 image
  134893. */
  134894. onLoadErrorObservable: Observable<string>;
  134895. /**
  134896. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  134897. * @param name Element's name, child elements will append suffixes for their own names.
  134898. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  134899. * @param options An object containing optional or exposed sub element properties
  134900. */
  134901. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  134902. resolution?: number;
  134903. clickToPlay?: boolean;
  134904. autoPlay?: boolean;
  134905. loop?: boolean;
  134906. size?: number;
  134907. poster?: string;
  134908. faceForward?: boolean;
  134909. useDirectMapping?: boolean;
  134910. halfDomeMode?: boolean;
  134911. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  134912. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  134913. protected _changeTextureMode(value: number): void;
  134914. /**
  134915. * Releases resources associated with this node.
  134916. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  134917. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  134918. */
  134919. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  134920. }
  134921. }
  134922. declare module BABYLON {
  134923. /**
  134924. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  134925. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  134926. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  134927. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  134928. */
  134929. export class PhotoDome extends TextureDome<Texture> {
  134930. /**
  134931. * Define the image as a Monoscopic panoramic 360 image.
  134932. */
  134933. static readonly MODE_MONOSCOPIC: number;
  134934. /**
  134935. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  134936. */
  134937. static readonly MODE_TOPBOTTOM: number;
  134938. /**
  134939. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  134940. */
  134941. static readonly MODE_SIDEBYSIDE: number;
  134942. /**
  134943. * Gets or sets the texture being displayed on the sphere
  134944. */
  134945. get photoTexture(): Texture;
  134946. /**
  134947. * sets the texture being displayed on the sphere
  134948. */
  134949. set photoTexture(value: Texture);
  134950. /**
  134951. * Gets the current video mode for the video. It can be:
  134952. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  134953. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  134954. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  134955. */
  134956. get imageMode(): number;
  134957. /**
  134958. * Sets the current video mode for the video. It can be:
  134959. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  134960. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  134961. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  134962. */
  134963. set imageMode(value: number);
  134964. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  134965. }
  134966. }
  134967. declare module BABYLON {
  134968. /**
  134969. * Class used to host RGBD texture specific utilities
  134970. */
  134971. export class RGBDTextureTools {
  134972. /**
  134973. * Expand the RGBD Texture from RGBD to Half Float if possible.
  134974. * @param texture the texture to expand.
  134975. */
  134976. static ExpandRGBDTexture(texture: Texture): void;
  134977. }
  134978. }
  134979. declare module BABYLON {
  134980. /**
  134981. * Class used to host texture specific utilities
  134982. */
  134983. export class BRDFTextureTools {
  134984. /**
  134985. * Prevents texture cache collision
  134986. */
  134987. private static _instanceNumber;
  134988. /**
  134989. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  134990. * @param scene defines the hosting scene
  134991. * @returns the environment BRDF texture
  134992. */
  134993. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  134994. private static _environmentBRDFBase64Texture;
  134995. }
  134996. }
  134997. declare module BABYLON {
  134998. /**
  134999. * @hidden
  135000. */
  135001. export interface IMaterialClearCoatDefines {
  135002. CLEARCOAT: boolean;
  135003. CLEARCOAT_DEFAULTIOR: boolean;
  135004. CLEARCOAT_TEXTURE: boolean;
  135005. CLEARCOAT_TEXTUREDIRECTUV: number;
  135006. CLEARCOAT_BUMP: boolean;
  135007. CLEARCOAT_BUMPDIRECTUV: number;
  135008. CLEARCOAT_TINT: boolean;
  135009. CLEARCOAT_TINT_TEXTURE: boolean;
  135010. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  135011. /** @hidden */
  135012. _areTexturesDirty: boolean;
  135013. }
  135014. /**
  135015. * Define the code related to the clear coat parameters of the pbr material.
  135016. */
  135017. export class PBRClearCoatConfiguration {
  135018. /**
  135019. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  135020. * The default fits with a polyurethane material.
  135021. */
  135022. private static readonly _DefaultIndexOfRefraction;
  135023. private _isEnabled;
  135024. /**
  135025. * Defines if the clear coat is enabled in the material.
  135026. */
  135027. isEnabled: boolean;
  135028. /**
  135029. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  135030. */
  135031. intensity: number;
  135032. /**
  135033. * Defines the clear coat layer roughness.
  135034. */
  135035. roughness: number;
  135036. private _indexOfRefraction;
  135037. /**
  135038. * Defines the index of refraction of the clear coat.
  135039. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  135040. * The default fits with a polyurethane material.
  135041. * Changing the default value is more performance intensive.
  135042. */
  135043. indexOfRefraction: number;
  135044. private _texture;
  135045. /**
  135046. * Stores the clear coat values in a texture.
  135047. */
  135048. texture: Nullable<BaseTexture>;
  135049. private _bumpTexture;
  135050. /**
  135051. * Define the clear coat specific bump texture.
  135052. */
  135053. bumpTexture: Nullable<BaseTexture>;
  135054. private _isTintEnabled;
  135055. /**
  135056. * Defines if the clear coat tint is enabled in the material.
  135057. */
  135058. isTintEnabled: boolean;
  135059. /**
  135060. * Defines the clear coat tint of the material.
  135061. * This is only use if tint is enabled
  135062. */
  135063. tintColor: Color3;
  135064. /**
  135065. * Defines the distance at which the tint color should be found in the
  135066. * clear coat media.
  135067. * This is only use if tint is enabled
  135068. */
  135069. tintColorAtDistance: number;
  135070. /**
  135071. * Defines the clear coat layer thickness.
  135072. * This is only use if tint is enabled
  135073. */
  135074. tintThickness: number;
  135075. private _tintTexture;
  135076. /**
  135077. * Stores the clear tint values in a texture.
  135078. * rgb is tint
  135079. * a is a thickness factor
  135080. */
  135081. tintTexture: Nullable<BaseTexture>;
  135082. /** @hidden */
  135083. private _internalMarkAllSubMeshesAsTexturesDirty;
  135084. /** @hidden */
  135085. _markAllSubMeshesAsTexturesDirty(): void;
  135086. /**
  135087. * Instantiate a new istance of clear coat configuration.
  135088. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135089. */
  135090. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135091. /**
  135092. * Gets wehter the submesh is ready to be used or not.
  135093. * @param defines the list of "defines" to update.
  135094. * @param scene defines the scene the material belongs to.
  135095. * @param engine defines the engine the material belongs to.
  135096. * @param disableBumpMap defines wether the material disables bump or not.
  135097. * @returns - boolean indicating that the submesh is ready or not.
  135098. */
  135099. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  135100. /**
  135101. * Checks to see if a texture is used in the material.
  135102. * @param defines the list of "defines" to update.
  135103. * @param scene defines the scene to the material belongs to.
  135104. */
  135105. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  135106. /**
  135107. * Binds the material data.
  135108. * @param uniformBuffer defines the Uniform buffer to fill in.
  135109. * @param scene defines the scene the material belongs to.
  135110. * @param engine defines the engine the material belongs to.
  135111. * @param disableBumpMap defines wether the material disables bump or not.
  135112. * @param isFrozen defines wether the material is frozen or not.
  135113. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  135114. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  135115. */
  135116. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  135117. /**
  135118. * Checks to see if a texture is used in the material.
  135119. * @param texture - Base texture to use.
  135120. * @returns - Boolean specifying if a texture is used in the material.
  135121. */
  135122. hasTexture(texture: BaseTexture): boolean;
  135123. /**
  135124. * Returns an array of the actively used textures.
  135125. * @param activeTextures Array of BaseTextures
  135126. */
  135127. getActiveTextures(activeTextures: BaseTexture[]): void;
  135128. /**
  135129. * Returns the animatable textures.
  135130. * @param animatables Array of animatable textures.
  135131. */
  135132. getAnimatables(animatables: IAnimatable[]): void;
  135133. /**
  135134. * Disposes the resources of the material.
  135135. * @param forceDisposeTextures - Forces the disposal of all textures.
  135136. */
  135137. dispose(forceDisposeTextures?: boolean): void;
  135138. /**
  135139. * Get the current class name of the texture useful for serialization or dynamic coding.
  135140. * @returns "PBRClearCoatConfiguration"
  135141. */
  135142. getClassName(): string;
  135143. /**
  135144. * Add fallbacks to the effect fallbacks list.
  135145. * @param defines defines the Base texture to use.
  135146. * @param fallbacks defines the current fallback list.
  135147. * @param currentRank defines the current fallback rank.
  135148. * @returns the new fallback rank.
  135149. */
  135150. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135151. /**
  135152. * Add the required uniforms to the current list.
  135153. * @param uniforms defines the current uniform list.
  135154. */
  135155. static AddUniforms(uniforms: string[]): void;
  135156. /**
  135157. * Add the required samplers to the current list.
  135158. * @param samplers defines the current sampler list.
  135159. */
  135160. static AddSamplers(samplers: string[]): void;
  135161. /**
  135162. * Add the required uniforms to the current buffer.
  135163. * @param uniformBuffer defines the current uniform buffer.
  135164. */
  135165. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135166. /**
  135167. * Makes a duplicate of the current configuration into another one.
  135168. * @param clearCoatConfiguration define the config where to copy the info
  135169. */
  135170. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  135171. /**
  135172. * Serializes this clear coat configuration.
  135173. * @returns - An object with the serialized config.
  135174. */
  135175. serialize(): any;
  135176. /**
  135177. * Parses a anisotropy Configuration from a serialized object.
  135178. * @param source - Serialized object.
  135179. * @param scene Defines the scene we are parsing for
  135180. * @param rootUrl Defines the rootUrl to load from
  135181. */
  135182. parse(source: any, scene: Scene, rootUrl: string): void;
  135183. }
  135184. }
  135185. declare module BABYLON {
  135186. /**
  135187. * @hidden
  135188. */
  135189. export interface IMaterialAnisotropicDefines {
  135190. ANISOTROPIC: boolean;
  135191. ANISOTROPIC_TEXTURE: boolean;
  135192. ANISOTROPIC_TEXTUREDIRECTUV: number;
  135193. MAINUV1: boolean;
  135194. _areTexturesDirty: boolean;
  135195. _needUVs: boolean;
  135196. }
  135197. /**
  135198. * Define the code related to the anisotropic parameters of the pbr material.
  135199. */
  135200. export class PBRAnisotropicConfiguration {
  135201. private _isEnabled;
  135202. /**
  135203. * Defines if the anisotropy is enabled in the material.
  135204. */
  135205. isEnabled: boolean;
  135206. /**
  135207. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  135208. */
  135209. intensity: number;
  135210. /**
  135211. * Defines if the effect is along the tangents, bitangents or in between.
  135212. * By default, the effect is "strectching" the highlights along the tangents.
  135213. */
  135214. direction: Vector2;
  135215. private _texture;
  135216. /**
  135217. * Stores the anisotropy values in a texture.
  135218. * rg is direction (like normal from -1 to 1)
  135219. * b is a intensity
  135220. */
  135221. texture: Nullable<BaseTexture>;
  135222. /** @hidden */
  135223. private _internalMarkAllSubMeshesAsTexturesDirty;
  135224. /** @hidden */
  135225. _markAllSubMeshesAsTexturesDirty(): void;
  135226. /**
  135227. * Instantiate a new istance of anisotropy configuration.
  135228. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135229. */
  135230. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135231. /**
  135232. * Specifies that the submesh is ready to be used.
  135233. * @param defines the list of "defines" to update.
  135234. * @param scene defines the scene the material belongs to.
  135235. * @returns - boolean indicating that the submesh is ready or not.
  135236. */
  135237. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  135238. /**
  135239. * Checks to see if a texture is used in the material.
  135240. * @param defines the list of "defines" to update.
  135241. * @param mesh the mesh we are preparing the defines for.
  135242. * @param scene defines the scene the material belongs to.
  135243. */
  135244. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  135245. /**
  135246. * Binds the material data.
  135247. * @param uniformBuffer defines the Uniform buffer to fill in.
  135248. * @param scene defines the scene the material belongs to.
  135249. * @param isFrozen defines wether the material is frozen or not.
  135250. */
  135251. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  135252. /**
  135253. * Checks to see if a texture is used in the material.
  135254. * @param texture - Base texture to use.
  135255. * @returns - Boolean specifying if a texture is used in the material.
  135256. */
  135257. hasTexture(texture: BaseTexture): boolean;
  135258. /**
  135259. * Returns an array of the actively used textures.
  135260. * @param activeTextures Array of BaseTextures
  135261. */
  135262. getActiveTextures(activeTextures: BaseTexture[]): void;
  135263. /**
  135264. * Returns the animatable textures.
  135265. * @param animatables Array of animatable textures.
  135266. */
  135267. getAnimatables(animatables: IAnimatable[]): void;
  135268. /**
  135269. * Disposes the resources of the material.
  135270. * @param forceDisposeTextures - Forces the disposal of all textures.
  135271. */
  135272. dispose(forceDisposeTextures?: boolean): void;
  135273. /**
  135274. * Get the current class name of the texture useful for serialization or dynamic coding.
  135275. * @returns "PBRAnisotropicConfiguration"
  135276. */
  135277. getClassName(): string;
  135278. /**
  135279. * Add fallbacks to the effect fallbacks list.
  135280. * @param defines defines the Base texture to use.
  135281. * @param fallbacks defines the current fallback list.
  135282. * @param currentRank defines the current fallback rank.
  135283. * @returns the new fallback rank.
  135284. */
  135285. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135286. /**
  135287. * Add the required uniforms to the current list.
  135288. * @param uniforms defines the current uniform list.
  135289. */
  135290. static AddUniforms(uniforms: string[]): void;
  135291. /**
  135292. * Add the required uniforms to the current buffer.
  135293. * @param uniformBuffer defines the current uniform buffer.
  135294. */
  135295. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135296. /**
  135297. * Add the required samplers to the current list.
  135298. * @param samplers defines the current sampler list.
  135299. */
  135300. static AddSamplers(samplers: string[]): void;
  135301. /**
  135302. * Makes a duplicate of the current configuration into another one.
  135303. * @param anisotropicConfiguration define the config where to copy the info
  135304. */
  135305. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  135306. /**
  135307. * Serializes this anisotropy configuration.
  135308. * @returns - An object with the serialized config.
  135309. */
  135310. serialize(): any;
  135311. /**
  135312. * Parses a anisotropy Configuration from a serialized object.
  135313. * @param source - Serialized object.
  135314. * @param scene Defines the scene we are parsing for
  135315. * @param rootUrl Defines the rootUrl to load from
  135316. */
  135317. parse(source: any, scene: Scene, rootUrl: string): void;
  135318. }
  135319. }
  135320. declare module BABYLON {
  135321. /**
  135322. * @hidden
  135323. */
  135324. export interface IMaterialBRDFDefines {
  135325. BRDF_V_HEIGHT_CORRELATED: boolean;
  135326. MS_BRDF_ENERGY_CONSERVATION: boolean;
  135327. SPHERICAL_HARMONICS: boolean;
  135328. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  135329. /** @hidden */
  135330. _areMiscDirty: boolean;
  135331. }
  135332. /**
  135333. * Define the code related to the BRDF parameters of the pbr material.
  135334. */
  135335. export class PBRBRDFConfiguration {
  135336. /**
  135337. * Default value used for the energy conservation.
  135338. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  135339. */
  135340. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  135341. /**
  135342. * Default value used for the Smith Visibility Height Correlated mode.
  135343. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  135344. */
  135345. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  135346. /**
  135347. * Default value used for the IBL diffuse part.
  135348. * This can help switching back to the polynomials mode globally which is a tiny bit
  135349. * less GPU intensive at the drawback of a lower quality.
  135350. */
  135351. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  135352. /**
  135353. * Default value used for activating energy conservation for the specular workflow.
  135354. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  135355. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  135356. */
  135357. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  135358. private _useEnergyConservation;
  135359. /**
  135360. * Defines if the material uses energy conservation.
  135361. */
  135362. useEnergyConservation: boolean;
  135363. private _useSmithVisibilityHeightCorrelated;
  135364. /**
  135365. * LEGACY Mode set to false
  135366. * Defines if the material uses height smith correlated visibility term.
  135367. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  135368. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  135369. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  135370. * Not relying on height correlated will also disable energy conservation.
  135371. */
  135372. useSmithVisibilityHeightCorrelated: boolean;
  135373. private _useSphericalHarmonics;
  135374. /**
  135375. * LEGACY Mode set to false
  135376. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  135377. * diffuse part of the IBL.
  135378. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  135379. * to the ground truth.
  135380. */
  135381. useSphericalHarmonics: boolean;
  135382. private _useSpecularGlossinessInputEnergyConservation;
  135383. /**
  135384. * Defines if the material uses energy conservation, when the specular workflow is active.
  135385. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  135386. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  135387. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  135388. */
  135389. useSpecularGlossinessInputEnergyConservation: boolean;
  135390. /** @hidden */
  135391. private _internalMarkAllSubMeshesAsMiscDirty;
  135392. /** @hidden */
  135393. _markAllSubMeshesAsMiscDirty(): void;
  135394. /**
  135395. * Instantiate a new istance of clear coat configuration.
  135396. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  135397. */
  135398. constructor(markAllSubMeshesAsMiscDirty: () => void);
  135399. /**
  135400. * Checks to see if a texture is used in the material.
  135401. * @param defines the list of "defines" to update.
  135402. */
  135403. prepareDefines(defines: IMaterialBRDFDefines): void;
  135404. /**
  135405. * Get the current class name of the texture useful for serialization or dynamic coding.
  135406. * @returns "PBRClearCoatConfiguration"
  135407. */
  135408. getClassName(): string;
  135409. /**
  135410. * Makes a duplicate of the current configuration into another one.
  135411. * @param brdfConfiguration define the config where to copy the info
  135412. */
  135413. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  135414. /**
  135415. * Serializes this BRDF configuration.
  135416. * @returns - An object with the serialized config.
  135417. */
  135418. serialize(): any;
  135419. /**
  135420. * Parses a anisotropy Configuration from a serialized object.
  135421. * @param source - Serialized object.
  135422. * @param scene Defines the scene we are parsing for
  135423. * @param rootUrl Defines the rootUrl to load from
  135424. */
  135425. parse(source: any, scene: Scene, rootUrl: string): void;
  135426. }
  135427. }
  135428. declare module BABYLON {
  135429. /**
  135430. * @hidden
  135431. */
  135432. export interface IMaterialSheenDefines {
  135433. SHEEN: boolean;
  135434. SHEEN_TEXTURE: boolean;
  135435. SHEEN_TEXTUREDIRECTUV: number;
  135436. SHEEN_LINKWITHALBEDO: boolean;
  135437. SHEEN_ROUGHNESS: boolean;
  135438. SHEEN_ALBEDOSCALING: boolean;
  135439. /** @hidden */
  135440. _areTexturesDirty: boolean;
  135441. }
  135442. /**
  135443. * Define the code related to the Sheen parameters of the pbr material.
  135444. */
  135445. export class PBRSheenConfiguration {
  135446. private _isEnabled;
  135447. /**
  135448. * Defines if the material uses sheen.
  135449. */
  135450. isEnabled: boolean;
  135451. private _linkSheenWithAlbedo;
  135452. /**
  135453. * Defines if the sheen is linked to the sheen color.
  135454. */
  135455. linkSheenWithAlbedo: boolean;
  135456. /**
  135457. * Defines the sheen intensity.
  135458. */
  135459. intensity: number;
  135460. /**
  135461. * Defines the sheen color.
  135462. */
  135463. color: Color3;
  135464. private _texture;
  135465. /**
  135466. * Stores the sheen tint values in a texture.
  135467. * rgb is tint
  135468. * a is a intensity or roughness if roughness has been defined
  135469. */
  135470. texture: Nullable<BaseTexture>;
  135471. private _roughness;
  135472. /**
  135473. * Defines the sheen roughness.
  135474. * It is not taken into account if linkSheenWithAlbedo is true.
  135475. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  135476. */
  135477. roughness: Nullable<number>;
  135478. private _albedoScaling;
  135479. /**
  135480. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  135481. * It allows the strength of the sheen effect to not depend on the base color of the material,
  135482. * making it easier to setup and tweak the effect
  135483. */
  135484. albedoScaling: boolean;
  135485. /** @hidden */
  135486. private _internalMarkAllSubMeshesAsTexturesDirty;
  135487. /** @hidden */
  135488. _markAllSubMeshesAsTexturesDirty(): void;
  135489. /**
  135490. * Instantiate a new istance of clear coat configuration.
  135491. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135492. */
  135493. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135494. /**
  135495. * Specifies that the submesh is ready to be used.
  135496. * @param defines the list of "defines" to update.
  135497. * @param scene defines the scene the material belongs to.
  135498. * @returns - boolean indicating that the submesh is ready or not.
  135499. */
  135500. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  135501. /**
  135502. * Checks to see if a texture is used in the material.
  135503. * @param defines the list of "defines" to update.
  135504. * @param scene defines the scene the material belongs to.
  135505. */
  135506. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  135507. /**
  135508. * Binds the material data.
  135509. * @param uniformBuffer defines the Uniform buffer to fill in.
  135510. * @param scene defines the scene the material belongs to.
  135511. * @param isFrozen defines wether the material is frozen or not.
  135512. */
  135513. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  135514. /**
  135515. * Checks to see if a texture is used in the material.
  135516. * @param texture - Base texture to use.
  135517. * @returns - Boolean specifying if a texture is used in the material.
  135518. */
  135519. hasTexture(texture: BaseTexture): boolean;
  135520. /**
  135521. * Returns an array of the actively used textures.
  135522. * @param activeTextures Array of BaseTextures
  135523. */
  135524. getActiveTextures(activeTextures: BaseTexture[]): void;
  135525. /**
  135526. * Returns the animatable textures.
  135527. * @param animatables Array of animatable textures.
  135528. */
  135529. getAnimatables(animatables: IAnimatable[]): void;
  135530. /**
  135531. * Disposes the resources of the material.
  135532. * @param forceDisposeTextures - Forces the disposal of all textures.
  135533. */
  135534. dispose(forceDisposeTextures?: boolean): void;
  135535. /**
  135536. * Get the current class name of the texture useful for serialization or dynamic coding.
  135537. * @returns "PBRSheenConfiguration"
  135538. */
  135539. getClassName(): string;
  135540. /**
  135541. * Add fallbacks to the effect fallbacks list.
  135542. * @param defines defines the Base texture to use.
  135543. * @param fallbacks defines the current fallback list.
  135544. * @param currentRank defines the current fallback rank.
  135545. * @returns the new fallback rank.
  135546. */
  135547. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135548. /**
  135549. * Add the required uniforms to the current list.
  135550. * @param uniforms defines the current uniform list.
  135551. */
  135552. static AddUniforms(uniforms: string[]): void;
  135553. /**
  135554. * Add the required uniforms to the current buffer.
  135555. * @param uniformBuffer defines the current uniform buffer.
  135556. */
  135557. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135558. /**
  135559. * Add the required samplers to the current list.
  135560. * @param samplers defines the current sampler list.
  135561. */
  135562. static AddSamplers(samplers: string[]): void;
  135563. /**
  135564. * Makes a duplicate of the current configuration into another one.
  135565. * @param sheenConfiguration define the config where to copy the info
  135566. */
  135567. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  135568. /**
  135569. * Serializes this BRDF configuration.
  135570. * @returns - An object with the serialized config.
  135571. */
  135572. serialize(): any;
  135573. /**
  135574. * Parses a anisotropy Configuration from a serialized object.
  135575. * @param source - Serialized object.
  135576. * @param scene Defines the scene we are parsing for
  135577. * @param rootUrl Defines the rootUrl to load from
  135578. */
  135579. parse(source: any, scene: Scene, rootUrl: string): void;
  135580. }
  135581. }
  135582. declare module BABYLON {
  135583. /**
  135584. * @hidden
  135585. */
  135586. export interface IMaterialSubSurfaceDefines {
  135587. SUBSURFACE: boolean;
  135588. SS_REFRACTION: boolean;
  135589. SS_TRANSLUCENCY: boolean;
  135590. SS_SCATTERING: boolean;
  135591. SS_THICKNESSANDMASK_TEXTURE: boolean;
  135592. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  135593. SS_REFRACTIONMAP_3D: boolean;
  135594. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  135595. SS_LODINREFRACTIONALPHA: boolean;
  135596. SS_GAMMAREFRACTION: boolean;
  135597. SS_RGBDREFRACTION: boolean;
  135598. SS_LINEARSPECULARREFRACTION: boolean;
  135599. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  135600. SS_ALBEDOFORREFRACTIONTINT: boolean;
  135601. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  135602. /** @hidden */
  135603. _areTexturesDirty: boolean;
  135604. }
  135605. /**
  135606. * Define the code related to the sub surface parameters of the pbr material.
  135607. */
  135608. export class PBRSubSurfaceConfiguration {
  135609. private _isRefractionEnabled;
  135610. /**
  135611. * Defines if the refraction is enabled in the material.
  135612. */
  135613. isRefractionEnabled: boolean;
  135614. private _isTranslucencyEnabled;
  135615. /**
  135616. * Defines if the translucency is enabled in the material.
  135617. */
  135618. isTranslucencyEnabled: boolean;
  135619. private _isScatteringEnabled;
  135620. /**
  135621. * Defines if the sub surface scattering is enabled in the material.
  135622. */
  135623. isScatteringEnabled: boolean;
  135624. private _scatteringDiffusionProfileIndex;
  135625. /**
  135626. * Diffusion profile for subsurface scattering.
  135627. * Useful for better scattering in the skins or foliages.
  135628. */
  135629. get scatteringDiffusionProfile(): Nullable<Color3>;
  135630. set scatteringDiffusionProfile(c: Nullable<Color3>);
  135631. /**
  135632. * Defines the refraction intensity of the material.
  135633. * The refraction when enabled replaces the Diffuse part of the material.
  135634. * The intensity helps transitionning between diffuse and refraction.
  135635. */
  135636. refractionIntensity: number;
  135637. /**
  135638. * Defines the translucency intensity of the material.
  135639. * When translucency has been enabled, this defines how much of the "translucency"
  135640. * is addded to the diffuse part of the material.
  135641. */
  135642. translucencyIntensity: number;
  135643. /**
  135644. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  135645. */
  135646. useAlbedoToTintRefraction: boolean;
  135647. private _thicknessTexture;
  135648. /**
  135649. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  135650. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  135651. * 0 would mean minimumThickness
  135652. * 1 would mean maximumThickness
  135653. * The other channels might be use as a mask to vary the different effects intensity.
  135654. */
  135655. thicknessTexture: Nullable<BaseTexture>;
  135656. private _refractionTexture;
  135657. /**
  135658. * Defines the texture to use for refraction.
  135659. */
  135660. refractionTexture: Nullable<BaseTexture>;
  135661. private _indexOfRefraction;
  135662. /**
  135663. * Index of refraction of the material base layer.
  135664. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  135665. *
  135666. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  135667. *
  135668. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  135669. */
  135670. indexOfRefraction: number;
  135671. private _volumeIndexOfRefraction;
  135672. /**
  135673. * Index of refraction of the material's volume.
  135674. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  135675. *
  135676. * This ONLY impacts refraction. If not provided or given a non-valid value,
  135677. * the volume will use the same IOR as the surface.
  135678. */
  135679. get volumeIndexOfRefraction(): number;
  135680. set volumeIndexOfRefraction(value: number);
  135681. private _invertRefractionY;
  135682. /**
  135683. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  135684. */
  135685. invertRefractionY: boolean;
  135686. private _linkRefractionWithTransparency;
  135687. /**
  135688. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  135689. * Materials half opaque for instance using refraction could benefit from this control.
  135690. */
  135691. linkRefractionWithTransparency: boolean;
  135692. /**
  135693. * Defines the minimum thickness stored in the thickness map.
  135694. * If no thickness map is defined, this value will be used to simulate thickness.
  135695. */
  135696. minimumThickness: number;
  135697. /**
  135698. * Defines the maximum thickness stored in the thickness map.
  135699. */
  135700. maximumThickness: number;
  135701. /**
  135702. * Defines the volume tint of the material.
  135703. * This is used for both translucency and scattering.
  135704. */
  135705. tintColor: Color3;
  135706. /**
  135707. * Defines the distance at which the tint color should be found in the media.
  135708. * This is used for refraction only.
  135709. */
  135710. tintColorAtDistance: number;
  135711. /**
  135712. * Defines how far each channel transmit through the media.
  135713. * It is defined as a color to simplify it selection.
  135714. */
  135715. diffusionDistance: Color3;
  135716. private _useMaskFromThicknessTexture;
  135717. /**
  135718. * Stores the intensity of the different subsurface effects in the thickness texture.
  135719. * * the green channel is the translucency intensity.
  135720. * * the blue channel is the scattering intensity.
  135721. * * the alpha channel is the refraction intensity.
  135722. */
  135723. useMaskFromThicknessTexture: boolean;
  135724. private _scene;
  135725. /** @hidden */
  135726. private _internalMarkAllSubMeshesAsTexturesDirty;
  135727. private _internalMarkScenePrePassDirty;
  135728. /** @hidden */
  135729. _markAllSubMeshesAsTexturesDirty(): void;
  135730. /** @hidden */
  135731. _markScenePrePassDirty(): void;
  135732. /**
  135733. * Instantiate a new istance of sub surface configuration.
  135734. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135735. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  135736. * @param scene The scene
  135737. */
  135738. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  135739. /**
  135740. * Gets wehter the submesh is ready to be used or not.
  135741. * @param defines the list of "defines" to update.
  135742. * @param scene defines the scene the material belongs to.
  135743. * @returns - boolean indicating that the submesh is ready or not.
  135744. */
  135745. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  135746. /**
  135747. * Checks to see if a texture is used in the material.
  135748. * @param defines the list of "defines" to update.
  135749. * @param scene defines the scene to the material belongs to.
  135750. */
  135751. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  135752. /**
  135753. * Binds the material data.
  135754. * @param uniformBuffer defines the Uniform buffer to fill in.
  135755. * @param scene defines the scene the material belongs to.
  135756. * @param engine defines the engine the material belongs to.
  135757. * @param isFrozen defines whether the material is frozen or not.
  135758. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  135759. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  135760. */
  135761. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  135762. /**
  135763. * Unbinds the material from the mesh.
  135764. * @param activeEffect defines the effect that should be unbound from.
  135765. * @returns true if unbound, otherwise false
  135766. */
  135767. unbind(activeEffect: Effect): boolean;
  135768. /**
  135769. * Returns the texture used for refraction or null if none is used.
  135770. * @param scene defines the scene the material belongs to.
  135771. * @returns - Refraction texture if present. If no refraction texture and refraction
  135772. * is linked with transparency, returns environment texture. Otherwise, returns null.
  135773. */
  135774. private _getRefractionTexture;
  135775. /**
  135776. * Returns true if alpha blending should be disabled.
  135777. */
  135778. get disableAlphaBlending(): boolean;
  135779. /**
  135780. * Fills the list of render target textures.
  135781. * @param renderTargets the list of render targets to update
  135782. */
  135783. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  135784. /**
  135785. * Checks to see if a texture is used in the material.
  135786. * @param texture - Base texture to use.
  135787. * @returns - Boolean specifying if a texture is used in the material.
  135788. */
  135789. hasTexture(texture: BaseTexture): boolean;
  135790. /**
  135791. * Gets a boolean indicating that current material needs to register RTT
  135792. * @returns true if this uses a render target otherwise false.
  135793. */
  135794. hasRenderTargetTextures(): boolean;
  135795. /**
  135796. * Returns an array of the actively used textures.
  135797. * @param activeTextures Array of BaseTextures
  135798. */
  135799. getActiveTextures(activeTextures: BaseTexture[]): void;
  135800. /**
  135801. * Returns the animatable textures.
  135802. * @param animatables Array of animatable textures.
  135803. */
  135804. getAnimatables(animatables: IAnimatable[]): void;
  135805. /**
  135806. * Disposes the resources of the material.
  135807. * @param forceDisposeTextures - Forces the disposal of all textures.
  135808. */
  135809. dispose(forceDisposeTextures?: boolean): void;
  135810. /**
  135811. * Get the current class name of the texture useful for serialization or dynamic coding.
  135812. * @returns "PBRSubSurfaceConfiguration"
  135813. */
  135814. getClassName(): string;
  135815. /**
  135816. * Add fallbacks to the effect fallbacks list.
  135817. * @param defines defines the Base texture to use.
  135818. * @param fallbacks defines the current fallback list.
  135819. * @param currentRank defines the current fallback rank.
  135820. * @returns the new fallback rank.
  135821. */
  135822. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135823. /**
  135824. * Add the required uniforms to the current list.
  135825. * @param uniforms defines the current uniform list.
  135826. */
  135827. static AddUniforms(uniforms: string[]): void;
  135828. /**
  135829. * Add the required samplers to the current list.
  135830. * @param samplers defines the current sampler list.
  135831. */
  135832. static AddSamplers(samplers: string[]): void;
  135833. /**
  135834. * Add the required uniforms to the current buffer.
  135835. * @param uniformBuffer defines the current uniform buffer.
  135836. */
  135837. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135838. /**
  135839. * Makes a duplicate of the current configuration into another one.
  135840. * @param configuration define the config where to copy the info
  135841. */
  135842. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  135843. /**
  135844. * Serializes this Sub Surface configuration.
  135845. * @returns - An object with the serialized config.
  135846. */
  135847. serialize(): any;
  135848. /**
  135849. * Parses a anisotropy Configuration from a serialized object.
  135850. * @param source - Serialized object.
  135851. * @param scene Defines the scene we are parsing for
  135852. * @param rootUrl Defines the rootUrl to load from
  135853. */
  135854. parse(source: any, scene: Scene, rootUrl: string): void;
  135855. }
  135856. }
  135857. declare module BABYLON {
  135858. /** @hidden */
  135859. export var pbrFragmentDeclaration: {
  135860. name: string;
  135861. shader: string;
  135862. };
  135863. }
  135864. declare module BABYLON {
  135865. /** @hidden */
  135866. export var pbrUboDeclaration: {
  135867. name: string;
  135868. shader: string;
  135869. };
  135870. }
  135871. declare module BABYLON {
  135872. /** @hidden */
  135873. export var pbrFragmentExtraDeclaration: {
  135874. name: string;
  135875. shader: string;
  135876. };
  135877. }
  135878. declare module BABYLON {
  135879. /** @hidden */
  135880. export var pbrFragmentSamplersDeclaration: {
  135881. name: string;
  135882. shader: string;
  135883. };
  135884. }
  135885. declare module BABYLON {
  135886. /** @hidden */
  135887. export var importanceSampling: {
  135888. name: string;
  135889. shader: string;
  135890. };
  135891. }
  135892. declare module BABYLON {
  135893. /** @hidden */
  135894. export var pbrHelperFunctions: {
  135895. name: string;
  135896. shader: string;
  135897. };
  135898. }
  135899. declare module BABYLON {
  135900. /** @hidden */
  135901. export var harmonicsFunctions: {
  135902. name: string;
  135903. shader: string;
  135904. };
  135905. }
  135906. declare module BABYLON {
  135907. /** @hidden */
  135908. export var pbrDirectLightingSetupFunctions: {
  135909. name: string;
  135910. shader: string;
  135911. };
  135912. }
  135913. declare module BABYLON {
  135914. /** @hidden */
  135915. export var pbrDirectLightingFalloffFunctions: {
  135916. name: string;
  135917. shader: string;
  135918. };
  135919. }
  135920. declare module BABYLON {
  135921. /** @hidden */
  135922. export var pbrBRDFFunctions: {
  135923. name: string;
  135924. shader: string;
  135925. };
  135926. }
  135927. declare module BABYLON {
  135928. /** @hidden */
  135929. export var hdrFilteringFunctions: {
  135930. name: string;
  135931. shader: string;
  135932. };
  135933. }
  135934. declare module BABYLON {
  135935. /** @hidden */
  135936. export var pbrDirectLightingFunctions: {
  135937. name: string;
  135938. shader: string;
  135939. };
  135940. }
  135941. declare module BABYLON {
  135942. /** @hidden */
  135943. export var pbrIBLFunctions: {
  135944. name: string;
  135945. shader: string;
  135946. };
  135947. }
  135948. declare module BABYLON {
  135949. /** @hidden */
  135950. export var pbrBlockAlbedoOpacity: {
  135951. name: string;
  135952. shader: string;
  135953. };
  135954. }
  135955. declare module BABYLON {
  135956. /** @hidden */
  135957. export var pbrBlockReflectivity: {
  135958. name: string;
  135959. shader: string;
  135960. };
  135961. }
  135962. declare module BABYLON {
  135963. /** @hidden */
  135964. export var pbrBlockAmbientOcclusion: {
  135965. name: string;
  135966. shader: string;
  135967. };
  135968. }
  135969. declare module BABYLON {
  135970. /** @hidden */
  135971. export var pbrBlockAlphaFresnel: {
  135972. name: string;
  135973. shader: string;
  135974. };
  135975. }
  135976. declare module BABYLON {
  135977. /** @hidden */
  135978. export var pbrBlockAnisotropic: {
  135979. name: string;
  135980. shader: string;
  135981. };
  135982. }
  135983. declare module BABYLON {
  135984. /** @hidden */
  135985. export var pbrBlockReflection: {
  135986. name: string;
  135987. shader: string;
  135988. };
  135989. }
  135990. declare module BABYLON {
  135991. /** @hidden */
  135992. export var pbrBlockSheen: {
  135993. name: string;
  135994. shader: string;
  135995. };
  135996. }
  135997. declare module BABYLON {
  135998. /** @hidden */
  135999. export var pbrBlockClearcoat: {
  136000. name: string;
  136001. shader: string;
  136002. };
  136003. }
  136004. declare module BABYLON {
  136005. /** @hidden */
  136006. export var pbrBlockSubSurface: {
  136007. name: string;
  136008. shader: string;
  136009. };
  136010. }
  136011. declare module BABYLON {
  136012. /** @hidden */
  136013. export var pbrBlockNormalGeometric: {
  136014. name: string;
  136015. shader: string;
  136016. };
  136017. }
  136018. declare module BABYLON {
  136019. /** @hidden */
  136020. export var pbrBlockNormalFinal: {
  136021. name: string;
  136022. shader: string;
  136023. };
  136024. }
  136025. declare module BABYLON {
  136026. /** @hidden */
  136027. export var pbrBlockLightmapInit: {
  136028. name: string;
  136029. shader: string;
  136030. };
  136031. }
  136032. declare module BABYLON {
  136033. /** @hidden */
  136034. export var pbrBlockGeometryInfo: {
  136035. name: string;
  136036. shader: string;
  136037. };
  136038. }
  136039. declare module BABYLON {
  136040. /** @hidden */
  136041. export var pbrBlockReflectance0: {
  136042. name: string;
  136043. shader: string;
  136044. };
  136045. }
  136046. declare module BABYLON {
  136047. /** @hidden */
  136048. export var pbrBlockReflectance: {
  136049. name: string;
  136050. shader: string;
  136051. };
  136052. }
  136053. declare module BABYLON {
  136054. /** @hidden */
  136055. export var pbrBlockDirectLighting: {
  136056. name: string;
  136057. shader: string;
  136058. };
  136059. }
  136060. declare module BABYLON {
  136061. /** @hidden */
  136062. export var pbrBlockFinalLitComponents: {
  136063. name: string;
  136064. shader: string;
  136065. };
  136066. }
  136067. declare module BABYLON {
  136068. /** @hidden */
  136069. export var pbrBlockFinalUnlitComponents: {
  136070. name: string;
  136071. shader: string;
  136072. };
  136073. }
  136074. declare module BABYLON {
  136075. /** @hidden */
  136076. export var pbrBlockFinalColorComposition: {
  136077. name: string;
  136078. shader: string;
  136079. };
  136080. }
  136081. declare module BABYLON {
  136082. /** @hidden */
  136083. export var pbrBlockImageProcessing: {
  136084. name: string;
  136085. shader: string;
  136086. };
  136087. }
  136088. declare module BABYLON {
  136089. /** @hidden */
  136090. export var pbrDebug: {
  136091. name: string;
  136092. shader: string;
  136093. };
  136094. }
  136095. declare module BABYLON {
  136096. /** @hidden */
  136097. export var pbrPixelShader: {
  136098. name: string;
  136099. shader: string;
  136100. };
  136101. }
  136102. declare module BABYLON {
  136103. /** @hidden */
  136104. export var pbrVertexDeclaration: {
  136105. name: string;
  136106. shader: string;
  136107. };
  136108. }
  136109. declare module BABYLON {
  136110. /** @hidden */
  136111. export var pbrVertexShader: {
  136112. name: string;
  136113. shader: string;
  136114. };
  136115. }
  136116. declare module BABYLON {
  136117. /**
  136118. * Manages the defines for the PBR Material.
  136119. * @hidden
  136120. */
  136121. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  136122. PBR: boolean;
  136123. NUM_SAMPLES: string;
  136124. REALTIME_FILTERING: boolean;
  136125. MAINUV1: boolean;
  136126. MAINUV2: boolean;
  136127. UV1: boolean;
  136128. UV2: boolean;
  136129. ALBEDO: boolean;
  136130. GAMMAALBEDO: boolean;
  136131. ALBEDODIRECTUV: number;
  136132. VERTEXCOLOR: boolean;
  136133. DETAIL: boolean;
  136134. DETAILDIRECTUV: number;
  136135. DETAIL_NORMALBLENDMETHOD: number;
  136136. AMBIENT: boolean;
  136137. AMBIENTDIRECTUV: number;
  136138. AMBIENTINGRAYSCALE: boolean;
  136139. OPACITY: boolean;
  136140. VERTEXALPHA: boolean;
  136141. OPACITYDIRECTUV: number;
  136142. OPACITYRGB: boolean;
  136143. ALPHATEST: boolean;
  136144. DEPTHPREPASS: boolean;
  136145. ALPHABLEND: boolean;
  136146. ALPHAFROMALBEDO: boolean;
  136147. ALPHATESTVALUE: string;
  136148. SPECULAROVERALPHA: boolean;
  136149. RADIANCEOVERALPHA: boolean;
  136150. ALPHAFRESNEL: boolean;
  136151. LINEARALPHAFRESNEL: boolean;
  136152. PREMULTIPLYALPHA: boolean;
  136153. EMISSIVE: boolean;
  136154. EMISSIVEDIRECTUV: number;
  136155. REFLECTIVITY: boolean;
  136156. REFLECTIVITYDIRECTUV: number;
  136157. SPECULARTERM: boolean;
  136158. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  136159. MICROSURFACEAUTOMATIC: boolean;
  136160. LODBASEDMICROSFURACE: boolean;
  136161. MICROSURFACEMAP: boolean;
  136162. MICROSURFACEMAPDIRECTUV: number;
  136163. METALLICWORKFLOW: boolean;
  136164. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  136165. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  136166. METALLNESSSTOREINMETALMAPBLUE: boolean;
  136167. AOSTOREINMETALMAPRED: boolean;
  136168. METALLIC_REFLECTANCE: boolean;
  136169. METALLIC_REFLECTANCEDIRECTUV: number;
  136170. ENVIRONMENTBRDF: boolean;
  136171. ENVIRONMENTBRDF_RGBD: boolean;
  136172. NORMAL: boolean;
  136173. TANGENT: boolean;
  136174. BUMP: boolean;
  136175. BUMPDIRECTUV: number;
  136176. OBJECTSPACE_NORMALMAP: boolean;
  136177. PARALLAX: boolean;
  136178. PARALLAXOCCLUSION: boolean;
  136179. NORMALXYSCALE: boolean;
  136180. LIGHTMAP: boolean;
  136181. LIGHTMAPDIRECTUV: number;
  136182. USELIGHTMAPASSHADOWMAP: boolean;
  136183. GAMMALIGHTMAP: boolean;
  136184. RGBDLIGHTMAP: boolean;
  136185. REFLECTION: boolean;
  136186. REFLECTIONMAP_3D: boolean;
  136187. REFLECTIONMAP_SPHERICAL: boolean;
  136188. REFLECTIONMAP_PLANAR: boolean;
  136189. REFLECTIONMAP_CUBIC: boolean;
  136190. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  136191. REFLECTIONMAP_PROJECTION: boolean;
  136192. REFLECTIONMAP_SKYBOX: boolean;
  136193. REFLECTIONMAP_EXPLICIT: boolean;
  136194. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  136195. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  136196. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  136197. INVERTCUBICMAP: boolean;
  136198. USESPHERICALFROMREFLECTIONMAP: boolean;
  136199. USEIRRADIANCEMAP: boolean;
  136200. SPHERICAL_HARMONICS: boolean;
  136201. USESPHERICALINVERTEX: boolean;
  136202. REFLECTIONMAP_OPPOSITEZ: boolean;
  136203. LODINREFLECTIONALPHA: boolean;
  136204. GAMMAREFLECTION: boolean;
  136205. RGBDREFLECTION: boolean;
  136206. LINEARSPECULARREFLECTION: boolean;
  136207. RADIANCEOCCLUSION: boolean;
  136208. HORIZONOCCLUSION: boolean;
  136209. INSTANCES: boolean;
  136210. THIN_INSTANCES: boolean;
  136211. PREPASS: boolean;
  136212. SCENE_MRT_COUNT: number;
  136213. NUM_BONE_INFLUENCERS: number;
  136214. BonesPerMesh: number;
  136215. BONETEXTURE: boolean;
  136216. NONUNIFORMSCALING: boolean;
  136217. MORPHTARGETS: boolean;
  136218. MORPHTARGETS_NORMAL: boolean;
  136219. MORPHTARGETS_TANGENT: boolean;
  136220. MORPHTARGETS_UV: boolean;
  136221. NUM_MORPH_INFLUENCERS: number;
  136222. IMAGEPROCESSING: boolean;
  136223. VIGNETTE: boolean;
  136224. VIGNETTEBLENDMODEMULTIPLY: boolean;
  136225. VIGNETTEBLENDMODEOPAQUE: boolean;
  136226. TONEMAPPING: boolean;
  136227. TONEMAPPING_ACES: boolean;
  136228. CONTRAST: boolean;
  136229. COLORCURVES: boolean;
  136230. COLORGRADING: boolean;
  136231. COLORGRADING3D: boolean;
  136232. SAMPLER3DGREENDEPTH: boolean;
  136233. SAMPLER3DBGRMAP: boolean;
  136234. IMAGEPROCESSINGPOSTPROCESS: boolean;
  136235. EXPOSURE: boolean;
  136236. MULTIVIEW: boolean;
  136237. USEPHYSICALLIGHTFALLOFF: boolean;
  136238. USEGLTFLIGHTFALLOFF: boolean;
  136239. TWOSIDEDLIGHTING: boolean;
  136240. SHADOWFLOAT: boolean;
  136241. CLIPPLANE: boolean;
  136242. CLIPPLANE2: boolean;
  136243. CLIPPLANE3: boolean;
  136244. CLIPPLANE4: boolean;
  136245. CLIPPLANE5: boolean;
  136246. CLIPPLANE6: boolean;
  136247. POINTSIZE: boolean;
  136248. FOG: boolean;
  136249. LOGARITHMICDEPTH: boolean;
  136250. FORCENORMALFORWARD: boolean;
  136251. SPECULARAA: boolean;
  136252. CLEARCOAT: boolean;
  136253. CLEARCOAT_DEFAULTIOR: boolean;
  136254. CLEARCOAT_TEXTURE: boolean;
  136255. CLEARCOAT_TEXTUREDIRECTUV: number;
  136256. CLEARCOAT_BUMP: boolean;
  136257. CLEARCOAT_BUMPDIRECTUV: number;
  136258. CLEARCOAT_TINT: boolean;
  136259. CLEARCOAT_TINT_TEXTURE: boolean;
  136260. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  136261. ANISOTROPIC: boolean;
  136262. ANISOTROPIC_TEXTURE: boolean;
  136263. ANISOTROPIC_TEXTUREDIRECTUV: number;
  136264. BRDF_V_HEIGHT_CORRELATED: boolean;
  136265. MS_BRDF_ENERGY_CONSERVATION: boolean;
  136266. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  136267. SHEEN: boolean;
  136268. SHEEN_TEXTURE: boolean;
  136269. SHEEN_TEXTUREDIRECTUV: number;
  136270. SHEEN_LINKWITHALBEDO: boolean;
  136271. SHEEN_ROUGHNESS: boolean;
  136272. SHEEN_ALBEDOSCALING: boolean;
  136273. SUBSURFACE: boolean;
  136274. SS_REFRACTION: boolean;
  136275. SS_TRANSLUCENCY: boolean;
  136276. SS_SCATTERING: boolean;
  136277. SS_THICKNESSANDMASK_TEXTURE: boolean;
  136278. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  136279. SS_REFRACTIONMAP_3D: boolean;
  136280. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  136281. SS_LODINREFRACTIONALPHA: boolean;
  136282. SS_GAMMAREFRACTION: boolean;
  136283. SS_RGBDREFRACTION: boolean;
  136284. SS_LINEARSPECULARREFRACTION: boolean;
  136285. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  136286. SS_ALBEDOFORREFRACTIONTINT: boolean;
  136287. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  136288. UNLIT: boolean;
  136289. DEBUGMODE: number;
  136290. /**
  136291. * Initializes the PBR Material defines.
  136292. */
  136293. constructor();
  136294. /**
  136295. * Resets the PBR Material defines.
  136296. */
  136297. reset(): void;
  136298. }
  136299. /**
  136300. * The Physically based material base class of BJS.
  136301. *
  136302. * This offers the main features of a standard PBR material.
  136303. * For more information, please refer to the documentation :
  136304. * https://doc.babylonjs.com/how_to/physically_based_rendering
  136305. */
  136306. export abstract class PBRBaseMaterial extends PushMaterial {
  136307. /**
  136308. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  136309. */
  136310. static readonly PBRMATERIAL_OPAQUE: number;
  136311. /**
  136312. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  136313. */
  136314. static readonly PBRMATERIAL_ALPHATEST: number;
  136315. /**
  136316. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136317. */
  136318. static readonly PBRMATERIAL_ALPHABLEND: number;
  136319. /**
  136320. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136321. * They are also discarded below the alpha cutoff threshold to improve performances.
  136322. */
  136323. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  136324. /**
  136325. * Defines the default value of how much AO map is occluding the analytical lights
  136326. * (point spot...).
  136327. */
  136328. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  136329. /**
  136330. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  136331. */
  136332. static readonly LIGHTFALLOFF_PHYSICAL: number;
  136333. /**
  136334. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  136335. * to enhance interoperability with other engines.
  136336. */
  136337. static readonly LIGHTFALLOFF_GLTF: number;
  136338. /**
  136339. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  136340. * to enhance interoperability with other materials.
  136341. */
  136342. static readonly LIGHTFALLOFF_STANDARD: number;
  136343. /**
  136344. * Intensity of the direct lights e.g. the four lights available in your scene.
  136345. * This impacts both the direct diffuse and specular highlights.
  136346. */
  136347. protected _directIntensity: number;
  136348. /**
  136349. * Intensity of the emissive part of the material.
  136350. * This helps controlling the emissive effect without modifying the emissive color.
  136351. */
  136352. protected _emissiveIntensity: number;
  136353. /**
  136354. * Intensity of the environment e.g. how much the environment will light the object
  136355. * either through harmonics for rough material or through the refelction for shiny ones.
  136356. */
  136357. protected _environmentIntensity: number;
  136358. /**
  136359. * This is a special control allowing the reduction of the specular highlights coming from the
  136360. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  136361. */
  136362. protected _specularIntensity: number;
  136363. /**
  136364. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  136365. */
  136366. private _lightingInfos;
  136367. /**
  136368. * Debug Control allowing disabling the bump map on this material.
  136369. */
  136370. protected _disableBumpMap: boolean;
  136371. /**
  136372. * AKA Diffuse Texture in standard nomenclature.
  136373. */
  136374. protected _albedoTexture: Nullable<BaseTexture>;
  136375. /**
  136376. * AKA Occlusion Texture in other nomenclature.
  136377. */
  136378. protected _ambientTexture: Nullable<BaseTexture>;
  136379. /**
  136380. * AKA Occlusion Texture Intensity in other nomenclature.
  136381. */
  136382. protected _ambientTextureStrength: number;
  136383. /**
  136384. * Defines how much the AO map is occluding the analytical lights (point spot...).
  136385. * 1 means it completely occludes it
  136386. * 0 mean it has no impact
  136387. */
  136388. protected _ambientTextureImpactOnAnalyticalLights: number;
  136389. /**
  136390. * Stores the alpha values in a texture.
  136391. */
  136392. protected _opacityTexture: Nullable<BaseTexture>;
  136393. /**
  136394. * Stores the reflection values in a texture.
  136395. */
  136396. protected _reflectionTexture: Nullable<BaseTexture>;
  136397. /**
  136398. * Stores the emissive values in a texture.
  136399. */
  136400. protected _emissiveTexture: Nullable<BaseTexture>;
  136401. /**
  136402. * AKA Specular texture in other nomenclature.
  136403. */
  136404. protected _reflectivityTexture: Nullable<BaseTexture>;
  136405. /**
  136406. * Used to switch from specular/glossiness to metallic/roughness workflow.
  136407. */
  136408. protected _metallicTexture: Nullable<BaseTexture>;
  136409. /**
  136410. * Specifies the metallic scalar of the metallic/roughness workflow.
  136411. * Can also be used to scale the metalness values of the metallic texture.
  136412. */
  136413. protected _metallic: Nullable<number>;
  136414. /**
  136415. * Specifies the roughness scalar of the metallic/roughness workflow.
  136416. * Can also be used to scale the roughness values of the metallic texture.
  136417. */
  136418. protected _roughness: Nullable<number>;
  136419. /**
  136420. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  136421. * By default the indexOfrefraction is used to compute F0;
  136422. *
  136423. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  136424. *
  136425. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  136426. * F90 = metallicReflectanceColor;
  136427. */
  136428. protected _metallicF0Factor: number;
  136429. /**
  136430. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  136431. * By default the F90 is always 1;
  136432. *
  136433. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  136434. *
  136435. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  136436. * F90 = metallicReflectanceColor;
  136437. */
  136438. protected _metallicReflectanceColor: Color3;
  136439. /**
  136440. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  136441. * This is multiply against the scalar values defined in the material.
  136442. */
  136443. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  136444. /**
  136445. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  136446. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  136447. */
  136448. protected _microSurfaceTexture: Nullable<BaseTexture>;
  136449. /**
  136450. * Stores surface normal data used to displace a mesh in a texture.
  136451. */
  136452. protected _bumpTexture: Nullable<BaseTexture>;
  136453. /**
  136454. * Stores the pre-calculated light information of a mesh in a texture.
  136455. */
  136456. protected _lightmapTexture: Nullable<BaseTexture>;
  136457. /**
  136458. * The color of a material in ambient lighting.
  136459. */
  136460. protected _ambientColor: Color3;
  136461. /**
  136462. * AKA Diffuse Color in other nomenclature.
  136463. */
  136464. protected _albedoColor: Color3;
  136465. /**
  136466. * AKA Specular Color in other nomenclature.
  136467. */
  136468. protected _reflectivityColor: Color3;
  136469. /**
  136470. * The color applied when light is reflected from a material.
  136471. */
  136472. protected _reflectionColor: Color3;
  136473. /**
  136474. * The color applied when light is emitted from a material.
  136475. */
  136476. protected _emissiveColor: Color3;
  136477. /**
  136478. * AKA Glossiness in other nomenclature.
  136479. */
  136480. protected _microSurface: number;
  136481. /**
  136482. * Specifies that the material will use the light map as a show map.
  136483. */
  136484. protected _useLightmapAsShadowmap: boolean;
  136485. /**
  136486. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  136487. * makes the reflect vector face the model (under horizon).
  136488. */
  136489. protected _useHorizonOcclusion: boolean;
  136490. /**
  136491. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  136492. * too much the area relying on ambient texture to define their ambient occlusion.
  136493. */
  136494. protected _useRadianceOcclusion: boolean;
  136495. /**
  136496. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  136497. */
  136498. protected _useAlphaFromAlbedoTexture: boolean;
  136499. /**
  136500. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  136501. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  136502. */
  136503. protected _useSpecularOverAlpha: boolean;
  136504. /**
  136505. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  136506. */
  136507. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  136508. /**
  136509. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  136510. */
  136511. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  136512. /**
  136513. * Specifies if the metallic texture contains the roughness information in its green channel.
  136514. */
  136515. protected _useRoughnessFromMetallicTextureGreen: boolean;
  136516. /**
  136517. * Specifies if the metallic texture contains the metallness information in its blue channel.
  136518. */
  136519. protected _useMetallnessFromMetallicTextureBlue: boolean;
  136520. /**
  136521. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  136522. */
  136523. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  136524. /**
  136525. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  136526. */
  136527. protected _useAmbientInGrayScale: boolean;
  136528. /**
  136529. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  136530. * The material will try to infer what glossiness each pixel should be.
  136531. */
  136532. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  136533. /**
  136534. * Defines the falloff type used in this material.
  136535. * It by default is Physical.
  136536. */
  136537. protected _lightFalloff: number;
  136538. /**
  136539. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  136540. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  136541. */
  136542. protected _useRadianceOverAlpha: boolean;
  136543. /**
  136544. * Allows using an object space normal map (instead of tangent space).
  136545. */
  136546. protected _useObjectSpaceNormalMap: boolean;
  136547. /**
  136548. * Allows using the bump map in parallax mode.
  136549. */
  136550. protected _useParallax: boolean;
  136551. /**
  136552. * Allows using the bump map in parallax occlusion mode.
  136553. */
  136554. protected _useParallaxOcclusion: boolean;
  136555. /**
  136556. * Controls the scale bias of the parallax mode.
  136557. */
  136558. protected _parallaxScaleBias: number;
  136559. /**
  136560. * If sets to true, disables all the lights affecting the material.
  136561. */
  136562. protected _disableLighting: boolean;
  136563. /**
  136564. * Number of Simultaneous lights allowed on the material.
  136565. */
  136566. protected _maxSimultaneousLights: number;
  136567. /**
  136568. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  136569. */
  136570. protected _invertNormalMapX: boolean;
  136571. /**
  136572. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  136573. */
  136574. protected _invertNormalMapY: boolean;
  136575. /**
  136576. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  136577. */
  136578. protected _twoSidedLighting: boolean;
  136579. /**
  136580. * Defines the alpha limits in alpha test mode.
  136581. */
  136582. protected _alphaCutOff: number;
  136583. /**
  136584. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  136585. */
  136586. protected _forceAlphaTest: boolean;
  136587. /**
  136588. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  136589. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  136590. */
  136591. protected _useAlphaFresnel: boolean;
  136592. /**
  136593. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  136594. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  136595. */
  136596. protected _useLinearAlphaFresnel: boolean;
  136597. /**
  136598. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  136599. * from cos thetav and roughness:
  136600. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  136601. */
  136602. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  136603. /**
  136604. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  136605. */
  136606. protected _forceIrradianceInFragment: boolean;
  136607. private _realTimeFiltering;
  136608. /**
  136609. * Enables realtime filtering on the texture.
  136610. */
  136611. get realTimeFiltering(): boolean;
  136612. set realTimeFiltering(b: boolean);
  136613. private _realTimeFilteringQuality;
  136614. /**
  136615. * Quality switch for realtime filtering
  136616. */
  136617. get realTimeFilteringQuality(): number;
  136618. set realTimeFilteringQuality(n: number);
  136619. /**
  136620. * Can this material render to several textures at once
  136621. */
  136622. get canRenderToMRT(): boolean;
  136623. /**
  136624. * Force normal to face away from face.
  136625. */
  136626. protected _forceNormalForward: boolean;
  136627. /**
  136628. * Enables specular anti aliasing in the PBR shader.
  136629. * It will both interacts on the Geometry for analytical and IBL lighting.
  136630. * It also prefilter the roughness map based on the bump values.
  136631. */
  136632. protected _enableSpecularAntiAliasing: boolean;
  136633. /**
  136634. * Default configuration related to image processing available in the PBR Material.
  136635. */
  136636. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  136637. /**
  136638. * Keep track of the image processing observer to allow dispose and replace.
  136639. */
  136640. private _imageProcessingObserver;
  136641. /**
  136642. * Attaches a new image processing configuration to the PBR Material.
  136643. * @param configuration
  136644. */
  136645. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  136646. /**
  136647. * Stores the available render targets.
  136648. */
  136649. private _renderTargets;
  136650. /**
  136651. * Sets the global ambient color for the material used in lighting calculations.
  136652. */
  136653. private _globalAmbientColor;
  136654. /**
  136655. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  136656. */
  136657. private _useLogarithmicDepth;
  136658. /**
  136659. * If set to true, no lighting calculations will be applied.
  136660. */
  136661. private _unlit;
  136662. private _debugMode;
  136663. /**
  136664. * @hidden
  136665. * This is reserved for the inspector.
  136666. * Defines the material debug mode.
  136667. * It helps seeing only some components of the material while troubleshooting.
  136668. */
  136669. debugMode: number;
  136670. /**
  136671. * @hidden
  136672. * This is reserved for the inspector.
  136673. * Specify from where on screen the debug mode should start.
  136674. * The value goes from -1 (full screen) to 1 (not visible)
  136675. * It helps with side by side comparison against the final render
  136676. * This defaults to -1
  136677. */
  136678. private debugLimit;
  136679. /**
  136680. * @hidden
  136681. * This is reserved for the inspector.
  136682. * As the default viewing range might not be enough (if the ambient is really small for instance)
  136683. * You can use the factor to better multiply the final value.
  136684. */
  136685. private debugFactor;
  136686. /**
  136687. * Defines the clear coat layer parameters for the material.
  136688. */
  136689. readonly clearCoat: PBRClearCoatConfiguration;
  136690. /**
  136691. * Defines the anisotropic parameters for the material.
  136692. */
  136693. readonly anisotropy: PBRAnisotropicConfiguration;
  136694. /**
  136695. * Defines the BRDF parameters for the material.
  136696. */
  136697. readonly brdf: PBRBRDFConfiguration;
  136698. /**
  136699. * Defines the Sheen parameters for the material.
  136700. */
  136701. readonly sheen: PBRSheenConfiguration;
  136702. /**
  136703. * Defines the SubSurface parameters for the material.
  136704. */
  136705. readonly subSurface: PBRSubSurfaceConfiguration;
  136706. /**
  136707. * Defines the detail map parameters for the material.
  136708. */
  136709. readonly detailMap: DetailMapConfiguration;
  136710. protected _rebuildInParallel: boolean;
  136711. /**
  136712. * Instantiates a new PBRMaterial instance.
  136713. *
  136714. * @param name The material name
  136715. * @param scene The scene the material will be use in.
  136716. */
  136717. constructor(name: string, scene: Scene);
  136718. /**
  136719. * Gets a boolean indicating that current material needs to register RTT
  136720. */
  136721. get hasRenderTargetTextures(): boolean;
  136722. /**
  136723. * Gets the name of the material class.
  136724. */
  136725. getClassName(): string;
  136726. /**
  136727. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  136728. */
  136729. get useLogarithmicDepth(): boolean;
  136730. /**
  136731. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  136732. */
  136733. set useLogarithmicDepth(value: boolean);
  136734. /**
  136735. * Returns true if alpha blending should be disabled.
  136736. */
  136737. protected get _disableAlphaBlending(): boolean;
  136738. /**
  136739. * Specifies whether or not this material should be rendered in alpha blend mode.
  136740. */
  136741. needAlphaBlending(): boolean;
  136742. /**
  136743. * Specifies whether or not this material should be rendered in alpha test mode.
  136744. */
  136745. needAlphaTesting(): boolean;
  136746. /**
  136747. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  136748. */
  136749. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  136750. /**
  136751. * Gets the texture used for the alpha test.
  136752. */
  136753. getAlphaTestTexture(): Nullable<BaseTexture>;
  136754. /**
  136755. * Specifies that the submesh is ready to be used.
  136756. * @param mesh - BJS mesh.
  136757. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  136758. * @param useInstances - Specifies that instances should be used.
  136759. * @returns - boolean indicating that the submesh is ready or not.
  136760. */
  136761. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  136762. /**
  136763. * Specifies if the material uses metallic roughness workflow.
  136764. * @returns boolean specifiying if the material uses metallic roughness workflow.
  136765. */
  136766. isMetallicWorkflow(): boolean;
  136767. private _prepareEffect;
  136768. private _prepareDefines;
  136769. /**
  136770. * Force shader compilation
  136771. */
  136772. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  136773. /**
  136774. * Initializes the uniform buffer layout for the shader.
  136775. */
  136776. buildUniformLayout(): void;
  136777. /**
  136778. * Unbinds the material from the mesh
  136779. */
  136780. unbind(): void;
  136781. /**
  136782. * Binds the submesh data.
  136783. * @param world - The world matrix.
  136784. * @param mesh - The BJS mesh.
  136785. * @param subMesh - A submesh of the BJS mesh.
  136786. */
  136787. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  136788. /**
  136789. * Returns the animatable textures.
  136790. * @returns - Array of animatable textures.
  136791. */
  136792. getAnimatables(): IAnimatable[];
  136793. /**
  136794. * Returns the texture used for reflections.
  136795. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  136796. */
  136797. private _getReflectionTexture;
  136798. /**
  136799. * Returns an array of the actively used textures.
  136800. * @returns - Array of BaseTextures
  136801. */
  136802. getActiveTextures(): BaseTexture[];
  136803. /**
  136804. * Checks to see if a texture is used in the material.
  136805. * @param texture - Base texture to use.
  136806. * @returns - Boolean specifying if a texture is used in the material.
  136807. */
  136808. hasTexture(texture: BaseTexture): boolean;
  136809. /**
  136810. * Sets the required values to the prepass renderer.
  136811. * @param prePassRenderer defines the prepass renderer to setup
  136812. */
  136813. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  136814. /**
  136815. * Disposes the resources of the material.
  136816. * @param forceDisposeEffect - Forces the disposal of effects.
  136817. * @param forceDisposeTextures - Forces the disposal of all textures.
  136818. */
  136819. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  136820. }
  136821. }
  136822. declare module BABYLON {
  136823. /**
  136824. * The Physically based material of BJS.
  136825. *
  136826. * This offers the main features of a standard PBR material.
  136827. * For more information, please refer to the documentation :
  136828. * https://doc.babylonjs.com/how_to/physically_based_rendering
  136829. */
  136830. export class PBRMaterial extends PBRBaseMaterial {
  136831. /**
  136832. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  136833. */
  136834. static readonly PBRMATERIAL_OPAQUE: number;
  136835. /**
  136836. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  136837. */
  136838. static readonly PBRMATERIAL_ALPHATEST: number;
  136839. /**
  136840. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136841. */
  136842. static readonly PBRMATERIAL_ALPHABLEND: number;
  136843. /**
  136844. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136845. * They are also discarded below the alpha cutoff threshold to improve performances.
  136846. */
  136847. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  136848. /**
  136849. * Defines the default value of how much AO map is occluding the analytical lights
  136850. * (point spot...).
  136851. */
  136852. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  136853. /**
  136854. * Intensity of the direct lights e.g. the four lights available in your scene.
  136855. * This impacts both the direct diffuse and specular highlights.
  136856. */
  136857. directIntensity: number;
  136858. /**
  136859. * Intensity of the emissive part of the material.
  136860. * This helps controlling the emissive effect without modifying the emissive color.
  136861. */
  136862. emissiveIntensity: number;
  136863. /**
  136864. * Intensity of the environment e.g. how much the environment will light the object
  136865. * either through harmonics for rough material or through the refelction for shiny ones.
  136866. */
  136867. environmentIntensity: number;
  136868. /**
  136869. * This is a special control allowing the reduction of the specular highlights coming from the
  136870. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  136871. */
  136872. specularIntensity: number;
  136873. /**
  136874. * Debug Control allowing disabling the bump map on this material.
  136875. */
  136876. disableBumpMap: boolean;
  136877. /**
  136878. * AKA Diffuse Texture in standard nomenclature.
  136879. */
  136880. albedoTexture: BaseTexture;
  136881. /**
  136882. * AKA Occlusion Texture in other nomenclature.
  136883. */
  136884. ambientTexture: BaseTexture;
  136885. /**
  136886. * AKA Occlusion Texture Intensity in other nomenclature.
  136887. */
  136888. ambientTextureStrength: number;
  136889. /**
  136890. * Defines how much the AO map is occluding the analytical lights (point spot...).
  136891. * 1 means it completely occludes it
  136892. * 0 mean it has no impact
  136893. */
  136894. ambientTextureImpactOnAnalyticalLights: number;
  136895. /**
  136896. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  136897. */
  136898. opacityTexture: BaseTexture;
  136899. /**
  136900. * Stores the reflection values in a texture.
  136901. */
  136902. reflectionTexture: Nullable<BaseTexture>;
  136903. /**
  136904. * Stores the emissive values in a texture.
  136905. */
  136906. emissiveTexture: BaseTexture;
  136907. /**
  136908. * AKA Specular texture in other nomenclature.
  136909. */
  136910. reflectivityTexture: BaseTexture;
  136911. /**
  136912. * Used to switch from specular/glossiness to metallic/roughness workflow.
  136913. */
  136914. metallicTexture: BaseTexture;
  136915. /**
  136916. * Specifies the metallic scalar of the metallic/roughness workflow.
  136917. * Can also be used to scale the metalness values of the metallic texture.
  136918. */
  136919. metallic: Nullable<number>;
  136920. /**
  136921. * Specifies the roughness scalar of the metallic/roughness workflow.
  136922. * Can also be used to scale the roughness values of the metallic texture.
  136923. */
  136924. roughness: Nullable<number>;
  136925. /**
  136926. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  136927. * By default the indexOfrefraction is used to compute F0;
  136928. *
  136929. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  136930. *
  136931. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  136932. * F90 = metallicReflectanceColor;
  136933. */
  136934. metallicF0Factor: number;
  136935. /**
  136936. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  136937. * By default the F90 is always 1;
  136938. *
  136939. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  136940. *
  136941. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  136942. * F90 = metallicReflectanceColor;
  136943. */
  136944. metallicReflectanceColor: Color3;
  136945. /**
  136946. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  136947. * This is multiply against the scalar values defined in the material.
  136948. */
  136949. metallicReflectanceTexture: Nullable<BaseTexture>;
  136950. /**
  136951. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  136952. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  136953. */
  136954. microSurfaceTexture: BaseTexture;
  136955. /**
  136956. * Stores surface normal data used to displace a mesh in a texture.
  136957. */
  136958. bumpTexture: BaseTexture;
  136959. /**
  136960. * Stores the pre-calculated light information of a mesh in a texture.
  136961. */
  136962. lightmapTexture: BaseTexture;
  136963. /**
  136964. * Stores the refracted light information in a texture.
  136965. */
  136966. get refractionTexture(): Nullable<BaseTexture>;
  136967. set refractionTexture(value: Nullable<BaseTexture>);
  136968. /**
  136969. * The color of a material in ambient lighting.
  136970. */
  136971. ambientColor: Color3;
  136972. /**
  136973. * AKA Diffuse Color in other nomenclature.
  136974. */
  136975. albedoColor: Color3;
  136976. /**
  136977. * AKA Specular Color in other nomenclature.
  136978. */
  136979. reflectivityColor: Color3;
  136980. /**
  136981. * The color reflected from the material.
  136982. */
  136983. reflectionColor: Color3;
  136984. /**
  136985. * The color emitted from the material.
  136986. */
  136987. emissiveColor: Color3;
  136988. /**
  136989. * AKA Glossiness in other nomenclature.
  136990. */
  136991. microSurface: number;
  136992. /**
  136993. * Index of refraction of the material base layer.
  136994. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  136995. *
  136996. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  136997. *
  136998. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  136999. */
  137000. get indexOfRefraction(): number;
  137001. set indexOfRefraction(value: number);
  137002. /**
  137003. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  137004. */
  137005. get invertRefractionY(): boolean;
  137006. set invertRefractionY(value: boolean);
  137007. /**
  137008. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  137009. * Materials half opaque for instance using refraction could benefit from this control.
  137010. */
  137011. get linkRefractionWithTransparency(): boolean;
  137012. set linkRefractionWithTransparency(value: boolean);
  137013. /**
  137014. * If true, the light map contains occlusion information instead of lighting info.
  137015. */
  137016. useLightmapAsShadowmap: boolean;
  137017. /**
  137018. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  137019. */
  137020. useAlphaFromAlbedoTexture: boolean;
  137021. /**
  137022. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  137023. */
  137024. forceAlphaTest: boolean;
  137025. /**
  137026. * Defines the alpha limits in alpha test mode.
  137027. */
  137028. alphaCutOff: number;
  137029. /**
  137030. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  137031. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  137032. */
  137033. useSpecularOverAlpha: boolean;
  137034. /**
  137035. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  137036. */
  137037. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  137038. /**
  137039. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  137040. */
  137041. useRoughnessFromMetallicTextureAlpha: boolean;
  137042. /**
  137043. * Specifies if the metallic texture contains the roughness information in its green channel.
  137044. */
  137045. useRoughnessFromMetallicTextureGreen: boolean;
  137046. /**
  137047. * Specifies if the metallic texture contains the metallness information in its blue channel.
  137048. */
  137049. useMetallnessFromMetallicTextureBlue: boolean;
  137050. /**
  137051. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  137052. */
  137053. useAmbientOcclusionFromMetallicTextureRed: boolean;
  137054. /**
  137055. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  137056. */
  137057. useAmbientInGrayScale: boolean;
  137058. /**
  137059. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  137060. * The material will try to infer what glossiness each pixel should be.
  137061. */
  137062. useAutoMicroSurfaceFromReflectivityMap: boolean;
  137063. /**
  137064. * BJS is using an harcoded light falloff based on a manually sets up range.
  137065. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  137066. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  137067. */
  137068. get usePhysicalLightFalloff(): boolean;
  137069. /**
  137070. * BJS is using an harcoded light falloff based on a manually sets up range.
  137071. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  137072. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  137073. */
  137074. set usePhysicalLightFalloff(value: boolean);
  137075. /**
  137076. * In order to support the falloff compatibility with gltf, a special mode has been added
  137077. * to reproduce the gltf light falloff.
  137078. */
  137079. get useGLTFLightFalloff(): boolean;
  137080. /**
  137081. * In order to support the falloff compatibility with gltf, a special mode has been added
  137082. * to reproduce the gltf light falloff.
  137083. */
  137084. set useGLTFLightFalloff(value: boolean);
  137085. /**
  137086. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  137087. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  137088. */
  137089. useRadianceOverAlpha: boolean;
  137090. /**
  137091. * Allows using an object space normal map (instead of tangent space).
  137092. */
  137093. useObjectSpaceNormalMap: boolean;
  137094. /**
  137095. * Allows using the bump map in parallax mode.
  137096. */
  137097. useParallax: boolean;
  137098. /**
  137099. * Allows using the bump map in parallax occlusion mode.
  137100. */
  137101. useParallaxOcclusion: boolean;
  137102. /**
  137103. * Controls the scale bias of the parallax mode.
  137104. */
  137105. parallaxScaleBias: number;
  137106. /**
  137107. * If sets to true, disables all the lights affecting the material.
  137108. */
  137109. disableLighting: boolean;
  137110. /**
  137111. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  137112. */
  137113. forceIrradianceInFragment: boolean;
  137114. /**
  137115. * Number of Simultaneous lights allowed on the material.
  137116. */
  137117. maxSimultaneousLights: number;
  137118. /**
  137119. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  137120. */
  137121. invertNormalMapX: boolean;
  137122. /**
  137123. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  137124. */
  137125. invertNormalMapY: boolean;
  137126. /**
  137127. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  137128. */
  137129. twoSidedLighting: boolean;
  137130. /**
  137131. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137132. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  137133. */
  137134. useAlphaFresnel: boolean;
  137135. /**
  137136. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137137. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  137138. */
  137139. useLinearAlphaFresnel: boolean;
  137140. /**
  137141. * Let user defines the brdf lookup texture used for IBL.
  137142. * A default 8bit version is embedded but you could point at :
  137143. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  137144. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  137145. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  137146. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  137147. */
  137148. environmentBRDFTexture: Nullable<BaseTexture>;
  137149. /**
  137150. * Force normal to face away from face.
  137151. */
  137152. forceNormalForward: boolean;
  137153. /**
  137154. * Enables specular anti aliasing in the PBR shader.
  137155. * It will both interacts on the Geometry for analytical and IBL lighting.
  137156. * It also prefilter the roughness map based on the bump values.
  137157. */
  137158. enableSpecularAntiAliasing: boolean;
  137159. /**
  137160. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  137161. * makes the reflect vector face the model (under horizon).
  137162. */
  137163. useHorizonOcclusion: boolean;
  137164. /**
  137165. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  137166. * too much the area relying on ambient texture to define their ambient occlusion.
  137167. */
  137168. useRadianceOcclusion: boolean;
  137169. /**
  137170. * If set to true, no lighting calculations will be applied.
  137171. */
  137172. unlit: boolean;
  137173. /**
  137174. * Gets the image processing configuration used either in this material.
  137175. */
  137176. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  137177. /**
  137178. * Sets the Default image processing configuration used either in the this material.
  137179. *
  137180. * If sets to null, the scene one is in use.
  137181. */
  137182. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  137183. /**
  137184. * Gets wether the color curves effect is enabled.
  137185. */
  137186. get cameraColorCurvesEnabled(): boolean;
  137187. /**
  137188. * Sets wether the color curves effect is enabled.
  137189. */
  137190. set cameraColorCurvesEnabled(value: boolean);
  137191. /**
  137192. * Gets wether the color grading effect is enabled.
  137193. */
  137194. get cameraColorGradingEnabled(): boolean;
  137195. /**
  137196. * Gets wether the color grading effect is enabled.
  137197. */
  137198. set cameraColorGradingEnabled(value: boolean);
  137199. /**
  137200. * Gets wether tonemapping is enabled or not.
  137201. */
  137202. get cameraToneMappingEnabled(): boolean;
  137203. /**
  137204. * Sets wether tonemapping is enabled or not
  137205. */
  137206. set cameraToneMappingEnabled(value: boolean);
  137207. /**
  137208. * The camera exposure used on this material.
  137209. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  137210. * This corresponds to a photographic exposure.
  137211. */
  137212. get cameraExposure(): number;
  137213. /**
  137214. * The camera exposure used on this material.
  137215. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  137216. * This corresponds to a photographic exposure.
  137217. */
  137218. set cameraExposure(value: number);
  137219. /**
  137220. * Gets The camera contrast used on this material.
  137221. */
  137222. get cameraContrast(): number;
  137223. /**
  137224. * Sets The camera contrast used on this material.
  137225. */
  137226. set cameraContrast(value: number);
  137227. /**
  137228. * Gets the Color Grading 2D Lookup Texture.
  137229. */
  137230. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  137231. /**
  137232. * Sets the Color Grading 2D Lookup Texture.
  137233. */
  137234. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  137235. /**
  137236. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  137237. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  137238. * 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;
  137239. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  137240. */
  137241. get cameraColorCurves(): Nullable<ColorCurves>;
  137242. /**
  137243. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  137244. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  137245. * 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;
  137246. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  137247. */
  137248. set cameraColorCurves(value: Nullable<ColorCurves>);
  137249. /**
  137250. * Instantiates a new PBRMaterial instance.
  137251. *
  137252. * @param name The material name
  137253. * @param scene The scene the material will be use in.
  137254. */
  137255. constructor(name: string, scene: Scene);
  137256. /**
  137257. * Returns the name of this material class.
  137258. */
  137259. getClassName(): string;
  137260. /**
  137261. * Makes a duplicate of the current material.
  137262. * @param name - name to use for the new material.
  137263. */
  137264. clone(name: string): PBRMaterial;
  137265. /**
  137266. * Serializes this PBR Material.
  137267. * @returns - An object with the serialized material.
  137268. */
  137269. serialize(): any;
  137270. /**
  137271. * Parses a PBR Material from a serialized object.
  137272. * @param source - Serialized object.
  137273. * @param scene - BJS scene instance.
  137274. * @param rootUrl - url for the scene object
  137275. * @returns - PBRMaterial
  137276. */
  137277. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  137278. }
  137279. }
  137280. declare module BABYLON {
  137281. /**
  137282. * Direct draw surface info
  137283. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  137284. */
  137285. export interface DDSInfo {
  137286. /**
  137287. * Width of the texture
  137288. */
  137289. width: number;
  137290. /**
  137291. * Width of the texture
  137292. */
  137293. height: number;
  137294. /**
  137295. * Number of Mipmaps for the texture
  137296. * @see https://en.wikipedia.org/wiki/Mipmap
  137297. */
  137298. mipmapCount: number;
  137299. /**
  137300. * If the textures format is a known fourCC format
  137301. * @see https://www.fourcc.org/
  137302. */
  137303. isFourCC: boolean;
  137304. /**
  137305. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  137306. */
  137307. isRGB: boolean;
  137308. /**
  137309. * If the texture is a lumincance format
  137310. */
  137311. isLuminance: boolean;
  137312. /**
  137313. * If this is a cube texture
  137314. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  137315. */
  137316. isCube: boolean;
  137317. /**
  137318. * If the texture is a compressed format eg. FOURCC_DXT1
  137319. */
  137320. isCompressed: boolean;
  137321. /**
  137322. * The dxgiFormat of the texture
  137323. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  137324. */
  137325. dxgiFormat: number;
  137326. /**
  137327. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  137328. */
  137329. textureType: number;
  137330. /**
  137331. * Sphericle polynomial created for the dds texture
  137332. */
  137333. sphericalPolynomial?: SphericalPolynomial;
  137334. }
  137335. /**
  137336. * Class used to provide DDS decompression tools
  137337. */
  137338. export class DDSTools {
  137339. /**
  137340. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  137341. */
  137342. static StoreLODInAlphaChannel: boolean;
  137343. /**
  137344. * Gets DDS information from an array buffer
  137345. * @param data defines the array buffer view to read data from
  137346. * @returns the DDS information
  137347. */
  137348. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  137349. private static _FloatView;
  137350. private static _Int32View;
  137351. private static _ToHalfFloat;
  137352. private static _FromHalfFloat;
  137353. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  137354. private static _GetHalfFloatRGBAArrayBuffer;
  137355. private static _GetFloatRGBAArrayBuffer;
  137356. private static _GetFloatAsUIntRGBAArrayBuffer;
  137357. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  137358. private static _GetRGBAArrayBuffer;
  137359. private static _ExtractLongWordOrder;
  137360. private static _GetRGBArrayBuffer;
  137361. private static _GetLuminanceArrayBuffer;
  137362. /**
  137363. * Uploads DDS Levels to a Babylon Texture
  137364. * @hidden
  137365. */
  137366. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  137367. }
  137368. interface ThinEngine {
  137369. /**
  137370. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  137371. * @param rootUrl defines the url where the file to load is located
  137372. * @param scene defines the current scene
  137373. * @param lodScale defines scale to apply to the mip map selection
  137374. * @param lodOffset defines offset to apply to the mip map selection
  137375. * @param onLoad defines an optional callback raised when the texture is loaded
  137376. * @param onError defines an optional callback raised if there is an issue to load the texture
  137377. * @param format defines the format of the data
  137378. * @param forcedExtension defines the extension to use to pick the right loader
  137379. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  137380. * @returns the cube texture as an InternalTexture
  137381. */
  137382. 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;
  137383. }
  137384. }
  137385. declare module BABYLON {
  137386. /**
  137387. * Implementation of the DDS Texture Loader.
  137388. * @hidden
  137389. */
  137390. export class _DDSTextureLoader implements IInternalTextureLoader {
  137391. /**
  137392. * Defines wether the loader supports cascade loading the different faces.
  137393. */
  137394. readonly supportCascades: boolean;
  137395. /**
  137396. * This returns if the loader support the current file information.
  137397. * @param extension defines the file extension of the file being loaded
  137398. * @returns true if the loader can load the specified file
  137399. */
  137400. canLoad(extension: string): boolean;
  137401. /**
  137402. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137403. * @param data contains the texture data
  137404. * @param texture defines the BabylonJS internal texture
  137405. * @param createPolynomials will be true if polynomials have been requested
  137406. * @param onLoad defines the callback to trigger once the texture is ready
  137407. * @param onError defines the callback to trigger in case of error
  137408. */
  137409. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137410. /**
  137411. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137412. * @param data contains the texture data
  137413. * @param texture defines the BabylonJS internal texture
  137414. * @param callback defines the method to call once ready to upload
  137415. */
  137416. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  137417. }
  137418. }
  137419. declare module BABYLON {
  137420. /**
  137421. * Implementation of the ENV Texture Loader.
  137422. * @hidden
  137423. */
  137424. export class _ENVTextureLoader implements IInternalTextureLoader {
  137425. /**
  137426. * Defines wether the loader supports cascade loading the different faces.
  137427. */
  137428. readonly supportCascades: boolean;
  137429. /**
  137430. * This returns if the loader support the current file information.
  137431. * @param extension defines the file extension of the file being loaded
  137432. * @returns true if the loader can load the specified file
  137433. */
  137434. canLoad(extension: string): boolean;
  137435. /**
  137436. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137437. * @param data contains the texture data
  137438. * @param texture defines the BabylonJS internal texture
  137439. * @param createPolynomials will be true if polynomials have been requested
  137440. * @param onLoad defines the callback to trigger once the texture is ready
  137441. * @param onError defines the callback to trigger in case of error
  137442. */
  137443. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137444. /**
  137445. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137446. * @param data contains the texture data
  137447. * @param texture defines the BabylonJS internal texture
  137448. * @param callback defines the method to call once ready to upload
  137449. */
  137450. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  137451. }
  137452. }
  137453. declare module BABYLON {
  137454. /**
  137455. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  137456. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  137457. */
  137458. export class KhronosTextureContainer {
  137459. /** contents of the KTX container file */
  137460. data: ArrayBufferView;
  137461. private static HEADER_LEN;
  137462. private static COMPRESSED_2D;
  137463. private static COMPRESSED_3D;
  137464. private static TEX_2D;
  137465. private static TEX_3D;
  137466. /**
  137467. * Gets the openGL type
  137468. */
  137469. glType: number;
  137470. /**
  137471. * Gets the openGL type size
  137472. */
  137473. glTypeSize: number;
  137474. /**
  137475. * Gets the openGL format
  137476. */
  137477. glFormat: number;
  137478. /**
  137479. * Gets the openGL internal format
  137480. */
  137481. glInternalFormat: number;
  137482. /**
  137483. * Gets the base internal format
  137484. */
  137485. glBaseInternalFormat: number;
  137486. /**
  137487. * Gets image width in pixel
  137488. */
  137489. pixelWidth: number;
  137490. /**
  137491. * Gets image height in pixel
  137492. */
  137493. pixelHeight: number;
  137494. /**
  137495. * Gets image depth in pixels
  137496. */
  137497. pixelDepth: number;
  137498. /**
  137499. * Gets the number of array elements
  137500. */
  137501. numberOfArrayElements: number;
  137502. /**
  137503. * Gets the number of faces
  137504. */
  137505. numberOfFaces: number;
  137506. /**
  137507. * Gets the number of mipmap levels
  137508. */
  137509. numberOfMipmapLevels: number;
  137510. /**
  137511. * Gets the bytes of key value data
  137512. */
  137513. bytesOfKeyValueData: number;
  137514. /**
  137515. * Gets the load type
  137516. */
  137517. loadType: number;
  137518. /**
  137519. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  137520. */
  137521. isInvalid: boolean;
  137522. /**
  137523. * Creates a new KhronosTextureContainer
  137524. * @param data contents of the KTX container file
  137525. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  137526. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  137527. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  137528. */
  137529. constructor(
  137530. /** contents of the KTX container file */
  137531. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  137532. /**
  137533. * Uploads KTX content to a Babylon Texture.
  137534. * It is assumed that the texture has already been created & is currently bound
  137535. * @hidden
  137536. */
  137537. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  137538. private _upload2DCompressedLevels;
  137539. /**
  137540. * Checks if the given data starts with a KTX file identifier.
  137541. * @param data the data to check
  137542. * @returns true if the data is a KTX file or false otherwise
  137543. */
  137544. static IsValid(data: ArrayBufferView): boolean;
  137545. }
  137546. }
  137547. declare module BABYLON {
  137548. /**
  137549. * Helper class to push actions to a pool of workers.
  137550. */
  137551. export class WorkerPool implements IDisposable {
  137552. private _workerInfos;
  137553. private _pendingActions;
  137554. /**
  137555. * Constructor
  137556. * @param workers Array of workers to use for actions
  137557. */
  137558. constructor(workers: Array<Worker>);
  137559. /**
  137560. * Terminates all workers and clears any pending actions.
  137561. */
  137562. dispose(): void;
  137563. /**
  137564. * Pushes an action to the worker pool. If all the workers are active, the action will be
  137565. * pended until a worker has completed its action.
  137566. * @param action The action to perform. Call onComplete when the action is complete.
  137567. */
  137568. push(action: (worker: Worker, onComplete: () => void) => void): void;
  137569. private _execute;
  137570. }
  137571. }
  137572. declare module BABYLON {
  137573. /**
  137574. * Class for loading KTX2 files
  137575. * @hidden
  137576. */
  137577. export class KhronosTextureContainer2 {
  137578. private static _WorkerPoolPromise?;
  137579. private static _Initialized;
  137580. private static _Ktx2Decoder;
  137581. /**
  137582. * URL to use when loading the KTX2 decoder module
  137583. */
  137584. static JSModuleURL: string;
  137585. /**
  137586. * Default number of workers used to handle data decoding
  137587. */
  137588. static DefaultNumWorkers: number;
  137589. private static GetDefaultNumWorkers;
  137590. private _engine;
  137591. private static _CreateWorkerPool;
  137592. /**
  137593. * Constructor
  137594. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  137595. */
  137596. constructor(engine: ThinEngine, numWorkers?: number);
  137597. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  137598. /**
  137599. * Stop all async operations and release resources.
  137600. */
  137601. dispose(): void;
  137602. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  137603. /**
  137604. * Checks if the given data starts with a KTX2 file identifier.
  137605. * @param data the data to check
  137606. * @returns true if the data is a KTX2 file or false otherwise
  137607. */
  137608. static IsValid(data: ArrayBufferView): boolean;
  137609. }
  137610. export function workerFunc(): void;
  137611. }
  137612. declare module BABYLON {
  137613. /**
  137614. * Implementation of the KTX Texture Loader.
  137615. * @hidden
  137616. */
  137617. export class _KTXTextureLoader implements IInternalTextureLoader {
  137618. /**
  137619. * Defines wether the loader supports cascade loading the different faces.
  137620. */
  137621. readonly supportCascades: boolean;
  137622. /**
  137623. * This returns if the loader support the current file information.
  137624. * @param extension defines the file extension of the file being loaded
  137625. * @param mimeType defines the optional mime type of the file being loaded
  137626. * @returns true if the loader can load the specified file
  137627. */
  137628. canLoad(extension: string, mimeType?: string): boolean;
  137629. /**
  137630. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  137631. * @param data contains the texture data
  137632. * @param texture defines the BabylonJS internal texture
  137633. * @param createPolynomials will be true if polynomials have been requested
  137634. * @param onLoad defines the callback to trigger once the texture is ready
  137635. * @param onError defines the callback to trigger in case of error
  137636. */
  137637. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  137638. /**
  137639. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  137640. * @param data contains the texture data
  137641. * @param texture defines the BabylonJS internal texture
  137642. * @param callback defines the method to call once ready to upload
  137643. */
  137644. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  137645. }
  137646. }
  137647. declare module BABYLON {
  137648. /** @hidden */
  137649. export var _forceSceneHelpersToBundle: boolean;
  137650. interface Scene {
  137651. /**
  137652. * Creates a default light for the scene.
  137653. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  137654. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  137655. */
  137656. createDefaultLight(replace?: boolean): void;
  137657. /**
  137658. * Creates a default camera for the scene.
  137659. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  137660. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  137661. * @param replace has default false, when true replaces the active camera in the scene
  137662. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  137663. */
  137664. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  137665. /**
  137666. * Creates a default camera and a default light.
  137667. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  137668. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  137669. * @param replace has the default false, when true replaces the active camera/light in the scene
  137670. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  137671. */
  137672. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  137673. /**
  137674. * Creates a new sky box
  137675. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  137676. * @param environmentTexture defines the texture to use as environment texture
  137677. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  137678. * @param scale defines the overall scale of the skybox
  137679. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  137680. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  137681. * @returns a new mesh holding the sky box
  137682. */
  137683. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  137684. /**
  137685. * Creates a new environment
  137686. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  137687. * @param options defines the options you can use to configure the environment
  137688. * @returns the new EnvironmentHelper
  137689. */
  137690. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  137691. /**
  137692. * Creates a new VREXperienceHelper
  137693. * @see https://doc.babylonjs.com/how_to/webvr_helper
  137694. * @param webVROptions defines the options used to create the new VREXperienceHelper
  137695. * @returns a new VREXperienceHelper
  137696. */
  137697. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  137698. /**
  137699. * Creates a new WebXRDefaultExperience
  137700. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  137701. * @param options experience options
  137702. * @returns a promise for a new WebXRDefaultExperience
  137703. */
  137704. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  137705. }
  137706. }
  137707. declare module BABYLON {
  137708. /**
  137709. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  137710. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  137711. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  137712. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  137713. */
  137714. export class VideoDome extends TextureDome<VideoTexture> {
  137715. /**
  137716. * Define the video source as a Monoscopic panoramic 360 video.
  137717. */
  137718. static readonly MODE_MONOSCOPIC: number;
  137719. /**
  137720. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  137721. */
  137722. static readonly MODE_TOPBOTTOM: number;
  137723. /**
  137724. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  137725. */
  137726. static readonly MODE_SIDEBYSIDE: number;
  137727. /**
  137728. * Get the video texture associated with this video dome
  137729. */
  137730. get videoTexture(): VideoTexture;
  137731. /**
  137732. * Get the video mode of this dome
  137733. */
  137734. get videoMode(): number;
  137735. /**
  137736. * Set the video mode of this dome.
  137737. * @see textureMode
  137738. */
  137739. set videoMode(value: number);
  137740. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  137741. }
  137742. }
  137743. declare module BABYLON {
  137744. /**
  137745. * This class can be used to get instrumentation data from a Babylon engine
  137746. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  137747. */
  137748. export class EngineInstrumentation implements IDisposable {
  137749. /**
  137750. * Define the instrumented engine.
  137751. */
  137752. engine: Engine;
  137753. private _captureGPUFrameTime;
  137754. private _gpuFrameTimeToken;
  137755. private _gpuFrameTime;
  137756. private _captureShaderCompilationTime;
  137757. private _shaderCompilationTime;
  137758. private _onBeginFrameObserver;
  137759. private _onEndFrameObserver;
  137760. private _onBeforeShaderCompilationObserver;
  137761. private _onAfterShaderCompilationObserver;
  137762. /**
  137763. * Gets the perf counter used for GPU frame time
  137764. */
  137765. get gpuFrameTimeCounter(): PerfCounter;
  137766. /**
  137767. * Gets the GPU frame time capture status
  137768. */
  137769. get captureGPUFrameTime(): boolean;
  137770. /**
  137771. * Enable or disable the GPU frame time capture
  137772. */
  137773. set captureGPUFrameTime(value: boolean);
  137774. /**
  137775. * Gets the perf counter used for shader compilation time
  137776. */
  137777. get shaderCompilationTimeCounter(): PerfCounter;
  137778. /**
  137779. * Gets the shader compilation time capture status
  137780. */
  137781. get captureShaderCompilationTime(): boolean;
  137782. /**
  137783. * Enable or disable the shader compilation time capture
  137784. */
  137785. set captureShaderCompilationTime(value: boolean);
  137786. /**
  137787. * Instantiates a new engine instrumentation.
  137788. * This class can be used to get instrumentation data from a Babylon engine
  137789. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  137790. * @param engine Defines the engine to instrument
  137791. */
  137792. constructor(
  137793. /**
  137794. * Define the instrumented engine.
  137795. */
  137796. engine: Engine);
  137797. /**
  137798. * Dispose and release associated resources.
  137799. */
  137800. dispose(): void;
  137801. }
  137802. }
  137803. declare module BABYLON {
  137804. /**
  137805. * This class can be used to get instrumentation data from a Babylon engine
  137806. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  137807. */
  137808. export class SceneInstrumentation implements IDisposable {
  137809. /**
  137810. * Defines the scene to instrument
  137811. */
  137812. scene: Scene;
  137813. private _captureActiveMeshesEvaluationTime;
  137814. private _activeMeshesEvaluationTime;
  137815. private _captureRenderTargetsRenderTime;
  137816. private _renderTargetsRenderTime;
  137817. private _captureFrameTime;
  137818. private _frameTime;
  137819. private _captureRenderTime;
  137820. private _renderTime;
  137821. private _captureInterFrameTime;
  137822. private _interFrameTime;
  137823. private _captureParticlesRenderTime;
  137824. private _particlesRenderTime;
  137825. private _captureSpritesRenderTime;
  137826. private _spritesRenderTime;
  137827. private _capturePhysicsTime;
  137828. private _physicsTime;
  137829. private _captureAnimationsTime;
  137830. private _animationsTime;
  137831. private _captureCameraRenderTime;
  137832. private _cameraRenderTime;
  137833. private _onBeforeActiveMeshesEvaluationObserver;
  137834. private _onAfterActiveMeshesEvaluationObserver;
  137835. private _onBeforeRenderTargetsRenderObserver;
  137836. private _onAfterRenderTargetsRenderObserver;
  137837. private _onAfterRenderObserver;
  137838. private _onBeforeDrawPhaseObserver;
  137839. private _onAfterDrawPhaseObserver;
  137840. private _onBeforeAnimationsObserver;
  137841. private _onBeforeParticlesRenderingObserver;
  137842. private _onAfterParticlesRenderingObserver;
  137843. private _onBeforeSpritesRenderingObserver;
  137844. private _onAfterSpritesRenderingObserver;
  137845. private _onBeforePhysicsObserver;
  137846. private _onAfterPhysicsObserver;
  137847. private _onAfterAnimationsObserver;
  137848. private _onBeforeCameraRenderObserver;
  137849. private _onAfterCameraRenderObserver;
  137850. /**
  137851. * Gets the perf counter used for active meshes evaluation time
  137852. */
  137853. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  137854. /**
  137855. * Gets the active meshes evaluation time capture status
  137856. */
  137857. get captureActiveMeshesEvaluationTime(): boolean;
  137858. /**
  137859. * Enable or disable the active meshes evaluation time capture
  137860. */
  137861. set captureActiveMeshesEvaluationTime(value: boolean);
  137862. /**
  137863. * Gets the perf counter used for render targets render time
  137864. */
  137865. get renderTargetsRenderTimeCounter(): PerfCounter;
  137866. /**
  137867. * Gets the render targets render time capture status
  137868. */
  137869. get captureRenderTargetsRenderTime(): boolean;
  137870. /**
  137871. * Enable or disable the render targets render time capture
  137872. */
  137873. set captureRenderTargetsRenderTime(value: boolean);
  137874. /**
  137875. * Gets the perf counter used for particles render time
  137876. */
  137877. get particlesRenderTimeCounter(): PerfCounter;
  137878. /**
  137879. * Gets the particles render time capture status
  137880. */
  137881. get captureParticlesRenderTime(): boolean;
  137882. /**
  137883. * Enable or disable the particles render time capture
  137884. */
  137885. set captureParticlesRenderTime(value: boolean);
  137886. /**
  137887. * Gets the perf counter used for sprites render time
  137888. */
  137889. get spritesRenderTimeCounter(): PerfCounter;
  137890. /**
  137891. * Gets the sprites render time capture status
  137892. */
  137893. get captureSpritesRenderTime(): boolean;
  137894. /**
  137895. * Enable or disable the sprites render time capture
  137896. */
  137897. set captureSpritesRenderTime(value: boolean);
  137898. /**
  137899. * Gets the perf counter used for physics time
  137900. */
  137901. get physicsTimeCounter(): PerfCounter;
  137902. /**
  137903. * Gets the physics time capture status
  137904. */
  137905. get capturePhysicsTime(): boolean;
  137906. /**
  137907. * Enable or disable the physics time capture
  137908. */
  137909. set capturePhysicsTime(value: boolean);
  137910. /**
  137911. * Gets the perf counter used for animations time
  137912. */
  137913. get animationsTimeCounter(): PerfCounter;
  137914. /**
  137915. * Gets the animations time capture status
  137916. */
  137917. get captureAnimationsTime(): boolean;
  137918. /**
  137919. * Enable or disable the animations time capture
  137920. */
  137921. set captureAnimationsTime(value: boolean);
  137922. /**
  137923. * Gets the perf counter used for frame time capture
  137924. */
  137925. get frameTimeCounter(): PerfCounter;
  137926. /**
  137927. * Gets the frame time capture status
  137928. */
  137929. get captureFrameTime(): boolean;
  137930. /**
  137931. * Enable or disable the frame time capture
  137932. */
  137933. set captureFrameTime(value: boolean);
  137934. /**
  137935. * Gets the perf counter used for inter-frames time capture
  137936. */
  137937. get interFrameTimeCounter(): PerfCounter;
  137938. /**
  137939. * Gets the inter-frames time capture status
  137940. */
  137941. get captureInterFrameTime(): boolean;
  137942. /**
  137943. * Enable or disable the inter-frames time capture
  137944. */
  137945. set captureInterFrameTime(value: boolean);
  137946. /**
  137947. * Gets the perf counter used for render time capture
  137948. */
  137949. get renderTimeCounter(): PerfCounter;
  137950. /**
  137951. * Gets the render time capture status
  137952. */
  137953. get captureRenderTime(): boolean;
  137954. /**
  137955. * Enable or disable the render time capture
  137956. */
  137957. set captureRenderTime(value: boolean);
  137958. /**
  137959. * Gets the perf counter used for camera render time capture
  137960. */
  137961. get cameraRenderTimeCounter(): PerfCounter;
  137962. /**
  137963. * Gets the camera render time capture status
  137964. */
  137965. get captureCameraRenderTime(): boolean;
  137966. /**
  137967. * Enable or disable the camera render time capture
  137968. */
  137969. set captureCameraRenderTime(value: boolean);
  137970. /**
  137971. * Gets the perf counter used for draw calls
  137972. */
  137973. get drawCallsCounter(): PerfCounter;
  137974. /**
  137975. * Instantiates a new scene instrumentation.
  137976. * This class can be used to get instrumentation data from a Babylon engine
  137977. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  137978. * @param scene Defines the scene to instrument
  137979. */
  137980. constructor(
  137981. /**
  137982. * Defines the scene to instrument
  137983. */
  137984. scene: Scene);
  137985. /**
  137986. * Dispose and release associated resources.
  137987. */
  137988. dispose(): void;
  137989. }
  137990. }
  137991. declare module BABYLON {
  137992. /** @hidden */
  137993. export var glowMapGenerationPixelShader: {
  137994. name: string;
  137995. shader: string;
  137996. };
  137997. }
  137998. declare module BABYLON {
  137999. /** @hidden */
  138000. export var glowMapGenerationVertexShader: {
  138001. name: string;
  138002. shader: string;
  138003. };
  138004. }
  138005. declare module BABYLON {
  138006. /**
  138007. * Effect layer options. This helps customizing the behaviour
  138008. * of the effect layer.
  138009. */
  138010. export interface IEffectLayerOptions {
  138011. /**
  138012. * Multiplication factor apply to the canvas size to compute the render target size
  138013. * used to generated the objects (the smaller the faster).
  138014. */
  138015. mainTextureRatio: number;
  138016. /**
  138017. * Enforces a fixed size texture to ensure effect stability across devices.
  138018. */
  138019. mainTextureFixedSize?: number;
  138020. /**
  138021. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  138022. */
  138023. alphaBlendingMode: number;
  138024. /**
  138025. * The camera attached to the layer.
  138026. */
  138027. camera: Nullable<Camera>;
  138028. /**
  138029. * The rendering group to draw the layer in.
  138030. */
  138031. renderingGroupId: number;
  138032. }
  138033. /**
  138034. * The effect layer Helps adding post process effect blended with the main pass.
  138035. *
  138036. * This can be for instance use to generate glow or higlight effects on the scene.
  138037. *
  138038. * The effect layer class can not be used directly and is intented to inherited from to be
  138039. * customized per effects.
  138040. */
  138041. export abstract class EffectLayer {
  138042. private _vertexBuffers;
  138043. private _indexBuffer;
  138044. private _cachedDefines;
  138045. private _effectLayerMapGenerationEffect;
  138046. private _effectLayerOptions;
  138047. private _mergeEffect;
  138048. protected _scene: Scene;
  138049. protected _engine: Engine;
  138050. protected _maxSize: number;
  138051. protected _mainTextureDesiredSize: ISize;
  138052. protected _mainTexture: RenderTargetTexture;
  138053. protected _shouldRender: boolean;
  138054. protected _postProcesses: PostProcess[];
  138055. protected _textures: BaseTexture[];
  138056. protected _emissiveTextureAndColor: {
  138057. texture: Nullable<BaseTexture>;
  138058. color: Color4;
  138059. };
  138060. /**
  138061. * The name of the layer
  138062. */
  138063. name: string;
  138064. /**
  138065. * The clear color of the texture used to generate the glow map.
  138066. */
  138067. neutralColor: Color4;
  138068. /**
  138069. * Specifies whether the highlight layer is enabled or not.
  138070. */
  138071. isEnabled: boolean;
  138072. /**
  138073. * Gets the camera attached to the layer.
  138074. */
  138075. get camera(): Nullable<Camera>;
  138076. /**
  138077. * Gets the rendering group id the layer should render in.
  138078. */
  138079. get renderingGroupId(): number;
  138080. set renderingGroupId(renderingGroupId: number);
  138081. /**
  138082. * An event triggered when the effect layer has been disposed.
  138083. */
  138084. onDisposeObservable: Observable<EffectLayer>;
  138085. /**
  138086. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  138087. */
  138088. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  138089. /**
  138090. * An event triggered when the generated texture is being merged in the scene.
  138091. */
  138092. onBeforeComposeObservable: Observable<EffectLayer>;
  138093. /**
  138094. * An event triggered when the mesh is rendered into the effect render target.
  138095. */
  138096. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  138097. /**
  138098. * An event triggered after the mesh has been rendered into the effect render target.
  138099. */
  138100. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  138101. /**
  138102. * An event triggered when the generated texture has been merged in the scene.
  138103. */
  138104. onAfterComposeObservable: Observable<EffectLayer>;
  138105. /**
  138106. * An event triggered when the efffect layer changes its size.
  138107. */
  138108. onSizeChangedObservable: Observable<EffectLayer>;
  138109. /** @hidden */
  138110. static _SceneComponentInitialization: (scene: Scene) => void;
  138111. /**
  138112. * Instantiates a new effect Layer and references it in the scene.
  138113. * @param name The name of the layer
  138114. * @param scene The scene to use the layer in
  138115. */
  138116. constructor(
  138117. /** The Friendly of the effect in the scene */
  138118. name: string, scene: Scene);
  138119. /**
  138120. * Get the effect name of the layer.
  138121. * @return The effect name
  138122. */
  138123. abstract getEffectName(): string;
  138124. /**
  138125. * Checks for the readiness of the element composing the layer.
  138126. * @param subMesh the mesh to check for
  138127. * @param useInstances specify whether or not to use instances to render the mesh
  138128. * @return true if ready otherwise, false
  138129. */
  138130. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138131. /**
  138132. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  138133. * @returns true if the effect requires stencil during the main canvas render pass.
  138134. */
  138135. abstract needStencil(): boolean;
  138136. /**
  138137. * Create the merge effect. This is the shader use to blit the information back
  138138. * to the main canvas at the end of the scene rendering.
  138139. * @returns The effect containing the shader used to merge the effect on the main canvas
  138140. */
  138141. protected abstract _createMergeEffect(): Effect;
  138142. /**
  138143. * Creates the render target textures and post processes used in the effect layer.
  138144. */
  138145. protected abstract _createTextureAndPostProcesses(): void;
  138146. /**
  138147. * Implementation specific of rendering the generating effect on the main canvas.
  138148. * @param effect The effect used to render through
  138149. */
  138150. protected abstract _internalRender(effect: Effect): void;
  138151. /**
  138152. * Sets the required values for both the emissive texture and and the main color.
  138153. */
  138154. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  138155. /**
  138156. * Free any resources and references associated to a mesh.
  138157. * Internal use
  138158. * @param mesh The mesh to free.
  138159. */
  138160. abstract _disposeMesh(mesh: Mesh): void;
  138161. /**
  138162. * Serializes this layer (Glow or Highlight for example)
  138163. * @returns a serialized layer object
  138164. */
  138165. abstract serialize?(): any;
  138166. /**
  138167. * Initializes the effect layer with the required options.
  138168. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  138169. */
  138170. protected _init(options: Partial<IEffectLayerOptions>): void;
  138171. /**
  138172. * Generates the index buffer of the full screen quad blending to the main canvas.
  138173. */
  138174. private _generateIndexBuffer;
  138175. /**
  138176. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  138177. */
  138178. private _generateVertexBuffer;
  138179. /**
  138180. * Sets the main texture desired size which is the closest power of two
  138181. * of the engine canvas size.
  138182. */
  138183. private _setMainTextureSize;
  138184. /**
  138185. * Creates the main texture for the effect layer.
  138186. */
  138187. protected _createMainTexture(): void;
  138188. /**
  138189. * Adds specific effects defines.
  138190. * @param defines The defines to add specifics to.
  138191. */
  138192. protected _addCustomEffectDefines(defines: string[]): void;
  138193. /**
  138194. * Checks for the readiness of the element composing the layer.
  138195. * @param subMesh the mesh to check for
  138196. * @param useInstances specify whether or not to use instances to render the mesh
  138197. * @param emissiveTexture the associated emissive texture used to generate the glow
  138198. * @return true if ready otherwise, false
  138199. */
  138200. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  138201. /**
  138202. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  138203. */
  138204. render(): void;
  138205. /**
  138206. * Determine if a given mesh will be used in the current effect.
  138207. * @param mesh mesh to test
  138208. * @returns true if the mesh will be used
  138209. */
  138210. hasMesh(mesh: AbstractMesh): boolean;
  138211. /**
  138212. * Returns true if the layer contains information to display, otherwise false.
  138213. * @returns true if the glow layer should be rendered
  138214. */
  138215. shouldRender(): boolean;
  138216. /**
  138217. * Returns true if the mesh should render, otherwise false.
  138218. * @param mesh The mesh to render
  138219. * @returns true if it should render otherwise false
  138220. */
  138221. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  138222. /**
  138223. * Returns true if the mesh can be rendered, otherwise false.
  138224. * @param mesh The mesh to render
  138225. * @param material The material used on the mesh
  138226. * @returns true if it can be rendered otherwise false
  138227. */
  138228. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  138229. /**
  138230. * Returns true if the mesh should render, otherwise false.
  138231. * @param mesh The mesh to render
  138232. * @returns true if it should render otherwise false
  138233. */
  138234. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  138235. /**
  138236. * Renders the submesh passed in parameter to the generation map.
  138237. */
  138238. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  138239. /**
  138240. * Defines whether the current material of the mesh should be use to render the effect.
  138241. * @param mesh defines the current mesh to render
  138242. */
  138243. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  138244. /**
  138245. * Rebuild the required buffers.
  138246. * @hidden Internal use only.
  138247. */
  138248. _rebuild(): void;
  138249. /**
  138250. * Dispose only the render target textures and post process.
  138251. */
  138252. private _disposeTextureAndPostProcesses;
  138253. /**
  138254. * Dispose the highlight layer and free resources.
  138255. */
  138256. dispose(): void;
  138257. /**
  138258. * Gets the class name of the effect layer
  138259. * @returns the string with the class name of the effect layer
  138260. */
  138261. getClassName(): string;
  138262. /**
  138263. * Creates an effect layer from parsed effect layer data
  138264. * @param parsedEffectLayer defines effect layer data
  138265. * @param scene defines the current scene
  138266. * @param rootUrl defines the root URL containing the effect layer information
  138267. * @returns a parsed effect Layer
  138268. */
  138269. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  138270. }
  138271. }
  138272. declare module BABYLON {
  138273. interface AbstractScene {
  138274. /**
  138275. * The list of effect layers (highlights/glow) added to the scene
  138276. * @see https://doc.babylonjs.com/how_to/highlight_layer
  138277. * @see https://doc.babylonjs.com/how_to/glow_layer
  138278. */
  138279. effectLayers: Array<EffectLayer>;
  138280. /**
  138281. * Removes the given effect layer from this scene.
  138282. * @param toRemove defines the effect layer to remove
  138283. * @returns the index of the removed effect layer
  138284. */
  138285. removeEffectLayer(toRemove: EffectLayer): number;
  138286. /**
  138287. * Adds the given effect layer to this scene
  138288. * @param newEffectLayer defines the effect layer to add
  138289. */
  138290. addEffectLayer(newEffectLayer: EffectLayer): void;
  138291. }
  138292. /**
  138293. * Defines the layer scene component responsible to manage any effect layers
  138294. * in a given scene.
  138295. */
  138296. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  138297. /**
  138298. * The component name helpfull to identify the component in the list of scene components.
  138299. */
  138300. readonly name: string;
  138301. /**
  138302. * The scene the component belongs to.
  138303. */
  138304. scene: Scene;
  138305. private _engine;
  138306. private _renderEffects;
  138307. private _needStencil;
  138308. private _previousStencilState;
  138309. /**
  138310. * Creates a new instance of the component for the given scene
  138311. * @param scene Defines the scene to register the component in
  138312. */
  138313. constructor(scene: Scene);
  138314. /**
  138315. * Registers the component in a given scene
  138316. */
  138317. register(): void;
  138318. /**
  138319. * Rebuilds the elements related to this component in case of
  138320. * context lost for instance.
  138321. */
  138322. rebuild(): void;
  138323. /**
  138324. * Serializes the component data to the specified json object
  138325. * @param serializationObject The object to serialize to
  138326. */
  138327. serialize(serializationObject: any): void;
  138328. /**
  138329. * Adds all the elements from the container to the scene
  138330. * @param container the container holding the elements
  138331. */
  138332. addFromContainer(container: AbstractScene): void;
  138333. /**
  138334. * Removes all the elements in the container from the scene
  138335. * @param container contains the elements to remove
  138336. * @param dispose if the removed element should be disposed (default: false)
  138337. */
  138338. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  138339. /**
  138340. * Disposes the component and the associated ressources.
  138341. */
  138342. dispose(): void;
  138343. private _isReadyForMesh;
  138344. private _renderMainTexture;
  138345. private _setStencil;
  138346. private _setStencilBack;
  138347. private _draw;
  138348. private _drawCamera;
  138349. private _drawRenderingGroup;
  138350. }
  138351. }
  138352. declare module BABYLON {
  138353. /** @hidden */
  138354. export var glowMapMergePixelShader: {
  138355. name: string;
  138356. shader: string;
  138357. };
  138358. }
  138359. declare module BABYLON {
  138360. /** @hidden */
  138361. export var glowMapMergeVertexShader: {
  138362. name: string;
  138363. shader: string;
  138364. };
  138365. }
  138366. declare module BABYLON {
  138367. interface AbstractScene {
  138368. /**
  138369. * Return a the first highlight layer of the scene with a given name.
  138370. * @param name The name of the highlight layer to look for.
  138371. * @return The highlight layer if found otherwise null.
  138372. */
  138373. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  138374. }
  138375. /**
  138376. * Glow layer options. This helps customizing the behaviour
  138377. * of the glow layer.
  138378. */
  138379. export interface IGlowLayerOptions {
  138380. /**
  138381. * Multiplication factor apply to the canvas size to compute the render target size
  138382. * used to generated the glowing objects (the smaller the faster).
  138383. */
  138384. mainTextureRatio: number;
  138385. /**
  138386. * Enforces a fixed size texture to ensure resize independant blur.
  138387. */
  138388. mainTextureFixedSize?: number;
  138389. /**
  138390. * How big is the kernel of the blur texture.
  138391. */
  138392. blurKernelSize: number;
  138393. /**
  138394. * The camera attached to the layer.
  138395. */
  138396. camera: Nullable<Camera>;
  138397. /**
  138398. * Enable MSAA by chosing the number of samples.
  138399. */
  138400. mainTextureSamples?: number;
  138401. /**
  138402. * The rendering group to draw the layer in.
  138403. */
  138404. renderingGroupId: number;
  138405. }
  138406. /**
  138407. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  138408. *
  138409. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  138410. *
  138411. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  138412. */
  138413. export class GlowLayer extends EffectLayer {
  138414. /**
  138415. * Effect Name of the layer.
  138416. */
  138417. static readonly EffectName: string;
  138418. /**
  138419. * The default blur kernel size used for the glow.
  138420. */
  138421. static DefaultBlurKernelSize: number;
  138422. /**
  138423. * The default texture size ratio used for the glow.
  138424. */
  138425. static DefaultTextureRatio: number;
  138426. /**
  138427. * Sets the kernel size of the blur.
  138428. */
  138429. set blurKernelSize(value: number);
  138430. /**
  138431. * Gets the kernel size of the blur.
  138432. */
  138433. get blurKernelSize(): number;
  138434. /**
  138435. * Sets the glow intensity.
  138436. */
  138437. set intensity(value: number);
  138438. /**
  138439. * Gets the glow intensity.
  138440. */
  138441. get intensity(): number;
  138442. private _options;
  138443. private _intensity;
  138444. private _horizontalBlurPostprocess1;
  138445. private _verticalBlurPostprocess1;
  138446. private _horizontalBlurPostprocess2;
  138447. private _verticalBlurPostprocess2;
  138448. private _blurTexture1;
  138449. private _blurTexture2;
  138450. private _postProcesses1;
  138451. private _postProcesses2;
  138452. private _includedOnlyMeshes;
  138453. private _excludedMeshes;
  138454. private _meshesUsingTheirOwnMaterials;
  138455. /**
  138456. * Callback used to let the user override the color selection on a per mesh basis
  138457. */
  138458. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  138459. /**
  138460. * Callback used to let the user override the texture selection on a per mesh basis
  138461. */
  138462. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  138463. /**
  138464. * Instantiates a new glow Layer and references it to the scene.
  138465. * @param name The name of the layer
  138466. * @param scene The scene to use the layer in
  138467. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  138468. */
  138469. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  138470. /**
  138471. * Get the effect name of the layer.
  138472. * @return The effect name
  138473. */
  138474. getEffectName(): string;
  138475. /**
  138476. * Create the merge effect. This is the shader use to blit the information back
  138477. * to the main canvas at the end of the scene rendering.
  138478. */
  138479. protected _createMergeEffect(): Effect;
  138480. /**
  138481. * Creates the render target textures and post processes used in the glow layer.
  138482. */
  138483. protected _createTextureAndPostProcesses(): void;
  138484. /**
  138485. * Checks for the readiness of the element composing the layer.
  138486. * @param subMesh the mesh to check for
  138487. * @param useInstances specify wether or not to use instances to render the mesh
  138488. * @param emissiveTexture the associated emissive texture used to generate the glow
  138489. * @return true if ready otherwise, false
  138490. */
  138491. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138492. /**
  138493. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  138494. */
  138495. needStencil(): boolean;
  138496. /**
  138497. * Returns true if the mesh can be rendered, otherwise false.
  138498. * @param mesh The mesh to render
  138499. * @param material The material used on the mesh
  138500. * @returns true if it can be rendered otherwise false
  138501. */
  138502. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  138503. /**
  138504. * Implementation specific of rendering the generating effect on the main canvas.
  138505. * @param effect The effect used to render through
  138506. */
  138507. protected _internalRender(effect: Effect): void;
  138508. /**
  138509. * Sets the required values for both the emissive texture and and the main color.
  138510. */
  138511. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  138512. /**
  138513. * Returns true if the mesh should render, otherwise false.
  138514. * @param mesh The mesh to render
  138515. * @returns true if it should render otherwise false
  138516. */
  138517. protected _shouldRenderMesh(mesh: Mesh): boolean;
  138518. /**
  138519. * Adds specific effects defines.
  138520. * @param defines The defines to add specifics to.
  138521. */
  138522. protected _addCustomEffectDefines(defines: string[]): void;
  138523. /**
  138524. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  138525. * @param mesh The mesh to exclude from the glow layer
  138526. */
  138527. addExcludedMesh(mesh: Mesh): void;
  138528. /**
  138529. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  138530. * @param mesh The mesh to remove
  138531. */
  138532. removeExcludedMesh(mesh: Mesh): void;
  138533. /**
  138534. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  138535. * @param mesh The mesh to include in the glow layer
  138536. */
  138537. addIncludedOnlyMesh(mesh: Mesh): void;
  138538. /**
  138539. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  138540. * @param mesh The mesh to remove
  138541. */
  138542. removeIncludedOnlyMesh(mesh: Mesh): void;
  138543. /**
  138544. * Determine if a given mesh will be used in the glow layer
  138545. * @param mesh The mesh to test
  138546. * @returns true if the mesh will be highlighted by the current glow layer
  138547. */
  138548. hasMesh(mesh: AbstractMesh): boolean;
  138549. /**
  138550. * Defines whether the current material of the mesh should be use to render the effect.
  138551. * @param mesh defines the current mesh to render
  138552. */
  138553. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  138554. /**
  138555. * Add a mesh to be rendered through its own material and not with emissive only.
  138556. * @param mesh The mesh for which we need to use its material
  138557. */
  138558. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  138559. /**
  138560. * Remove a mesh from being rendered through its own material and not with emissive only.
  138561. * @param mesh The mesh for which we need to not use its material
  138562. */
  138563. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  138564. /**
  138565. * Free any resources and references associated to a mesh.
  138566. * Internal use
  138567. * @param mesh The mesh to free.
  138568. * @hidden
  138569. */
  138570. _disposeMesh(mesh: Mesh): void;
  138571. /**
  138572. * Gets the class name of the effect layer
  138573. * @returns the string with the class name of the effect layer
  138574. */
  138575. getClassName(): string;
  138576. /**
  138577. * Serializes this glow layer
  138578. * @returns a serialized glow layer object
  138579. */
  138580. serialize(): any;
  138581. /**
  138582. * Creates a Glow Layer from parsed glow layer data
  138583. * @param parsedGlowLayer defines glow layer data
  138584. * @param scene defines the current scene
  138585. * @param rootUrl defines the root URL containing the glow layer information
  138586. * @returns a parsed Glow Layer
  138587. */
  138588. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  138589. }
  138590. }
  138591. declare module BABYLON {
  138592. /** @hidden */
  138593. export var glowBlurPostProcessPixelShader: {
  138594. name: string;
  138595. shader: string;
  138596. };
  138597. }
  138598. declare module BABYLON {
  138599. interface AbstractScene {
  138600. /**
  138601. * Return a the first highlight layer of the scene with a given name.
  138602. * @param name The name of the highlight layer to look for.
  138603. * @return The highlight layer if found otherwise null.
  138604. */
  138605. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  138606. }
  138607. /**
  138608. * Highlight layer options. This helps customizing the behaviour
  138609. * of the highlight layer.
  138610. */
  138611. export interface IHighlightLayerOptions {
  138612. /**
  138613. * Multiplication factor apply to the canvas size to compute the render target size
  138614. * used to generated the glowing objects (the smaller the faster).
  138615. */
  138616. mainTextureRatio: number;
  138617. /**
  138618. * Enforces a fixed size texture to ensure resize independant blur.
  138619. */
  138620. mainTextureFixedSize?: number;
  138621. /**
  138622. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  138623. * of the picture to blur (the smaller the faster).
  138624. */
  138625. blurTextureSizeRatio: number;
  138626. /**
  138627. * How big in texel of the blur texture is the vertical blur.
  138628. */
  138629. blurVerticalSize: number;
  138630. /**
  138631. * How big in texel of the blur texture is the horizontal blur.
  138632. */
  138633. blurHorizontalSize: number;
  138634. /**
  138635. * Alpha blending mode used to apply the blur. Default is combine.
  138636. */
  138637. alphaBlendingMode: number;
  138638. /**
  138639. * The camera attached to the layer.
  138640. */
  138641. camera: Nullable<Camera>;
  138642. /**
  138643. * Should we display highlight as a solid stroke?
  138644. */
  138645. isStroke?: boolean;
  138646. /**
  138647. * The rendering group to draw the layer in.
  138648. */
  138649. renderingGroupId: number;
  138650. }
  138651. /**
  138652. * The highlight layer Helps adding a glow effect around a mesh.
  138653. *
  138654. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  138655. * glowy meshes to your scene.
  138656. *
  138657. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  138658. */
  138659. export class HighlightLayer extends EffectLayer {
  138660. name: string;
  138661. /**
  138662. * Effect Name of the highlight layer.
  138663. */
  138664. static readonly EffectName: string;
  138665. /**
  138666. * The neutral color used during the preparation of the glow effect.
  138667. * This is black by default as the blend operation is a blend operation.
  138668. */
  138669. static NeutralColor: Color4;
  138670. /**
  138671. * Stencil value used for glowing meshes.
  138672. */
  138673. static GlowingMeshStencilReference: number;
  138674. /**
  138675. * Stencil value used for the other meshes in the scene.
  138676. */
  138677. static NormalMeshStencilReference: number;
  138678. /**
  138679. * Specifies whether or not the inner glow is ACTIVE in the layer.
  138680. */
  138681. innerGlow: boolean;
  138682. /**
  138683. * Specifies whether or not the outer glow is ACTIVE in the layer.
  138684. */
  138685. outerGlow: boolean;
  138686. /**
  138687. * Specifies the horizontal size of the blur.
  138688. */
  138689. set blurHorizontalSize(value: number);
  138690. /**
  138691. * Specifies the vertical size of the blur.
  138692. */
  138693. set blurVerticalSize(value: number);
  138694. /**
  138695. * Gets the horizontal size of the blur.
  138696. */
  138697. get blurHorizontalSize(): number;
  138698. /**
  138699. * Gets the vertical size of the blur.
  138700. */
  138701. get blurVerticalSize(): number;
  138702. /**
  138703. * An event triggered when the highlight layer is being blurred.
  138704. */
  138705. onBeforeBlurObservable: Observable<HighlightLayer>;
  138706. /**
  138707. * An event triggered when the highlight layer has been blurred.
  138708. */
  138709. onAfterBlurObservable: Observable<HighlightLayer>;
  138710. private _instanceGlowingMeshStencilReference;
  138711. private _options;
  138712. private _downSamplePostprocess;
  138713. private _horizontalBlurPostprocess;
  138714. private _verticalBlurPostprocess;
  138715. private _blurTexture;
  138716. private _meshes;
  138717. private _excludedMeshes;
  138718. /**
  138719. * Instantiates a new highlight Layer and references it to the scene..
  138720. * @param name The name of the layer
  138721. * @param scene The scene to use the layer in
  138722. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  138723. */
  138724. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  138725. /**
  138726. * Get the effect name of the layer.
  138727. * @return The effect name
  138728. */
  138729. getEffectName(): string;
  138730. /**
  138731. * Create the merge effect. This is the shader use to blit the information back
  138732. * to the main canvas at the end of the scene rendering.
  138733. */
  138734. protected _createMergeEffect(): Effect;
  138735. /**
  138736. * Creates the render target textures and post processes used in the highlight layer.
  138737. */
  138738. protected _createTextureAndPostProcesses(): void;
  138739. /**
  138740. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  138741. */
  138742. needStencil(): boolean;
  138743. /**
  138744. * Checks for the readiness of the element composing the layer.
  138745. * @param subMesh the mesh to check for
  138746. * @param useInstances specify wether or not to use instances to render the mesh
  138747. * @param emissiveTexture the associated emissive texture used to generate the glow
  138748. * @return true if ready otherwise, false
  138749. */
  138750. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138751. /**
  138752. * Implementation specific of rendering the generating effect on the main canvas.
  138753. * @param effect The effect used to render through
  138754. */
  138755. protected _internalRender(effect: Effect): void;
  138756. /**
  138757. * Returns true if the layer contains information to display, otherwise false.
  138758. */
  138759. shouldRender(): boolean;
  138760. /**
  138761. * Returns true if the mesh should render, otherwise false.
  138762. * @param mesh The mesh to render
  138763. * @returns true if it should render otherwise false
  138764. */
  138765. protected _shouldRenderMesh(mesh: Mesh): boolean;
  138766. /**
  138767. * Returns true if the mesh can be rendered, otherwise false.
  138768. * @param mesh The mesh to render
  138769. * @param material The material used on the mesh
  138770. * @returns true if it can be rendered otherwise false
  138771. */
  138772. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  138773. /**
  138774. * Adds specific effects defines.
  138775. * @param defines The defines to add specifics to.
  138776. */
  138777. protected _addCustomEffectDefines(defines: string[]): void;
  138778. /**
  138779. * Sets the required values for both the emissive texture and and the main color.
  138780. */
  138781. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  138782. /**
  138783. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  138784. * @param mesh The mesh to exclude from the highlight layer
  138785. */
  138786. addExcludedMesh(mesh: Mesh): void;
  138787. /**
  138788. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  138789. * @param mesh The mesh to highlight
  138790. */
  138791. removeExcludedMesh(mesh: Mesh): void;
  138792. /**
  138793. * Determine if a given mesh will be highlighted by the current HighlightLayer
  138794. * @param mesh mesh to test
  138795. * @returns true if the mesh will be highlighted by the current HighlightLayer
  138796. */
  138797. hasMesh(mesh: AbstractMesh): boolean;
  138798. /**
  138799. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  138800. * @param mesh The mesh to highlight
  138801. * @param color The color of the highlight
  138802. * @param glowEmissiveOnly Extract the glow from the emissive texture
  138803. */
  138804. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  138805. /**
  138806. * Remove a mesh from the highlight layer in order to make it stop glowing.
  138807. * @param mesh The mesh to highlight
  138808. */
  138809. removeMesh(mesh: Mesh): void;
  138810. /**
  138811. * Remove all the meshes currently referenced in the highlight layer
  138812. */
  138813. removeAllMeshes(): void;
  138814. /**
  138815. * Force the stencil to the normal expected value for none glowing parts
  138816. */
  138817. private _defaultStencilReference;
  138818. /**
  138819. * Free any resources and references associated to a mesh.
  138820. * Internal use
  138821. * @param mesh The mesh to free.
  138822. * @hidden
  138823. */
  138824. _disposeMesh(mesh: Mesh): void;
  138825. /**
  138826. * Dispose the highlight layer and free resources.
  138827. */
  138828. dispose(): void;
  138829. /**
  138830. * Gets the class name of the effect layer
  138831. * @returns the string with the class name of the effect layer
  138832. */
  138833. getClassName(): string;
  138834. /**
  138835. * Serializes this Highlight layer
  138836. * @returns a serialized Highlight layer object
  138837. */
  138838. serialize(): any;
  138839. /**
  138840. * Creates a Highlight layer from parsed Highlight layer data
  138841. * @param parsedHightlightLayer defines the Highlight layer data
  138842. * @param scene defines the current scene
  138843. * @param rootUrl defines the root URL containing the Highlight layer information
  138844. * @returns a parsed Highlight layer
  138845. */
  138846. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  138847. }
  138848. }
  138849. declare module BABYLON {
  138850. interface AbstractScene {
  138851. /**
  138852. * The list of layers (background and foreground) of the scene
  138853. */
  138854. layers: Array<Layer>;
  138855. }
  138856. /**
  138857. * Defines the layer scene component responsible to manage any layers
  138858. * in a given scene.
  138859. */
  138860. export class LayerSceneComponent implements ISceneComponent {
  138861. /**
  138862. * The component name helpfull to identify the component in the list of scene components.
  138863. */
  138864. readonly name: string;
  138865. /**
  138866. * The scene the component belongs to.
  138867. */
  138868. scene: Scene;
  138869. private _engine;
  138870. /**
  138871. * Creates a new instance of the component for the given scene
  138872. * @param scene Defines the scene to register the component in
  138873. */
  138874. constructor(scene: Scene);
  138875. /**
  138876. * Registers the component in a given scene
  138877. */
  138878. register(): void;
  138879. /**
  138880. * Rebuilds the elements related to this component in case of
  138881. * context lost for instance.
  138882. */
  138883. rebuild(): void;
  138884. /**
  138885. * Disposes the component and the associated ressources.
  138886. */
  138887. dispose(): void;
  138888. private _draw;
  138889. private _drawCameraPredicate;
  138890. private _drawCameraBackground;
  138891. private _drawCameraForeground;
  138892. private _drawRenderTargetPredicate;
  138893. private _drawRenderTargetBackground;
  138894. private _drawRenderTargetForeground;
  138895. /**
  138896. * Adds all the elements from the container to the scene
  138897. * @param container the container holding the elements
  138898. */
  138899. addFromContainer(container: AbstractScene): void;
  138900. /**
  138901. * Removes all the elements in the container from the scene
  138902. * @param container contains the elements to remove
  138903. * @param dispose if the removed element should be disposed (default: false)
  138904. */
  138905. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  138906. }
  138907. }
  138908. declare module BABYLON {
  138909. /** @hidden */
  138910. export var layerPixelShader: {
  138911. name: string;
  138912. shader: string;
  138913. };
  138914. }
  138915. declare module BABYLON {
  138916. /** @hidden */
  138917. export var layerVertexShader: {
  138918. name: string;
  138919. shader: string;
  138920. };
  138921. }
  138922. declare module BABYLON {
  138923. /**
  138924. * This represents a full screen 2d layer.
  138925. * This can be useful to display a picture in the background of your scene for instance.
  138926. * @see https://www.babylonjs-playground.com/#08A2BS#1
  138927. */
  138928. export class Layer {
  138929. /**
  138930. * Define the name of the layer.
  138931. */
  138932. name: string;
  138933. /**
  138934. * Define the texture the layer should display.
  138935. */
  138936. texture: Nullable<Texture>;
  138937. /**
  138938. * Is the layer in background or foreground.
  138939. */
  138940. isBackground: boolean;
  138941. /**
  138942. * Define the color of the layer (instead of texture).
  138943. */
  138944. color: Color4;
  138945. /**
  138946. * Define the scale of the layer in order to zoom in out of the texture.
  138947. */
  138948. scale: Vector2;
  138949. /**
  138950. * Define an offset for the layer in order to shift the texture.
  138951. */
  138952. offset: Vector2;
  138953. /**
  138954. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  138955. */
  138956. alphaBlendingMode: number;
  138957. /**
  138958. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  138959. * Alpha test will not mix with the background color in case of transparency.
  138960. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  138961. */
  138962. alphaTest: boolean;
  138963. /**
  138964. * Define a mask to restrict the layer to only some of the scene cameras.
  138965. */
  138966. layerMask: number;
  138967. /**
  138968. * Define the list of render target the layer is visible into.
  138969. */
  138970. renderTargetTextures: RenderTargetTexture[];
  138971. /**
  138972. * Define if the layer is only used in renderTarget or if it also
  138973. * renders in the main frame buffer of the canvas.
  138974. */
  138975. renderOnlyInRenderTargetTextures: boolean;
  138976. private _scene;
  138977. private _vertexBuffers;
  138978. private _indexBuffer;
  138979. private _effect;
  138980. private _previousDefines;
  138981. /**
  138982. * An event triggered when the layer is disposed.
  138983. */
  138984. onDisposeObservable: Observable<Layer>;
  138985. private _onDisposeObserver;
  138986. /**
  138987. * Back compatibility with callback before the onDisposeObservable existed.
  138988. * The set callback will be triggered when the layer has been disposed.
  138989. */
  138990. set onDispose(callback: () => void);
  138991. /**
  138992. * An event triggered before rendering the scene
  138993. */
  138994. onBeforeRenderObservable: Observable<Layer>;
  138995. private _onBeforeRenderObserver;
  138996. /**
  138997. * Back compatibility with callback before the onBeforeRenderObservable existed.
  138998. * The set callback will be triggered just before rendering the layer.
  138999. */
  139000. set onBeforeRender(callback: () => void);
  139001. /**
  139002. * An event triggered after rendering the scene
  139003. */
  139004. onAfterRenderObservable: Observable<Layer>;
  139005. private _onAfterRenderObserver;
  139006. /**
  139007. * Back compatibility with callback before the onAfterRenderObservable existed.
  139008. * The set callback will be triggered just after rendering the layer.
  139009. */
  139010. set onAfterRender(callback: () => void);
  139011. /**
  139012. * Instantiates a new layer.
  139013. * This represents a full screen 2d layer.
  139014. * This can be useful to display a picture in the background of your scene for instance.
  139015. * @see https://www.babylonjs-playground.com/#08A2BS#1
  139016. * @param name Define the name of the layer in the scene
  139017. * @param imgUrl Define the url of the texture to display in the layer
  139018. * @param scene Define the scene the layer belongs to
  139019. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  139020. * @param color Defines a color for the layer
  139021. */
  139022. constructor(
  139023. /**
  139024. * Define the name of the layer.
  139025. */
  139026. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  139027. private _createIndexBuffer;
  139028. /** @hidden */
  139029. _rebuild(): void;
  139030. /**
  139031. * Renders the layer in the scene.
  139032. */
  139033. render(): void;
  139034. /**
  139035. * Disposes and releases the associated ressources.
  139036. */
  139037. dispose(): void;
  139038. }
  139039. }
  139040. declare module BABYLON {
  139041. /** @hidden */
  139042. export var lensFlarePixelShader: {
  139043. name: string;
  139044. shader: string;
  139045. };
  139046. }
  139047. declare module BABYLON {
  139048. /** @hidden */
  139049. export var lensFlareVertexShader: {
  139050. name: string;
  139051. shader: string;
  139052. };
  139053. }
  139054. declare module BABYLON {
  139055. /**
  139056. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  139057. * It is usually composed of several `lensFlare`.
  139058. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139059. */
  139060. export class LensFlareSystem {
  139061. /**
  139062. * Define the name of the lens flare system
  139063. */
  139064. name: string;
  139065. /**
  139066. * List of lens flares used in this system.
  139067. */
  139068. lensFlares: LensFlare[];
  139069. /**
  139070. * Define a limit from the border the lens flare can be visible.
  139071. */
  139072. borderLimit: number;
  139073. /**
  139074. * Define a viewport border we do not want to see the lens flare in.
  139075. */
  139076. viewportBorder: number;
  139077. /**
  139078. * Define a predicate which could limit the list of meshes able to occlude the effect.
  139079. */
  139080. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  139081. /**
  139082. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  139083. */
  139084. layerMask: number;
  139085. /**
  139086. * Define the id of the lens flare system in the scene.
  139087. * (equal to name by default)
  139088. */
  139089. id: string;
  139090. private _scene;
  139091. private _emitter;
  139092. private _vertexBuffers;
  139093. private _indexBuffer;
  139094. private _effect;
  139095. private _positionX;
  139096. private _positionY;
  139097. private _isEnabled;
  139098. /** @hidden */
  139099. static _SceneComponentInitialization: (scene: Scene) => void;
  139100. /**
  139101. * Instantiates a lens flare system.
  139102. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  139103. * It is usually composed of several `lensFlare`.
  139104. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139105. * @param name Define the name of the lens flare system in the scene
  139106. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  139107. * @param scene Define the scene the lens flare system belongs to
  139108. */
  139109. constructor(
  139110. /**
  139111. * Define the name of the lens flare system
  139112. */
  139113. name: string, emitter: any, scene: Scene);
  139114. /**
  139115. * Define if the lens flare system is enabled.
  139116. */
  139117. get isEnabled(): boolean;
  139118. set isEnabled(value: boolean);
  139119. /**
  139120. * Get the scene the effects belongs to.
  139121. * @returns the scene holding the lens flare system
  139122. */
  139123. getScene(): Scene;
  139124. /**
  139125. * Get the emitter of the lens flare system.
  139126. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  139127. * @returns the emitter of the lens flare system
  139128. */
  139129. getEmitter(): any;
  139130. /**
  139131. * Set the emitter of the lens flare system.
  139132. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  139133. * @param newEmitter Define the new emitter of the system
  139134. */
  139135. setEmitter(newEmitter: any): void;
  139136. /**
  139137. * Get the lens flare system emitter position.
  139138. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  139139. * @returns the position
  139140. */
  139141. getEmitterPosition(): Vector3;
  139142. /**
  139143. * @hidden
  139144. */
  139145. computeEffectivePosition(globalViewport: Viewport): boolean;
  139146. /** @hidden */
  139147. _isVisible(): boolean;
  139148. /**
  139149. * @hidden
  139150. */
  139151. render(): boolean;
  139152. /**
  139153. * Dispose and release the lens flare with its associated resources.
  139154. */
  139155. dispose(): void;
  139156. /**
  139157. * Parse a lens flare system from a JSON repressentation
  139158. * @param parsedLensFlareSystem Define the JSON to parse
  139159. * @param scene Define the scene the parsed system should be instantiated in
  139160. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  139161. * @returns the parsed system
  139162. */
  139163. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  139164. /**
  139165. * Serialize the current Lens Flare System into a JSON representation.
  139166. * @returns the serialized JSON
  139167. */
  139168. serialize(): any;
  139169. }
  139170. }
  139171. declare module BABYLON {
  139172. /**
  139173. * This represents one of the lens effect in a `lensFlareSystem`.
  139174. * It controls one of the indiviual texture used in the effect.
  139175. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139176. */
  139177. export class LensFlare {
  139178. /**
  139179. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  139180. */
  139181. size: number;
  139182. /**
  139183. * 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.
  139184. */
  139185. position: number;
  139186. /**
  139187. * Define the lens color.
  139188. */
  139189. color: Color3;
  139190. /**
  139191. * Define the lens texture.
  139192. */
  139193. texture: Nullable<Texture>;
  139194. /**
  139195. * Define the alpha mode to render this particular lens.
  139196. */
  139197. alphaMode: number;
  139198. private _system;
  139199. /**
  139200. * Creates a new Lens Flare.
  139201. * This represents one of the lens effect in a `lensFlareSystem`.
  139202. * It controls one of the indiviual texture used in the effect.
  139203. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139204. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  139205. * @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.
  139206. * @param color Define the lens color
  139207. * @param imgUrl Define the lens texture url
  139208. * @param system Define the `lensFlareSystem` this flare is part of
  139209. * @returns The newly created Lens Flare
  139210. */
  139211. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  139212. /**
  139213. * Instantiates a new Lens Flare.
  139214. * This represents one of the lens effect in a `lensFlareSystem`.
  139215. * It controls one of the indiviual texture used in the effect.
  139216. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139217. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  139218. * @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.
  139219. * @param color Define the lens color
  139220. * @param imgUrl Define the lens texture url
  139221. * @param system Define the `lensFlareSystem` this flare is part of
  139222. */
  139223. constructor(
  139224. /**
  139225. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  139226. */
  139227. size: number,
  139228. /**
  139229. * 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.
  139230. */
  139231. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  139232. /**
  139233. * Dispose and release the lens flare with its associated resources.
  139234. */
  139235. dispose(): void;
  139236. }
  139237. }
  139238. declare module BABYLON {
  139239. interface AbstractScene {
  139240. /**
  139241. * The list of lens flare system added to the scene
  139242. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139243. */
  139244. lensFlareSystems: Array<LensFlareSystem>;
  139245. /**
  139246. * Removes the given lens flare system from this scene.
  139247. * @param toRemove The lens flare system to remove
  139248. * @returns The index of the removed lens flare system
  139249. */
  139250. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  139251. /**
  139252. * Adds the given lens flare system to this scene
  139253. * @param newLensFlareSystem The lens flare system to add
  139254. */
  139255. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  139256. /**
  139257. * Gets a lens flare system using its name
  139258. * @param name defines the name to look for
  139259. * @returns the lens flare system or null if not found
  139260. */
  139261. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  139262. /**
  139263. * Gets a lens flare system using its id
  139264. * @param id defines the id to look for
  139265. * @returns the lens flare system or null if not found
  139266. */
  139267. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  139268. }
  139269. /**
  139270. * Defines the lens flare scene component responsible to manage any lens flares
  139271. * in a given scene.
  139272. */
  139273. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  139274. /**
  139275. * The component name helpfull to identify the component in the list of scene components.
  139276. */
  139277. readonly name: string;
  139278. /**
  139279. * The scene the component belongs to.
  139280. */
  139281. scene: Scene;
  139282. /**
  139283. * Creates a new instance of the component for the given scene
  139284. * @param scene Defines the scene to register the component in
  139285. */
  139286. constructor(scene: Scene);
  139287. /**
  139288. * Registers the component in a given scene
  139289. */
  139290. register(): void;
  139291. /**
  139292. * Rebuilds the elements related to this component in case of
  139293. * context lost for instance.
  139294. */
  139295. rebuild(): void;
  139296. /**
  139297. * Adds all the elements from the container to the scene
  139298. * @param container the container holding the elements
  139299. */
  139300. addFromContainer(container: AbstractScene): void;
  139301. /**
  139302. * Removes all the elements in the container from the scene
  139303. * @param container contains the elements to remove
  139304. * @param dispose if the removed element should be disposed (default: false)
  139305. */
  139306. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139307. /**
  139308. * Serializes the component data to the specified json object
  139309. * @param serializationObject The object to serialize to
  139310. */
  139311. serialize(serializationObject: any): void;
  139312. /**
  139313. * Disposes the component and the associated ressources.
  139314. */
  139315. dispose(): void;
  139316. private _draw;
  139317. }
  139318. }
  139319. declare module BABYLON {
  139320. /** @hidden */
  139321. export var depthPixelShader: {
  139322. name: string;
  139323. shader: string;
  139324. };
  139325. }
  139326. declare module BABYLON {
  139327. /** @hidden */
  139328. export var depthVertexShader: {
  139329. name: string;
  139330. shader: string;
  139331. };
  139332. }
  139333. declare module BABYLON {
  139334. /**
  139335. * This represents a depth renderer in Babylon.
  139336. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  139337. */
  139338. export class DepthRenderer {
  139339. private _scene;
  139340. private _depthMap;
  139341. private _effect;
  139342. private readonly _storeNonLinearDepth;
  139343. private readonly _clearColor;
  139344. /** Get if the depth renderer is using packed depth or not */
  139345. readonly isPacked: boolean;
  139346. private _cachedDefines;
  139347. private _camera;
  139348. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  139349. enabled: boolean;
  139350. /**
  139351. * Specifiess that the depth renderer will only be used within
  139352. * the camera it is created for.
  139353. * This can help forcing its rendering during the camera processing.
  139354. */
  139355. useOnlyInActiveCamera: boolean;
  139356. /** @hidden */
  139357. static _SceneComponentInitialization: (scene: Scene) => void;
  139358. /**
  139359. * Instantiates a depth renderer
  139360. * @param scene The scene the renderer belongs to
  139361. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  139362. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  139363. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  139364. */
  139365. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  139366. /**
  139367. * Creates the depth rendering effect and checks if the effect is ready.
  139368. * @param subMesh The submesh to be used to render the depth map of
  139369. * @param useInstances If multiple world instances should be used
  139370. * @returns if the depth renderer is ready to render the depth map
  139371. */
  139372. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139373. /**
  139374. * Gets the texture which the depth map will be written to.
  139375. * @returns The depth map texture
  139376. */
  139377. getDepthMap(): RenderTargetTexture;
  139378. /**
  139379. * Disposes of the depth renderer.
  139380. */
  139381. dispose(): void;
  139382. }
  139383. }
  139384. declare module BABYLON {
  139385. /** @hidden */
  139386. export var minmaxReduxPixelShader: {
  139387. name: string;
  139388. shader: string;
  139389. };
  139390. }
  139391. declare module BABYLON {
  139392. /**
  139393. * This class computes a min/max reduction from a texture: it means it computes the minimum
  139394. * and maximum values from all values of the texture.
  139395. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  139396. * The source values are read from the red channel of the texture.
  139397. */
  139398. export class MinMaxReducer {
  139399. /**
  139400. * Observable triggered when the computation has been performed
  139401. */
  139402. onAfterReductionPerformed: Observable<{
  139403. min: number;
  139404. max: number;
  139405. }>;
  139406. protected _camera: Camera;
  139407. protected _sourceTexture: Nullable<RenderTargetTexture>;
  139408. protected _reductionSteps: Nullable<Array<PostProcess>>;
  139409. protected _postProcessManager: PostProcessManager;
  139410. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  139411. protected _forceFullscreenViewport: boolean;
  139412. /**
  139413. * Creates a min/max reducer
  139414. * @param camera The camera to use for the post processes
  139415. */
  139416. constructor(camera: Camera);
  139417. /**
  139418. * Gets the texture used to read the values from.
  139419. */
  139420. get sourceTexture(): Nullable<RenderTargetTexture>;
  139421. /**
  139422. * Sets the source texture to read the values from.
  139423. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  139424. * because in such textures '1' value must not be taken into account to compute the maximum
  139425. * as this value is used to clear the texture.
  139426. * Note that the computation is not activated by calling this function, you must call activate() for that!
  139427. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  139428. * @param depthRedux Indicates if the texture is a depth texture or not
  139429. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  139430. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  139431. */
  139432. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  139433. /**
  139434. * Defines the refresh rate of the computation.
  139435. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  139436. */
  139437. get refreshRate(): number;
  139438. set refreshRate(value: number);
  139439. protected _activated: boolean;
  139440. /**
  139441. * Gets the activation status of the reducer
  139442. */
  139443. get activated(): boolean;
  139444. /**
  139445. * Activates the reduction computation.
  139446. * When activated, the observers registered in onAfterReductionPerformed are
  139447. * called after the compuation is performed
  139448. */
  139449. activate(): void;
  139450. /**
  139451. * Deactivates the reduction computation.
  139452. */
  139453. deactivate(): void;
  139454. /**
  139455. * Disposes the min/max reducer
  139456. * @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.
  139457. */
  139458. dispose(disposeAll?: boolean): void;
  139459. }
  139460. }
  139461. declare module BABYLON {
  139462. /**
  139463. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  139464. */
  139465. export class DepthReducer extends MinMaxReducer {
  139466. private _depthRenderer;
  139467. private _depthRendererId;
  139468. /**
  139469. * Gets the depth renderer used for the computation.
  139470. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  139471. */
  139472. get depthRenderer(): Nullable<DepthRenderer>;
  139473. /**
  139474. * Creates a depth reducer
  139475. * @param camera The camera used to render the depth texture
  139476. */
  139477. constructor(camera: Camera);
  139478. /**
  139479. * Sets the depth renderer to use to generate the depth map
  139480. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  139481. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  139482. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  139483. */
  139484. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  139485. /** @hidden */
  139486. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  139487. /**
  139488. * Activates the reduction computation.
  139489. * When activated, the observers registered in onAfterReductionPerformed are
  139490. * called after the compuation is performed
  139491. */
  139492. activate(): void;
  139493. /**
  139494. * Deactivates the reduction computation.
  139495. */
  139496. deactivate(): void;
  139497. /**
  139498. * Disposes the depth reducer
  139499. * @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.
  139500. */
  139501. dispose(disposeAll?: boolean): void;
  139502. }
  139503. }
  139504. declare module BABYLON {
  139505. /**
  139506. * A CSM implementation allowing casting shadows on large scenes.
  139507. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  139508. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  139509. */
  139510. export class CascadedShadowGenerator extends ShadowGenerator {
  139511. private static readonly frustumCornersNDCSpace;
  139512. /**
  139513. * Name of the CSM class
  139514. */
  139515. static CLASSNAME: string;
  139516. /**
  139517. * Defines the default number of cascades used by the CSM.
  139518. */
  139519. static readonly DEFAULT_CASCADES_COUNT: number;
  139520. /**
  139521. * Defines the minimum number of cascades used by the CSM.
  139522. */
  139523. static readonly MIN_CASCADES_COUNT: number;
  139524. /**
  139525. * Defines the maximum number of cascades used by the CSM.
  139526. */
  139527. static readonly MAX_CASCADES_COUNT: number;
  139528. protected _validateFilter(filter: number): number;
  139529. /**
  139530. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  139531. */
  139532. penumbraDarkness: number;
  139533. private _numCascades;
  139534. /**
  139535. * Gets or set the number of cascades used by the CSM.
  139536. */
  139537. get numCascades(): number;
  139538. set numCascades(value: number);
  139539. /**
  139540. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  139541. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  139542. */
  139543. stabilizeCascades: boolean;
  139544. private _freezeShadowCastersBoundingInfo;
  139545. private _freezeShadowCastersBoundingInfoObservable;
  139546. /**
  139547. * Enables or disables the shadow casters bounding info computation.
  139548. * If your shadow casters don't move, you can disable this feature.
  139549. * If it is enabled, the bounding box computation is done every frame.
  139550. */
  139551. get freezeShadowCastersBoundingInfo(): boolean;
  139552. set freezeShadowCastersBoundingInfo(freeze: boolean);
  139553. private _scbiMin;
  139554. private _scbiMax;
  139555. protected _computeShadowCastersBoundingInfo(): void;
  139556. protected _shadowCastersBoundingInfo: BoundingInfo;
  139557. /**
  139558. * Gets or sets the shadow casters bounding info.
  139559. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  139560. * so that the system won't overwrite the bounds you provide
  139561. */
  139562. get shadowCastersBoundingInfo(): BoundingInfo;
  139563. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  139564. protected _breaksAreDirty: boolean;
  139565. protected _minDistance: number;
  139566. protected _maxDistance: number;
  139567. /**
  139568. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  139569. *
  139570. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  139571. * If you don't know these values, simply leave them to their defaults and don't call this function.
  139572. * @param min minimal distance for the breaks (default to 0.)
  139573. * @param max maximal distance for the breaks (default to 1.)
  139574. */
  139575. setMinMaxDistance(min: number, max: number): void;
  139576. /** Gets the minimal distance used in the cascade break computation */
  139577. get minDistance(): number;
  139578. /** Gets the maximal distance used in the cascade break computation */
  139579. get maxDistance(): number;
  139580. /**
  139581. * Gets the class name of that object
  139582. * @returns "CascadedShadowGenerator"
  139583. */
  139584. getClassName(): string;
  139585. private _cascadeMinExtents;
  139586. private _cascadeMaxExtents;
  139587. /**
  139588. * Gets a cascade minimum extents
  139589. * @param cascadeIndex index of the cascade
  139590. * @returns the minimum cascade extents
  139591. */
  139592. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  139593. /**
  139594. * Gets a cascade maximum extents
  139595. * @param cascadeIndex index of the cascade
  139596. * @returns the maximum cascade extents
  139597. */
  139598. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  139599. private _cascades;
  139600. private _currentLayer;
  139601. private _viewSpaceFrustumsZ;
  139602. private _viewMatrices;
  139603. private _projectionMatrices;
  139604. private _transformMatrices;
  139605. private _transformMatricesAsArray;
  139606. private _frustumLengths;
  139607. private _lightSizeUVCorrection;
  139608. private _depthCorrection;
  139609. private _frustumCornersWorldSpace;
  139610. private _frustumCenter;
  139611. private _shadowCameraPos;
  139612. private _shadowMaxZ;
  139613. /**
  139614. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  139615. * It defaults to camera.maxZ
  139616. */
  139617. get shadowMaxZ(): number;
  139618. /**
  139619. * Sets the shadow max z distance.
  139620. */
  139621. set shadowMaxZ(value: number);
  139622. protected _debug: boolean;
  139623. /**
  139624. * Gets or sets the debug flag.
  139625. * When enabled, the cascades are materialized by different colors on the screen.
  139626. */
  139627. get debug(): boolean;
  139628. set debug(dbg: boolean);
  139629. private _depthClamp;
  139630. /**
  139631. * Gets or sets the depth clamping value.
  139632. *
  139633. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  139634. * to account for the shadow casters far away.
  139635. *
  139636. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  139637. */
  139638. get depthClamp(): boolean;
  139639. set depthClamp(value: boolean);
  139640. private _cascadeBlendPercentage;
  139641. /**
  139642. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  139643. * It defaults to 0.1 (10% blending).
  139644. */
  139645. get cascadeBlendPercentage(): number;
  139646. set cascadeBlendPercentage(value: number);
  139647. private _lambda;
  139648. /**
  139649. * Gets or set the lambda parameter.
  139650. * This parameter is used to split the camera frustum and create the cascades.
  139651. * 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.
  139652. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  139653. */
  139654. get lambda(): number;
  139655. set lambda(value: number);
  139656. /**
  139657. * Gets the view matrix corresponding to a given cascade
  139658. * @param cascadeNum cascade to retrieve the view matrix from
  139659. * @returns the cascade view matrix
  139660. */
  139661. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  139662. /**
  139663. * Gets the projection matrix corresponding to a given cascade
  139664. * @param cascadeNum cascade to retrieve the projection matrix from
  139665. * @returns the cascade projection matrix
  139666. */
  139667. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  139668. /**
  139669. * Gets the transformation matrix corresponding to a given cascade
  139670. * @param cascadeNum cascade to retrieve the transformation matrix from
  139671. * @returns the cascade transformation matrix
  139672. */
  139673. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  139674. private _depthRenderer;
  139675. /**
  139676. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  139677. *
  139678. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  139679. *
  139680. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  139681. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  139682. * @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
  139683. */
  139684. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  139685. private _depthReducer;
  139686. private _autoCalcDepthBounds;
  139687. /**
  139688. * Gets or sets the autoCalcDepthBounds property.
  139689. *
  139690. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  139691. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  139692. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  139693. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  139694. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  139695. */
  139696. get autoCalcDepthBounds(): boolean;
  139697. set autoCalcDepthBounds(value: boolean);
  139698. /**
  139699. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  139700. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  139701. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  139702. * for setting the refresh rate on the renderer yourself!
  139703. */
  139704. get autoCalcDepthBoundsRefreshRate(): number;
  139705. set autoCalcDepthBoundsRefreshRate(value: number);
  139706. /**
  139707. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  139708. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  139709. * you change the camera near/far planes!
  139710. */
  139711. splitFrustum(): void;
  139712. private _splitFrustum;
  139713. private _computeMatrices;
  139714. private _computeFrustumInWorldSpace;
  139715. private _computeCascadeFrustum;
  139716. /**
  139717. * Support test.
  139718. */
  139719. static get IsSupported(): boolean;
  139720. /** @hidden */
  139721. static _SceneComponentInitialization: (scene: Scene) => void;
  139722. /**
  139723. * Creates a Cascaded Shadow Generator object.
  139724. * A ShadowGenerator is the required tool to use the shadows.
  139725. * Each directional light casting shadows needs to use its own ShadowGenerator.
  139726. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  139727. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  139728. * @param light The directional light object generating the shadows.
  139729. * @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.
  139730. */
  139731. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  139732. protected _initializeGenerator(): void;
  139733. protected _createTargetRenderTexture(): void;
  139734. protected _initializeShadowMap(): void;
  139735. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  139736. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  139737. /**
  139738. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  139739. * @param defines Defines of the material we want to update
  139740. * @param lightIndex Index of the light in the enabled light list of the material
  139741. */
  139742. prepareDefines(defines: any, lightIndex: number): void;
  139743. /**
  139744. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  139745. * defined in the generator but impacting the effect).
  139746. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  139747. * @param effect The effect we are binfing the information for
  139748. */
  139749. bindShadowLight(lightIndex: string, effect: Effect): void;
  139750. /**
  139751. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  139752. * (eq to view projection * shadow projection matrices)
  139753. * @returns The transform matrix used to create the shadow map
  139754. */
  139755. getTransformMatrix(): Matrix;
  139756. /**
  139757. * Disposes the ShadowGenerator.
  139758. * Returns nothing.
  139759. */
  139760. dispose(): void;
  139761. /**
  139762. * Serializes the shadow generator setup to a json object.
  139763. * @returns The serialized JSON object
  139764. */
  139765. serialize(): any;
  139766. /**
  139767. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  139768. * @param parsedShadowGenerator The JSON object to parse
  139769. * @param scene The scene to create the shadow map for
  139770. * @returns The parsed shadow generator
  139771. */
  139772. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  139773. }
  139774. }
  139775. declare module BABYLON {
  139776. /**
  139777. * Defines the shadow generator component responsible to manage any shadow generators
  139778. * in a given scene.
  139779. */
  139780. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  139781. /**
  139782. * The component name helpfull to identify the component in the list of scene components.
  139783. */
  139784. readonly name: string;
  139785. /**
  139786. * The scene the component belongs to.
  139787. */
  139788. scene: Scene;
  139789. /**
  139790. * Creates a new instance of the component for the given scene
  139791. * @param scene Defines the scene to register the component in
  139792. */
  139793. constructor(scene: Scene);
  139794. /**
  139795. * Registers the component in a given scene
  139796. */
  139797. register(): void;
  139798. /**
  139799. * Rebuilds the elements related to this component in case of
  139800. * context lost for instance.
  139801. */
  139802. rebuild(): void;
  139803. /**
  139804. * Serializes the component data to the specified json object
  139805. * @param serializationObject The object to serialize to
  139806. */
  139807. serialize(serializationObject: any): void;
  139808. /**
  139809. * Adds all the elements from the container to the scene
  139810. * @param container the container holding the elements
  139811. */
  139812. addFromContainer(container: AbstractScene): void;
  139813. /**
  139814. * Removes all the elements in the container from the scene
  139815. * @param container contains the elements to remove
  139816. * @param dispose if the removed element should be disposed (default: false)
  139817. */
  139818. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139819. /**
  139820. * Rebuilds the elements related to this component in case of
  139821. * context lost for instance.
  139822. */
  139823. dispose(): void;
  139824. private _gatherRenderTargets;
  139825. }
  139826. }
  139827. declare module BABYLON {
  139828. /**
  139829. * A point light is a light defined by an unique point in world space.
  139830. * The light is emitted in every direction from this point.
  139831. * A good example of a point light is a standard light bulb.
  139832. * Documentation: https://doc.babylonjs.com/babylon101/lights
  139833. */
  139834. export class PointLight extends ShadowLight {
  139835. private _shadowAngle;
  139836. /**
  139837. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  139838. * This specifies what angle the shadow will use to be created.
  139839. *
  139840. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  139841. */
  139842. get shadowAngle(): number;
  139843. /**
  139844. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  139845. * This specifies what angle the shadow will use to be created.
  139846. *
  139847. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  139848. */
  139849. set shadowAngle(value: number);
  139850. /**
  139851. * Gets the direction if it has been set.
  139852. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  139853. */
  139854. get direction(): Vector3;
  139855. /**
  139856. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  139857. */
  139858. set direction(value: Vector3);
  139859. /**
  139860. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  139861. * A PointLight emits the light in every direction.
  139862. * It can cast shadows.
  139863. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  139864. * ```javascript
  139865. * var pointLight = new PointLight("pl", camera.position, scene);
  139866. * ```
  139867. * Documentation : https://doc.babylonjs.com/babylon101/lights
  139868. * @param name The light friendly name
  139869. * @param position The position of the point light in the scene
  139870. * @param scene The scene the lights belongs to
  139871. */
  139872. constructor(name: string, position: Vector3, scene: Scene);
  139873. /**
  139874. * Returns the string "PointLight"
  139875. * @returns the class name
  139876. */
  139877. getClassName(): string;
  139878. /**
  139879. * Returns the integer 0.
  139880. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  139881. */
  139882. getTypeID(): number;
  139883. /**
  139884. * Specifies wether or not the shadowmap should be a cube texture.
  139885. * @returns true if the shadowmap needs to be a cube texture.
  139886. */
  139887. needCube(): boolean;
  139888. /**
  139889. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  139890. * @param faceIndex The index of the face we are computed the direction to generate shadow
  139891. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  139892. */
  139893. getShadowDirection(faceIndex?: number): Vector3;
  139894. /**
  139895. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  139896. * - fov = PI / 2
  139897. * - aspect ratio : 1.0
  139898. * - z-near and far equal to the active camera minZ and maxZ.
  139899. * Returns the PointLight.
  139900. */
  139901. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  139902. protected _buildUniformLayout(): void;
  139903. /**
  139904. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  139905. * @param effect The effect to update
  139906. * @param lightIndex The index of the light in the effect to update
  139907. * @returns The point light
  139908. */
  139909. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  139910. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  139911. /**
  139912. * Prepares the list of defines specific to the light type.
  139913. * @param defines the list of defines
  139914. * @param lightIndex defines the index of the light for the effect
  139915. */
  139916. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  139917. }
  139918. }
  139919. declare module BABYLON {
  139920. /**
  139921. * Header information of HDR texture files.
  139922. */
  139923. export interface HDRInfo {
  139924. /**
  139925. * The height of the texture in pixels.
  139926. */
  139927. height: number;
  139928. /**
  139929. * The width of the texture in pixels.
  139930. */
  139931. width: number;
  139932. /**
  139933. * The index of the beginning of the data in the binary file.
  139934. */
  139935. dataPosition: number;
  139936. }
  139937. /**
  139938. * This groups tools to convert HDR texture to native colors array.
  139939. */
  139940. export class HDRTools {
  139941. private static Ldexp;
  139942. private static Rgbe2float;
  139943. private static readStringLine;
  139944. /**
  139945. * Reads header information from an RGBE texture stored in a native array.
  139946. * More information on this format are available here:
  139947. * https://en.wikipedia.org/wiki/RGBE_image_format
  139948. *
  139949. * @param uint8array The binary file stored in native array.
  139950. * @return The header information.
  139951. */
  139952. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  139953. /**
  139954. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  139955. * This RGBE texture needs to store the information as a panorama.
  139956. *
  139957. * More information on this format are available here:
  139958. * https://en.wikipedia.org/wiki/RGBE_image_format
  139959. *
  139960. * @param buffer The binary file stored in an array buffer.
  139961. * @param size The expected size of the extracted cubemap.
  139962. * @return The Cube Map information.
  139963. */
  139964. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  139965. /**
  139966. * Returns the pixels data extracted from an RGBE texture.
  139967. * This pixels will be stored left to right up to down in the R G B order in one array.
  139968. *
  139969. * More information on this format are available here:
  139970. * https://en.wikipedia.org/wiki/RGBE_image_format
  139971. *
  139972. * @param uint8array The binary file stored in an array buffer.
  139973. * @param hdrInfo The header information of the file.
  139974. * @return The pixels data in RGB right to left up to down order.
  139975. */
  139976. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  139977. private static RGBE_ReadPixels_RLE;
  139978. private static RGBE_ReadPixels_NOT_RLE;
  139979. }
  139980. }
  139981. declare module BABYLON {
  139982. /**
  139983. * Effect Render Options
  139984. */
  139985. export interface IEffectRendererOptions {
  139986. /**
  139987. * Defines the vertices positions.
  139988. */
  139989. positions?: number[];
  139990. /**
  139991. * Defines the indices.
  139992. */
  139993. indices?: number[];
  139994. }
  139995. /**
  139996. * Helper class to render one or more effects.
  139997. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  139998. */
  139999. export class EffectRenderer {
  140000. private engine;
  140001. private static _DefaultOptions;
  140002. private _vertexBuffers;
  140003. private _indexBuffer;
  140004. private _fullscreenViewport;
  140005. /**
  140006. * Creates an effect renderer
  140007. * @param engine the engine to use for rendering
  140008. * @param options defines the options of the effect renderer
  140009. */
  140010. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  140011. /**
  140012. * Sets the current viewport in normalized coordinates 0-1
  140013. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  140014. */
  140015. setViewport(viewport?: Viewport): void;
  140016. /**
  140017. * Binds the embedded attributes buffer to the effect.
  140018. * @param effect Defines the effect to bind the attributes for
  140019. */
  140020. bindBuffers(effect: Effect): void;
  140021. /**
  140022. * Sets the current effect wrapper to use during draw.
  140023. * The effect needs to be ready before calling this api.
  140024. * This also sets the default full screen position attribute.
  140025. * @param effectWrapper Defines the effect to draw with
  140026. */
  140027. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  140028. /**
  140029. * Restores engine states
  140030. */
  140031. restoreStates(): void;
  140032. /**
  140033. * Draws a full screen quad.
  140034. */
  140035. draw(): void;
  140036. private isRenderTargetTexture;
  140037. /**
  140038. * renders one or more effects to a specified texture
  140039. * @param effectWrapper the effect to renderer
  140040. * @param outputTexture texture to draw to, if null it will render to the screen.
  140041. */
  140042. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  140043. /**
  140044. * Disposes of the effect renderer
  140045. */
  140046. dispose(): void;
  140047. }
  140048. /**
  140049. * Options to create an EffectWrapper
  140050. */
  140051. interface EffectWrapperCreationOptions {
  140052. /**
  140053. * Engine to use to create the effect
  140054. */
  140055. engine: ThinEngine;
  140056. /**
  140057. * Fragment shader for the effect
  140058. */
  140059. fragmentShader: string;
  140060. /**
  140061. * Use the shader store instead of direct source code
  140062. */
  140063. useShaderStore?: boolean;
  140064. /**
  140065. * Vertex shader for the effect
  140066. */
  140067. vertexShader?: string;
  140068. /**
  140069. * Attributes to use in the shader
  140070. */
  140071. attributeNames?: Array<string>;
  140072. /**
  140073. * Uniforms to use in the shader
  140074. */
  140075. uniformNames?: Array<string>;
  140076. /**
  140077. * Texture sampler names to use in the shader
  140078. */
  140079. samplerNames?: Array<string>;
  140080. /**
  140081. * Defines to use in the shader
  140082. */
  140083. defines?: Array<string>;
  140084. /**
  140085. * Callback when effect is compiled
  140086. */
  140087. onCompiled?: Nullable<(effect: Effect) => void>;
  140088. /**
  140089. * The friendly name of the effect displayed in Spector.
  140090. */
  140091. name?: string;
  140092. }
  140093. /**
  140094. * Wraps an effect to be used for rendering
  140095. */
  140096. export class EffectWrapper {
  140097. /**
  140098. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  140099. */
  140100. onApplyObservable: Observable<{}>;
  140101. /**
  140102. * The underlying effect
  140103. */
  140104. effect: Effect;
  140105. /**
  140106. * Creates an effect to be renderer
  140107. * @param creationOptions options to create the effect
  140108. */
  140109. constructor(creationOptions: EffectWrapperCreationOptions);
  140110. /**
  140111. * Disposes of the effect wrapper
  140112. */
  140113. dispose(): void;
  140114. }
  140115. }
  140116. declare module BABYLON {
  140117. /** @hidden */
  140118. export var hdrFilteringVertexShader: {
  140119. name: string;
  140120. shader: string;
  140121. };
  140122. }
  140123. declare module BABYLON {
  140124. /** @hidden */
  140125. export var hdrFilteringPixelShader: {
  140126. name: string;
  140127. shader: string;
  140128. };
  140129. }
  140130. declare module BABYLON {
  140131. /**
  140132. * Options for texture filtering
  140133. */
  140134. interface IHDRFilteringOptions {
  140135. /**
  140136. * Scales pixel intensity for the input HDR map.
  140137. */
  140138. hdrScale?: number;
  140139. /**
  140140. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  140141. */
  140142. quality?: number;
  140143. }
  140144. /**
  140145. * Filters HDR maps to get correct renderings of PBR reflections
  140146. */
  140147. export class HDRFiltering {
  140148. private _engine;
  140149. private _effectRenderer;
  140150. private _effectWrapper;
  140151. private _lodGenerationOffset;
  140152. private _lodGenerationScale;
  140153. /**
  140154. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  140155. * you care about baking speed.
  140156. */
  140157. quality: number;
  140158. /**
  140159. * Scales pixel intensity for the input HDR map.
  140160. */
  140161. hdrScale: number;
  140162. /**
  140163. * Instantiates HDR filter for reflection maps
  140164. *
  140165. * @param engine Thin engine
  140166. * @param options Options
  140167. */
  140168. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  140169. private _createRenderTarget;
  140170. private _prefilterInternal;
  140171. private _createEffect;
  140172. /**
  140173. * Get a value indicating if the filter is ready to be used
  140174. * @param texture Texture to filter
  140175. * @returns true if the filter is ready
  140176. */
  140177. isReady(texture: BaseTexture): boolean;
  140178. /**
  140179. * Prefilters a cube texture to have mipmap levels representing roughness values.
  140180. * Prefiltering will be invoked at the end of next rendering pass.
  140181. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  140182. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  140183. * @param texture Texture to filter
  140184. * @param onFinished Callback when filtering is done
  140185. * @return Promise called when prefiltering is done
  140186. */
  140187. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  140188. }
  140189. }
  140190. declare module BABYLON {
  140191. /**
  140192. * This represents a texture coming from an HDR input.
  140193. *
  140194. * The only supported format is currently panorama picture stored in RGBE format.
  140195. * Example of such files can be found on HDRLib: http://hdrlib.com/
  140196. */
  140197. export class HDRCubeTexture extends BaseTexture {
  140198. private static _facesMapping;
  140199. private _generateHarmonics;
  140200. private _noMipmap;
  140201. private _prefilterOnLoad;
  140202. private _textureMatrix;
  140203. private _size;
  140204. private _onLoad;
  140205. private _onError;
  140206. /**
  140207. * The texture URL.
  140208. */
  140209. url: string;
  140210. protected _isBlocking: boolean;
  140211. /**
  140212. * Sets wether or not the texture is blocking during loading.
  140213. */
  140214. set isBlocking(value: boolean);
  140215. /**
  140216. * Gets wether or not the texture is blocking during loading.
  140217. */
  140218. get isBlocking(): boolean;
  140219. protected _rotationY: number;
  140220. /**
  140221. * Sets texture matrix rotation angle around Y axis in radians.
  140222. */
  140223. set rotationY(value: number);
  140224. /**
  140225. * Gets texture matrix rotation angle around Y axis radians.
  140226. */
  140227. get rotationY(): number;
  140228. /**
  140229. * Gets or sets the center of the bounding box associated with the cube texture
  140230. * It must define where the camera used to render the texture was set
  140231. */
  140232. boundingBoxPosition: Vector3;
  140233. private _boundingBoxSize;
  140234. /**
  140235. * Gets or sets the size of the bounding box associated with the cube texture
  140236. * When defined, the cubemap will switch to local mode
  140237. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  140238. * @example https://www.babylonjs-playground.com/#RNASML
  140239. */
  140240. set boundingBoxSize(value: Vector3);
  140241. get boundingBoxSize(): Vector3;
  140242. /**
  140243. * Instantiates an HDRTexture from the following parameters.
  140244. *
  140245. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  140246. * @param sceneOrEngine The scene or engine the texture will be used in
  140247. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  140248. * @param noMipmap Forces to not generate the mipmap if true
  140249. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  140250. * @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)
  140251. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  140252. */
  140253. 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>);
  140254. /**
  140255. * Get the current class name of the texture useful for serialization or dynamic coding.
  140256. * @returns "HDRCubeTexture"
  140257. */
  140258. getClassName(): string;
  140259. /**
  140260. * Occurs when the file is raw .hdr file.
  140261. */
  140262. private loadTexture;
  140263. clone(): HDRCubeTexture;
  140264. delayLoad(): void;
  140265. /**
  140266. * Get the texture reflection matrix used to rotate/transform the reflection.
  140267. * @returns the reflection matrix
  140268. */
  140269. getReflectionTextureMatrix(): Matrix;
  140270. /**
  140271. * Set the texture reflection matrix used to rotate/transform the reflection.
  140272. * @param value Define the reflection matrix to set
  140273. */
  140274. setReflectionTextureMatrix(value: Matrix): void;
  140275. /**
  140276. * Parses a JSON representation of an HDR Texture in order to create the texture
  140277. * @param parsedTexture Define the JSON representation
  140278. * @param scene Define the scene the texture should be created in
  140279. * @param rootUrl Define the root url in case we need to load relative dependencies
  140280. * @returns the newly created texture after parsing
  140281. */
  140282. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  140283. serialize(): any;
  140284. }
  140285. }
  140286. declare module BABYLON {
  140287. /**
  140288. * Class used to control physics engine
  140289. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  140290. */
  140291. export class PhysicsEngine implements IPhysicsEngine {
  140292. private _physicsPlugin;
  140293. /**
  140294. * Global value used to control the smallest number supported by the simulation
  140295. */
  140296. static Epsilon: number;
  140297. private _impostors;
  140298. private _joints;
  140299. private _subTimeStep;
  140300. /**
  140301. * Gets the gravity vector used by the simulation
  140302. */
  140303. gravity: Vector3;
  140304. /**
  140305. * Factory used to create the default physics plugin.
  140306. * @returns The default physics plugin
  140307. */
  140308. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  140309. /**
  140310. * Creates a new Physics Engine
  140311. * @param gravity defines the gravity vector used by the simulation
  140312. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  140313. */
  140314. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  140315. /**
  140316. * Sets the gravity vector used by the simulation
  140317. * @param gravity defines the gravity vector to use
  140318. */
  140319. setGravity(gravity: Vector3): void;
  140320. /**
  140321. * Set the time step of the physics engine.
  140322. * Default is 1/60.
  140323. * To slow it down, enter 1/600 for example.
  140324. * To speed it up, 1/30
  140325. * @param newTimeStep defines the new timestep to apply to this world.
  140326. */
  140327. setTimeStep(newTimeStep?: number): void;
  140328. /**
  140329. * Get the time step of the physics engine.
  140330. * @returns the current time step
  140331. */
  140332. getTimeStep(): number;
  140333. /**
  140334. * Set the sub time step of the physics engine.
  140335. * Default is 0 meaning there is no sub steps
  140336. * To increase physics resolution precision, set a small value (like 1 ms)
  140337. * @param subTimeStep defines the new sub timestep used for physics resolution.
  140338. */
  140339. setSubTimeStep(subTimeStep?: number): void;
  140340. /**
  140341. * Get the sub time step of the physics engine.
  140342. * @returns the current sub time step
  140343. */
  140344. getSubTimeStep(): number;
  140345. /**
  140346. * Release all resources
  140347. */
  140348. dispose(): void;
  140349. /**
  140350. * Gets the name of the current physics plugin
  140351. * @returns the name of the plugin
  140352. */
  140353. getPhysicsPluginName(): string;
  140354. /**
  140355. * Adding a new impostor for the impostor tracking.
  140356. * This will be done by the impostor itself.
  140357. * @param impostor the impostor to add
  140358. */
  140359. addImpostor(impostor: PhysicsImpostor): void;
  140360. /**
  140361. * Remove an impostor from the engine.
  140362. * This impostor and its mesh will not longer be updated by the physics engine.
  140363. * @param impostor the impostor to remove
  140364. */
  140365. removeImpostor(impostor: PhysicsImpostor): void;
  140366. /**
  140367. * Add a joint to the physics engine
  140368. * @param mainImpostor defines the main impostor to which the joint is added.
  140369. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  140370. * @param joint defines the joint that will connect both impostors.
  140371. */
  140372. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  140373. /**
  140374. * Removes a joint from the simulation
  140375. * @param mainImpostor defines the impostor used with the joint
  140376. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  140377. * @param joint defines the joint to remove
  140378. */
  140379. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  140380. /**
  140381. * Called by the scene. No need to call it.
  140382. * @param delta defines the timespam between frames
  140383. */
  140384. _step(delta: number): void;
  140385. /**
  140386. * Gets the current plugin used to run the simulation
  140387. * @returns current plugin
  140388. */
  140389. getPhysicsPlugin(): IPhysicsEnginePlugin;
  140390. /**
  140391. * Gets the list of physic impostors
  140392. * @returns an array of PhysicsImpostor
  140393. */
  140394. getImpostors(): Array<PhysicsImpostor>;
  140395. /**
  140396. * Gets the impostor for a physics enabled object
  140397. * @param object defines the object impersonated by the impostor
  140398. * @returns the PhysicsImpostor or null if not found
  140399. */
  140400. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  140401. /**
  140402. * Gets the impostor for a physics body object
  140403. * @param body defines physics body used by the impostor
  140404. * @returns the PhysicsImpostor or null if not found
  140405. */
  140406. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  140407. /**
  140408. * Does a raycast in the physics world
  140409. * @param from when should the ray start?
  140410. * @param to when should the ray end?
  140411. * @returns PhysicsRaycastResult
  140412. */
  140413. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  140414. }
  140415. }
  140416. declare module BABYLON {
  140417. /** @hidden */
  140418. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  140419. private _useDeltaForWorldStep;
  140420. world: any;
  140421. name: string;
  140422. private _physicsMaterials;
  140423. private _fixedTimeStep;
  140424. private _cannonRaycastResult;
  140425. private _raycastResult;
  140426. private _physicsBodysToRemoveAfterStep;
  140427. private _firstFrame;
  140428. BJSCANNON: any;
  140429. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  140430. setGravity(gravity: Vector3): void;
  140431. setTimeStep(timeStep: number): void;
  140432. getTimeStep(): number;
  140433. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  140434. private _removeMarkedPhysicsBodiesFromWorld;
  140435. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140436. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140437. generatePhysicsBody(impostor: PhysicsImpostor): void;
  140438. private _processChildMeshes;
  140439. removePhysicsBody(impostor: PhysicsImpostor): void;
  140440. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  140441. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  140442. private _addMaterial;
  140443. private _checkWithEpsilon;
  140444. private _createShape;
  140445. private _createHeightmap;
  140446. private _minus90X;
  140447. private _plus90X;
  140448. private _tmpPosition;
  140449. private _tmpDeltaPosition;
  140450. private _tmpUnityRotation;
  140451. private _updatePhysicsBodyTransformation;
  140452. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  140453. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  140454. isSupported(): boolean;
  140455. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140456. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140457. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140458. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140459. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  140460. getBodyMass(impostor: PhysicsImpostor): number;
  140461. getBodyFriction(impostor: PhysicsImpostor): number;
  140462. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  140463. getBodyRestitution(impostor: PhysicsImpostor): number;
  140464. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  140465. sleepBody(impostor: PhysicsImpostor): void;
  140466. wakeUpBody(impostor: PhysicsImpostor): void;
  140467. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  140468. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  140469. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  140470. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  140471. getRadius(impostor: PhysicsImpostor): number;
  140472. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  140473. dispose(): void;
  140474. private _extendNamespace;
  140475. /**
  140476. * Does a raycast in the physics world
  140477. * @param from when should the ray start?
  140478. * @param to when should the ray end?
  140479. * @returns PhysicsRaycastResult
  140480. */
  140481. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  140482. }
  140483. }
  140484. declare module BABYLON {
  140485. /** @hidden */
  140486. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  140487. private _useDeltaForWorldStep;
  140488. world: any;
  140489. name: string;
  140490. BJSOIMO: any;
  140491. private _raycastResult;
  140492. private _fixedTimeStep;
  140493. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  140494. setGravity(gravity: Vector3): void;
  140495. setTimeStep(timeStep: number): void;
  140496. getTimeStep(): number;
  140497. private _tmpImpostorsArray;
  140498. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  140499. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140500. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140501. generatePhysicsBody(impostor: PhysicsImpostor): void;
  140502. private _tmpPositionVector;
  140503. removePhysicsBody(impostor: PhysicsImpostor): void;
  140504. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  140505. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  140506. isSupported(): boolean;
  140507. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  140508. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  140509. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140510. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140511. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140512. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140513. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  140514. getBodyMass(impostor: PhysicsImpostor): number;
  140515. getBodyFriction(impostor: PhysicsImpostor): number;
  140516. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  140517. getBodyRestitution(impostor: PhysicsImpostor): number;
  140518. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  140519. sleepBody(impostor: PhysicsImpostor): void;
  140520. wakeUpBody(impostor: PhysicsImpostor): void;
  140521. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  140522. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  140523. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  140524. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  140525. getRadius(impostor: PhysicsImpostor): number;
  140526. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  140527. dispose(): void;
  140528. /**
  140529. * Does a raycast in the physics world
  140530. * @param from when should the ray start?
  140531. * @param to when should the ray end?
  140532. * @returns PhysicsRaycastResult
  140533. */
  140534. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  140535. }
  140536. }
  140537. declare module BABYLON {
  140538. /**
  140539. * AmmoJS Physics plugin
  140540. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  140541. * @see https://github.com/kripken/ammo.js/
  140542. */
  140543. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  140544. private _useDeltaForWorldStep;
  140545. /**
  140546. * Reference to the Ammo library
  140547. */
  140548. bjsAMMO: any;
  140549. /**
  140550. * Created ammoJS world which physics bodies are added to
  140551. */
  140552. world: any;
  140553. /**
  140554. * Name of the plugin
  140555. */
  140556. name: string;
  140557. private _timeStep;
  140558. private _fixedTimeStep;
  140559. private _maxSteps;
  140560. private _tmpQuaternion;
  140561. private _tmpAmmoTransform;
  140562. private _tmpAmmoQuaternion;
  140563. private _tmpAmmoConcreteContactResultCallback;
  140564. private _collisionConfiguration;
  140565. private _dispatcher;
  140566. private _overlappingPairCache;
  140567. private _solver;
  140568. private _softBodySolver;
  140569. private _tmpAmmoVectorA;
  140570. private _tmpAmmoVectorB;
  140571. private _tmpAmmoVectorC;
  140572. private _tmpAmmoVectorD;
  140573. private _tmpContactCallbackResult;
  140574. private _tmpAmmoVectorRCA;
  140575. private _tmpAmmoVectorRCB;
  140576. private _raycastResult;
  140577. private static readonly DISABLE_COLLISION_FLAG;
  140578. private static readonly KINEMATIC_FLAG;
  140579. private static readonly DISABLE_DEACTIVATION_FLAG;
  140580. /**
  140581. * Initializes the ammoJS plugin
  140582. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  140583. * @param ammoInjection can be used to inject your own ammo reference
  140584. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  140585. */
  140586. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  140587. /**
  140588. * Sets the gravity of the physics world (m/(s^2))
  140589. * @param gravity Gravity to set
  140590. */
  140591. setGravity(gravity: Vector3): void;
  140592. /**
  140593. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  140594. * @param timeStep timestep to use in seconds
  140595. */
  140596. setTimeStep(timeStep: number): void;
  140597. /**
  140598. * 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)
  140599. * @param fixedTimeStep fixedTimeStep to use in seconds
  140600. */
  140601. setFixedTimeStep(fixedTimeStep: number): void;
  140602. /**
  140603. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  140604. * @param maxSteps the maximum number of steps by the physics engine per frame
  140605. */
  140606. setMaxSteps(maxSteps: number): void;
  140607. /**
  140608. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  140609. * @returns the current timestep in seconds
  140610. */
  140611. getTimeStep(): number;
  140612. /**
  140613. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  140614. */
  140615. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  140616. private _isImpostorInContact;
  140617. private _isImpostorPairInContact;
  140618. private _stepSimulation;
  140619. /**
  140620. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  140621. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  140622. * After the step the babylon meshes are set to the position of the physics imposters
  140623. * @param delta amount of time to step forward
  140624. * @param impostors array of imposters to update before/after the step
  140625. */
  140626. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  140627. /**
  140628. * Update babylon mesh to match physics world object
  140629. * @param impostor imposter to match
  140630. */
  140631. private _afterSoftStep;
  140632. /**
  140633. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  140634. * @param impostor imposter to match
  140635. */
  140636. private _ropeStep;
  140637. /**
  140638. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  140639. * @param impostor imposter to match
  140640. */
  140641. private _softbodyOrClothStep;
  140642. private _tmpMatrix;
  140643. /**
  140644. * Applies an impulse on the imposter
  140645. * @param impostor imposter to apply impulse to
  140646. * @param force amount of force to be applied to the imposter
  140647. * @param contactPoint the location to apply the impulse on the imposter
  140648. */
  140649. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140650. /**
  140651. * Applies a force on the imposter
  140652. * @param impostor imposter to apply force
  140653. * @param force amount of force to be applied to the imposter
  140654. * @param contactPoint the location to apply the force on the imposter
  140655. */
  140656. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  140657. /**
  140658. * Creates a physics body using the plugin
  140659. * @param impostor the imposter to create the physics body on
  140660. */
  140661. generatePhysicsBody(impostor: PhysicsImpostor): void;
  140662. /**
  140663. * Removes the physics body from the imposter and disposes of the body's memory
  140664. * @param impostor imposter to remove the physics body from
  140665. */
  140666. removePhysicsBody(impostor: PhysicsImpostor): void;
  140667. /**
  140668. * Generates a joint
  140669. * @param impostorJoint the imposter joint to create the joint with
  140670. */
  140671. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  140672. /**
  140673. * Removes a joint
  140674. * @param impostorJoint the imposter joint to remove the joint from
  140675. */
  140676. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  140677. private _addMeshVerts;
  140678. /**
  140679. * Initialise the soft body vertices to match its object's (mesh) vertices
  140680. * Softbody vertices (nodes) are in world space and to match this
  140681. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  140682. * @param impostor to create the softbody for
  140683. */
  140684. private _softVertexData;
  140685. /**
  140686. * Create an impostor's soft body
  140687. * @param impostor to create the softbody for
  140688. */
  140689. private _createSoftbody;
  140690. /**
  140691. * Create cloth for an impostor
  140692. * @param impostor to create the softbody for
  140693. */
  140694. private _createCloth;
  140695. /**
  140696. * Create rope for an impostor
  140697. * @param impostor to create the softbody for
  140698. */
  140699. private _createRope;
  140700. /**
  140701. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  140702. * @param impostor to create the custom physics shape for
  140703. */
  140704. private _createCustom;
  140705. private _addHullVerts;
  140706. private _createShape;
  140707. /**
  140708. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  140709. * @param impostor imposter containing the physics body and babylon object
  140710. */
  140711. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  140712. /**
  140713. * Sets the babylon object's position/rotation from the physics body's position/rotation
  140714. * @param impostor imposter containing the physics body and babylon object
  140715. * @param newPosition new position
  140716. * @param newRotation new rotation
  140717. */
  140718. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  140719. /**
  140720. * If this plugin is supported
  140721. * @returns true if its supported
  140722. */
  140723. isSupported(): boolean;
  140724. /**
  140725. * Sets the linear velocity of the physics body
  140726. * @param impostor imposter to set the velocity on
  140727. * @param velocity velocity to set
  140728. */
  140729. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140730. /**
  140731. * Sets the angular velocity of the physics body
  140732. * @param impostor imposter to set the velocity on
  140733. * @param velocity velocity to set
  140734. */
  140735. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  140736. /**
  140737. * gets the linear velocity
  140738. * @param impostor imposter to get linear velocity from
  140739. * @returns linear velocity
  140740. */
  140741. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140742. /**
  140743. * gets the angular velocity
  140744. * @param impostor imposter to get angular velocity from
  140745. * @returns angular velocity
  140746. */
  140747. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  140748. /**
  140749. * Sets the mass of physics body
  140750. * @param impostor imposter to set the mass on
  140751. * @param mass mass to set
  140752. */
  140753. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  140754. /**
  140755. * Gets the mass of the physics body
  140756. * @param impostor imposter to get the mass from
  140757. * @returns mass
  140758. */
  140759. getBodyMass(impostor: PhysicsImpostor): number;
  140760. /**
  140761. * Gets friction of the impostor
  140762. * @param impostor impostor to get friction from
  140763. * @returns friction value
  140764. */
  140765. getBodyFriction(impostor: PhysicsImpostor): number;
  140766. /**
  140767. * Sets friction of the impostor
  140768. * @param impostor impostor to set friction on
  140769. * @param friction friction value
  140770. */
  140771. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  140772. /**
  140773. * Gets restitution of the impostor
  140774. * @param impostor impostor to get restitution from
  140775. * @returns restitution value
  140776. */
  140777. getBodyRestitution(impostor: PhysicsImpostor): number;
  140778. /**
  140779. * Sets resitution of the impostor
  140780. * @param impostor impostor to set resitution on
  140781. * @param restitution resitution value
  140782. */
  140783. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  140784. /**
  140785. * Gets pressure inside the impostor
  140786. * @param impostor impostor to get pressure from
  140787. * @returns pressure value
  140788. */
  140789. getBodyPressure(impostor: PhysicsImpostor): number;
  140790. /**
  140791. * Sets pressure inside a soft body impostor
  140792. * Cloth and rope must remain 0 pressure
  140793. * @param impostor impostor to set pressure on
  140794. * @param pressure pressure value
  140795. */
  140796. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  140797. /**
  140798. * Gets stiffness of the impostor
  140799. * @param impostor impostor to get stiffness from
  140800. * @returns pressure value
  140801. */
  140802. getBodyStiffness(impostor: PhysicsImpostor): number;
  140803. /**
  140804. * Sets stiffness of the impostor
  140805. * @param impostor impostor to set stiffness on
  140806. * @param stiffness stiffness value from 0 to 1
  140807. */
  140808. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  140809. /**
  140810. * Gets velocityIterations of the impostor
  140811. * @param impostor impostor to get velocity iterations from
  140812. * @returns velocityIterations value
  140813. */
  140814. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  140815. /**
  140816. * Sets velocityIterations of the impostor
  140817. * @param impostor impostor to set velocity iterations on
  140818. * @param velocityIterations velocityIterations value
  140819. */
  140820. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  140821. /**
  140822. * Gets positionIterations of the impostor
  140823. * @param impostor impostor to get position iterations from
  140824. * @returns positionIterations value
  140825. */
  140826. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  140827. /**
  140828. * Sets positionIterations of the impostor
  140829. * @param impostor impostor to set position on
  140830. * @param positionIterations positionIterations value
  140831. */
  140832. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  140833. /**
  140834. * Append an anchor to a cloth object
  140835. * @param impostor is the cloth impostor to add anchor to
  140836. * @param otherImpostor is the rigid impostor to anchor to
  140837. * @param width ratio across width from 0 to 1
  140838. * @param height ratio up height from 0 to 1
  140839. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  140840. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  140841. */
  140842. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  140843. /**
  140844. * Append an hook to a rope object
  140845. * @param impostor is the rope impostor to add hook to
  140846. * @param otherImpostor is the rigid impostor to hook to
  140847. * @param length ratio along the rope from 0 to 1
  140848. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  140849. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  140850. */
  140851. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  140852. /**
  140853. * Sleeps the physics body and stops it from being active
  140854. * @param impostor impostor to sleep
  140855. */
  140856. sleepBody(impostor: PhysicsImpostor): void;
  140857. /**
  140858. * Activates the physics body
  140859. * @param impostor impostor to activate
  140860. */
  140861. wakeUpBody(impostor: PhysicsImpostor): void;
  140862. /**
  140863. * Updates the distance parameters of the joint
  140864. * @param joint joint to update
  140865. * @param maxDistance maximum distance of the joint
  140866. * @param minDistance minimum distance of the joint
  140867. */
  140868. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  140869. /**
  140870. * Sets a motor on the joint
  140871. * @param joint joint to set motor on
  140872. * @param speed speed of the motor
  140873. * @param maxForce maximum force of the motor
  140874. * @param motorIndex index of the motor
  140875. */
  140876. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  140877. /**
  140878. * Sets the motors limit
  140879. * @param joint joint to set limit on
  140880. * @param upperLimit upper limit
  140881. * @param lowerLimit lower limit
  140882. */
  140883. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  140884. /**
  140885. * Syncs the position and rotation of a mesh with the impostor
  140886. * @param mesh mesh to sync
  140887. * @param impostor impostor to update the mesh with
  140888. */
  140889. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  140890. /**
  140891. * Gets the radius of the impostor
  140892. * @param impostor impostor to get radius from
  140893. * @returns the radius
  140894. */
  140895. getRadius(impostor: PhysicsImpostor): number;
  140896. /**
  140897. * Gets the box size of the impostor
  140898. * @param impostor impostor to get box size from
  140899. * @param result the resulting box size
  140900. */
  140901. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  140902. /**
  140903. * Disposes of the impostor
  140904. */
  140905. dispose(): void;
  140906. /**
  140907. * Does a raycast in the physics world
  140908. * @param from when should the ray start?
  140909. * @param to when should the ray end?
  140910. * @returns PhysicsRaycastResult
  140911. */
  140912. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  140913. }
  140914. }
  140915. declare module BABYLON {
  140916. interface AbstractScene {
  140917. /**
  140918. * The list of reflection probes added to the scene
  140919. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  140920. */
  140921. reflectionProbes: Array<ReflectionProbe>;
  140922. /**
  140923. * Removes the given reflection probe from this scene.
  140924. * @param toRemove The reflection probe to remove
  140925. * @returns The index of the removed reflection probe
  140926. */
  140927. removeReflectionProbe(toRemove: ReflectionProbe): number;
  140928. /**
  140929. * Adds the given reflection probe to this scene.
  140930. * @param newReflectionProbe The reflection probe to add
  140931. */
  140932. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  140933. }
  140934. /**
  140935. * Class used to generate realtime reflection / refraction cube textures
  140936. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  140937. */
  140938. export class ReflectionProbe {
  140939. /** defines the name of the probe */
  140940. name: string;
  140941. private _scene;
  140942. private _renderTargetTexture;
  140943. private _projectionMatrix;
  140944. private _viewMatrix;
  140945. private _target;
  140946. private _add;
  140947. private _attachedMesh;
  140948. private _invertYAxis;
  140949. /** Gets or sets probe position (center of the cube map) */
  140950. position: Vector3;
  140951. /**
  140952. * Creates a new reflection probe
  140953. * @param name defines the name of the probe
  140954. * @param size defines the texture resolution (for each face)
  140955. * @param scene defines the hosting scene
  140956. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  140957. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  140958. */
  140959. constructor(
  140960. /** defines the name of the probe */
  140961. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  140962. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  140963. get samples(): number;
  140964. set samples(value: number);
  140965. /** Gets or sets the refresh rate to use (on every frame by default) */
  140966. get refreshRate(): number;
  140967. set refreshRate(value: number);
  140968. /**
  140969. * Gets the hosting scene
  140970. * @returns a Scene
  140971. */
  140972. getScene(): Scene;
  140973. /** Gets the internal CubeTexture used to render to */
  140974. get cubeTexture(): RenderTargetTexture;
  140975. /** Gets the list of meshes to render */
  140976. get renderList(): Nullable<AbstractMesh[]>;
  140977. /**
  140978. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  140979. * @param mesh defines the mesh to attach to
  140980. */
  140981. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  140982. /**
  140983. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  140984. * @param renderingGroupId The rendering group id corresponding to its index
  140985. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  140986. */
  140987. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  140988. /**
  140989. * Clean all associated resources
  140990. */
  140991. dispose(): void;
  140992. /**
  140993. * Converts the reflection probe information to a readable string for debug purpose.
  140994. * @param fullDetails Supports for multiple levels of logging within scene loading
  140995. * @returns the human readable reflection probe info
  140996. */
  140997. toString(fullDetails?: boolean): string;
  140998. /**
  140999. * Get the class name of the relfection probe.
  141000. * @returns "ReflectionProbe"
  141001. */
  141002. getClassName(): string;
  141003. /**
  141004. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  141005. * @returns The JSON representation of the texture
  141006. */
  141007. serialize(): any;
  141008. /**
  141009. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  141010. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  141011. * @param scene Define the scene the parsed reflection probe should be instantiated in
  141012. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  141013. * @returns The parsed reflection probe if successful
  141014. */
  141015. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  141016. }
  141017. }
  141018. declare module BABYLON {
  141019. /** @hidden */
  141020. export var _BabylonLoaderRegistered: boolean;
  141021. /**
  141022. * Helps setting up some configuration for the babylon file loader.
  141023. */
  141024. export class BabylonFileLoaderConfiguration {
  141025. /**
  141026. * The loader does not allow injecting custom physix engine into the plugins.
  141027. * Unfortunately in ES6, we need to manually inject them into the plugin.
  141028. * So you could set this variable to your engine import to make it work.
  141029. */
  141030. static LoaderInjectedPhysicsEngine: any;
  141031. }
  141032. }
  141033. declare module BABYLON {
  141034. /**
  141035. * The Physically based simple base material of BJS.
  141036. *
  141037. * This enables better naming and convention enforcements on top of the pbrMaterial.
  141038. * It is used as the base class for both the specGloss and metalRough conventions.
  141039. */
  141040. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  141041. /**
  141042. * Number of Simultaneous lights allowed on the material.
  141043. */
  141044. maxSimultaneousLights: number;
  141045. /**
  141046. * If sets to true, disables all the lights affecting the material.
  141047. */
  141048. disableLighting: boolean;
  141049. /**
  141050. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  141051. */
  141052. environmentTexture: BaseTexture;
  141053. /**
  141054. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  141055. */
  141056. invertNormalMapX: boolean;
  141057. /**
  141058. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  141059. */
  141060. invertNormalMapY: boolean;
  141061. /**
  141062. * Normal map used in the model.
  141063. */
  141064. normalTexture: BaseTexture;
  141065. /**
  141066. * Emissivie color used to self-illuminate the model.
  141067. */
  141068. emissiveColor: Color3;
  141069. /**
  141070. * Emissivie texture used to self-illuminate the model.
  141071. */
  141072. emissiveTexture: BaseTexture;
  141073. /**
  141074. * Occlusion Channel Strenght.
  141075. */
  141076. occlusionStrength: number;
  141077. /**
  141078. * Occlusion Texture of the material (adding extra occlusion effects).
  141079. */
  141080. occlusionTexture: BaseTexture;
  141081. /**
  141082. * Defines the alpha limits in alpha test mode.
  141083. */
  141084. alphaCutOff: number;
  141085. /**
  141086. * Gets the current double sided mode.
  141087. */
  141088. get doubleSided(): boolean;
  141089. /**
  141090. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  141091. */
  141092. set doubleSided(value: boolean);
  141093. /**
  141094. * Stores the pre-calculated light information of a mesh in a texture.
  141095. */
  141096. lightmapTexture: BaseTexture;
  141097. /**
  141098. * If true, the light map contains occlusion information instead of lighting info.
  141099. */
  141100. useLightmapAsShadowmap: boolean;
  141101. /**
  141102. * Instantiates a new PBRMaterial instance.
  141103. *
  141104. * @param name The material name
  141105. * @param scene The scene the material will be use in.
  141106. */
  141107. constructor(name: string, scene: Scene);
  141108. getClassName(): string;
  141109. }
  141110. }
  141111. declare module BABYLON {
  141112. /**
  141113. * The PBR material of BJS following the metal roughness convention.
  141114. *
  141115. * This fits to the PBR convention in the GLTF definition:
  141116. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  141117. */
  141118. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  141119. /**
  141120. * The base color has two different interpretations depending on the value of metalness.
  141121. * When the material is a metal, the base color is the specific measured reflectance value
  141122. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  141123. * of the material.
  141124. */
  141125. baseColor: Color3;
  141126. /**
  141127. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  141128. * well as opacity information in the alpha channel.
  141129. */
  141130. baseTexture: BaseTexture;
  141131. /**
  141132. * Specifies the metallic scalar value of the material.
  141133. * Can also be used to scale the metalness values of the metallic texture.
  141134. */
  141135. metallic: number;
  141136. /**
  141137. * Specifies the roughness scalar value of the material.
  141138. * Can also be used to scale the roughness values of the metallic texture.
  141139. */
  141140. roughness: number;
  141141. /**
  141142. * Texture containing both the metallic value in the B channel and the
  141143. * roughness value in the G channel to keep better precision.
  141144. */
  141145. metallicRoughnessTexture: BaseTexture;
  141146. /**
  141147. * Instantiates a new PBRMetalRoughnessMaterial instance.
  141148. *
  141149. * @param name The material name
  141150. * @param scene The scene the material will be use in.
  141151. */
  141152. constructor(name: string, scene: Scene);
  141153. /**
  141154. * Return the currrent class name of the material.
  141155. */
  141156. getClassName(): string;
  141157. /**
  141158. * Makes a duplicate of the current material.
  141159. * @param name - name to use for the new material.
  141160. */
  141161. clone(name: string): PBRMetallicRoughnessMaterial;
  141162. /**
  141163. * Serialize the material to a parsable JSON object.
  141164. */
  141165. serialize(): any;
  141166. /**
  141167. * Parses a JSON object correponding to the serialize function.
  141168. */
  141169. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  141170. }
  141171. }
  141172. declare module BABYLON {
  141173. /**
  141174. * The PBR material of BJS following the specular glossiness convention.
  141175. *
  141176. * This fits to the PBR convention in the GLTF definition:
  141177. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  141178. */
  141179. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  141180. /**
  141181. * Specifies the diffuse color of the material.
  141182. */
  141183. diffuseColor: Color3;
  141184. /**
  141185. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  141186. * channel.
  141187. */
  141188. diffuseTexture: BaseTexture;
  141189. /**
  141190. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  141191. */
  141192. specularColor: Color3;
  141193. /**
  141194. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  141195. */
  141196. glossiness: number;
  141197. /**
  141198. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  141199. */
  141200. specularGlossinessTexture: BaseTexture;
  141201. /**
  141202. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  141203. *
  141204. * @param name The material name
  141205. * @param scene The scene the material will be use in.
  141206. */
  141207. constructor(name: string, scene: Scene);
  141208. /**
  141209. * Return the currrent class name of the material.
  141210. */
  141211. getClassName(): string;
  141212. /**
  141213. * Makes a duplicate of the current material.
  141214. * @param name - name to use for the new material.
  141215. */
  141216. clone(name: string): PBRSpecularGlossinessMaterial;
  141217. /**
  141218. * Serialize the material to a parsable JSON object.
  141219. */
  141220. serialize(): any;
  141221. /**
  141222. * Parses a JSON object correponding to the serialize function.
  141223. */
  141224. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  141225. }
  141226. }
  141227. declare module BABYLON {
  141228. /**
  141229. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  141230. * It can help converting any input color in a desired output one. This can then be used to create effects
  141231. * from sepia, black and white to sixties or futuristic rendering...
  141232. *
  141233. * The only supported format is currently 3dl.
  141234. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  141235. */
  141236. export class ColorGradingTexture extends BaseTexture {
  141237. /**
  141238. * The texture URL.
  141239. */
  141240. url: string;
  141241. /**
  141242. * Empty line regex stored for GC.
  141243. */
  141244. private static _noneEmptyLineRegex;
  141245. private _textureMatrix;
  141246. private _onLoad;
  141247. /**
  141248. * Instantiates a ColorGradingTexture from the following parameters.
  141249. *
  141250. * @param url The location of the color gradind data (currently only supporting 3dl)
  141251. * @param sceneOrEngine The scene or engine the texture will be used in
  141252. * @param onLoad defines a callback triggered when the texture has been loaded
  141253. */
  141254. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  141255. /**
  141256. * Fires the onload event from the constructor if requested.
  141257. */
  141258. private _triggerOnLoad;
  141259. /**
  141260. * Returns the texture matrix used in most of the material.
  141261. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  141262. */
  141263. getTextureMatrix(): Matrix;
  141264. /**
  141265. * Occurs when the file being loaded is a .3dl LUT file.
  141266. */
  141267. private load3dlTexture;
  141268. /**
  141269. * Starts the loading process of the texture.
  141270. */
  141271. private loadTexture;
  141272. /**
  141273. * Clones the color gradind texture.
  141274. */
  141275. clone(): ColorGradingTexture;
  141276. /**
  141277. * Called during delayed load for textures.
  141278. */
  141279. delayLoad(): void;
  141280. /**
  141281. * Parses a color grading texture serialized by Babylon.
  141282. * @param parsedTexture The texture information being parsedTexture
  141283. * @param scene The scene to load the texture in
  141284. * @param rootUrl The root url of the data assets to load
  141285. * @return A color gradind texture
  141286. */
  141287. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  141288. /**
  141289. * Serializes the LUT texture to json format.
  141290. */
  141291. serialize(): any;
  141292. }
  141293. }
  141294. declare module BABYLON {
  141295. /**
  141296. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  141297. */
  141298. export class EquiRectangularCubeTexture extends BaseTexture {
  141299. /** The six faces of the cube. */
  141300. private static _FacesMapping;
  141301. private _noMipmap;
  141302. private _onLoad;
  141303. private _onError;
  141304. /** The size of the cubemap. */
  141305. private _size;
  141306. /** The buffer of the image. */
  141307. private _buffer;
  141308. /** The width of the input image. */
  141309. private _width;
  141310. /** The height of the input image. */
  141311. private _height;
  141312. /** The URL to the image. */
  141313. url: string;
  141314. /**
  141315. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  141316. * @param url The location of the image
  141317. * @param scene The scene the texture will be used in
  141318. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  141319. * @param noMipmap Forces to not generate the mipmap if true
  141320. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  141321. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  141322. * @param onLoad — defines a callback called when texture is loaded
  141323. * @param onError — defines a callback called if there is an error
  141324. */
  141325. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  141326. /**
  141327. * Load the image data, by putting the image on a canvas and extracting its buffer.
  141328. */
  141329. private loadImage;
  141330. /**
  141331. * Convert the image buffer into a cubemap and create a CubeTexture.
  141332. */
  141333. private loadTexture;
  141334. /**
  141335. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  141336. * @param buffer The ArrayBuffer that should be converted.
  141337. * @returns The buffer as Float32Array.
  141338. */
  141339. private getFloat32ArrayFromArrayBuffer;
  141340. /**
  141341. * Get the current class name of the texture useful for serialization or dynamic coding.
  141342. * @returns "EquiRectangularCubeTexture"
  141343. */
  141344. getClassName(): string;
  141345. /**
  141346. * Create a clone of the current EquiRectangularCubeTexture and return it.
  141347. * @returns A clone of the current EquiRectangularCubeTexture.
  141348. */
  141349. clone(): EquiRectangularCubeTexture;
  141350. }
  141351. }
  141352. declare module BABYLON {
  141353. /**
  141354. * Defines the options related to the creation of an HtmlElementTexture
  141355. */
  141356. export interface IHtmlElementTextureOptions {
  141357. /**
  141358. * Defines wether mip maps should be created or not.
  141359. */
  141360. generateMipMaps?: boolean;
  141361. /**
  141362. * Defines the sampling mode of the texture.
  141363. */
  141364. samplingMode?: number;
  141365. /**
  141366. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  141367. */
  141368. engine: Nullable<ThinEngine>;
  141369. /**
  141370. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  141371. */
  141372. scene: Nullable<Scene>;
  141373. }
  141374. /**
  141375. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  141376. * To be as efficient as possible depending on your constraints nothing aside the first upload
  141377. * is automatically managed.
  141378. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  141379. * in your application.
  141380. *
  141381. * As the update is not automatic, you need to call them manually.
  141382. */
  141383. export class HtmlElementTexture extends BaseTexture {
  141384. /**
  141385. * The texture URL.
  141386. */
  141387. element: HTMLVideoElement | HTMLCanvasElement;
  141388. private static readonly DefaultOptions;
  141389. private _textureMatrix;
  141390. private _isVideo;
  141391. private _generateMipMaps;
  141392. private _samplingMode;
  141393. /**
  141394. * Instantiates a HtmlElementTexture from the following parameters.
  141395. *
  141396. * @param name Defines the name of the texture
  141397. * @param element Defines the video or canvas the texture is filled with
  141398. * @param options Defines the other none mandatory texture creation options
  141399. */
  141400. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  141401. private _createInternalTexture;
  141402. /**
  141403. * Returns the texture matrix used in most of the material.
  141404. */
  141405. getTextureMatrix(): Matrix;
  141406. /**
  141407. * Updates the content of the texture.
  141408. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  141409. */
  141410. update(invertY?: Nullable<boolean>): void;
  141411. }
  141412. }
  141413. declare module BABYLON {
  141414. /**
  141415. * Based on jsTGALoader - Javascript loader for TGA file
  141416. * By Vincent Thibault
  141417. * @see http://blog.robrowser.com/javascript-tga-loader.html
  141418. */
  141419. export class TGATools {
  141420. private static _TYPE_INDEXED;
  141421. private static _TYPE_RGB;
  141422. private static _TYPE_GREY;
  141423. private static _TYPE_RLE_INDEXED;
  141424. private static _TYPE_RLE_RGB;
  141425. private static _TYPE_RLE_GREY;
  141426. private static _ORIGIN_MASK;
  141427. private static _ORIGIN_SHIFT;
  141428. private static _ORIGIN_BL;
  141429. private static _ORIGIN_BR;
  141430. private static _ORIGIN_UL;
  141431. private static _ORIGIN_UR;
  141432. /**
  141433. * Gets the header of a TGA file
  141434. * @param data defines the TGA data
  141435. * @returns the header
  141436. */
  141437. static GetTGAHeader(data: Uint8Array): any;
  141438. /**
  141439. * Uploads TGA content to a Babylon Texture
  141440. * @hidden
  141441. */
  141442. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  141443. /** @hidden */
  141444. 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;
  141445. /** @hidden */
  141446. 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;
  141447. /** @hidden */
  141448. 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;
  141449. /** @hidden */
  141450. 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;
  141451. /** @hidden */
  141452. 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;
  141453. /** @hidden */
  141454. 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;
  141455. }
  141456. }
  141457. declare module BABYLON {
  141458. /**
  141459. * Implementation of the TGA Texture Loader.
  141460. * @hidden
  141461. */
  141462. export class _TGATextureLoader implements IInternalTextureLoader {
  141463. /**
  141464. * Defines wether the loader supports cascade loading the different faces.
  141465. */
  141466. readonly supportCascades: boolean;
  141467. /**
  141468. * This returns if the loader support the current file information.
  141469. * @param extension defines the file extension of the file being loaded
  141470. * @returns true if the loader can load the specified file
  141471. */
  141472. canLoad(extension: string): boolean;
  141473. /**
  141474. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  141475. * @param data contains the texture data
  141476. * @param texture defines the BabylonJS internal texture
  141477. * @param createPolynomials will be true if polynomials have been requested
  141478. * @param onLoad defines the callback to trigger once the texture is ready
  141479. * @param onError defines the callback to trigger in case of error
  141480. */
  141481. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  141482. /**
  141483. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  141484. * @param data contains the texture data
  141485. * @param texture defines the BabylonJS internal texture
  141486. * @param callback defines the method to call once ready to upload
  141487. */
  141488. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  141489. }
  141490. }
  141491. declare module BABYLON {
  141492. /**
  141493. * Info about the .basis files
  141494. */
  141495. class BasisFileInfo {
  141496. /**
  141497. * If the file has alpha
  141498. */
  141499. hasAlpha: boolean;
  141500. /**
  141501. * Info about each image of the basis file
  141502. */
  141503. images: Array<{
  141504. levels: Array<{
  141505. width: number;
  141506. height: number;
  141507. transcodedPixels: ArrayBufferView;
  141508. }>;
  141509. }>;
  141510. }
  141511. /**
  141512. * Result of transcoding a basis file
  141513. */
  141514. class TranscodeResult {
  141515. /**
  141516. * Info about the .basis file
  141517. */
  141518. fileInfo: BasisFileInfo;
  141519. /**
  141520. * Format to use when loading the file
  141521. */
  141522. format: number;
  141523. }
  141524. /**
  141525. * Configuration options for the Basis transcoder
  141526. */
  141527. export class BasisTranscodeConfiguration {
  141528. /**
  141529. * Supported compression formats used to determine the supported output format of the transcoder
  141530. */
  141531. supportedCompressionFormats?: {
  141532. /**
  141533. * etc1 compression format
  141534. */
  141535. etc1?: boolean;
  141536. /**
  141537. * s3tc compression format
  141538. */
  141539. s3tc?: boolean;
  141540. /**
  141541. * pvrtc compression format
  141542. */
  141543. pvrtc?: boolean;
  141544. /**
  141545. * etc2 compression format
  141546. */
  141547. etc2?: boolean;
  141548. };
  141549. /**
  141550. * If mipmap levels should be loaded for transcoded images (Default: true)
  141551. */
  141552. loadMipmapLevels?: boolean;
  141553. /**
  141554. * Index of a single image to load (Default: all images)
  141555. */
  141556. loadSingleImage?: number;
  141557. }
  141558. /**
  141559. * Used to load .Basis files
  141560. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  141561. */
  141562. export class BasisTools {
  141563. private static _IgnoreSupportedFormats;
  141564. /**
  141565. * URL to use when loading the basis transcoder
  141566. */
  141567. static JSModuleURL: string;
  141568. /**
  141569. * URL to use when loading the wasm module for the transcoder
  141570. */
  141571. static WasmModuleURL: string;
  141572. /**
  141573. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  141574. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  141575. * @returns internal format corresponding to the Basis format
  141576. */
  141577. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  141578. private static _WorkerPromise;
  141579. private static _Worker;
  141580. private static _actionId;
  141581. private static _CreateWorkerAsync;
  141582. /**
  141583. * Transcodes a loaded image file to compressed pixel data
  141584. * @param data image data to transcode
  141585. * @param config configuration options for the transcoding
  141586. * @returns a promise resulting in the transcoded image
  141587. */
  141588. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  141589. /**
  141590. * Loads a texture from the transcode result
  141591. * @param texture texture load to
  141592. * @param transcodeResult the result of transcoding the basis file to load from
  141593. */
  141594. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  141595. }
  141596. }
  141597. declare module BABYLON {
  141598. /**
  141599. * Loader for .basis file format
  141600. */
  141601. export class _BasisTextureLoader implements IInternalTextureLoader {
  141602. /**
  141603. * Defines whether the loader supports cascade loading the different faces.
  141604. */
  141605. readonly supportCascades: boolean;
  141606. /**
  141607. * This returns if the loader support the current file information.
  141608. * @param extension defines the file extension of the file being loaded
  141609. * @returns true if the loader can load the specified file
  141610. */
  141611. canLoad(extension: string): boolean;
  141612. /**
  141613. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  141614. * @param data contains the texture data
  141615. * @param texture defines the BabylonJS internal texture
  141616. * @param createPolynomials will be true if polynomials have been requested
  141617. * @param onLoad defines the callback to trigger once the texture is ready
  141618. * @param onError defines the callback to trigger in case of error
  141619. */
  141620. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  141621. /**
  141622. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  141623. * @param data contains the texture data
  141624. * @param texture defines the BabylonJS internal texture
  141625. * @param callback defines the method to call once ready to upload
  141626. */
  141627. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  141628. }
  141629. }
  141630. declare module BABYLON {
  141631. /**
  141632. * Defines the basic options interface of a TexturePacker Frame
  141633. */
  141634. export interface ITexturePackerFrame {
  141635. /**
  141636. * The frame ID
  141637. */
  141638. id: number;
  141639. /**
  141640. * The frames Scale
  141641. */
  141642. scale: Vector2;
  141643. /**
  141644. * The Frames offset
  141645. */
  141646. offset: Vector2;
  141647. }
  141648. /**
  141649. * This is a support class for frame Data on texture packer sets.
  141650. */
  141651. export class TexturePackerFrame implements ITexturePackerFrame {
  141652. /**
  141653. * The frame ID
  141654. */
  141655. id: number;
  141656. /**
  141657. * The frames Scale
  141658. */
  141659. scale: Vector2;
  141660. /**
  141661. * The Frames offset
  141662. */
  141663. offset: Vector2;
  141664. /**
  141665. * Initializes a texture package frame.
  141666. * @param id The numerical frame identifier
  141667. * @param scale Scalar Vector2 for UV frame
  141668. * @param offset Vector2 for the frame position in UV units.
  141669. * @returns TexturePackerFrame
  141670. */
  141671. constructor(id: number, scale: Vector2, offset: Vector2);
  141672. }
  141673. }
  141674. declare module BABYLON {
  141675. /**
  141676. * Defines the basic options interface of a TexturePacker
  141677. */
  141678. export interface ITexturePackerOptions {
  141679. /**
  141680. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  141681. */
  141682. map?: string[];
  141683. /**
  141684. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  141685. */
  141686. uvsIn?: string;
  141687. /**
  141688. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  141689. */
  141690. uvsOut?: string;
  141691. /**
  141692. * number representing the layout style. Defaults to LAYOUT_STRIP
  141693. */
  141694. layout?: number;
  141695. /**
  141696. * number of columns if using custom column count layout(2). This defaults to 4.
  141697. */
  141698. colnum?: number;
  141699. /**
  141700. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  141701. */
  141702. updateInputMeshes?: boolean;
  141703. /**
  141704. * boolean flag to dispose all the source textures. Defaults to true.
  141705. */
  141706. disposeSources?: boolean;
  141707. /**
  141708. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  141709. */
  141710. fillBlanks?: boolean;
  141711. /**
  141712. * string value representing the context fill style color. Defaults to 'black'.
  141713. */
  141714. customFillColor?: string;
  141715. /**
  141716. * Width and Height Value of each Frame in the TexturePacker Sets
  141717. */
  141718. frameSize?: number;
  141719. /**
  141720. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  141721. */
  141722. paddingRatio?: number;
  141723. /**
  141724. * Number that declares the fill method for the padding gutter.
  141725. */
  141726. paddingMode?: number;
  141727. /**
  141728. * If in SUBUV_COLOR padding mode what color to use.
  141729. */
  141730. paddingColor?: Color3 | Color4;
  141731. }
  141732. /**
  141733. * Defines the basic interface of a TexturePacker JSON File
  141734. */
  141735. export interface ITexturePackerJSON {
  141736. /**
  141737. * The frame ID
  141738. */
  141739. name: string;
  141740. /**
  141741. * The base64 channel data
  141742. */
  141743. sets: any;
  141744. /**
  141745. * The options of the Packer
  141746. */
  141747. options: ITexturePackerOptions;
  141748. /**
  141749. * The frame data of the Packer
  141750. */
  141751. frames: Array<number>;
  141752. }
  141753. /**
  141754. * This is a support class that generates a series of packed texture sets.
  141755. * @see https://doc.babylonjs.com/babylon101/materials
  141756. */
  141757. export class TexturePacker {
  141758. /** Packer Layout Constant 0 */
  141759. static readonly LAYOUT_STRIP: number;
  141760. /** Packer Layout Constant 1 */
  141761. static readonly LAYOUT_POWER2: number;
  141762. /** Packer Layout Constant 2 */
  141763. static readonly LAYOUT_COLNUM: number;
  141764. /** Packer Layout Constant 0 */
  141765. static readonly SUBUV_WRAP: number;
  141766. /** Packer Layout Constant 1 */
  141767. static readonly SUBUV_EXTEND: number;
  141768. /** Packer Layout Constant 2 */
  141769. static readonly SUBUV_COLOR: number;
  141770. /** The Name of the Texture Package */
  141771. name: string;
  141772. /** The scene scope of the TexturePacker */
  141773. scene: Scene;
  141774. /** The Meshes to target */
  141775. meshes: AbstractMesh[];
  141776. /** Arguments passed with the Constructor */
  141777. options: ITexturePackerOptions;
  141778. /** The promise that is started upon initialization */
  141779. promise: Nullable<Promise<TexturePacker | string>>;
  141780. /** The Container object for the channel sets that are generated */
  141781. sets: object;
  141782. /** The Container array for the frames that are generated */
  141783. frames: TexturePackerFrame[];
  141784. /** The expected number of textures the system is parsing. */
  141785. private _expecting;
  141786. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  141787. private _paddingValue;
  141788. /**
  141789. * Initializes a texture package series from an array of meshes or a single mesh.
  141790. * @param name The name of the package
  141791. * @param meshes The target meshes to compose the package from
  141792. * @param options The arguments that texture packer should follow while building.
  141793. * @param scene The scene which the textures are scoped to.
  141794. * @returns TexturePacker
  141795. */
  141796. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  141797. /**
  141798. * Starts the package process
  141799. * @param resolve The promises resolution function
  141800. * @returns TexturePacker
  141801. */
  141802. private _createFrames;
  141803. /**
  141804. * Calculates the Size of the Channel Sets
  141805. * @returns Vector2
  141806. */
  141807. private _calculateSize;
  141808. /**
  141809. * Calculates the UV data for the frames.
  141810. * @param baseSize the base frameSize
  141811. * @param padding the base frame padding
  141812. * @param dtSize size of the Dynamic Texture for that channel
  141813. * @param dtUnits is 1/dtSize
  141814. * @param update flag to update the input meshes
  141815. */
  141816. private _calculateMeshUVFrames;
  141817. /**
  141818. * Calculates the frames Offset.
  141819. * @param index of the frame
  141820. * @returns Vector2
  141821. */
  141822. private _getFrameOffset;
  141823. /**
  141824. * Updates a Mesh to the frame data
  141825. * @param mesh that is the target
  141826. * @param frameID or the frame index
  141827. */
  141828. private _updateMeshUV;
  141829. /**
  141830. * Updates a Meshes materials to use the texture packer channels
  141831. * @param m is the mesh to target
  141832. * @param force all channels on the packer to be set.
  141833. */
  141834. private _updateTextureReferences;
  141835. /**
  141836. * Public method to set a Mesh to a frame
  141837. * @param m that is the target
  141838. * @param frameID or the frame index
  141839. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  141840. */
  141841. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  141842. /**
  141843. * Starts the async promise to compile the texture packer.
  141844. * @returns Promise<void>
  141845. */
  141846. processAsync(): Promise<void>;
  141847. /**
  141848. * Disposes all textures associated with this packer
  141849. */
  141850. dispose(): void;
  141851. /**
  141852. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  141853. * @param imageType is the image type to use.
  141854. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  141855. */
  141856. download(imageType?: string, quality?: number): void;
  141857. /**
  141858. * Public method to load a texturePacker JSON file.
  141859. * @param data of the JSON file in string format.
  141860. */
  141861. updateFromJSON(data: string): void;
  141862. }
  141863. }
  141864. declare module BABYLON {
  141865. /**
  141866. * 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.
  141867. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  141868. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  141869. */
  141870. export class CustomProceduralTexture extends ProceduralTexture {
  141871. private _animate;
  141872. private _time;
  141873. private _config;
  141874. private _texturePath;
  141875. /**
  141876. * Instantiates a new Custom Procedural Texture.
  141877. * 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.
  141878. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  141879. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  141880. * @param name Define the name of the texture
  141881. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  141882. * @param size Define the size of the texture to create
  141883. * @param scene Define the scene the texture belongs to
  141884. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  141885. * @param generateMipMaps Define if the texture should creates mip maps or not
  141886. */
  141887. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  141888. private _loadJson;
  141889. /**
  141890. * Is the texture ready to be used ? (rendered at least once)
  141891. * @returns true if ready, otherwise, false.
  141892. */
  141893. isReady(): boolean;
  141894. /**
  141895. * Render the texture to its associated render target.
  141896. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  141897. */
  141898. render(useCameraPostProcess?: boolean): void;
  141899. /**
  141900. * Update the list of dependant textures samplers in the shader.
  141901. */
  141902. updateTextures(): void;
  141903. /**
  141904. * Update the uniform values of the procedural texture in the shader.
  141905. */
  141906. updateShaderUniforms(): void;
  141907. /**
  141908. * Define if the texture animates or not.
  141909. */
  141910. get animate(): boolean;
  141911. set animate(value: boolean);
  141912. }
  141913. }
  141914. declare module BABYLON {
  141915. /** @hidden */
  141916. export var noisePixelShader: {
  141917. name: string;
  141918. shader: string;
  141919. };
  141920. }
  141921. declare module BABYLON {
  141922. /**
  141923. * Class used to generate noise procedural textures
  141924. */
  141925. export class NoiseProceduralTexture extends ProceduralTexture {
  141926. /** Gets or sets the start time (default is 0) */
  141927. time: number;
  141928. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  141929. brightness: number;
  141930. /** Defines the number of octaves to process */
  141931. octaves: number;
  141932. /** Defines the level of persistence (0.8 by default) */
  141933. persistence: number;
  141934. /** Gets or sets animation speed factor (default is 1) */
  141935. animationSpeedFactor: number;
  141936. /**
  141937. * Creates a new NoiseProceduralTexture
  141938. * @param name defines the name fo the texture
  141939. * @param size defines the size of the texture (default is 256)
  141940. * @param scene defines the hosting scene
  141941. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  141942. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  141943. */
  141944. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  141945. private _updateShaderUniforms;
  141946. protected _getDefines(): string;
  141947. /** Generate the current state of the procedural texture */
  141948. render(useCameraPostProcess?: boolean): void;
  141949. /**
  141950. * Serializes this noise procedural texture
  141951. * @returns a serialized noise procedural texture object
  141952. */
  141953. serialize(): any;
  141954. /**
  141955. * Clone the texture.
  141956. * @returns the cloned texture
  141957. */
  141958. clone(): NoiseProceduralTexture;
  141959. /**
  141960. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  141961. * @param parsedTexture defines parsed texture data
  141962. * @param scene defines the current scene
  141963. * @param rootUrl defines the root URL containing noise procedural texture information
  141964. * @returns a parsed NoiseProceduralTexture
  141965. */
  141966. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  141967. }
  141968. }
  141969. declare module BABYLON {
  141970. /**
  141971. * Raw cube texture where the raw buffers are passed in
  141972. */
  141973. export class RawCubeTexture extends CubeTexture {
  141974. /**
  141975. * Creates a cube texture where the raw buffers are passed in.
  141976. * @param scene defines the scene the texture is attached to
  141977. * @param data defines the array of data to use to create each face
  141978. * @param size defines the size of the textures
  141979. * @param format defines the format of the data
  141980. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  141981. * @param generateMipMaps defines if the engine should generate the mip levels
  141982. * @param invertY defines if data must be stored with Y axis inverted
  141983. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  141984. * @param compression defines the compression used (null by default)
  141985. */
  141986. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  141987. /**
  141988. * Updates the raw cube texture.
  141989. * @param data defines the data to store
  141990. * @param format defines the data format
  141991. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  141992. * @param invertY defines if data must be stored with Y axis inverted
  141993. * @param compression defines the compression used (null by default)
  141994. * @param level defines which level of the texture to update
  141995. */
  141996. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  141997. /**
  141998. * Updates a raw cube texture with RGBD encoded data.
  141999. * @param data defines the array of data [mipmap][face] to use to create each face
  142000. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  142001. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  142002. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  142003. * @returns a promsie that resolves when the operation is complete
  142004. */
  142005. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  142006. /**
  142007. * Clones the raw cube texture.
  142008. * @return a new cube texture
  142009. */
  142010. clone(): CubeTexture;
  142011. /** @hidden */
  142012. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  142013. }
  142014. }
  142015. declare module BABYLON {
  142016. /**
  142017. * Class used to store 2D array textures containing user data
  142018. */
  142019. export class RawTexture2DArray extends Texture {
  142020. /** Gets or sets the texture format to use */
  142021. format: number;
  142022. /**
  142023. * Create a new RawTexture2DArray
  142024. * @param data defines the data of the texture
  142025. * @param width defines the width of the texture
  142026. * @param height defines the height of the texture
  142027. * @param depth defines the number of layers of the texture
  142028. * @param format defines the texture format to use
  142029. * @param scene defines the hosting scene
  142030. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  142031. * @param invertY defines if texture must be stored with Y axis inverted
  142032. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142033. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  142034. */
  142035. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  142036. /** Gets or sets the texture format to use */
  142037. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  142038. /**
  142039. * Update the texture with new data
  142040. * @param data defines the data to store in the texture
  142041. */
  142042. update(data: ArrayBufferView): void;
  142043. }
  142044. }
  142045. declare module BABYLON {
  142046. /**
  142047. * Class used to store 3D textures containing user data
  142048. */
  142049. export class RawTexture3D extends Texture {
  142050. /** Gets or sets the texture format to use */
  142051. format: number;
  142052. /**
  142053. * Create a new RawTexture3D
  142054. * @param data defines the data of the texture
  142055. * @param width defines the width of the texture
  142056. * @param height defines the height of the texture
  142057. * @param depth defines the depth of the texture
  142058. * @param format defines the texture format to use
  142059. * @param scene defines the hosting scene
  142060. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  142061. * @param invertY defines if texture must be stored with Y axis inverted
  142062. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142063. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  142064. */
  142065. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  142066. /** Gets or sets the texture format to use */
  142067. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  142068. /**
  142069. * Update the texture with new data
  142070. * @param data defines the data to store in the texture
  142071. */
  142072. update(data: ArrayBufferView): void;
  142073. }
  142074. }
  142075. declare module BABYLON {
  142076. /**
  142077. * Creates a refraction texture used by refraction channel of the standard material.
  142078. * It is like a mirror but to see through a material.
  142079. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142080. */
  142081. export class RefractionTexture extends RenderTargetTexture {
  142082. /**
  142083. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  142084. * 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.
  142085. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142086. */
  142087. refractionPlane: Plane;
  142088. /**
  142089. * Define how deep under the surface we should see.
  142090. */
  142091. depth: number;
  142092. /**
  142093. * Creates a refraction texture used by refraction channel of the standard material.
  142094. * It is like a mirror but to see through a material.
  142095. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142096. * @param name Define the texture name
  142097. * @param size Define the size of the underlying texture
  142098. * @param scene Define the scene the refraction belongs to
  142099. * @param generateMipMaps Define if we need to generate mips level for the refraction
  142100. */
  142101. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  142102. /**
  142103. * Clone the refraction texture.
  142104. * @returns the cloned texture
  142105. */
  142106. clone(): RefractionTexture;
  142107. /**
  142108. * Serialize the texture to a JSON representation you could use in Parse later on
  142109. * @returns the serialized JSON representation
  142110. */
  142111. serialize(): any;
  142112. }
  142113. }
  142114. declare module BABYLON {
  142115. /**
  142116. * Block used to add support for vertex skinning (bones)
  142117. */
  142118. export class BonesBlock extends NodeMaterialBlock {
  142119. /**
  142120. * Creates a new BonesBlock
  142121. * @param name defines the block name
  142122. */
  142123. constructor(name: string);
  142124. /**
  142125. * Initialize the block and prepare the context for build
  142126. * @param state defines the state that will be used for the build
  142127. */
  142128. initialize(state: NodeMaterialBuildState): void;
  142129. /**
  142130. * Gets the current class name
  142131. * @returns the class name
  142132. */
  142133. getClassName(): string;
  142134. /**
  142135. * Gets the matrix indices input component
  142136. */
  142137. get matricesIndices(): NodeMaterialConnectionPoint;
  142138. /**
  142139. * Gets the matrix weights input component
  142140. */
  142141. get matricesWeights(): NodeMaterialConnectionPoint;
  142142. /**
  142143. * Gets the extra matrix indices input component
  142144. */
  142145. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  142146. /**
  142147. * Gets the extra matrix weights input component
  142148. */
  142149. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  142150. /**
  142151. * Gets the world input component
  142152. */
  142153. get world(): NodeMaterialConnectionPoint;
  142154. /**
  142155. * Gets the output component
  142156. */
  142157. get output(): NodeMaterialConnectionPoint;
  142158. autoConfigure(material: NodeMaterial): void;
  142159. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  142160. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142161. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142162. protected _buildBlock(state: NodeMaterialBuildState): this;
  142163. }
  142164. }
  142165. declare module BABYLON {
  142166. /**
  142167. * Block used to add support for instances
  142168. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  142169. */
  142170. export class InstancesBlock extends NodeMaterialBlock {
  142171. /**
  142172. * Creates a new InstancesBlock
  142173. * @param name defines the block name
  142174. */
  142175. constructor(name: string);
  142176. /**
  142177. * Gets the current class name
  142178. * @returns the class name
  142179. */
  142180. getClassName(): string;
  142181. /**
  142182. * Gets the first world row input component
  142183. */
  142184. get world0(): NodeMaterialConnectionPoint;
  142185. /**
  142186. * Gets the second world row input component
  142187. */
  142188. get world1(): NodeMaterialConnectionPoint;
  142189. /**
  142190. * Gets the third world row input component
  142191. */
  142192. get world2(): NodeMaterialConnectionPoint;
  142193. /**
  142194. * Gets the forth world row input component
  142195. */
  142196. get world3(): NodeMaterialConnectionPoint;
  142197. /**
  142198. * Gets the world input component
  142199. */
  142200. get world(): NodeMaterialConnectionPoint;
  142201. /**
  142202. * Gets the output component
  142203. */
  142204. get output(): NodeMaterialConnectionPoint;
  142205. /**
  142206. * Gets the isntanceID component
  142207. */
  142208. get instanceID(): NodeMaterialConnectionPoint;
  142209. autoConfigure(material: NodeMaterial): void;
  142210. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  142211. protected _buildBlock(state: NodeMaterialBuildState): this;
  142212. }
  142213. }
  142214. declare module BABYLON {
  142215. /**
  142216. * Block used to add morph targets support to vertex shader
  142217. */
  142218. export class MorphTargetsBlock extends NodeMaterialBlock {
  142219. private _repeatableContentAnchor;
  142220. /**
  142221. * Create a new MorphTargetsBlock
  142222. * @param name defines the block name
  142223. */
  142224. constructor(name: string);
  142225. /**
  142226. * Gets the current class name
  142227. * @returns the class name
  142228. */
  142229. getClassName(): string;
  142230. /**
  142231. * Gets the position input component
  142232. */
  142233. get position(): NodeMaterialConnectionPoint;
  142234. /**
  142235. * Gets the normal input component
  142236. */
  142237. get normal(): NodeMaterialConnectionPoint;
  142238. /**
  142239. * Gets the tangent input component
  142240. */
  142241. get tangent(): NodeMaterialConnectionPoint;
  142242. /**
  142243. * Gets the tangent input component
  142244. */
  142245. get uv(): NodeMaterialConnectionPoint;
  142246. /**
  142247. * Gets the position output component
  142248. */
  142249. get positionOutput(): NodeMaterialConnectionPoint;
  142250. /**
  142251. * Gets the normal output component
  142252. */
  142253. get normalOutput(): NodeMaterialConnectionPoint;
  142254. /**
  142255. * Gets the tangent output component
  142256. */
  142257. get tangentOutput(): NodeMaterialConnectionPoint;
  142258. /**
  142259. * Gets the tangent output component
  142260. */
  142261. get uvOutput(): NodeMaterialConnectionPoint;
  142262. initialize(state: NodeMaterialBuildState): void;
  142263. autoConfigure(material: NodeMaterial): void;
  142264. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142265. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142266. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  142267. protected _buildBlock(state: NodeMaterialBuildState): this;
  142268. }
  142269. }
  142270. declare module BABYLON {
  142271. /**
  142272. * Block used to get data information from a light
  142273. */
  142274. export class LightInformationBlock extends NodeMaterialBlock {
  142275. private _lightDataUniformName;
  142276. private _lightColorUniformName;
  142277. private _lightTypeDefineName;
  142278. /**
  142279. * Gets or sets the light associated with this block
  142280. */
  142281. light: Nullable<Light>;
  142282. /**
  142283. * Creates a new LightInformationBlock
  142284. * @param name defines the block name
  142285. */
  142286. constructor(name: string);
  142287. /**
  142288. * Gets the current class name
  142289. * @returns the class name
  142290. */
  142291. getClassName(): string;
  142292. /**
  142293. * Gets the world position input component
  142294. */
  142295. get worldPosition(): NodeMaterialConnectionPoint;
  142296. /**
  142297. * Gets the direction output component
  142298. */
  142299. get direction(): NodeMaterialConnectionPoint;
  142300. /**
  142301. * Gets the direction output component
  142302. */
  142303. get color(): NodeMaterialConnectionPoint;
  142304. /**
  142305. * Gets the direction output component
  142306. */
  142307. get intensity(): NodeMaterialConnectionPoint;
  142308. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142309. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142310. protected _buildBlock(state: NodeMaterialBuildState): this;
  142311. serialize(): any;
  142312. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142313. }
  142314. }
  142315. declare module BABYLON {
  142316. /**
  142317. * Block used to add image processing support to fragment shader
  142318. */
  142319. export class ImageProcessingBlock extends NodeMaterialBlock {
  142320. /**
  142321. * Create a new ImageProcessingBlock
  142322. * @param name defines the block name
  142323. */
  142324. constructor(name: string);
  142325. /**
  142326. * Gets the current class name
  142327. * @returns the class name
  142328. */
  142329. getClassName(): string;
  142330. /**
  142331. * Gets the color input component
  142332. */
  142333. get color(): NodeMaterialConnectionPoint;
  142334. /**
  142335. * Gets the output component
  142336. */
  142337. get output(): NodeMaterialConnectionPoint;
  142338. /**
  142339. * Initialize the block and prepare the context for build
  142340. * @param state defines the state that will be used for the build
  142341. */
  142342. initialize(state: NodeMaterialBuildState): void;
  142343. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  142344. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142345. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142346. protected _buildBlock(state: NodeMaterialBuildState): this;
  142347. }
  142348. }
  142349. declare module BABYLON {
  142350. /**
  142351. * Block used to pertub normals based on a normal map
  142352. */
  142353. export class PerturbNormalBlock extends NodeMaterialBlock {
  142354. private _tangentSpaceParameterName;
  142355. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  142356. invertX: boolean;
  142357. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  142358. invertY: boolean;
  142359. /**
  142360. * Create a new PerturbNormalBlock
  142361. * @param name defines the block name
  142362. */
  142363. constructor(name: string);
  142364. /**
  142365. * Gets the current class name
  142366. * @returns the class name
  142367. */
  142368. getClassName(): string;
  142369. /**
  142370. * Gets the world position input component
  142371. */
  142372. get worldPosition(): NodeMaterialConnectionPoint;
  142373. /**
  142374. * Gets the world normal input component
  142375. */
  142376. get worldNormal(): NodeMaterialConnectionPoint;
  142377. /**
  142378. * Gets the world tangent input component
  142379. */
  142380. get worldTangent(): NodeMaterialConnectionPoint;
  142381. /**
  142382. * Gets the uv input component
  142383. */
  142384. get uv(): NodeMaterialConnectionPoint;
  142385. /**
  142386. * Gets the normal map color input component
  142387. */
  142388. get normalMapColor(): NodeMaterialConnectionPoint;
  142389. /**
  142390. * Gets the strength input component
  142391. */
  142392. get strength(): NodeMaterialConnectionPoint;
  142393. /**
  142394. * Gets the output component
  142395. */
  142396. get output(): NodeMaterialConnectionPoint;
  142397. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142398. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142399. autoConfigure(material: NodeMaterial): void;
  142400. protected _buildBlock(state: NodeMaterialBuildState): this;
  142401. protected _dumpPropertiesCode(): string;
  142402. serialize(): any;
  142403. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142404. }
  142405. }
  142406. declare module BABYLON {
  142407. /**
  142408. * Block used to discard a pixel if a value is smaller than a cutoff
  142409. */
  142410. export class DiscardBlock extends NodeMaterialBlock {
  142411. /**
  142412. * Create a new DiscardBlock
  142413. * @param name defines the block name
  142414. */
  142415. constructor(name: string);
  142416. /**
  142417. * Gets the current class name
  142418. * @returns the class name
  142419. */
  142420. getClassName(): string;
  142421. /**
  142422. * Gets the color input component
  142423. */
  142424. get value(): NodeMaterialConnectionPoint;
  142425. /**
  142426. * Gets the cutoff input component
  142427. */
  142428. get cutoff(): NodeMaterialConnectionPoint;
  142429. protected _buildBlock(state: NodeMaterialBuildState): this;
  142430. }
  142431. }
  142432. declare module BABYLON {
  142433. /**
  142434. * Block used to test if the fragment shader is front facing
  142435. */
  142436. export class FrontFacingBlock extends NodeMaterialBlock {
  142437. /**
  142438. * Creates a new FrontFacingBlock
  142439. * @param name defines the block name
  142440. */
  142441. constructor(name: string);
  142442. /**
  142443. * Gets the current class name
  142444. * @returns the class name
  142445. */
  142446. getClassName(): string;
  142447. /**
  142448. * Gets the output component
  142449. */
  142450. get output(): NodeMaterialConnectionPoint;
  142451. protected _buildBlock(state: NodeMaterialBuildState): this;
  142452. }
  142453. }
  142454. declare module BABYLON {
  142455. /**
  142456. * Block used to get the derivative value on x and y of a given input
  142457. */
  142458. export class DerivativeBlock extends NodeMaterialBlock {
  142459. /**
  142460. * Create a new DerivativeBlock
  142461. * @param name defines the block name
  142462. */
  142463. constructor(name: string);
  142464. /**
  142465. * Gets the current class name
  142466. * @returns the class name
  142467. */
  142468. getClassName(): string;
  142469. /**
  142470. * Gets the input component
  142471. */
  142472. get input(): NodeMaterialConnectionPoint;
  142473. /**
  142474. * Gets the derivative output on x
  142475. */
  142476. get dx(): NodeMaterialConnectionPoint;
  142477. /**
  142478. * Gets the derivative output on y
  142479. */
  142480. get dy(): NodeMaterialConnectionPoint;
  142481. protected _buildBlock(state: NodeMaterialBuildState): this;
  142482. }
  142483. }
  142484. declare module BABYLON {
  142485. /**
  142486. * Block used to make gl_FragCoord available
  142487. */
  142488. export class FragCoordBlock extends NodeMaterialBlock {
  142489. /**
  142490. * Creates a new FragCoordBlock
  142491. * @param name defines the block name
  142492. */
  142493. constructor(name: string);
  142494. /**
  142495. * Gets the current class name
  142496. * @returns the class name
  142497. */
  142498. getClassName(): string;
  142499. /**
  142500. * Gets the xy component
  142501. */
  142502. get xy(): NodeMaterialConnectionPoint;
  142503. /**
  142504. * Gets the xyz component
  142505. */
  142506. get xyz(): NodeMaterialConnectionPoint;
  142507. /**
  142508. * Gets the xyzw component
  142509. */
  142510. get xyzw(): NodeMaterialConnectionPoint;
  142511. /**
  142512. * Gets the x component
  142513. */
  142514. get x(): NodeMaterialConnectionPoint;
  142515. /**
  142516. * Gets the y component
  142517. */
  142518. get y(): NodeMaterialConnectionPoint;
  142519. /**
  142520. * Gets the z component
  142521. */
  142522. get z(): NodeMaterialConnectionPoint;
  142523. /**
  142524. * Gets the w component
  142525. */
  142526. get output(): NodeMaterialConnectionPoint;
  142527. protected writeOutputs(state: NodeMaterialBuildState): string;
  142528. protected _buildBlock(state: NodeMaterialBuildState): this;
  142529. }
  142530. }
  142531. declare module BABYLON {
  142532. /**
  142533. * Block used to get the screen sizes
  142534. */
  142535. export class ScreenSizeBlock extends NodeMaterialBlock {
  142536. private _varName;
  142537. private _scene;
  142538. /**
  142539. * Creates a new ScreenSizeBlock
  142540. * @param name defines the block name
  142541. */
  142542. constructor(name: string);
  142543. /**
  142544. * Gets the current class name
  142545. * @returns the class name
  142546. */
  142547. getClassName(): string;
  142548. /**
  142549. * Gets the xy component
  142550. */
  142551. get xy(): NodeMaterialConnectionPoint;
  142552. /**
  142553. * Gets the x component
  142554. */
  142555. get x(): NodeMaterialConnectionPoint;
  142556. /**
  142557. * Gets the y component
  142558. */
  142559. get y(): NodeMaterialConnectionPoint;
  142560. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142561. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  142562. protected _buildBlock(state: NodeMaterialBuildState): this;
  142563. }
  142564. }
  142565. declare module BABYLON {
  142566. /**
  142567. * Block used to add support for scene fog
  142568. */
  142569. export class FogBlock extends NodeMaterialBlock {
  142570. private _fogDistanceName;
  142571. private _fogParameters;
  142572. /**
  142573. * Create a new FogBlock
  142574. * @param name defines the block name
  142575. */
  142576. constructor(name: string);
  142577. /**
  142578. * Gets the current class name
  142579. * @returns the class name
  142580. */
  142581. getClassName(): string;
  142582. /**
  142583. * Gets the world position input component
  142584. */
  142585. get worldPosition(): NodeMaterialConnectionPoint;
  142586. /**
  142587. * Gets the view input component
  142588. */
  142589. get view(): NodeMaterialConnectionPoint;
  142590. /**
  142591. * Gets the color input component
  142592. */
  142593. get input(): NodeMaterialConnectionPoint;
  142594. /**
  142595. * Gets the fog color input component
  142596. */
  142597. get fogColor(): NodeMaterialConnectionPoint;
  142598. /**
  142599. * Gets the output component
  142600. */
  142601. get output(): NodeMaterialConnectionPoint;
  142602. autoConfigure(material: NodeMaterial): void;
  142603. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142604. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142605. protected _buildBlock(state: NodeMaterialBuildState): this;
  142606. }
  142607. }
  142608. declare module BABYLON {
  142609. /**
  142610. * Block used to add light in the fragment shader
  142611. */
  142612. export class LightBlock extends NodeMaterialBlock {
  142613. private _lightId;
  142614. /**
  142615. * Gets or sets the light associated with this block
  142616. */
  142617. light: Nullable<Light>;
  142618. /**
  142619. * Create a new LightBlock
  142620. * @param name defines the block name
  142621. */
  142622. constructor(name: string);
  142623. /**
  142624. * Gets the current class name
  142625. * @returns the class name
  142626. */
  142627. getClassName(): string;
  142628. /**
  142629. * Gets the world position input component
  142630. */
  142631. get worldPosition(): NodeMaterialConnectionPoint;
  142632. /**
  142633. * Gets the world normal input component
  142634. */
  142635. get worldNormal(): NodeMaterialConnectionPoint;
  142636. /**
  142637. * Gets the camera (or eye) position component
  142638. */
  142639. get cameraPosition(): NodeMaterialConnectionPoint;
  142640. /**
  142641. * Gets the glossiness component
  142642. */
  142643. get glossiness(): NodeMaterialConnectionPoint;
  142644. /**
  142645. * Gets the glossinness power component
  142646. */
  142647. get glossPower(): NodeMaterialConnectionPoint;
  142648. /**
  142649. * Gets the diffuse color component
  142650. */
  142651. get diffuseColor(): NodeMaterialConnectionPoint;
  142652. /**
  142653. * Gets the specular color component
  142654. */
  142655. get specularColor(): NodeMaterialConnectionPoint;
  142656. /**
  142657. * Gets the diffuse output component
  142658. */
  142659. get diffuseOutput(): NodeMaterialConnectionPoint;
  142660. /**
  142661. * Gets the specular output component
  142662. */
  142663. get specularOutput(): NodeMaterialConnectionPoint;
  142664. /**
  142665. * Gets the shadow output component
  142666. */
  142667. get shadow(): NodeMaterialConnectionPoint;
  142668. autoConfigure(material: NodeMaterial): void;
  142669. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142670. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  142671. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142672. private _injectVertexCode;
  142673. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  142674. serialize(): any;
  142675. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142676. }
  142677. }
  142678. declare module BABYLON {
  142679. /**
  142680. * Block used to read a reflection texture from a sampler
  142681. */
  142682. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  142683. /**
  142684. * Create a new ReflectionTextureBlock
  142685. * @param name defines the block name
  142686. */
  142687. constructor(name: string);
  142688. /**
  142689. * Gets the current class name
  142690. * @returns the class name
  142691. */
  142692. getClassName(): string;
  142693. /**
  142694. * Gets the world position input component
  142695. */
  142696. get position(): NodeMaterialConnectionPoint;
  142697. /**
  142698. * Gets the world position input component
  142699. */
  142700. get worldPosition(): NodeMaterialConnectionPoint;
  142701. /**
  142702. * Gets the world normal input component
  142703. */
  142704. get worldNormal(): NodeMaterialConnectionPoint;
  142705. /**
  142706. * Gets the world input component
  142707. */
  142708. get world(): NodeMaterialConnectionPoint;
  142709. /**
  142710. * Gets the camera (or eye) position component
  142711. */
  142712. get cameraPosition(): NodeMaterialConnectionPoint;
  142713. /**
  142714. * Gets the view input component
  142715. */
  142716. get view(): NodeMaterialConnectionPoint;
  142717. /**
  142718. * Gets the rgb output component
  142719. */
  142720. get rgb(): NodeMaterialConnectionPoint;
  142721. /**
  142722. * Gets the rgba output component
  142723. */
  142724. get rgba(): NodeMaterialConnectionPoint;
  142725. /**
  142726. * Gets the r output component
  142727. */
  142728. get r(): NodeMaterialConnectionPoint;
  142729. /**
  142730. * Gets the g output component
  142731. */
  142732. get g(): NodeMaterialConnectionPoint;
  142733. /**
  142734. * Gets the b output component
  142735. */
  142736. get b(): NodeMaterialConnectionPoint;
  142737. /**
  142738. * Gets the a output component
  142739. */
  142740. get a(): NodeMaterialConnectionPoint;
  142741. autoConfigure(material: NodeMaterial): void;
  142742. protected _buildBlock(state: NodeMaterialBuildState): this;
  142743. }
  142744. }
  142745. declare module BABYLON {
  142746. /**
  142747. * Block used to add 2 vectors
  142748. */
  142749. export class AddBlock extends NodeMaterialBlock {
  142750. /**
  142751. * Creates a new AddBlock
  142752. * @param name defines the block name
  142753. */
  142754. constructor(name: string);
  142755. /**
  142756. * Gets the current class name
  142757. * @returns the class name
  142758. */
  142759. getClassName(): string;
  142760. /**
  142761. * Gets the left operand input component
  142762. */
  142763. get left(): NodeMaterialConnectionPoint;
  142764. /**
  142765. * Gets the right operand input component
  142766. */
  142767. get right(): NodeMaterialConnectionPoint;
  142768. /**
  142769. * Gets the output component
  142770. */
  142771. get output(): NodeMaterialConnectionPoint;
  142772. protected _buildBlock(state: NodeMaterialBuildState): this;
  142773. }
  142774. }
  142775. declare module BABYLON {
  142776. /**
  142777. * Block used to scale a vector by a float
  142778. */
  142779. export class ScaleBlock extends NodeMaterialBlock {
  142780. /**
  142781. * Creates a new ScaleBlock
  142782. * @param name defines the block name
  142783. */
  142784. constructor(name: string);
  142785. /**
  142786. * Gets the current class name
  142787. * @returns the class name
  142788. */
  142789. getClassName(): string;
  142790. /**
  142791. * Gets the input component
  142792. */
  142793. get input(): NodeMaterialConnectionPoint;
  142794. /**
  142795. * Gets the factor input component
  142796. */
  142797. get factor(): NodeMaterialConnectionPoint;
  142798. /**
  142799. * Gets the output component
  142800. */
  142801. get output(): NodeMaterialConnectionPoint;
  142802. protected _buildBlock(state: NodeMaterialBuildState): this;
  142803. }
  142804. }
  142805. declare module BABYLON {
  142806. /**
  142807. * Block used to clamp a float
  142808. */
  142809. export class ClampBlock extends NodeMaterialBlock {
  142810. /** Gets or sets the minimum range */
  142811. minimum: number;
  142812. /** Gets or sets the maximum range */
  142813. maximum: number;
  142814. /**
  142815. * Creates a new ClampBlock
  142816. * @param name defines the block name
  142817. */
  142818. constructor(name: string);
  142819. /**
  142820. * Gets the current class name
  142821. * @returns the class name
  142822. */
  142823. getClassName(): string;
  142824. /**
  142825. * Gets the value input component
  142826. */
  142827. get value(): NodeMaterialConnectionPoint;
  142828. /**
  142829. * Gets the output component
  142830. */
  142831. get output(): NodeMaterialConnectionPoint;
  142832. protected _buildBlock(state: NodeMaterialBuildState): this;
  142833. protected _dumpPropertiesCode(): string;
  142834. serialize(): any;
  142835. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142836. }
  142837. }
  142838. declare module BABYLON {
  142839. /**
  142840. * Block used to apply a cross product between 2 vectors
  142841. */
  142842. export class CrossBlock extends NodeMaterialBlock {
  142843. /**
  142844. * Creates a new CrossBlock
  142845. * @param name defines the block name
  142846. */
  142847. constructor(name: string);
  142848. /**
  142849. * Gets the current class name
  142850. * @returns the class name
  142851. */
  142852. getClassName(): string;
  142853. /**
  142854. * Gets the left operand input component
  142855. */
  142856. get left(): NodeMaterialConnectionPoint;
  142857. /**
  142858. * Gets the right operand input component
  142859. */
  142860. get right(): NodeMaterialConnectionPoint;
  142861. /**
  142862. * Gets the output component
  142863. */
  142864. get output(): NodeMaterialConnectionPoint;
  142865. protected _buildBlock(state: NodeMaterialBuildState): this;
  142866. }
  142867. }
  142868. declare module BABYLON {
  142869. /**
  142870. * Block used to apply a dot product between 2 vectors
  142871. */
  142872. export class DotBlock extends NodeMaterialBlock {
  142873. /**
  142874. * Creates a new DotBlock
  142875. * @param name defines the block name
  142876. */
  142877. constructor(name: string);
  142878. /**
  142879. * Gets the current class name
  142880. * @returns the class name
  142881. */
  142882. getClassName(): string;
  142883. /**
  142884. * Gets the left operand input component
  142885. */
  142886. get left(): NodeMaterialConnectionPoint;
  142887. /**
  142888. * Gets the right operand input component
  142889. */
  142890. get right(): NodeMaterialConnectionPoint;
  142891. /**
  142892. * Gets the output component
  142893. */
  142894. get output(): NodeMaterialConnectionPoint;
  142895. protected _buildBlock(state: NodeMaterialBuildState): this;
  142896. }
  142897. }
  142898. declare module BABYLON {
  142899. /**
  142900. * Block used to normalize a vector
  142901. */
  142902. export class NormalizeBlock extends NodeMaterialBlock {
  142903. /**
  142904. * Creates a new NormalizeBlock
  142905. * @param name defines the block name
  142906. */
  142907. constructor(name: string);
  142908. /**
  142909. * Gets the current class name
  142910. * @returns the class name
  142911. */
  142912. getClassName(): string;
  142913. /**
  142914. * Gets the input component
  142915. */
  142916. get input(): NodeMaterialConnectionPoint;
  142917. /**
  142918. * Gets the output component
  142919. */
  142920. get output(): NodeMaterialConnectionPoint;
  142921. protected _buildBlock(state: NodeMaterialBuildState): this;
  142922. }
  142923. }
  142924. declare module BABYLON {
  142925. /**
  142926. * Operations supported by the Trigonometry block
  142927. */
  142928. export enum TrigonometryBlockOperations {
  142929. /** Cos */
  142930. Cos = 0,
  142931. /** Sin */
  142932. Sin = 1,
  142933. /** Abs */
  142934. Abs = 2,
  142935. /** Exp */
  142936. Exp = 3,
  142937. /** Exp2 */
  142938. Exp2 = 4,
  142939. /** Round */
  142940. Round = 5,
  142941. /** Floor */
  142942. Floor = 6,
  142943. /** Ceiling */
  142944. Ceiling = 7,
  142945. /** Square root */
  142946. Sqrt = 8,
  142947. /** Log */
  142948. Log = 9,
  142949. /** Tangent */
  142950. Tan = 10,
  142951. /** Arc tangent */
  142952. ArcTan = 11,
  142953. /** Arc cosinus */
  142954. ArcCos = 12,
  142955. /** Arc sinus */
  142956. ArcSin = 13,
  142957. /** Fraction */
  142958. Fract = 14,
  142959. /** Sign */
  142960. Sign = 15,
  142961. /** To radians (from degrees) */
  142962. Radians = 16,
  142963. /** To degrees (from radians) */
  142964. Degrees = 17
  142965. }
  142966. /**
  142967. * Block used to apply trigonometry operation to floats
  142968. */
  142969. export class TrigonometryBlock extends NodeMaterialBlock {
  142970. /**
  142971. * Gets or sets the operation applied by the block
  142972. */
  142973. operation: TrigonometryBlockOperations;
  142974. /**
  142975. * Creates a new TrigonometryBlock
  142976. * @param name defines the block name
  142977. */
  142978. constructor(name: string);
  142979. /**
  142980. * Gets the current class name
  142981. * @returns the class name
  142982. */
  142983. getClassName(): string;
  142984. /**
  142985. * Gets the input component
  142986. */
  142987. get input(): NodeMaterialConnectionPoint;
  142988. /**
  142989. * Gets the output component
  142990. */
  142991. get output(): NodeMaterialConnectionPoint;
  142992. protected _buildBlock(state: NodeMaterialBuildState): this;
  142993. serialize(): any;
  142994. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142995. protected _dumpPropertiesCode(): string;
  142996. }
  142997. }
  142998. declare module BABYLON {
  142999. /**
  143000. * Block used to create a Color3/4 out of individual inputs (one for each component)
  143001. */
  143002. export class ColorMergerBlock extends NodeMaterialBlock {
  143003. /**
  143004. * Create a new ColorMergerBlock
  143005. * @param name defines the block name
  143006. */
  143007. constructor(name: string);
  143008. /**
  143009. * Gets the current class name
  143010. * @returns the class name
  143011. */
  143012. getClassName(): string;
  143013. /**
  143014. * Gets the rgb component (input)
  143015. */
  143016. get rgbIn(): NodeMaterialConnectionPoint;
  143017. /**
  143018. * Gets the r component (input)
  143019. */
  143020. get r(): NodeMaterialConnectionPoint;
  143021. /**
  143022. * Gets the g component (input)
  143023. */
  143024. get g(): NodeMaterialConnectionPoint;
  143025. /**
  143026. * Gets the b component (input)
  143027. */
  143028. get b(): NodeMaterialConnectionPoint;
  143029. /**
  143030. * Gets the a component (input)
  143031. */
  143032. get a(): NodeMaterialConnectionPoint;
  143033. /**
  143034. * Gets the rgba component (output)
  143035. */
  143036. get rgba(): NodeMaterialConnectionPoint;
  143037. /**
  143038. * Gets the rgb component (output)
  143039. */
  143040. get rgbOut(): NodeMaterialConnectionPoint;
  143041. /**
  143042. * Gets the rgb component (output)
  143043. * @deprecated Please use rgbOut instead.
  143044. */
  143045. get rgb(): NodeMaterialConnectionPoint;
  143046. protected _buildBlock(state: NodeMaterialBuildState): this;
  143047. }
  143048. }
  143049. declare module BABYLON {
  143050. /**
  143051. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  143052. */
  143053. export class VectorSplitterBlock extends NodeMaterialBlock {
  143054. /**
  143055. * Create a new VectorSplitterBlock
  143056. * @param name defines the block name
  143057. */
  143058. constructor(name: string);
  143059. /**
  143060. * Gets the current class name
  143061. * @returns the class name
  143062. */
  143063. getClassName(): string;
  143064. /**
  143065. * Gets the xyzw component (input)
  143066. */
  143067. get xyzw(): NodeMaterialConnectionPoint;
  143068. /**
  143069. * Gets the xyz component (input)
  143070. */
  143071. get xyzIn(): NodeMaterialConnectionPoint;
  143072. /**
  143073. * Gets the xy component (input)
  143074. */
  143075. get xyIn(): NodeMaterialConnectionPoint;
  143076. /**
  143077. * Gets the xyz component (output)
  143078. */
  143079. get xyzOut(): NodeMaterialConnectionPoint;
  143080. /**
  143081. * Gets the xy component (output)
  143082. */
  143083. get xyOut(): NodeMaterialConnectionPoint;
  143084. /**
  143085. * Gets the x component (output)
  143086. */
  143087. get x(): NodeMaterialConnectionPoint;
  143088. /**
  143089. * Gets the y component (output)
  143090. */
  143091. get y(): NodeMaterialConnectionPoint;
  143092. /**
  143093. * Gets the z component (output)
  143094. */
  143095. get z(): NodeMaterialConnectionPoint;
  143096. /**
  143097. * Gets the w component (output)
  143098. */
  143099. get w(): NodeMaterialConnectionPoint;
  143100. protected _inputRename(name: string): string;
  143101. protected _outputRename(name: string): string;
  143102. protected _buildBlock(state: NodeMaterialBuildState): this;
  143103. }
  143104. }
  143105. declare module BABYLON {
  143106. /**
  143107. * Block used to lerp between 2 values
  143108. */
  143109. export class LerpBlock extends NodeMaterialBlock {
  143110. /**
  143111. * Creates a new LerpBlock
  143112. * @param name defines the block name
  143113. */
  143114. constructor(name: string);
  143115. /**
  143116. * Gets the current class name
  143117. * @returns the class name
  143118. */
  143119. getClassName(): string;
  143120. /**
  143121. * Gets the left operand input component
  143122. */
  143123. get left(): NodeMaterialConnectionPoint;
  143124. /**
  143125. * Gets the right operand input component
  143126. */
  143127. get right(): NodeMaterialConnectionPoint;
  143128. /**
  143129. * Gets the gradient operand input component
  143130. */
  143131. get gradient(): NodeMaterialConnectionPoint;
  143132. /**
  143133. * Gets the output component
  143134. */
  143135. get output(): NodeMaterialConnectionPoint;
  143136. protected _buildBlock(state: NodeMaterialBuildState): this;
  143137. }
  143138. }
  143139. declare module BABYLON {
  143140. /**
  143141. * Block used to divide 2 vectors
  143142. */
  143143. export class DivideBlock extends NodeMaterialBlock {
  143144. /**
  143145. * Creates a new DivideBlock
  143146. * @param name defines the block name
  143147. */
  143148. constructor(name: string);
  143149. /**
  143150. * Gets the current class name
  143151. * @returns the class name
  143152. */
  143153. getClassName(): string;
  143154. /**
  143155. * Gets the left operand input component
  143156. */
  143157. get left(): NodeMaterialConnectionPoint;
  143158. /**
  143159. * Gets the right operand input component
  143160. */
  143161. get right(): NodeMaterialConnectionPoint;
  143162. /**
  143163. * Gets the output component
  143164. */
  143165. get output(): NodeMaterialConnectionPoint;
  143166. protected _buildBlock(state: NodeMaterialBuildState): this;
  143167. }
  143168. }
  143169. declare module BABYLON {
  143170. /**
  143171. * Block used to subtract 2 vectors
  143172. */
  143173. export class SubtractBlock extends NodeMaterialBlock {
  143174. /**
  143175. * Creates a new SubtractBlock
  143176. * @param name defines the block name
  143177. */
  143178. constructor(name: string);
  143179. /**
  143180. * Gets the current class name
  143181. * @returns the class name
  143182. */
  143183. getClassName(): string;
  143184. /**
  143185. * Gets the left operand input component
  143186. */
  143187. get left(): NodeMaterialConnectionPoint;
  143188. /**
  143189. * Gets the right operand input component
  143190. */
  143191. get right(): NodeMaterialConnectionPoint;
  143192. /**
  143193. * Gets the output component
  143194. */
  143195. get output(): NodeMaterialConnectionPoint;
  143196. protected _buildBlock(state: NodeMaterialBuildState): this;
  143197. }
  143198. }
  143199. declare module BABYLON {
  143200. /**
  143201. * Block used to step a value
  143202. */
  143203. export class StepBlock extends NodeMaterialBlock {
  143204. /**
  143205. * Creates a new StepBlock
  143206. * @param name defines the block name
  143207. */
  143208. constructor(name: string);
  143209. /**
  143210. * Gets the current class name
  143211. * @returns the class name
  143212. */
  143213. getClassName(): string;
  143214. /**
  143215. * Gets the value operand input component
  143216. */
  143217. get value(): NodeMaterialConnectionPoint;
  143218. /**
  143219. * Gets the edge operand input component
  143220. */
  143221. get edge(): NodeMaterialConnectionPoint;
  143222. /**
  143223. * Gets the output component
  143224. */
  143225. get output(): NodeMaterialConnectionPoint;
  143226. protected _buildBlock(state: NodeMaterialBuildState): this;
  143227. }
  143228. }
  143229. declare module BABYLON {
  143230. /**
  143231. * Block used to get the opposite (1 - x) of a value
  143232. */
  143233. export class OneMinusBlock extends NodeMaterialBlock {
  143234. /**
  143235. * Creates a new OneMinusBlock
  143236. * @param name defines the block name
  143237. */
  143238. constructor(name: string);
  143239. /**
  143240. * Gets the current class name
  143241. * @returns the class name
  143242. */
  143243. getClassName(): string;
  143244. /**
  143245. * Gets the input component
  143246. */
  143247. get input(): NodeMaterialConnectionPoint;
  143248. /**
  143249. * Gets the output component
  143250. */
  143251. get output(): NodeMaterialConnectionPoint;
  143252. protected _buildBlock(state: NodeMaterialBuildState): this;
  143253. }
  143254. }
  143255. declare module BABYLON {
  143256. /**
  143257. * Block used to get the view direction
  143258. */
  143259. export class ViewDirectionBlock extends NodeMaterialBlock {
  143260. /**
  143261. * Creates a new ViewDirectionBlock
  143262. * @param name defines the block name
  143263. */
  143264. constructor(name: string);
  143265. /**
  143266. * Gets the current class name
  143267. * @returns the class name
  143268. */
  143269. getClassName(): string;
  143270. /**
  143271. * Gets the world position component
  143272. */
  143273. get worldPosition(): NodeMaterialConnectionPoint;
  143274. /**
  143275. * Gets the camera position component
  143276. */
  143277. get cameraPosition(): NodeMaterialConnectionPoint;
  143278. /**
  143279. * Gets the output component
  143280. */
  143281. get output(): NodeMaterialConnectionPoint;
  143282. autoConfigure(material: NodeMaterial): void;
  143283. protected _buildBlock(state: NodeMaterialBuildState): this;
  143284. }
  143285. }
  143286. declare module BABYLON {
  143287. /**
  143288. * Block used to compute fresnel value
  143289. */
  143290. export class FresnelBlock extends NodeMaterialBlock {
  143291. /**
  143292. * Create a new FresnelBlock
  143293. * @param name defines the block name
  143294. */
  143295. constructor(name: string);
  143296. /**
  143297. * Gets the current class name
  143298. * @returns the class name
  143299. */
  143300. getClassName(): string;
  143301. /**
  143302. * Gets the world normal input component
  143303. */
  143304. get worldNormal(): NodeMaterialConnectionPoint;
  143305. /**
  143306. * Gets the view direction input component
  143307. */
  143308. get viewDirection(): NodeMaterialConnectionPoint;
  143309. /**
  143310. * Gets the bias input component
  143311. */
  143312. get bias(): NodeMaterialConnectionPoint;
  143313. /**
  143314. * Gets the camera (or eye) position component
  143315. */
  143316. get power(): NodeMaterialConnectionPoint;
  143317. /**
  143318. * Gets the fresnel output component
  143319. */
  143320. get fresnel(): NodeMaterialConnectionPoint;
  143321. autoConfigure(material: NodeMaterial): void;
  143322. protected _buildBlock(state: NodeMaterialBuildState): this;
  143323. }
  143324. }
  143325. declare module BABYLON {
  143326. /**
  143327. * Block used to get the max of 2 values
  143328. */
  143329. export class MaxBlock extends NodeMaterialBlock {
  143330. /**
  143331. * Creates a new MaxBlock
  143332. * @param name defines the block name
  143333. */
  143334. constructor(name: string);
  143335. /**
  143336. * Gets the current class name
  143337. * @returns the class name
  143338. */
  143339. getClassName(): string;
  143340. /**
  143341. * Gets the left operand input component
  143342. */
  143343. get left(): NodeMaterialConnectionPoint;
  143344. /**
  143345. * Gets the right operand input component
  143346. */
  143347. get right(): NodeMaterialConnectionPoint;
  143348. /**
  143349. * Gets the output component
  143350. */
  143351. get output(): NodeMaterialConnectionPoint;
  143352. protected _buildBlock(state: NodeMaterialBuildState): this;
  143353. }
  143354. }
  143355. declare module BABYLON {
  143356. /**
  143357. * Block used to get the min of 2 values
  143358. */
  143359. export class MinBlock extends NodeMaterialBlock {
  143360. /**
  143361. * Creates a new MinBlock
  143362. * @param name defines the block name
  143363. */
  143364. constructor(name: string);
  143365. /**
  143366. * Gets the current class name
  143367. * @returns the class name
  143368. */
  143369. getClassName(): string;
  143370. /**
  143371. * Gets the left operand input component
  143372. */
  143373. get left(): NodeMaterialConnectionPoint;
  143374. /**
  143375. * Gets the right operand input component
  143376. */
  143377. get right(): NodeMaterialConnectionPoint;
  143378. /**
  143379. * Gets the output component
  143380. */
  143381. get output(): NodeMaterialConnectionPoint;
  143382. protected _buildBlock(state: NodeMaterialBuildState): this;
  143383. }
  143384. }
  143385. declare module BABYLON {
  143386. /**
  143387. * Block used to get the distance between 2 values
  143388. */
  143389. export class DistanceBlock extends NodeMaterialBlock {
  143390. /**
  143391. * Creates a new DistanceBlock
  143392. * @param name defines the block name
  143393. */
  143394. constructor(name: string);
  143395. /**
  143396. * Gets the current class name
  143397. * @returns the class name
  143398. */
  143399. getClassName(): string;
  143400. /**
  143401. * Gets the left operand input component
  143402. */
  143403. get left(): NodeMaterialConnectionPoint;
  143404. /**
  143405. * Gets the right operand input component
  143406. */
  143407. get right(): NodeMaterialConnectionPoint;
  143408. /**
  143409. * Gets the output component
  143410. */
  143411. get output(): NodeMaterialConnectionPoint;
  143412. protected _buildBlock(state: NodeMaterialBuildState): this;
  143413. }
  143414. }
  143415. declare module BABYLON {
  143416. /**
  143417. * Block used to get the length of a vector
  143418. */
  143419. export class LengthBlock extends NodeMaterialBlock {
  143420. /**
  143421. * Creates a new LengthBlock
  143422. * @param name defines the block name
  143423. */
  143424. constructor(name: string);
  143425. /**
  143426. * Gets the current class name
  143427. * @returns the class name
  143428. */
  143429. getClassName(): string;
  143430. /**
  143431. * Gets the value input component
  143432. */
  143433. get value(): NodeMaterialConnectionPoint;
  143434. /**
  143435. * Gets the output component
  143436. */
  143437. get output(): NodeMaterialConnectionPoint;
  143438. protected _buildBlock(state: NodeMaterialBuildState): this;
  143439. }
  143440. }
  143441. declare module BABYLON {
  143442. /**
  143443. * Block used to get negative version of a value (i.e. x * -1)
  143444. */
  143445. export class NegateBlock extends NodeMaterialBlock {
  143446. /**
  143447. * Creates a new NegateBlock
  143448. * @param name defines the block name
  143449. */
  143450. constructor(name: string);
  143451. /**
  143452. * Gets the current class name
  143453. * @returns the class name
  143454. */
  143455. getClassName(): string;
  143456. /**
  143457. * Gets the value input component
  143458. */
  143459. get value(): NodeMaterialConnectionPoint;
  143460. /**
  143461. * Gets the output component
  143462. */
  143463. get output(): NodeMaterialConnectionPoint;
  143464. protected _buildBlock(state: NodeMaterialBuildState): this;
  143465. }
  143466. }
  143467. declare module BABYLON {
  143468. /**
  143469. * Block used to get the value of the first parameter raised to the power of the second
  143470. */
  143471. export class PowBlock extends NodeMaterialBlock {
  143472. /**
  143473. * Creates a new PowBlock
  143474. * @param name defines the block name
  143475. */
  143476. constructor(name: string);
  143477. /**
  143478. * Gets the current class name
  143479. * @returns the class name
  143480. */
  143481. getClassName(): string;
  143482. /**
  143483. * Gets the value operand input component
  143484. */
  143485. get value(): NodeMaterialConnectionPoint;
  143486. /**
  143487. * Gets the power operand input component
  143488. */
  143489. get power(): NodeMaterialConnectionPoint;
  143490. /**
  143491. * Gets the output component
  143492. */
  143493. get output(): NodeMaterialConnectionPoint;
  143494. protected _buildBlock(state: NodeMaterialBuildState): this;
  143495. }
  143496. }
  143497. declare module BABYLON {
  143498. /**
  143499. * Block used to get a random number
  143500. */
  143501. export class RandomNumberBlock extends NodeMaterialBlock {
  143502. /**
  143503. * Creates a new RandomNumberBlock
  143504. * @param name defines the block name
  143505. */
  143506. constructor(name: string);
  143507. /**
  143508. * Gets the current class name
  143509. * @returns the class name
  143510. */
  143511. getClassName(): string;
  143512. /**
  143513. * Gets the seed input component
  143514. */
  143515. get seed(): NodeMaterialConnectionPoint;
  143516. /**
  143517. * Gets the output component
  143518. */
  143519. get output(): NodeMaterialConnectionPoint;
  143520. protected _buildBlock(state: NodeMaterialBuildState): this;
  143521. }
  143522. }
  143523. declare module BABYLON {
  143524. /**
  143525. * Block used to compute arc tangent of 2 values
  143526. */
  143527. export class ArcTan2Block extends NodeMaterialBlock {
  143528. /**
  143529. * Creates a new ArcTan2Block
  143530. * @param name defines the block name
  143531. */
  143532. constructor(name: string);
  143533. /**
  143534. * Gets the current class name
  143535. * @returns the class name
  143536. */
  143537. getClassName(): string;
  143538. /**
  143539. * Gets the x operand input component
  143540. */
  143541. get x(): NodeMaterialConnectionPoint;
  143542. /**
  143543. * Gets the y operand input component
  143544. */
  143545. get y(): NodeMaterialConnectionPoint;
  143546. /**
  143547. * Gets the output component
  143548. */
  143549. get output(): NodeMaterialConnectionPoint;
  143550. protected _buildBlock(state: NodeMaterialBuildState): this;
  143551. }
  143552. }
  143553. declare module BABYLON {
  143554. /**
  143555. * Block used to smooth step a value
  143556. */
  143557. export class SmoothStepBlock extends NodeMaterialBlock {
  143558. /**
  143559. * Creates a new SmoothStepBlock
  143560. * @param name defines the block name
  143561. */
  143562. constructor(name: string);
  143563. /**
  143564. * Gets the current class name
  143565. * @returns the class name
  143566. */
  143567. getClassName(): string;
  143568. /**
  143569. * Gets the value operand input component
  143570. */
  143571. get value(): NodeMaterialConnectionPoint;
  143572. /**
  143573. * Gets the first edge operand input component
  143574. */
  143575. get edge0(): NodeMaterialConnectionPoint;
  143576. /**
  143577. * Gets the second edge operand input component
  143578. */
  143579. get edge1(): NodeMaterialConnectionPoint;
  143580. /**
  143581. * Gets the output component
  143582. */
  143583. get output(): NodeMaterialConnectionPoint;
  143584. protected _buildBlock(state: NodeMaterialBuildState): this;
  143585. }
  143586. }
  143587. declare module BABYLON {
  143588. /**
  143589. * Block used to get the reciprocal (1 / x) of a value
  143590. */
  143591. export class ReciprocalBlock extends NodeMaterialBlock {
  143592. /**
  143593. * Creates a new ReciprocalBlock
  143594. * @param name defines the block name
  143595. */
  143596. constructor(name: string);
  143597. /**
  143598. * Gets the current class name
  143599. * @returns the class name
  143600. */
  143601. getClassName(): string;
  143602. /**
  143603. * Gets the input component
  143604. */
  143605. get input(): NodeMaterialConnectionPoint;
  143606. /**
  143607. * Gets the output component
  143608. */
  143609. get output(): NodeMaterialConnectionPoint;
  143610. protected _buildBlock(state: NodeMaterialBuildState): this;
  143611. }
  143612. }
  143613. declare module BABYLON {
  143614. /**
  143615. * Block used to replace a color by another one
  143616. */
  143617. export class ReplaceColorBlock extends NodeMaterialBlock {
  143618. /**
  143619. * Creates a new ReplaceColorBlock
  143620. * @param name defines the block name
  143621. */
  143622. constructor(name: string);
  143623. /**
  143624. * Gets the current class name
  143625. * @returns the class name
  143626. */
  143627. getClassName(): string;
  143628. /**
  143629. * Gets the value input component
  143630. */
  143631. get value(): NodeMaterialConnectionPoint;
  143632. /**
  143633. * Gets the reference input component
  143634. */
  143635. get reference(): NodeMaterialConnectionPoint;
  143636. /**
  143637. * Gets the distance input component
  143638. */
  143639. get distance(): NodeMaterialConnectionPoint;
  143640. /**
  143641. * Gets the replacement input component
  143642. */
  143643. get replacement(): NodeMaterialConnectionPoint;
  143644. /**
  143645. * Gets the output component
  143646. */
  143647. get output(): NodeMaterialConnectionPoint;
  143648. protected _buildBlock(state: NodeMaterialBuildState): this;
  143649. }
  143650. }
  143651. declare module BABYLON {
  143652. /**
  143653. * Block used to posterize a value
  143654. * @see https://en.wikipedia.org/wiki/Posterization
  143655. */
  143656. export class PosterizeBlock extends NodeMaterialBlock {
  143657. /**
  143658. * Creates a new PosterizeBlock
  143659. * @param name defines the block name
  143660. */
  143661. constructor(name: string);
  143662. /**
  143663. * Gets the current class name
  143664. * @returns the class name
  143665. */
  143666. getClassName(): string;
  143667. /**
  143668. * Gets the value input component
  143669. */
  143670. get value(): NodeMaterialConnectionPoint;
  143671. /**
  143672. * Gets the steps input component
  143673. */
  143674. get steps(): NodeMaterialConnectionPoint;
  143675. /**
  143676. * Gets the output component
  143677. */
  143678. get output(): NodeMaterialConnectionPoint;
  143679. protected _buildBlock(state: NodeMaterialBuildState): this;
  143680. }
  143681. }
  143682. declare module BABYLON {
  143683. /**
  143684. * Operations supported by the Wave block
  143685. */
  143686. export enum WaveBlockKind {
  143687. /** SawTooth */
  143688. SawTooth = 0,
  143689. /** Square */
  143690. Square = 1,
  143691. /** Triangle */
  143692. Triangle = 2
  143693. }
  143694. /**
  143695. * Block used to apply wave operation to floats
  143696. */
  143697. export class WaveBlock extends NodeMaterialBlock {
  143698. /**
  143699. * Gets or sets the kibnd of wave to be applied by the block
  143700. */
  143701. kind: WaveBlockKind;
  143702. /**
  143703. * Creates a new WaveBlock
  143704. * @param name defines the block name
  143705. */
  143706. constructor(name: string);
  143707. /**
  143708. * Gets the current class name
  143709. * @returns the class name
  143710. */
  143711. getClassName(): string;
  143712. /**
  143713. * Gets the input component
  143714. */
  143715. get input(): NodeMaterialConnectionPoint;
  143716. /**
  143717. * Gets the output component
  143718. */
  143719. get output(): NodeMaterialConnectionPoint;
  143720. protected _buildBlock(state: NodeMaterialBuildState): this;
  143721. serialize(): any;
  143722. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143723. }
  143724. }
  143725. declare module BABYLON {
  143726. /**
  143727. * Class used to store a color step for the GradientBlock
  143728. */
  143729. export class GradientBlockColorStep {
  143730. private _parent;
  143731. private _step;
  143732. /**
  143733. * Gets value indicating which step this color is associated with (between 0 and 1)
  143734. */
  143735. get step(): number;
  143736. /**
  143737. * Sets a value indicating which step this color is associated with (between 0 and 1)
  143738. */
  143739. set step(val: number);
  143740. private _color;
  143741. /**
  143742. * Gets the color associated with this step
  143743. */
  143744. get color(): Color3;
  143745. /**
  143746. * Sets the color associated with this step
  143747. */
  143748. set color(val: Color3);
  143749. /**
  143750. * Creates a new GradientBlockColorStep
  143751. * @param parent defines the parent gradient for this block
  143752. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  143753. * @param color defines the color associated with this step
  143754. */
  143755. constructor(parent: GradientBlock, step: number, color: Color3);
  143756. }
  143757. /**
  143758. * Block used to return a color from a gradient based on an input value between 0 and 1
  143759. */
  143760. export class GradientBlock extends NodeMaterialBlock {
  143761. /**
  143762. * Gets or sets the list of color steps
  143763. */
  143764. colorSteps: GradientBlockColorStep[];
  143765. /** Gets an observable raised when the value is changed */
  143766. onValueChangedObservable: Observable<GradientBlock>;
  143767. /** calls observable when the value is changed*/
  143768. colorStepsUpdated(): void;
  143769. /**
  143770. * Creates a new GradientBlock
  143771. * @param name defines the block name
  143772. */
  143773. constructor(name: string);
  143774. /**
  143775. * Gets the current class name
  143776. * @returns the class name
  143777. */
  143778. getClassName(): string;
  143779. /**
  143780. * Gets the gradient input component
  143781. */
  143782. get gradient(): NodeMaterialConnectionPoint;
  143783. /**
  143784. * Gets the output component
  143785. */
  143786. get output(): NodeMaterialConnectionPoint;
  143787. private _writeColorConstant;
  143788. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143789. serialize(): any;
  143790. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143791. protected _dumpPropertiesCode(): string;
  143792. }
  143793. }
  143794. declare module BABYLON {
  143795. /**
  143796. * Block used to normalize lerp between 2 values
  143797. */
  143798. export class NLerpBlock extends NodeMaterialBlock {
  143799. /**
  143800. * Creates a new NLerpBlock
  143801. * @param name defines the block name
  143802. */
  143803. constructor(name: string);
  143804. /**
  143805. * Gets the current class name
  143806. * @returns the class name
  143807. */
  143808. getClassName(): string;
  143809. /**
  143810. * Gets the left operand input component
  143811. */
  143812. get left(): NodeMaterialConnectionPoint;
  143813. /**
  143814. * Gets the right operand input component
  143815. */
  143816. get right(): NodeMaterialConnectionPoint;
  143817. /**
  143818. * Gets the gradient operand input component
  143819. */
  143820. get gradient(): NodeMaterialConnectionPoint;
  143821. /**
  143822. * Gets the output component
  143823. */
  143824. get output(): NodeMaterialConnectionPoint;
  143825. protected _buildBlock(state: NodeMaterialBuildState): this;
  143826. }
  143827. }
  143828. declare module BABYLON {
  143829. /**
  143830. * block used to Generate a Worley Noise 3D Noise Pattern
  143831. */
  143832. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  143833. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  143834. manhattanDistance: boolean;
  143835. /**
  143836. * Creates a new WorleyNoise3DBlock
  143837. * @param name defines the block name
  143838. */
  143839. constructor(name: string);
  143840. /**
  143841. * Gets the current class name
  143842. * @returns the class name
  143843. */
  143844. getClassName(): string;
  143845. /**
  143846. * Gets the seed input component
  143847. */
  143848. get seed(): NodeMaterialConnectionPoint;
  143849. /**
  143850. * Gets the jitter input component
  143851. */
  143852. get jitter(): NodeMaterialConnectionPoint;
  143853. /**
  143854. * Gets the output component
  143855. */
  143856. get output(): NodeMaterialConnectionPoint;
  143857. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143858. /**
  143859. * Exposes the properties to the UI?
  143860. */
  143861. protected _dumpPropertiesCode(): string;
  143862. /**
  143863. * Exposes the properties to the Seralize?
  143864. */
  143865. serialize(): any;
  143866. /**
  143867. * Exposes the properties to the deseralize?
  143868. */
  143869. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143870. }
  143871. }
  143872. declare module BABYLON {
  143873. /**
  143874. * block used to Generate a Simplex Perlin 3d Noise Pattern
  143875. */
  143876. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  143877. /**
  143878. * Creates a new SimplexPerlin3DBlock
  143879. * @param name defines the block name
  143880. */
  143881. constructor(name: string);
  143882. /**
  143883. * Gets the current class name
  143884. * @returns the class name
  143885. */
  143886. getClassName(): string;
  143887. /**
  143888. * Gets the seed operand input component
  143889. */
  143890. get seed(): NodeMaterialConnectionPoint;
  143891. /**
  143892. * Gets the output component
  143893. */
  143894. get output(): NodeMaterialConnectionPoint;
  143895. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143896. }
  143897. }
  143898. declare module BABYLON {
  143899. /**
  143900. * Block used to blend normals
  143901. */
  143902. export class NormalBlendBlock extends NodeMaterialBlock {
  143903. /**
  143904. * Creates a new NormalBlendBlock
  143905. * @param name defines the block name
  143906. */
  143907. constructor(name: string);
  143908. /**
  143909. * Gets the current class name
  143910. * @returns the class name
  143911. */
  143912. getClassName(): string;
  143913. /**
  143914. * Gets the first input component
  143915. */
  143916. get normalMap0(): NodeMaterialConnectionPoint;
  143917. /**
  143918. * Gets the second input component
  143919. */
  143920. get normalMap1(): NodeMaterialConnectionPoint;
  143921. /**
  143922. * Gets the output component
  143923. */
  143924. get output(): NodeMaterialConnectionPoint;
  143925. protected _buildBlock(state: NodeMaterialBuildState): this;
  143926. }
  143927. }
  143928. declare module BABYLON {
  143929. /**
  143930. * Block used to rotate a 2d vector by a given angle
  143931. */
  143932. export class Rotate2dBlock extends NodeMaterialBlock {
  143933. /**
  143934. * Creates a new Rotate2dBlock
  143935. * @param name defines the block name
  143936. */
  143937. constructor(name: string);
  143938. /**
  143939. * Gets the current class name
  143940. * @returns the class name
  143941. */
  143942. getClassName(): string;
  143943. /**
  143944. * Gets the input vector
  143945. */
  143946. get input(): NodeMaterialConnectionPoint;
  143947. /**
  143948. * Gets the input angle
  143949. */
  143950. get angle(): NodeMaterialConnectionPoint;
  143951. /**
  143952. * Gets the output component
  143953. */
  143954. get output(): NodeMaterialConnectionPoint;
  143955. autoConfigure(material: NodeMaterial): void;
  143956. protected _buildBlock(state: NodeMaterialBuildState): this;
  143957. }
  143958. }
  143959. declare module BABYLON {
  143960. /**
  143961. * Block used to get the reflected vector from a direction and a normal
  143962. */
  143963. export class ReflectBlock extends NodeMaterialBlock {
  143964. /**
  143965. * Creates a new ReflectBlock
  143966. * @param name defines the block name
  143967. */
  143968. constructor(name: string);
  143969. /**
  143970. * Gets the current class name
  143971. * @returns the class name
  143972. */
  143973. getClassName(): string;
  143974. /**
  143975. * Gets the incident component
  143976. */
  143977. get incident(): NodeMaterialConnectionPoint;
  143978. /**
  143979. * Gets the normal component
  143980. */
  143981. get normal(): NodeMaterialConnectionPoint;
  143982. /**
  143983. * Gets the output component
  143984. */
  143985. get output(): NodeMaterialConnectionPoint;
  143986. protected _buildBlock(state: NodeMaterialBuildState): this;
  143987. }
  143988. }
  143989. declare module BABYLON {
  143990. /**
  143991. * Block used to get the refracted vector from a direction and a normal
  143992. */
  143993. export class RefractBlock extends NodeMaterialBlock {
  143994. /**
  143995. * Creates a new RefractBlock
  143996. * @param name defines the block name
  143997. */
  143998. constructor(name: string);
  143999. /**
  144000. * Gets the current class name
  144001. * @returns the class name
  144002. */
  144003. getClassName(): string;
  144004. /**
  144005. * Gets the incident component
  144006. */
  144007. get incident(): NodeMaterialConnectionPoint;
  144008. /**
  144009. * Gets the normal component
  144010. */
  144011. get normal(): NodeMaterialConnectionPoint;
  144012. /**
  144013. * Gets the index of refraction component
  144014. */
  144015. get ior(): NodeMaterialConnectionPoint;
  144016. /**
  144017. * Gets the output component
  144018. */
  144019. get output(): NodeMaterialConnectionPoint;
  144020. protected _buildBlock(state: NodeMaterialBuildState): this;
  144021. }
  144022. }
  144023. declare module BABYLON {
  144024. /**
  144025. * Block used to desaturate a color
  144026. */
  144027. export class DesaturateBlock extends NodeMaterialBlock {
  144028. /**
  144029. * Creates a new DesaturateBlock
  144030. * @param name defines the block name
  144031. */
  144032. constructor(name: string);
  144033. /**
  144034. * Gets the current class name
  144035. * @returns the class name
  144036. */
  144037. getClassName(): string;
  144038. /**
  144039. * Gets the color operand input component
  144040. */
  144041. get color(): NodeMaterialConnectionPoint;
  144042. /**
  144043. * Gets the level operand input component
  144044. */
  144045. get level(): NodeMaterialConnectionPoint;
  144046. /**
  144047. * Gets the output component
  144048. */
  144049. get output(): NodeMaterialConnectionPoint;
  144050. protected _buildBlock(state: NodeMaterialBuildState): this;
  144051. }
  144052. }
  144053. declare module BABYLON {
  144054. /**
  144055. * Block used to implement the ambient occlusion module of the PBR material
  144056. */
  144057. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  144058. /**
  144059. * Create a new AmbientOcclusionBlock
  144060. * @param name defines the block name
  144061. */
  144062. constructor(name: string);
  144063. /**
  144064. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  144065. */
  144066. useAmbientInGrayScale: boolean;
  144067. /**
  144068. * Initialize the block and prepare the context for build
  144069. * @param state defines the state that will be used for the build
  144070. */
  144071. initialize(state: NodeMaterialBuildState): void;
  144072. /**
  144073. * Gets the current class name
  144074. * @returns the class name
  144075. */
  144076. getClassName(): string;
  144077. /**
  144078. * Gets the texture input component
  144079. */
  144080. get texture(): NodeMaterialConnectionPoint;
  144081. /**
  144082. * Gets the texture intensity component
  144083. */
  144084. get intensity(): NodeMaterialConnectionPoint;
  144085. /**
  144086. * Gets the direct light intensity input component
  144087. */
  144088. get directLightIntensity(): NodeMaterialConnectionPoint;
  144089. /**
  144090. * Gets the ambient occlusion object output component
  144091. */
  144092. get ambientOcclusion(): NodeMaterialConnectionPoint;
  144093. /**
  144094. * Gets the main code of the block (fragment side)
  144095. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  144096. * @returns the shader code
  144097. */
  144098. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  144099. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144100. protected _buildBlock(state: NodeMaterialBuildState): this;
  144101. protected _dumpPropertiesCode(): string;
  144102. serialize(): any;
  144103. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144104. }
  144105. }
  144106. declare module BABYLON {
  144107. /**
  144108. * Block used to implement the reflection module of the PBR material
  144109. */
  144110. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  144111. /** @hidden */
  144112. _defineLODReflectionAlpha: string;
  144113. /** @hidden */
  144114. _defineLinearSpecularReflection: string;
  144115. private _vEnvironmentIrradianceName;
  144116. /** @hidden */
  144117. _vReflectionMicrosurfaceInfosName: string;
  144118. /** @hidden */
  144119. _vReflectionInfosName: string;
  144120. /** @hidden */
  144121. _vReflectionFilteringInfoName: string;
  144122. private _scene;
  144123. /**
  144124. * The three properties below are set by the main PBR block prior to calling methods of this class.
  144125. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  144126. * It's less burden on the user side in the editor part.
  144127. */
  144128. /** @hidden */
  144129. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  144130. /** @hidden */
  144131. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  144132. /** @hidden */
  144133. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  144134. /**
  144135. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  144136. * diffuse part of the IBL.
  144137. */
  144138. useSphericalHarmonics: boolean;
  144139. /**
  144140. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  144141. */
  144142. forceIrradianceInFragment: boolean;
  144143. /**
  144144. * Create a new ReflectionBlock
  144145. * @param name defines the block name
  144146. */
  144147. constructor(name: string);
  144148. /**
  144149. * Gets the current class name
  144150. * @returns the class name
  144151. */
  144152. getClassName(): string;
  144153. /**
  144154. * Gets the position input component
  144155. */
  144156. get position(): NodeMaterialConnectionPoint;
  144157. /**
  144158. * Gets the world position input component
  144159. */
  144160. get worldPosition(): NodeMaterialConnectionPoint;
  144161. /**
  144162. * Gets the world normal input component
  144163. */
  144164. get worldNormal(): NodeMaterialConnectionPoint;
  144165. /**
  144166. * Gets the world input component
  144167. */
  144168. get world(): NodeMaterialConnectionPoint;
  144169. /**
  144170. * Gets the camera (or eye) position component
  144171. */
  144172. get cameraPosition(): NodeMaterialConnectionPoint;
  144173. /**
  144174. * Gets the view input component
  144175. */
  144176. get view(): NodeMaterialConnectionPoint;
  144177. /**
  144178. * Gets the color input component
  144179. */
  144180. get color(): NodeMaterialConnectionPoint;
  144181. /**
  144182. * Gets the reflection object output component
  144183. */
  144184. get reflection(): NodeMaterialConnectionPoint;
  144185. /**
  144186. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  144187. */
  144188. get hasTexture(): boolean;
  144189. /**
  144190. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  144191. */
  144192. get reflectionColor(): string;
  144193. protected _getTexture(): Nullable<BaseTexture>;
  144194. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144195. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144196. /**
  144197. * Gets the code to inject in the vertex shader
  144198. * @param state current state of the node material building
  144199. * @returns the shader code
  144200. */
  144201. handleVertexSide(state: NodeMaterialBuildState): string;
  144202. /**
  144203. * Gets the main code of the block (fragment side)
  144204. * @param state current state of the node material building
  144205. * @param normalVarName name of the existing variable corresponding to the normal
  144206. * @returns the shader code
  144207. */
  144208. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  144209. protected _buildBlock(state: NodeMaterialBuildState): this;
  144210. protected _dumpPropertiesCode(): string;
  144211. serialize(): any;
  144212. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144213. }
  144214. }
  144215. declare module BABYLON {
  144216. /**
  144217. * Block used to implement the sheen module of the PBR material
  144218. */
  144219. export class SheenBlock extends NodeMaterialBlock {
  144220. /**
  144221. * Create a new SheenBlock
  144222. * @param name defines the block name
  144223. */
  144224. constructor(name: string);
  144225. /**
  144226. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  144227. * It allows the strength of the sheen effect to not depend on the base color of the material,
  144228. * making it easier to setup and tweak the effect
  144229. */
  144230. albedoScaling: boolean;
  144231. /**
  144232. * Defines if the sheen is linked to the sheen color.
  144233. */
  144234. linkSheenWithAlbedo: boolean;
  144235. /**
  144236. * Initialize the block and prepare the context for build
  144237. * @param state defines the state that will be used for the build
  144238. */
  144239. initialize(state: NodeMaterialBuildState): void;
  144240. /**
  144241. * Gets the current class name
  144242. * @returns the class name
  144243. */
  144244. getClassName(): string;
  144245. /**
  144246. * Gets the intensity input component
  144247. */
  144248. get intensity(): NodeMaterialConnectionPoint;
  144249. /**
  144250. * Gets the color input component
  144251. */
  144252. get color(): NodeMaterialConnectionPoint;
  144253. /**
  144254. * Gets the roughness input component
  144255. */
  144256. get roughness(): NodeMaterialConnectionPoint;
  144257. /**
  144258. * Gets the sheen object output component
  144259. */
  144260. get sheen(): NodeMaterialConnectionPoint;
  144261. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144262. /**
  144263. * Gets the main code of the block (fragment side)
  144264. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  144265. * @returns the shader code
  144266. */
  144267. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  144268. protected _buildBlock(state: NodeMaterialBuildState): this;
  144269. protected _dumpPropertiesCode(): string;
  144270. serialize(): any;
  144271. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144272. }
  144273. }
  144274. declare module BABYLON {
  144275. /**
  144276. * Block used to implement the reflectivity module of the PBR material
  144277. */
  144278. export class ReflectivityBlock extends NodeMaterialBlock {
  144279. private _metallicReflectanceColor;
  144280. private _metallicF0Factor;
  144281. /** @hidden */
  144282. _vMetallicReflectanceFactorsName: string;
  144283. /**
  144284. * The property below is set by the main PBR block prior to calling methods of this class.
  144285. */
  144286. /** @hidden */
  144287. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  144288. /**
  144289. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  144290. */
  144291. useAmbientOcclusionFromMetallicTextureRed: boolean;
  144292. /**
  144293. * Specifies if the metallic texture contains the metallness information in its blue channel.
  144294. */
  144295. useMetallnessFromMetallicTextureBlue: boolean;
  144296. /**
  144297. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  144298. */
  144299. useRoughnessFromMetallicTextureAlpha: boolean;
  144300. /**
  144301. * Specifies if the metallic texture contains the roughness information in its green channel.
  144302. */
  144303. useRoughnessFromMetallicTextureGreen: boolean;
  144304. /**
  144305. * Create a new ReflectivityBlock
  144306. * @param name defines the block name
  144307. */
  144308. constructor(name: string);
  144309. /**
  144310. * Initialize the block and prepare the context for build
  144311. * @param state defines the state that will be used for the build
  144312. */
  144313. initialize(state: NodeMaterialBuildState): void;
  144314. /**
  144315. * Gets the current class name
  144316. * @returns the class name
  144317. */
  144318. getClassName(): string;
  144319. /**
  144320. * Gets the metallic input component
  144321. */
  144322. get metallic(): NodeMaterialConnectionPoint;
  144323. /**
  144324. * Gets the roughness input component
  144325. */
  144326. get roughness(): NodeMaterialConnectionPoint;
  144327. /**
  144328. * Gets the texture input component
  144329. */
  144330. get texture(): NodeMaterialConnectionPoint;
  144331. /**
  144332. * Gets the reflectivity object output component
  144333. */
  144334. get reflectivity(): NodeMaterialConnectionPoint;
  144335. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144336. /**
  144337. * Gets the main code of the block (fragment side)
  144338. * @param state current state of the node material building
  144339. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  144340. * @returns the shader code
  144341. */
  144342. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  144343. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144344. protected _buildBlock(state: NodeMaterialBuildState): this;
  144345. protected _dumpPropertiesCode(): string;
  144346. serialize(): any;
  144347. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144348. }
  144349. }
  144350. declare module BABYLON {
  144351. /**
  144352. * Block used to implement the anisotropy module of the PBR material
  144353. */
  144354. export class AnisotropyBlock extends NodeMaterialBlock {
  144355. /**
  144356. * The two properties below are set by the main PBR block prior to calling methods of this class.
  144357. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  144358. * It's less burden on the user side in the editor part.
  144359. */
  144360. /** @hidden */
  144361. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  144362. /** @hidden */
  144363. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  144364. /**
  144365. * Create a new AnisotropyBlock
  144366. * @param name defines the block name
  144367. */
  144368. constructor(name: string);
  144369. /**
  144370. * Initialize the block and prepare the context for build
  144371. * @param state defines the state that will be used for the build
  144372. */
  144373. initialize(state: NodeMaterialBuildState): void;
  144374. /**
  144375. * Gets the current class name
  144376. * @returns the class name
  144377. */
  144378. getClassName(): string;
  144379. /**
  144380. * Gets the intensity input component
  144381. */
  144382. get intensity(): NodeMaterialConnectionPoint;
  144383. /**
  144384. * Gets the direction input component
  144385. */
  144386. get direction(): NodeMaterialConnectionPoint;
  144387. /**
  144388. * Gets the texture input component
  144389. */
  144390. get texture(): NodeMaterialConnectionPoint;
  144391. /**
  144392. * Gets the uv input component
  144393. */
  144394. get uv(): NodeMaterialConnectionPoint;
  144395. /**
  144396. * Gets the worldTangent input component
  144397. */
  144398. get worldTangent(): NodeMaterialConnectionPoint;
  144399. /**
  144400. * Gets the anisotropy object output component
  144401. */
  144402. get anisotropy(): NodeMaterialConnectionPoint;
  144403. private _generateTBNSpace;
  144404. /**
  144405. * Gets the main code of the block (fragment side)
  144406. * @param state current state of the node material building
  144407. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  144408. * @returns the shader code
  144409. */
  144410. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  144411. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144412. protected _buildBlock(state: NodeMaterialBuildState): this;
  144413. }
  144414. }
  144415. declare module BABYLON {
  144416. /**
  144417. * Block used to implement the clear coat module of the PBR material
  144418. */
  144419. export class ClearCoatBlock extends NodeMaterialBlock {
  144420. private _scene;
  144421. /**
  144422. * Create a new ClearCoatBlock
  144423. * @param name defines the block name
  144424. */
  144425. constructor(name: string);
  144426. /**
  144427. * Initialize the block and prepare the context for build
  144428. * @param state defines the state that will be used for the build
  144429. */
  144430. initialize(state: NodeMaterialBuildState): void;
  144431. /**
  144432. * Gets the current class name
  144433. * @returns the class name
  144434. */
  144435. getClassName(): string;
  144436. /**
  144437. * Gets the intensity input component
  144438. */
  144439. get intensity(): NodeMaterialConnectionPoint;
  144440. /**
  144441. * Gets the roughness input component
  144442. */
  144443. get roughness(): NodeMaterialConnectionPoint;
  144444. /**
  144445. * Gets the ior input component
  144446. */
  144447. get ior(): NodeMaterialConnectionPoint;
  144448. /**
  144449. * Gets the texture input component
  144450. */
  144451. get texture(): NodeMaterialConnectionPoint;
  144452. /**
  144453. * Gets the bump texture input component
  144454. */
  144455. get bumpTexture(): NodeMaterialConnectionPoint;
  144456. /**
  144457. * Gets the uv input component
  144458. */
  144459. get uv(): NodeMaterialConnectionPoint;
  144460. /**
  144461. * Gets the tint color input component
  144462. */
  144463. get tintColor(): NodeMaterialConnectionPoint;
  144464. /**
  144465. * Gets the tint "at distance" input component
  144466. */
  144467. get tintAtDistance(): NodeMaterialConnectionPoint;
  144468. /**
  144469. * Gets the tint thickness input component
  144470. */
  144471. get tintThickness(): NodeMaterialConnectionPoint;
  144472. /**
  144473. * Gets the world tangent input component
  144474. */
  144475. get worldTangent(): NodeMaterialConnectionPoint;
  144476. /**
  144477. * Gets the clear coat object output component
  144478. */
  144479. get clearcoat(): NodeMaterialConnectionPoint;
  144480. autoConfigure(material: NodeMaterial): void;
  144481. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144482. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144483. private _generateTBNSpace;
  144484. /**
  144485. * Gets the main code of the block (fragment side)
  144486. * @param state current state of the node material building
  144487. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  144488. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  144489. * @param worldPosVarName name of the variable holding the world position
  144490. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  144491. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  144492. * @param worldNormalVarName name of the variable holding the world normal
  144493. * @returns the shader code
  144494. */
  144495. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  144496. protected _buildBlock(state: NodeMaterialBuildState): this;
  144497. }
  144498. }
  144499. declare module BABYLON {
  144500. /**
  144501. * Block used to implement the sub surface module of the PBR material
  144502. */
  144503. export class SubSurfaceBlock extends NodeMaterialBlock {
  144504. /**
  144505. * Create a new SubSurfaceBlock
  144506. * @param name defines the block name
  144507. */
  144508. constructor(name: string);
  144509. /**
  144510. * Stores the intensity of the different subsurface effects in the thickness texture.
  144511. * * the green channel is the translucency intensity.
  144512. * * the blue channel is the scattering intensity.
  144513. * * the alpha channel is the refraction intensity.
  144514. */
  144515. useMaskFromThicknessTexture: boolean;
  144516. /**
  144517. * Initialize the block and prepare the context for build
  144518. * @param state defines the state that will be used for the build
  144519. */
  144520. initialize(state: NodeMaterialBuildState): void;
  144521. /**
  144522. * Gets the current class name
  144523. * @returns the class name
  144524. */
  144525. getClassName(): string;
  144526. /**
  144527. * Gets the min thickness input component
  144528. */
  144529. get minThickness(): NodeMaterialConnectionPoint;
  144530. /**
  144531. * Gets the max thickness input component
  144532. */
  144533. get maxThickness(): NodeMaterialConnectionPoint;
  144534. /**
  144535. * Gets the thickness texture component
  144536. */
  144537. get thicknessTexture(): NodeMaterialConnectionPoint;
  144538. /**
  144539. * Gets the tint color input component
  144540. */
  144541. get tintColor(): NodeMaterialConnectionPoint;
  144542. /**
  144543. * Gets the translucency intensity input component
  144544. */
  144545. get translucencyIntensity(): NodeMaterialConnectionPoint;
  144546. /**
  144547. * Gets the translucency diffusion distance input component
  144548. */
  144549. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  144550. /**
  144551. * Gets the refraction object parameters
  144552. */
  144553. get refraction(): NodeMaterialConnectionPoint;
  144554. /**
  144555. * Gets the sub surface object output component
  144556. */
  144557. get subsurface(): NodeMaterialConnectionPoint;
  144558. autoConfigure(material: NodeMaterial): void;
  144559. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144560. /**
  144561. * Gets the main code of the block (fragment side)
  144562. * @param state current state of the node material building
  144563. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  144564. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  144565. * @param worldPosVarName name of the variable holding the world position
  144566. * @returns the shader code
  144567. */
  144568. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  144569. protected _buildBlock(state: NodeMaterialBuildState): this;
  144570. }
  144571. }
  144572. declare module BABYLON {
  144573. /**
  144574. * Block used to implement the PBR metallic/roughness model
  144575. */
  144576. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  144577. /**
  144578. * Gets or sets the light associated with this block
  144579. */
  144580. light: Nullable<Light>;
  144581. private _lightId;
  144582. private _scene;
  144583. private _environmentBRDFTexture;
  144584. private _environmentBrdfSamplerName;
  144585. private _vNormalWName;
  144586. private _invertNormalName;
  144587. /**
  144588. * Create a new ReflectionBlock
  144589. * @param name defines the block name
  144590. */
  144591. constructor(name: string);
  144592. /**
  144593. * Intensity of the direct lights e.g. the four lights available in your scene.
  144594. * This impacts both the direct diffuse and specular highlights.
  144595. */
  144596. directIntensity: number;
  144597. /**
  144598. * Intensity of the environment e.g. how much the environment will light the object
  144599. * either through harmonics for rough material or through the refelction for shiny ones.
  144600. */
  144601. environmentIntensity: number;
  144602. /**
  144603. * This is a special control allowing the reduction of the specular highlights coming from the
  144604. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  144605. */
  144606. specularIntensity: number;
  144607. /**
  144608. * Defines the falloff type used in this material.
  144609. * It by default is Physical.
  144610. */
  144611. lightFalloff: number;
  144612. /**
  144613. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  144614. */
  144615. useAlphaFromAlbedoTexture: boolean;
  144616. /**
  144617. * Specifies that alpha test should be used
  144618. */
  144619. useAlphaTest: boolean;
  144620. /**
  144621. * Defines the alpha limits in alpha test mode.
  144622. */
  144623. alphaTestCutoff: number;
  144624. /**
  144625. * Specifies that alpha blending should be used
  144626. */
  144627. useAlphaBlending: boolean;
  144628. /**
  144629. * Defines if the alpha value should be determined via the rgb values.
  144630. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  144631. */
  144632. opacityRGB: boolean;
  144633. /**
  144634. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  144635. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  144636. */
  144637. useRadianceOverAlpha: boolean;
  144638. /**
  144639. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  144640. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  144641. */
  144642. useSpecularOverAlpha: boolean;
  144643. /**
  144644. * Enables specular anti aliasing in the PBR shader.
  144645. * It will both interacts on the Geometry for analytical and IBL lighting.
  144646. * It also prefilter the roughness map based on the bump values.
  144647. */
  144648. enableSpecularAntiAliasing: boolean;
  144649. /**
  144650. * Enables realtime filtering on the texture.
  144651. */
  144652. realTimeFiltering: boolean;
  144653. /**
  144654. * Quality switch for realtime filtering
  144655. */
  144656. realTimeFilteringQuality: number;
  144657. /**
  144658. * Defines if the material uses energy conservation.
  144659. */
  144660. useEnergyConservation: boolean;
  144661. /**
  144662. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  144663. * too much the area relying on ambient texture to define their ambient occlusion.
  144664. */
  144665. useRadianceOcclusion: boolean;
  144666. /**
  144667. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  144668. * makes the reflect vector face the model (under horizon).
  144669. */
  144670. useHorizonOcclusion: boolean;
  144671. /**
  144672. * If set to true, no lighting calculations will be applied.
  144673. */
  144674. unlit: boolean;
  144675. /**
  144676. * Force normal to face away from face.
  144677. */
  144678. forceNormalForward: boolean;
  144679. /**
  144680. * Defines the material debug mode.
  144681. * It helps seeing only some components of the material while troubleshooting.
  144682. */
  144683. debugMode: number;
  144684. /**
  144685. * Specify from where on screen the debug mode should start.
  144686. * The value goes from -1 (full screen) to 1 (not visible)
  144687. * It helps with side by side comparison against the final render
  144688. * This defaults to 0
  144689. */
  144690. debugLimit: number;
  144691. /**
  144692. * As the default viewing range might not be enough (if the ambient is really small for instance)
  144693. * You can use the factor to better multiply the final value.
  144694. */
  144695. debugFactor: number;
  144696. /**
  144697. * Initialize the block and prepare the context for build
  144698. * @param state defines the state that will be used for the build
  144699. */
  144700. initialize(state: NodeMaterialBuildState): void;
  144701. /**
  144702. * Gets the current class name
  144703. * @returns the class name
  144704. */
  144705. getClassName(): string;
  144706. /**
  144707. * Gets the world position input component
  144708. */
  144709. get worldPosition(): NodeMaterialConnectionPoint;
  144710. /**
  144711. * Gets the world normal input component
  144712. */
  144713. get worldNormal(): NodeMaterialConnectionPoint;
  144714. /**
  144715. * Gets the perturbed normal input component
  144716. */
  144717. get perturbedNormal(): NodeMaterialConnectionPoint;
  144718. /**
  144719. * Gets the camera position input component
  144720. */
  144721. get cameraPosition(): NodeMaterialConnectionPoint;
  144722. /**
  144723. * Gets the base color input component
  144724. */
  144725. get baseColor(): NodeMaterialConnectionPoint;
  144726. /**
  144727. * Gets the opacity texture input component
  144728. */
  144729. get opacityTexture(): NodeMaterialConnectionPoint;
  144730. /**
  144731. * Gets the ambient color input component
  144732. */
  144733. get ambientColor(): NodeMaterialConnectionPoint;
  144734. /**
  144735. * Gets the reflectivity object parameters
  144736. */
  144737. get reflectivity(): NodeMaterialConnectionPoint;
  144738. /**
  144739. * Gets the ambient occlusion object parameters
  144740. */
  144741. get ambientOcclusion(): NodeMaterialConnectionPoint;
  144742. /**
  144743. * Gets the reflection object parameters
  144744. */
  144745. get reflection(): NodeMaterialConnectionPoint;
  144746. /**
  144747. * Gets the sheen object parameters
  144748. */
  144749. get sheen(): NodeMaterialConnectionPoint;
  144750. /**
  144751. * Gets the clear coat object parameters
  144752. */
  144753. get clearcoat(): NodeMaterialConnectionPoint;
  144754. /**
  144755. * Gets the sub surface object parameters
  144756. */
  144757. get subsurface(): NodeMaterialConnectionPoint;
  144758. /**
  144759. * Gets the anisotropy object parameters
  144760. */
  144761. get anisotropy(): NodeMaterialConnectionPoint;
  144762. /**
  144763. * Gets the ambient output component
  144764. */
  144765. get ambient(): NodeMaterialConnectionPoint;
  144766. /**
  144767. * Gets the diffuse output component
  144768. */
  144769. get diffuse(): NodeMaterialConnectionPoint;
  144770. /**
  144771. * Gets the specular output component
  144772. */
  144773. get specular(): NodeMaterialConnectionPoint;
  144774. /**
  144775. * Gets the sheen output component
  144776. */
  144777. get sheenDir(): NodeMaterialConnectionPoint;
  144778. /**
  144779. * Gets the clear coat output component
  144780. */
  144781. get clearcoatDir(): NodeMaterialConnectionPoint;
  144782. /**
  144783. * Gets the indirect diffuse output component
  144784. */
  144785. get diffuseIndirect(): NodeMaterialConnectionPoint;
  144786. /**
  144787. * Gets the indirect specular output component
  144788. */
  144789. get specularIndirect(): NodeMaterialConnectionPoint;
  144790. /**
  144791. * Gets the indirect sheen output component
  144792. */
  144793. get sheenIndirect(): NodeMaterialConnectionPoint;
  144794. /**
  144795. * Gets the indirect clear coat output component
  144796. */
  144797. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  144798. /**
  144799. * Gets the refraction output component
  144800. */
  144801. get refraction(): NodeMaterialConnectionPoint;
  144802. /**
  144803. * Gets the global lighting output component
  144804. */
  144805. get lighting(): NodeMaterialConnectionPoint;
  144806. /**
  144807. * Gets the shadow output component
  144808. */
  144809. get shadow(): NodeMaterialConnectionPoint;
  144810. /**
  144811. * Gets the alpha output component
  144812. */
  144813. get alpha(): NodeMaterialConnectionPoint;
  144814. autoConfigure(material: NodeMaterial): void;
  144815. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144816. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  144817. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144818. private _injectVertexCode;
  144819. /**
  144820. * Gets the code corresponding to the albedo/opacity module
  144821. * @returns the shader code
  144822. */
  144823. getAlbedoOpacityCode(): string;
  144824. protected _buildBlock(state: NodeMaterialBuildState): this;
  144825. protected _dumpPropertiesCode(): string;
  144826. serialize(): any;
  144827. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144828. }
  144829. }
  144830. declare module BABYLON {
  144831. /**
  144832. * Block used to compute value of one parameter modulo another
  144833. */
  144834. export class ModBlock extends NodeMaterialBlock {
  144835. /**
  144836. * Creates a new ModBlock
  144837. * @param name defines the block name
  144838. */
  144839. constructor(name: string);
  144840. /**
  144841. * Gets the current class name
  144842. * @returns the class name
  144843. */
  144844. getClassName(): string;
  144845. /**
  144846. * Gets the left operand input component
  144847. */
  144848. get left(): NodeMaterialConnectionPoint;
  144849. /**
  144850. * Gets the right operand input component
  144851. */
  144852. get right(): NodeMaterialConnectionPoint;
  144853. /**
  144854. * Gets the output component
  144855. */
  144856. get output(): NodeMaterialConnectionPoint;
  144857. protected _buildBlock(state: NodeMaterialBuildState): this;
  144858. }
  144859. }
  144860. declare module BABYLON {
  144861. /**
  144862. * Configuration for Draco compression
  144863. */
  144864. export interface IDracoCompressionConfiguration {
  144865. /**
  144866. * Configuration for the decoder.
  144867. */
  144868. decoder: {
  144869. /**
  144870. * The url to the WebAssembly module.
  144871. */
  144872. wasmUrl?: string;
  144873. /**
  144874. * The url to the WebAssembly binary.
  144875. */
  144876. wasmBinaryUrl?: string;
  144877. /**
  144878. * The url to the fallback JavaScript module.
  144879. */
  144880. fallbackUrl?: string;
  144881. };
  144882. }
  144883. /**
  144884. * Draco compression (https://google.github.io/draco/)
  144885. *
  144886. * This class wraps the Draco module.
  144887. *
  144888. * **Encoder**
  144889. *
  144890. * The encoder is not currently implemented.
  144891. *
  144892. * **Decoder**
  144893. *
  144894. * 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.
  144895. *
  144896. * To update the configuration, use the following code:
  144897. * ```javascript
  144898. * DracoCompression.Configuration = {
  144899. * decoder: {
  144900. * wasmUrl: "<url to the WebAssembly library>",
  144901. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  144902. * fallbackUrl: "<url to the fallback JavaScript library>",
  144903. * }
  144904. * };
  144905. * ```
  144906. *
  144907. * 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.
  144908. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  144909. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  144910. *
  144911. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  144912. * ```javascript
  144913. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  144914. * ```
  144915. *
  144916. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  144917. */
  144918. export class DracoCompression implements IDisposable {
  144919. private _workerPoolPromise?;
  144920. private _decoderModulePromise?;
  144921. /**
  144922. * The configuration. Defaults to the following urls:
  144923. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  144924. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  144925. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  144926. */
  144927. static Configuration: IDracoCompressionConfiguration;
  144928. /**
  144929. * Returns true if the decoder configuration is available.
  144930. */
  144931. static get DecoderAvailable(): boolean;
  144932. /**
  144933. * Default number of workers to create when creating the draco compression object.
  144934. */
  144935. static DefaultNumWorkers: number;
  144936. private static GetDefaultNumWorkers;
  144937. private static _Default;
  144938. /**
  144939. * Default instance for the draco compression object.
  144940. */
  144941. static get Default(): DracoCompression;
  144942. /**
  144943. * Constructor
  144944. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  144945. */
  144946. constructor(numWorkers?: number);
  144947. /**
  144948. * Stop all async operations and release resources.
  144949. */
  144950. dispose(): void;
  144951. /**
  144952. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  144953. * @returns a promise that resolves when ready
  144954. */
  144955. whenReadyAsync(): Promise<void>;
  144956. /**
  144957. * Decode Draco compressed mesh data to vertex data.
  144958. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  144959. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  144960. * @returns A promise that resolves with the decoded vertex data
  144961. */
  144962. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  144963. [kind: string]: number;
  144964. }): Promise<VertexData>;
  144965. }
  144966. }
  144967. declare module BABYLON {
  144968. /**
  144969. * Class for building Constructive Solid Geometry
  144970. */
  144971. export class CSG {
  144972. private polygons;
  144973. /**
  144974. * The world matrix
  144975. */
  144976. matrix: Matrix;
  144977. /**
  144978. * Stores the position
  144979. */
  144980. position: Vector3;
  144981. /**
  144982. * Stores the rotation
  144983. */
  144984. rotation: Vector3;
  144985. /**
  144986. * Stores the rotation quaternion
  144987. */
  144988. rotationQuaternion: Nullable<Quaternion>;
  144989. /**
  144990. * Stores the scaling vector
  144991. */
  144992. scaling: Vector3;
  144993. /**
  144994. * Convert the Mesh to CSG
  144995. * @param mesh The Mesh to convert to CSG
  144996. * @returns A new CSG from the Mesh
  144997. */
  144998. static FromMesh(mesh: Mesh): CSG;
  144999. /**
  145000. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  145001. * @param polygons Polygons used to construct a CSG solid
  145002. */
  145003. private static FromPolygons;
  145004. /**
  145005. * Clones, or makes a deep copy, of the CSG
  145006. * @returns A new CSG
  145007. */
  145008. clone(): CSG;
  145009. /**
  145010. * Unions this CSG with another CSG
  145011. * @param csg The CSG to union against this CSG
  145012. * @returns The unioned CSG
  145013. */
  145014. union(csg: CSG): CSG;
  145015. /**
  145016. * Unions this CSG with another CSG in place
  145017. * @param csg The CSG to union against this CSG
  145018. */
  145019. unionInPlace(csg: CSG): void;
  145020. /**
  145021. * Subtracts this CSG with another CSG
  145022. * @param csg The CSG to subtract against this CSG
  145023. * @returns A new CSG
  145024. */
  145025. subtract(csg: CSG): CSG;
  145026. /**
  145027. * Subtracts this CSG with another CSG in place
  145028. * @param csg The CSG to subtact against this CSG
  145029. */
  145030. subtractInPlace(csg: CSG): void;
  145031. /**
  145032. * Intersect this CSG with another CSG
  145033. * @param csg The CSG to intersect against this CSG
  145034. * @returns A new CSG
  145035. */
  145036. intersect(csg: CSG): CSG;
  145037. /**
  145038. * Intersects this CSG with another CSG in place
  145039. * @param csg The CSG to intersect against this CSG
  145040. */
  145041. intersectInPlace(csg: CSG): void;
  145042. /**
  145043. * Return a new CSG solid with solid and empty space switched. This solid is
  145044. * not modified.
  145045. * @returns A new CSG solid with solid and empty space switched
  145046. */
  145047. inverse(): CSG;
  145048. /**
  145049. * Inverses the CSG in place
  145050. */
  145051. inverseInPlace(): void;
  145052. /**
  145053. * This is used to keep meshes transformations so they can be restored
  145054. * when we build back a Babylon Mesh
  145055. * NB : All CSG operations are performed in world coordinates
  145056. * @param csg The CSG to copy the transform attributes from
  145057. * @returns This CSG
  145058. */
  145059. copyTransformAttributes(csg: CSG): CSG;
  145060. /**
  145061. * Build Raw mesh from CSG
  145062. * Coordinates here are in world space
  145063. * @param name The name of the mesh geometry
  145064. * @param scene The Scene
  145065. * @param keepSubMeshes Specifies if the submeshes should be kept
  145066. * @returns A new Mesh
  145067. */
  145068. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  145069. /**
  145070. * Build Mesh from CSG taking material and transforms into account
  145071. * @param name The name of the Mesh
  145072. * @param material The material of the Mesh
  145073. * @param scene The Scene
  145074. * @param keepSubMeshes Specifies if submeshes should be kept
  145075. * @returns The new Mesh
  145076. */
  145077. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  145078. }
  145079. }
  145080. declare module BABYLON {
  145081. /**
  145082. * Class used to create a trail following a mesh
  145083. */
  145084. export class TrailMesh extends Mesh {
  145085. private _generator;
  145086. private _autoStart;
  145087. private _running;
  145088. private _diameter;
  145089. private _length;
  145090. private _sectionPolygonPointsCount;
  145091. private _sectionVectors;
  145092. private _sectionNormalVectors;
  145093. private _beforeRenderObserver;
  145094. /**
  145095. * @constructor
  145096. * @param name The value used by scene.getMeshByName() to do a lookup.
  145097. * @param generator The mesh or transform node to generate a trail.
  145098. * @param scene The scene to add this mesh to.
  145099. * @param diameter Diameter of trailing mesh. Default is 1.
  145100. * @param length Length of trailing mesh. Default is 60.
  145101. * @param autoStart Automatically start trailing mesh. Default true.
  145102. */
  145103. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  145104. /**
  145105. * "TrailMesh"
  145106. * @returns "TrailMesh"
  145107. */
  145108. getClassName(): string;
  145109. private _createMesh;
  145110. /**
  145111. * Start trailing mesh.
  145112. */
  145113. start(): void;
  145114. /**
  145115. * Stop trailing mesh.
  145116. */
  145117. stop(): void;
  145118. /**
  145119. * Update trailing mesh geometry.
  145120. */
  145121. update(): void;
  145122. /**
  145123. * Returns a new TrailMesh object.
  145124. * @param name is a string, the name given to the new mesh
  145125. * @param newGenerator use new generator object for cloned trail mesh
  145126. * @returns a new mesh
  145127. */
  145128. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  145129. /**
  145130. * Serializes this trail mesh
  145131. * @param serializationObject object to write serialization to
  145132. */
  145133. serialize(serializationObject: any): void;
  145134. /**
  145135. * Parses a serialized trail mesh
  145136. * @param parsedMesh the serialized mesh
  145137. * @param scene the scene to create the trail mesh in
  145138. * @returns the created trail mesh
  145139. */
  145140. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  145141. }
  145142. }
  145143. declare module BABYLON {
  145144. /**
  145145. * Class containing static functions to help procedurally build meshes
  145146. */
  145147. export class TiledBoxBuilder {
  145148. /**
  145149. * Creates a box mesh
  145150. * 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)
  145151. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145152. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145153. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145155. * @param name defines the name of the mesh
  145156. * @param options defines the options used to create the mesh
  145157. * @param scene defines the hosting scene
  145158. * @returns the box mesh
  145159. */
  145160. static CreateTiledBox(name: string, options: {
  145161. pattern?: number;
  145162. width?: number;
  145163. height?: number;
  145164. depth?: number;
  145165. tileSize?: number;
  145166. tileWidth?: number;
  145167. tileHeight?: number;
  145168. alignHorizontal?: number;
  145169. alignVertical?: number;
  145170. faceUV?: Vector4[];
  145171. faceColors?: Color4[];
  145172. sideOrientation?: number;
  145173. updatable?: boolean;
  145174. }, scene?: Nullable<Scene>): Mesh;
  145175. }
  145176. }
  145177. declare module BABYLON {
  145178. /**
  145179. * Class containing static functions to help procedurally build meshes
  145180. */
  145181. export class TorusKnotBuilder {
  145182. /**
  145183. * Creates a torus knot mesh
  145184. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  145185. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  145186. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  145187. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  145188. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145189. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145191. * @param name defines the name of the mesh
  145192. * @param options defines the options used to create the mesh
  145193. * @param scene defines the hosting scene
  145194. * @returns the torus knot mesh
  145195. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  145196. */
  145197. static CreateTorusKnot(name: string, options: {
  145198. radius?: number;
  145199. tube?: number;
  145200. radialSegments?: number;
  145201. tubularSegments?: number;
  145202. p?: number;
  145203. q?: number;
  145204. updatable?: boolean;
  145205. sideOrientation?: number;
  145206. frontUVs?: Vector4;
  145207. backUVs?: Vector4;
  145208. }, scene: any): Mesh;
  145209. }
  145210. }
  145211. declare module BABYLON {
  145212. /**
  145213. * Polygon
  145214. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  145215. */
  145216. export class Polygon {
  145217. /**
  145218. * Creates a rectangle
  145219. * @param xmin bottom X coord
  145220. * @param ymin bottom Y coord
  145221. * @param xmax top X coord
  145222. * @param ymax top Y coord
  145223. * @returns points that make the resulting rectation
  145224. */
  145225. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  145226. /**
  145227. * Creates a circle
  145228. * @param radius radius of circle
  145229. * @param cx scale in x
  145230. * @param cy scale in y
  145231. * @param numberOfSides number of sides that make up the circle
  145232. * @returns points that make the resulting circle
  145233. */
  145234. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  145235. /**
  145236. * Creates a polygon from input string
  145237. * @param input Input polygon data
  145238. * @returns the parsed points
  145239. */
  145240. static Parse(input: string): Vector2[];
  145241. /**
  145242. * Starts building a polygon from x and y coordinates
  145243. * @param x x coordinate
  145244. * @param y y coordinate
  145245. * @returns the started path2
  145246. */
  145247. static StartingAt(x: number, y: number): Path2;
  145248. }
  145249. /**
  145250. * Builds a polygon
  145251. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  145252. */
  145253. export class PolygonMeshBuilder {
  145254. private _points;
  145255. private _outlinepoints;
  145256. private _holes;
  145257. private _name;
  145258. private _scene;
  145259. private _epoints;
  145260. private _eholes;
  145261. private _addToepoint;
  145262. /**
  145263. * Babylon reference to the earcut plugin.
  145264. */
  145265. bjsEarcut: any;
  145266. /**
  145267. * Creates a PolygonMeshBuilder
  145268. * @param name name of the builder
  145269. * @param contours Path of the polygon
  145270. * @param scene scene to add to when creating the mesh
  145271. * @param earcutInjection can be used to inject your own earcut reference
  145272. */
  145273. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  145274. /**
  145275. * Adds a whole within the polygon
  145276. * @param hole Array of points defining the hole
  145277. * @returns this
  145278. */
  145279. addHole(hole: Vector2[]): PolygonMeshBuilder;
  145280. /**
  145281. * Creates the polygon
  145282. * @param updatable If the mesh should be updatable
  145283. * @param depth The depth of the mesh created
  145284. * @returns the created mesh
  145285. */
  145286. build(updatable?: boolean, depth?: number): Mesh;
  145287. /**
  145288. * Creates the polygon
  145289. * @param depth The depth of the mesh created
  145290. * @returns the created VertexData
  145291. */
  145292. buildVertexData(depth?: number): VertexData;
  145293. /**
  145294. * Adds a side to the polygon
  145295. * @param positions points that make the polygon
  145296. * @param normals normals of the polygon
  145297. * @param uvs uvs of the polygon
  145298. * @param indices indices of the polygon
  145299. * @param bounds bounds of the polygon
  145300. * @param points points of the polygon
  145301. * @param depth depth of the polygon
  145302. * @param flip flip of the polygon
  145303. */
  145304. private addSide;
  145305. }
  145306. }
  145307. declare module BABYLON {
  145308. /**
  145309. * Class containing static functions to help procedurally build meshes
  145310. */
  145311. export class PolygonBuilder {
  145312. /**
  145313. * Creates a polygon mesh
  145314. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  145315. * * 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
  145316. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  145317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145318. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  145319. * * Remember you can only change the shape positions, not their number when updating a polygon
  145320. * @param name defines the name of the mesh
  145321. * @param options defines the options used to create the mesh
  145322. * @param scene defines the hosting scene
  145323. * @param earcutInjection can be used to inject your own earcut reference
  145324. * @returns the polygon mesh
  145325. */
  145326. static CreatePolygon(name: string, options: {
  145327. shape: Vector3[];
  145328. holes?: Vector3[][];
  145329. depth?: number;
  145330. faceUV?: Vector4[];
  145331. faceColors?: Color4[];
  145332. updatable?: boolean;
  145333. sideOrientation?: number;
  145334. frontUVs?: Vector4;
  145335. backUVs?: Vector4;
  145336. wrap?: boolean;
  145337. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145338. /**
  145339. * Creates an extruded polygon mesh, with depth in the Y direction.
  145340. * * 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)
  145341. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145342. * @param name defines the name of the mesh
  145343. * @param options defines the options used to create the mesh
  145344. * @param scene defines the hosting scene
  145345. * @param earcutInjection can be used to inject your own earcut reference
  145346. * @returns the polygon mesh
  145347. */
  145348. static ExtrudePolygon(name: string, options: {
  145349. shape: Vector3[];
  145350. holes?: Vector3[][];
  145351. depth?: number;
  145352. faceUV?: Vector4[];
  145353. faceColors?: Color4[];
  145354. updatable?: boolean;
  145355. sideOrientation?: number;
  145356. frontUVs?: Vector4;
  145357. backUVs?: Vector4;
  145358. wrap?: boolean;
  145359. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145360. }
  145361. }
  145362. declare module BABYLON {
  145363. /**
  145364. * Class containing static functions to help procedurally build meshes
  145365. */
  145366. export class LatheBuilder {
  145367. /**
  145368. * Creates lathe mesh.
  145369. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  145370. * * 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
  145371. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  145372. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  145373. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  145374. * * 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
  145375. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  145376. * * 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
  145377. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145378. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145379. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145381. * @param name defines the name of the mesh
  145382. * @param options defines the options used to create the mesh
  145383. * @param scene defines the hosting scene
  145384. * @returns the lathe mesh
  145385. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  145386. */
  145387. static CreateLathe(name: string, options: {
  145388. shape: Vector3[];
  145389. radius?: number;
  145390. tessellation?: number;
  145391. clip?: number;
  145392. arc?: number;
  145393. closed?: boolean;
  145394. updatable?: boolean;
  145395. sideOrientation?: number;
  145396. frontUVs?: Vector4;
  145397. backUVs?: Vector4;
  145398. cap?: number;
  145399. invertUV?: boolean;
  145400. }, scene?: Nullable<Scene>): Mesh;
  145401. }
  145402. }
  145403. declare module BABYLON {
  145404. /**
  145405. * Class containing static functions to help procedurally build meshes
  145406. */
  145407. export class TiledPlaneBuilder {
  145408. /**
  145409. * Creates a tiled plane mesh
  145410. * * The parameter `pattern` will, depending on value, do nothing or
  145411. * * * flip (reflect about central vertical) alternate tiles across and up
  145412. * * * flip every tile on alternate rows
  145413. * * * rotate (180 degs) alternate tiles across and up
  145414. * * * rotate every tile on alternate rows
  145415. * * * flip and rotate alternate tiles across and up
  145416. * * * flip and rotate every tile on alternate rows
  145417. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  145418. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  145419. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145420. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  145421. * * 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)
  145422. * * 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)
  145423. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  145424. * @param name defines the name of the mesh
  145425. * @param options defines the options used to create the mesh
  145426. * @param scene defines the hosting scene
  145427. * @returns the box mesh
  145428. */
  145429. static CreateTiledPlane(name: string, options: {
  145430. pattern?: number;
  145431. tileSize?: number;
  145432. tileWidth?: number;
  145433. tileHeight?: number;
  145434. size?: number;
  145435. width?: number;
  145436. height?: number;
  145437. alignHorizontal?: number;
  145438. alignVertical?: number;
  145439. sideOrientation?: number;
  145440. frontUVs?: Vector4;
  145441. backUVs?: Vector4;
  145442. updatable?: boolean;
  145443. }, scene?: Nullable<Scene>): Mesh;
  145444. }
  145445. }
  145446. declare module BABYLON {
  145447. /**
  145448. * Class containing static functions to help procedurally build meshes
  145449. */
  145450. export class TubeBuilder {
  145451. /**
  145452. * Creates a tube mesh.
  145453. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  145454. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  145455. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  145456. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  145457. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  145458. * * 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)
  145459. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  145460. * * 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
  145461. * * 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
  145462. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145463. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145464. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145466. * @param name defines the name of the mesh
  145467. * @param options defines the options used to create the mesh
  145468. * @param scene defines the hosting scene
  145469. * @returns the tube mesh
  145470. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145471. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  145472. */
  145473. static CreateTube(name: string, options: {
  145474. path: Vector3[];
  145475. radius?: number;
  145476. tessellation?: number;
  145477. radiusFunction?: {
  145478. (i: number, distance: number): number;
  145479. };
  145480. cap?: number;
  145481. arc?: number;
  145482. updatable?: boolean;
  145483. sideOrientation?: number;
  145484. frontUVs?: Vector4;
  145485. backUVs?: Vector4;
  145486. instance?: Mesh;
  145487. invertUV?: boolean;
  145488. }, scene?: Nullable<Scene>): Mesh;
  145489. }
  145490. }
  145491. declare module BABYLON {
  145492. /**
  145493. * Class containing static functions to help procedurally build meshes
  145494. */
  145495. export class IcoSphereBuilder {
  145496. /**
  145497. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  145498. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  145499. * * 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`)
  145500. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  145501. * * 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
  145502. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145503. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145505. * @param name defines the name of the mesh
  145506. * @param options defines the options used to create the mesh
  145507. * @param scene defines the hosting scene
  145508. * @returns the icosahedron mesh
  145509. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  145510. */
  145511. static CreateIcoSphere(name: string, options: {
  145512. radius?: number;
  145513. radiusX?: number;
  145514. radiusY?: number;
  145515. radiusZ?: number;
  145516. flat?: boolean;
  145517. subdivisions?: number;
  145518. sideOrientation?: number;
  145519. frontUVs?: Vector4;
  145520. backUVs?: Vector4;
  145521. updatable?: boolean;
  145522. }, scene?: Nullable<Scene>): Mesh;
  145523. }
  145524. }
  145525. declare module BABYLON {
  145526. /**
  145527. * Class containing static functions to help procedurally build meshes
  145528. */
  145529. export class DecalBuilder {
  145530. /**
  145531. * Creates a decal mesh.
  145532. * 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
  145533. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  145534. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  145535. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  145536. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  145537. * @param name defines the name of the mesh
  145538. * @param sourceMesh defines the mesh where the decal must be applied
  145539. * @param options defines the options used to create the mesh
  145540. * @param scene defines the hosting scene
  145541. * @returns the decal mesh
  145542. * @see https://doc.babylonjs.com/how_to/decals
  145543. */
  145544. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  145545. position?: Vector3;
  145546. normal?: Vector3;
  145547. size?: Vector3;
  145548. angle?: number;
  145549. }): Mesh;
  145550. }
  145551. }
  145552. declare module BABYLON {
  145553. /**
  145554. * Class containing static functions to help procedurally build meshes
  145555. */
  145556. export class MeshBuilder {
  145557. /**
  145558. * Creates a box mesh
  145559. * * The parameter `size` sets the size (float) of each box side (default 1)
  145560. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  145561. * * 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)
  145562. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145563. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145564. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145566. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  145567. * @param name defines the name of the mesh
  145568. * @param options defines the options used to create the mesh
  145569. * @param scene defines the hosting scene
  145570. * @returns the box mesh
  145571. */
  145572. static CreateBox(name: string, options: {
  145573. size?: number;
  145574. width?: number;
  145575. height?: number;
  145576. depth?: number;
  145577. faceUV?: Vector4[];
  145578. faceColors?: Color4[];
  145579. sideOrientation?: number;
  145580. frontUVs?: Vector4;
  145581. backUVs?: Vector4;
  145582. wrap?: boolean;
  145583. topBaseAt?: number;
  145584. bottomBaseAt?: number;
  145585. updatable?: boolean;
  145586. }, scene?: Nullable<Scene>): Mesh;
  145587. /**
  145588. * Creates a tiled box mesh
  145589. * * faceTiles sets the pattern, tile size and number of tiles for a face
  145590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145591. * @param name defines the name of the mesh
  145592. * @param options defines the options used to create the mesh
  145593. * @param scene defines the hosting scene
  145594. * @returns the tiled box mesh
  145595. */
  145596. static CreateTiledBox(name: string, options: {
  145597. pattern?: number;
  145598. size?: number;
  145599. width?: number;
  145600. height?: number;
  145601. depth: number;
  145602. tileSize?: number;
  145603. tileWidth?: number;
  145604. tileHeight?: number;
  145605. faceUV?: Vector4[];
  145606. faceColors?: Color4[];
  145607. alignHorizontal?: number;
  145608. alignVertical?: number;
  145609. sideOrientation?: number;
  145610. updatable?: boolean;
  145611. }, scene?: Nullable<Scene>): Mesh;
  145612. /**
  145613. * Creates a sphere mesh
  145614. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  145615. * * 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`)
  145616. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  145617. * * 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
  145618. * * 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)
  145619. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145620. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145622. * @param name defines the name of the mesh
  145623. * @param options defines the options used to create the mesh
  145624. * @param scene defines the hosting scene
  145625. * @returns the sphere mesh
  145626. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  145627. */
  145628. static CreateSphere(name: string, options: {
  145629. segments?: number;
  145630. diameter?: number;
  145631. diameterX?: number;
  145632. diameterY?: number;
  145633. diameterZ?: number;
  145634. arc?: number;
  145635. slice?: number;
  145636. sideOrientation?: number;
  145637. frontUVs?: Vector4;
  145638. backUVs?: Vector4;
  145639. updatable?: boolean;
  145640. }, scene?: Nullable<Scene>): Mesh;
  145641. /**
  145642. * Creates a plane polygonal mesh. By default, this is a disc
  145643. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  145644. * * 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
  145645. * * 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
  145646. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145647. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145649. * @param name defines the name of the mesh
  145650. * @param options defines the options used to create the mesh
  145651. * @param scene defines the hosting scene
  145652. * @returns the plane polygonal mesh
  145653. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  145654. */
  145655. static CreateDisc(name: string, options: {
  145656. radius?: number;
  145657. tessellation?: number;
  145658. arc?: number;
  145659. updatable?: boolean;
  145660. sideOrientation?: number;
  145661. frontUVs?: Vector4;
  145662. backUVs?: Vector4;
  145663. }, scene?: Nullable<Scene>): Mesh;
  145664. /**
  145665. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  145666. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  145667. * * 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`)
  145668. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  145669. * * 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
  145670. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145671. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145673. * @param name defines the name of the mesh
  145674. * @param options defines the options used to create the mesh
  145675. * @param scene defines the hosting scene
  145676. * @returns the icosahedron mesh
  145677. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  145678. */
  145679. static CreateIcoSphere(name: string, options: {
  145680. radius?: number;
  145681. radiusX?: number;
  145682. radiusY?: number;
  145683. radiusZ?: number;
  145684. flat?: boolean;
  145685. subdivisions?: number;
  145686. sideOrientation?: number;
  145687. frontUVs?: Vector4;
  145688. backUVs?: Vector4;
  145689. updatable?: boolean;
  145690. }, scene?: Nullable<Scene>): Mesh;
  145691. /**
  145692. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  145693. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  145694. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  145695. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  145696. * * 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
  145697. * * 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
  145698. * * 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
  145699. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145700. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145701. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145702. * * 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
  145703. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  145704. * * 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
  145705. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  145706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145707. * @param name defines the name of the mesh
  145708. * @param options defines the options used to create the mesh
  145709. * @param scene defines the hosting scene
  145710. * @returns the ribbon mesh
  145711. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  145712. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145713. */
  145714. static CreateRibbon(name: string, options: {
  145715. pathArray: Vector3[][];
  145716. closeArray?: boolean;
  145717. closePath?: boolean;
  145718. offset?: number;
  145719. updatable?: boolean;
  145720. sideOrientation?: number;
  145721. frontUVs?: Vector4;
  145722. backUVs?: Vector4;
  145723. instance?: Mesh;
  145724. invertUV?: boolean;
  145725. uvs?: Vector2[];
  145726. colors?: Color4[];
  145727. }, scene?: Nullable<Scene>): Mesh;
  145728. /**
  145729. * Creates a cylinder or a cone mesh
  145730. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  145731. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  145732. * * 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.
  145733. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  145734. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  145735. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  145736. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  145737. * * 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).
  145738. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  145739. * * 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).
  145740. * * 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
  145741. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  145742. * * 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
  145743. * * 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.
  145744. * * If `enclose` is false, a ring surface is one element.
  145745. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  145746. * * 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
  145747. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145748. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145750. * @param name defines the name of the mesh
  145751. * @param options defines the options used to create the mesh
  145752. * @param scene defines the hosting scene
  145753. * @returns the cylinder mesh
  145754. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  145755. */
  145756. static CreateCylinder(name: string, options: {
  145757. height?: number;
  145758. diameterTop?: number;
  145759. diameterBottom?: number;
  145760. diameter?: number;
  145761. tessellation?: number;
  145762. subdivisions?: number;
  145763. arc?: number;
  145764. faceColors?: Color4[];
  145765. faceUV?: Vector4[];
  145766. updatable?: boolean;
  145767. hasRings?: boolean;
  145768. enclose?: boolean;
  145769. cap?: number;
  145770. sideOrientation?: number;
  145771. frontUVs?: Vector4;
  145772. backUVs?: Vector4;
  145773. }, scene?: Nullable<Scene>): Mesh;
  145774. /**
  145775. * Creates a torus mesh
  145776. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  145777. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  145778. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  145779. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145780. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145781. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145782. * @param name defines the name of the mesh
  145783. * @param options defines the options used to create the mesh
  145784. * @param scene defines the hosting scene
  145785. * @returns the torus mesh
  145786. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  145787. */
  145788. static CreateTorus(name: string, options: {
  145789. diameter?: number;
  145790. thickness?: number;
  145791. tessellation?: number;
  145792. updatable?: boolean;
  145793. sideOrientation?: number;
  145794. frontUVs?: Vector4;
  145795. backUVs?: Vector4;
  145796. }, scene?: Nullable<Scene>): Mesh;
  145797. /**
  145798. * Creates a torus knot mesh
  145799. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  145800. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  145801. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  145802. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  145803. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145804. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145806. * @param name defines the name of the mesh
  145807. * @param options defines the options used to create the mesh
  145808. * @param scene defines the hosting scene
  145809. * @returns the torus knot mesh
  145810. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  145811. */
  145812. static CreateTorusKnot(name: string, options: {
  145813. radius?: number;
  145814. tube?: number;
  145815. radialSegments?: number;
  145816. tubularSegments?: number;
  145817. p?: number;
  145818. q?: number;
  145819. updatable?: boolean;
  145820. sideOrientation?: number;
  145821. frontUVs?: Vector4;
  145822. backUVs?: Vector4;
  145823. }, scene?: Nullable<Scene>): Mesh;
  145824. /**
  145825. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  145826. * * 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
  145827. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  145828. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  145829. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  145830. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  145831. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  145832. * * 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
  145833. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  145834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145835. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  145836. * @param name defines the name of the new line system
  145837. * @param options defines the options used to create the line system
  145838. * @param scene defines the hosting scene
  145839. * @returns a new line system mesh
  145840. */
  145841. static CreateLineSystem(name: string, options: {
  145842. lines: Vector3[][];
  145843. updatable?: boolean;
  145844. instance?: Nullable<LinesMesh>;
  145845. colors?: Nullable<Color4[][]>;
  145846. useVertexAlpha?: boolean;
  145847. }, scene: Nullable<Scene>): LinesMesh;
  145848. /**
  145849. * Creates a line mesh
  145850. * 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
  145851. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  145852. * * The parameter `points` is an array successive Vector3
  145853. * * 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
  145854. * * The optional parameter `colors` is an array of successive Color4, one per line point
  145855. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  145856. * * When updating an instance, remember that only point positions can change, not the number of points
  145857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145858. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  145859. * @param name defines the name of the new line system
  145860. * @param options defines the options used to create the line system
  145861. * @param scene defines the hosting scene
  145862. * @returns a new line mesh
  145863. */
  145864. static CreateLines(name: string, options: {
  145865. points: Vector3[];
  145866. updatable?: boolean;
  145867. instance?: Nullable<LinesMesh>;
  145868. colors?: Color4[];
  145869. useVertexAlpha?: boolean;
  145870. }, scene?: Nullable<Scene>): LinesMesh;
  145871. /**
  145872. * Creates a dashed line mesh
  145873. * * 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
  145874. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  145875. * * The parameter `points` is an array successive Vector3
  145876. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  145877. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  145878. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  145879. * * 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
  145880. * * When updating an instance, remember that only point positions can change, not the number of points
  145881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145882. * @param name defines the name of the mesh
  145883. * @param options defines the options used to create the mesh
  145884. * @param scene defines the hosting scene
  145885. * @returns the dashed line mesh
  145886. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  145887. */
  145888. static CreateDashedLines(name: string, options: {
  145889. points: Vector3[];
  145890. dashSize?: number;
  145891. gapSize?: number;
  145892. dashNb?: number;
  145893. updatable?: boolean;
  145894. instance?: LinesMesh;
  145895. }, scene?: Nullable<Scene>): LinesMesh;
  145896. /**
  145897. * 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.
  145898. * * 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.
  145899. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  145900. * * 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.
  145901. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  145902. * * 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
  145903. * * 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
  145904. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  145905. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145906. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145907. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  145908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145909. * @param name defines the name of the mesh
  145910. * @param options defines the options used to create the mesh
  145911. * @param scene defines the hosting scene
  145912. * @returns the extruded shape mesh
  145913. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145914. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  145915. */
  145916. static ExtrudeShape(name: string, options: {
  145917. shape: Vector3[];
  145918. path: Vector3[];
  145919. scale?: number;
  145920. rotation?: number;
  145921. cap?: number;
  145922. updatable?: boolean;
  145923. sideOrientation?: number;
  145924. frontUVs?: Vector4;
  145925. backUVs?: Vector4;
  145926. instance?: Mesh;
  145927. invertUV?: boolean;
  145928. }, scene?: Nullable<Scene>): Mesh;
  145929. /**
  145930. * Creates an custom extruded shape mesh.
  145931. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  145932. * * 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.
  145933. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  145934. * * 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
  145935. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  145936. * * 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
  145937. * * It must returns a float value that will be the scale value applied to the shape on each path point
  145938. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  145939. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  145940. * * 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
  145941. * * 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
  145942. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  145943. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145944. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145945. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145946. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145947. * @param name defines the name of the mesh
  145948. * @param options defines the options used to create the mesh
  145949. * @param scene defines the hosting scene
  145950. * @returns the custom extruded shape mesh
  145951. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  145952. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  145953. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  145954. */
  145955. static ExtrudeShapeCustom(name: string, options: {
  145956. shape: Vector3[];
  145957. path: Vector3[];
  145958. scaleFunction?: any;
  145959. rotationFunction?: any;
  145960. ribbonCloseArray?: boolean;
  145961. ribbonClosePath?: boolean;
  145962. cap?: number;
  145963. updatable?: boolean;
  145964. sideOrientation?: number;
  145965. frontUVs?: Vector4;
  145966. backUVs?: Vector4;
  145967. instance?: Mesh;
  145968. invertUV?: boolean;
  145969. }, scene?: Nullable<Scene>): Mesh;
  145970. /**
  145971. * Creates lathe mesh.
  145972. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  145973. * * 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
  145974. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  145975. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  145976. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  145977. * * 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
  145978. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  145979. * * 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
  145980. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145981. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  145982. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145984. * @param name defines the name of the mesh
  145985. * @param options defines the options used to create the mesh
  145986. * @param scene defines the hosting scene
  145987. * @returns the lathe mesh
  145988. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  145989. */
  145990. static CreateLathe(name: string, options: {
  145991. shape: Vector3[];
  145992. radius?: number;
  145993. tessellation?: number;
  145994. clip?: number;
  145995. arc?: number;
  145996. closed?: boolean;
  145997. updatable?: boolean;
  145998. sideOrientation?: number;
  145999. frontUVs?: Vector4;
  146000. backUVs?: Vector4;
  146001. cap?: number;
  146002. invertUV?: boolean;
  146003. }, scene?: Nullable<Scene>): Mesh;
  146004. /**
  146005. * Creates a tiled plane mesh
  146006. * * You can set a limited pattern arrangement with the tiles
  146007. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146008. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146009. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146010. * @param name defines the name of the mesh
  146011. * @param options defines the options used to create the mesh
  146012. * @param scene defines the hosting scene
  146013. * @returns the plane mesh
  146014. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  146015. */
  146016. static CreateTiledPlane(name: string, options: {
  146017. pattern?: number;
  146018. tileSize?: number;
  146019. tileWidth?: number;
  146020. tileHeight?: number;
  146021. size?: number;
  146022. width?: number;
  146023. height?: number;
  146024. alignHorizontal?: number;
  146025. alignVertical?: number;
  146026. sideOrientation?: number;
  146027. frontUVs?: Vector4;
  146028. backUVs?: Vector4;
  146029. updatable?: boolean;
  146030. }, scene?: Nullable<Scene>): Mesh;
  146031. /**
  146032. * Creates a plane mesh
  146033. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  146034. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  146035. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  146036. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146037. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146039. * @param name defines the name of the mesh
  146040. * @param options defines the options used to create the mesh
  146041. * @param scene defines the hosting scene
  146042. * @returns the plane mesh
  146043. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  146044. */
  146045. static CreatePlane(name: string, options: {
  146046. size?: number;
  146047. width?: number;
  146048. height?: number;
  146049. sideOrientation?: number;
  146050. frontUVs?: Vector4;
  146051. backUVs?: Vector4;
  146052. updatable?: boolean;
  146053. sourcePlane?: Plane;
  146054. }, scene?: Nullable<Scene>): Mesh;
  146055. /**
  146056. * Creates a ground mesh
  146057. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  146058. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  146059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146060. * @param name defines the name of the mesh
  146061. * @param options defines the options used to create the mesh
  146062. * @param scene defines the hosting scene
  146063. * @returns the ground mesh
  146064. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  146065. */
  146066. static CreateGround(name: string, options: {
  146067. width?: number;
  146068. height?: number;
  146069. subdivisions?: number;
  146070. subdivisionsX?: number;
  146071. subdivisionsY?: number;
  146072. updatable?: boolean;
  146073. }, scene?: Nullable<Scene>): Mesh;
  146074. /**
  146075. * Creates a tiled ground mesh
  146076. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  146077. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  146078. * * 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
  146079. * * 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
  146080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146081. * @param name defines the name of the mesh
  146082. * @param options defines the options used to create the mesh
  146083. * @param scene defines the hosting scene
  146084. * @returns the tiled ground mesh
  146085. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  146086. */
  146087. static CreateTiledGround(name: string, options: {
  146088. xmin: number;
  146089. zmin: number;
  146090. xmax: number;
  146091. zmax: number;
  146092. subdivisions?: {
  146093. w: number;
  146094. h: number;
  146095. };
  146096. precision?: {
  146097. w: number;
  146098. h: number;
  146099. };
  146100. updatable?: boolean;
  146101. }, scene?: Nullable<Scene>): Mesh;
  146102. /**
  146103. * Creates a ground mesh from a height map
  146104. * * The parameter `url` sets the URL of the height map image resource.
  146105. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  146106. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  146107. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  146108. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  146109. * * 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.
  146110. * * 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).
  146111. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  146112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146113. * @param name defines the name of the mesh
  146114. * @param url defines the url to the height map
  146115. * @param options defines the options used to create the mesh
  146116. * @param scene defines the hosting scene
  146117. * @returns the ground mesh
  146118. * @see https://doc.babylonjs.com/babylon101/height_map
  146119. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  146120. */
  146121. static CreateGroundFromHeightMap(name: string, url: string, options: {
  146122. width?: number;
  146123. height?: number;
  146124. subdivisions?: number;
  146125. minHeight?: number;
  146126. maxHeight?: number;
  146127. colorFilter?: Color3;
  146128. alphaFilter?: number;
  146129. updatable?: boolean;
  146130. onReady?: (mesh: GroundMesh) => void;
  146131. }, scene?: Nullable<Scene>): GroundMesh;
  146132. /**
  146133. * Creates a polygon mesh
  146134. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  146135. * * 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
  146136. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146138. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  146139. * * Remember you can only change the shape positions, not their number when updating a polygon
  146140. * @param name defines the name of the mesh
  146141. * @param options defines the options used to create the mesh
  146142. * @param scene defines the hosting scene
  146143. * @param earcutInjection can be used to inject your own earcut reference
  146144. * @returns the polygon mesh
  146145. */
  146146. static CreatePolygon(name: string, options: {
  146147. shape: Vector3[];
  146148. holes?: Vector3[][];
  146149. depth?: number;
  146150. faceUV?: Vector4[];
  146151. faceColors?: Color4[];
  146152. updatable?: boolean;
  146153. sideOrientation?: number;
  146154. frontUVs?: Vector4;
  146155. backUVs?: Vector4;
  146156. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146157. /**
  146158. * Creates an extruded polygon mesh, with depth in the Y direction.
  146159. * * 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)
  146160. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146161. * @param name defines the name of the mesh
  146162. * @param options defines the options used to create the mesh
  146163. * @param scene defines the hosting scene
  146164. * @param earcutInjection can be used to inject your own earcut reference
  146165. * @returns the polygon mesh
  146166. */
  146167. static ExtrudePolygon(name: string, options: {
  146168. shape: Vector3[];
  146169. holes?: Vector3[][];
  146170. depth?: number;
  146171. faceUV?: Vector4[];
  146172. faceColors?: Color4[];
  146173. updatable?: boolean;
  146174. sideOrientation?: number;
  146175. frontUVs?: Vector4;
  146176. backUVs?: Vector4;
  146177. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146178. /**
  146179. * Creates a tube mesh.
  146180. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146181. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  146182. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  146183. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  146184. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  146185. * * 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)
  146186. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  146187. * * 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
  146188. * * 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
  146189. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146190. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146191. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146193. * @param name defines the name of the mesh
  146194. * @param options defines the options used to create the mesh
  146195. * @param scene defines the hosting scene
  146196. * @returns the tube mesh
  146197. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146198. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  146199. */
  146200. static CreateTube(name: string, options: {
  146201. path: Vector3[];
  146202. radius?: number;
  146203. tessellation?: number;
  146204. radiusFunction?: {
  146205. (i: number, distance: number): number;
  146206. };
  146207. cap?: number;
  146208. arc?: number;
  146209. updatable?: boolean;
  146210. sideOrientation?: number;
  146211. frontUVs?: Vector4;
  146212. backUVs?: Vector4;
  146213. instance?: Mesh;
  146214. invertUV?: boolean;
  146215. }, scene?: Nullable<Scene>): Mesh;
  146216. /**
  146217. * Creates a polyhedron mesh
  146218. * * 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
  146219. * * The parameter `size` (positive float, default 1) sets the polygon size
  146220. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  146221. * * 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`
  146222. * * 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
  146223. * * 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)`)
  146224. * * 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
  146225. * * 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
  146226. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146227. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146229. * @param name defines the name of the mesh
  146230. * @param options defines the options used to create the mesh
  146231. * @param scene defines the hosting scene
  146232. * @returns the polyhedron mesh
  146233. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  146234. */
  146235. static CreatePolyhedron(name: string, options: {
  146236. type?: number;
  146237. size?: number;
  146238. sizeX?: number;
  146239. sizeY?: number;
  146240. sizeZ?: number;
  146241. custom?: any;
  146242. faceUV?: Vector4[];
  146243. faceColors?: Color4[];
  146244. flat?: boolean;
  146245. updatable?: boolean;
  146246. sideOrientation?: number;
  146247. frontUVs?: Vector4;
  146248. backUVs?: Vector4;
  146249. }, scene?: Nullable<Scene>): Mesh;
  146250. /**
  146251. * Creates a decal mesh.
  146252. * 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
  146253. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  146254. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  146255. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  146256. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  146257. * @param name defines the name of the mesh
  146258. * @param sourceMesh defines the mesh where the decal must be applied
  146259. * @param options defines the options used to create the mesh
  146260. * @param scene defines the hosting scene
  146261. * @returns the decal mesh
  146262. * @see https://doc.babylonjs.com/how_to/decals
  146263. */
  146264. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  146265. position?: Vector3;
  146266. normal?: Vector3;
  146267. size?: Vector3;
  146268. angle?: number;
  146269. }): Mesh;
  146270. }
  146271. }
  146272. declare module BABYLON {
  146273. /**
  146274. * A simplifier interface for future simplification implementations
  146275. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146276. */
  146277. export interface ISimplifier {
  146278. /**
  146279. * Simplification of a given mesh according to the given settings.
  146280. * Since this requires computation, it is assumed that the function runs async.
  146281. * @param settings The settings of the simplification, including quality and distance
  146282. * @param successCallback A callback that will be called after the mesh was simplified.
  146283. * @param errorCallback in case of an error, this callback will be called. optional.
  146284. */
  146285. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  146286. }
  146287. /**
  146288. * Expected simplification settings.
  146289. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  146290. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146291. */
  146292. export interface ISimplificationSettings {
  146293. /**
  146294. * Gets or sets the expected quality
  146295. */
  146296. quality: number;
  146297. /**
  146298. * Gets or sets the distance when this optimized version should be used
  146299. */
  146300. distance: number;
  146301. /**
  146302. * Gets an already optimized mesh
  146303. */
  146304. optimizeMesh?: boolean;
  146305. }
  146306. /**
  146307. * Class used to specify simplification options
  146308. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146309. */
  146310. export class SimplificationSettings implements ISimplificationSettings {
  146311. /** expected quality */
  146312. quality: number;
  146313. /** distance when this optimized version should be used */
  146314. distance: number;
  146315. /** already optimized mesh */
  146316. optimizeMesh?: boolean | undefined;
  146317. /**
  146318. * Creates a SimplificationSettings
  146319. * @param quality expected quality
  146320. * @param distance distance when this optimized version should be used
  146321. * @param optimizeMesh already optimized mesh
  146322. */
  146323. constructor(
  146324. /** expected quality */
  146325. quality: number,
  146326. /** distance when this optimized version should be used */
  146327. distance: number,
  146328. /** already optimized mesh */
  146329. optimizeMesh?: boolean | undefined);
  146330. }
  146331. /**
  146332. * Interface used to define a simplification task
  146333. */
  146334. export interface ISimplificationTask {
  146335. /**
  146336. * Array of settings
  146337. */
  146338. settings: Array<ISimplificationSettings>;
  146339. /**
  146340. * Simplification type
  146341. */
  146342. simplificationType: SimplificationType;
  146343. /**
  146344. * Mesh to simplify
  146345. */
  146346. mesh: Mesh;
  146347. /**
  146348. * Callback called on success
  146349. */
  146350. successCallback?: () => void;
  146351. /**
  146352. * Defines if parallel processing can be used
  146353. */
  146354. parallelProcessing: boolean;
  146355. }
  146356. /**
  146357. * Queue used to order the simplification tasks
  146358. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146359. */
  146360. export class SimplificationQueue {
  146361. private _simplificationArray;
  146362. /**
  146363. * Gets a boolean indicating that the process is still running
  146364. */
  146365. running: boolean;
  146366. /**
  146367. * Creates a new queue
  146368. */
  146369. constructor();
  146370. /**
  146371. * Adds a new simplification task
  146372. * @param task defines a task to add
  146373. */
  146374. addTask(task: ISimplificationTask): void;
  146375. /**
  146376. * Execute next task
  146377. */
  146378. executeNext(): void;
  146379. /**
  146380. * Execute a simplification task
  146381. * @param task defines the task to run
  146382. */
  146383. runSimplification(task: ISimplificationTask): void;
  146384. private getSimplifier;
  146385. }
  146386. /**
  146387. * The implemented types of simplification
  146388. * At the moment only Quadratic Error Decimation is implemented
  146389. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146390. */
  146391. export enum SimplificationType {
  146392. /** Quadratic error decimation */
  146393. QUADRATIC = 0
  146394. }
  146395. /**
  146396. * An implementation of the Quadratic Error simplification algorithm.
  146397. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  146398. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  146399. * @author RaananW
  146400. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146401. */
  146402. export class QuadraticErrorSimplification implements ISimplifier {
  146403. private _mesh;
  146404. private triangles;
  146405. private vertices;
  146406. private references;
  146407. private _reconstructedMesh;
  146408. /** Gets or sets the number pf sync interations */
  146409. syncIterations: number;
  146410. /** Gets or sets the aggressiveness of the simplifier */
  146411. aggressiveness: number;
  146412. /** Gets or sets the number of allowed iterations for decimation */
  146413. decimationIterations: number;
  146414. /** Gets or sets the espilon to use for bounding box computation */
  146415. boundingBoxEpsilon: number;
  146416. /**
  146417. * Creates a new QuadraticErrorSimplification
  146418. * @param _mesh defines the target mesh
  146419. */
  146420. constructor(_mesh: Mesh);
  146421. /**
  146422. * Simplification of a given mesh according to the given settings.
  146423. * Since this requires computation, it is assumed that the function runs async.
  146424. * @param settings The settings of the simplification, including quality and distance
  146425. * @param successCallback A callback that will be called after the mesh was simplified.
  146426. */
  146427. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  146428. private runDecimation;
  146429. private initWithMesh;
  146430. private init;
  146431. private reconstructMesh;
  146432. private initDecimatedMesh;
  146433. private isFlipped;
  146434. private updateTriangles;
  146435. private identifyBorder;
  146436. private updateMesh;
  146437. private vertexError;
  146438. private calculateError;
  146439. }
  146440. }
  146441. declare module BABYLON {
  146442. interface Scene {
  146443. /** @hidden (Backing field) */
  146444. _simplificationQueue: SimplificationQueue;
  146445. /**
  146446. * Gets or sets the simplification queue attached to the scene
  146447. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146448. */
  146449. simplificationQueue: SimplificationQueue;
  146450. }
  146451. interface Mesh {
  146452. /**
  146453. * Simplify the mesh according to the given array of settings.
  146454. * Function will return immediately and will simplify async
  146455. * @param settings a collection of simplification settings
  146456. * @param parallelProcessing should all levels calculate parallel or one after the other
  146457. * @param simplificationType the type of simplification to run
  146458. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  146459. * @returns the current mesh
  146460. */
  146461. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  146462. }
  146463. /**
  146464. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  146465. * created in a scene
  146466. */
  146467. export class SimplicationQueueSceneComponent implements ISceneComponent {
  146468. /**
  146469. * The component name helpfull to identify the component in the list of scene components.
  146470. */
  146471. readonly name: string;
  146472. /**
  146473. * The scene the component belongs to.
  146474. */
  146475. scene: Scene;
  146476. /**
  146477. * Creates a new instance of the component for the given scene
  146478. * @param scene Defines the scene to register the component in
  146479. */
  146480. constructor(scene: Scene);
  146481. /**
  146482. * Registers the component in a given scene
  146483. */
  146484. register(): void;
  146485. /**
  146486. * Rebuilds the elements related to this component in case of
  146487. * context lost for instance.
  146488. */
  146489. rebuild(): void;
  146490. /**
  146491. * Disposes the component and the associated ressources
  146492. */
  146493. dispose(): void;
  146494. private _beforeCameraUpdate;
  146495. }
  146496. }
  146497. declare module BABYLON {
  146498. interface Mesh {
  146499. /**
  146500. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  146501. */
  146502. thinInstanceEnablePicking: boolean;
  146503. /**
  146504. * Creates a new thin instance
  146505. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  146506. * @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
  146507. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  146508. */
  146509. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  146510. /**
  146511. * Adds the transformation (matrix) of the current mesh as a thin instance
  146512. * @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
  146513. * @returns the thin instance index number
  146514. */
  146515. thinInstanceAddSelf(refresh: boolean): number;
  146516. /**
  146517. * Registers a custom attribute to be used with thin instances
  146518. * @param kind name of the attribute
  146519. * @param stride size in floats of the attribute
  146520. */
  146521. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  146522. /**
  146523. * Sets the matrix of a thin instance
  146524. * @param index index of the thin instance
  146525. * @param matrix matrix to set
  146526. * @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
  146527. */
  146528. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  146529. /**
  146530. * Sets the value of a custom attribute for a thin instance
  146531. * @param kind name of the attribute
  146532. * @param index index of the thin instance
  146533. * @param value value to set
  146534. * @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
  146535. */
  146536. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  146537. /**
  146538. * 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.
  146539. */
  146540. thinInstanceCount: number;
  146541. /**
  146542. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  146543. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  146544. * @param buffer buffer to set
  146545. * @param stride size in floats of each value of the buffer
  146546. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  146547. */
  146548. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  146549. /**
  146550. * Gets the list of world matrices
  146551. * @return an array containing all the world matrices from the thin instances
  146552. */
  146553. thinInstanceGetWorldMatrices(): Matrix[];
  146554. /**
  146555. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  146556. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  146557. */
  146558. thinInstanceBufferUpdated(kind: string): void;
  146559. /**
  146560. * Applies a partial update to a buffer directly on the GPU
  146561. * 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
  146562. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  146563. * @param data the data to set in the GPU buffer
  146564. * @param offset the offset in the GPU buffer where to update the data
  146565. */
  146566. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  146567. /**
  146568. * Refreshes the bounding info, taking into account all the thin instances defined
  146569. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  146570. */
  146571. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  146572. /** @hidden */
  146573. _thinInstanceInitializeUserStorage(): void;
  146574. /** @hidden */
  146575. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  146576. /** @hidden */
  146577. _userThinInstanceBuffersStorage: {
  146578. data: {
  146579. [key: string]: Float32Array;
  146580. };
  146581. sizes: {
  146582. [key: string]: number;
  146583. };
  146584. vertexBuffers: {
  146585. [key: string]: Nullable<VertexBuffer>;
  146586. };
  146587. strides: {
  146588. [key: string]: number;
  146589. };
  146590. };
  146591. }
  146592. }
  146593. declare module BABYLON {
  146594. /**
  146595. * Navigation plugin interface to add navigation constrained by a navigation mesh
  146596. */
  146597. export interface INavigationEnginePlugin {
  146598. /**
  146599. * plugin name
  146600. */
  146601. name: string;
  146602. /**
  146603. * Creates a navigation mesh
  146604. * @param meshes array of all the geometry used to compute the navigatio mesh
  146605. * @param parameters bunch of parameters used to filter geometry
  146606. */
  146607. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  146608. /**
  146609. * Create a navigation mesh debug mesh
  146610. * @param scene is where the mesh will be added
  146611. * @returns debug display mesh
  146612. */
  146613. createDebugNavMesh(scene: Scene): Mesh;
  146614. /**
  146615. * Get a navigation mesh constrained position, closest to the parameter position
  146616. * @param position world position
  146617. * @returns the closest point to position constrained by the navigation mesh
  146618. */
  146619. getClosestPoint(position: Vector3): Vector3;
  146620. /**
  146621. * Get a navigation mesh constrained position, closest to the parameter position
  146622. * @param position world position
  146623. * @param result output the closest point to position constrained by the navigation mesh
  146624. */
  146625. getClosestPointToRef(position: Vector3, result: Vector3): void;
  146626. /**
  146627. * Get a navigation mesh constrained position, within a particular radius
  146628. * @param position world position
  146629. * @param maxRadius the maximum distance to the constrained world position
  146630. * @returns the closest point to position constrained by the navigation mesh
  146631. */
  146632. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  146633. /**
  146634. * Get a navigation mesh constrained position, within a particular radius
  146635. * @param position world position
  146636. * @param maxRadius the maximum distance to the constrained world position
  146637. * @param result output the closest point to position constrained by the navigation mesh
  146638. */
  146639. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  146640. /**
  146641. * Compute the final position from a segment made of destination-position
  146642. * @param position world position
  146643. * @param destination world position
  146644. * @returns the resulting point along the navmesh
  146645. */
  146646. moveAlong(position: Vector3, destination: Vector3): Vector3;
  146647. /**
  146648. * Compute the final position from a segment made of destination-position
  146649. * @param position world position
  146650. * @param destination world position
  146651. * @param result output the resulting point along the navmesh
  146652. */
  146653. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  146654. /**
  146655. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  146656. * @param start world position
  146657. * @param end world position
  146658. * @returns array containing world position composing the path
  146659. */
  146660. computePath(start: Vector3, end: Vector3): Vector3[];
  146661. /**
  146662. * If this plugin is supported
  146663. * @returns true if plugin is supported
  146664. */
  146665. isSupported(): boolean;
  146666. /**
  146667. * Create a new Crowd so you can add agents
  146668. * @param maxAgents the maximum agent count in the crowd
  146669. * @param maxAgentRadius the maximum radius an agent can have
  146670. * @param scene to attach the crowd to
  146671. * @returns the crowd you can add agents to
  146672. */
  146673. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  146674. /**
  146675. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  146676. * The queries will try to find a solution within those bounds
  146677. * default is (1,1,1)
  146678. * @param extent x,y,z value that define the extent around the queries point of reference
  146679. */
  146680. setDefaultQueryExtent(extent: Vector3): void;
  146681. /**
  146682. * Get the Bounding box extent specified by setDefaultQueryExtent
  146683. * @returns the box extent values
  146684. */
  146685. getDefaultQueryExtent(): Vector3;
  146686. /**
  146687. * build the navmesh from a previously saved state using getNavmeshData
  146688. * @param data the Uint8Array returned by getNavmeshData
  146689. */
  146690. buildFromNavmeshData(data: Uint8Array): void;
  146691. /**
  146692. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  146693. * @returns data the Uint8Array that can be saved and reused
  146694. */
  146695. getNavmeshData(): Uint8Array;
  146696. /**
  146697. * Get the Bounding box extent result specified by setDefaultQueryExtent
  146698. * @param result output the box extent values
  146699. */
  146700. getDefaultQueryExtentToRef(result: Vector3): void;
  146701. /**
  146702. * Release all resources
  146703. */
  146704. dispose(): void;
  146705. }
  146706. /**
  146707. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  146708. */
  146709. export interface ICrowd {
  146710. /**
  146711. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  146712. * You can attach anything to that node. The node position is updated in the scene update tick.
  146713. * @param pos world position that will be constrained by the navigation mesh
  146714. * @param parameters agent parameters
  146715. * @param transform hooked to the agent that will be update by the scene
  146716. * @returns agent index
  146717. */
  146718. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  146719. /**
  146720. * Returns the agent position in world space
  146721. * @param index agent index returned by addAgent
  146722. * @returns world space position
  146723. */
  146724. getAgentPosition(index: number): Vector3;
  146725. /**
  146726. * Gets the agent position result in world space
  146727. * @param index agent index returned by addAgent
  146728. * @param result output world space position
  146729. */
  146730. getAgentPositionToRef(index: number, result: Vector3): void;
  146731. /**
  146732. * Gets the agent velocity in world space
  146733. * @param index agent index returned by addAgent
  146734. * @returns world space velocity
  146735. */
  146736. getAgentVelocity(index: number): Vector3;
  146737. /**
  146738. * Gets the agent velocity result in world space
  146739. * @param index agent index returned by addAgent
  146740. * @param result output world space velocity
  146741. */
  146742. getAgentVelocityToRef(index: number, result: Vector3): void;
  146743. /**
  146744. * remove a particular agent previously created
  146745. * @param index agent index returned by addAgent
  146746. */
  146747. removeAgent(index: number): void;
  146748. /**
  146749. * get the list of all agents attached to this crowd
  146750. * @returns list of agent indices
  146751. */
  146752. getAgents(): number[];
  146753. /**
  146754. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  146755. * @param deltaTime in seconds
  146756. */
  146757. update(deltaTime: number): void;
  146758. /**
  146759. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  146760. * @param index agent index returned by addAgent
  146761. * @param destination targeted world position
  146762. */
  146763. agentGoto(index: number, destination: Vector3): void;
  146764. /**
  146765. * Teleport the agent to a new position
  146766. * @param index agent index returned by addAgent
  146767. * @param destination targeted world position
  146768. */
  146769. agentTeleport(index: number, destination: Vector3): void;
  146770. /**
  146771. * Update agent parameters
  146772. * @param index agent index returned by addAgent
  146773. * @param parameters agent parameters
  146774. */
  146775. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  146776. /**
  146777. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  146778. * The queries will try to find a solution within those bounds
  146779. * default is (1,1,1)
  146780. * @param extent x,y,z value that define the extent around the queries point of reference
  146781. */
  146782. setDefaultQueryExtent(extent: Vector3): void;
  146783. /**
  146784. * Get the Bounding box extent specified by setDefaultQueryExtent
  146785. * @returns the box extent values
  146786. */
  146787. getDefaultQueryExtent(): Vector3;
  146788. /**
  146789. * Get the Bounding box extent result specified by setDefaultQueryExtent
  146790. * @param result output the box extent values
  146791. */
  146792. getDefaultQueryExtentToRef(result: Vector3): void;
  146793. /**
  146794. * Release all resources
  146795. */
  146796. dispose(): void;
  146797. }
  146798. /**
  146799. * Configures an agent
  146800. */
  146801. export interface IAgentParameters {
  146802. /**
  146803. * Agent radius. [Limit: >= 0]
  146804. */
  146805. radius: number;
  146806. /**
  146807. * Agent height. [Limit: > 0]
  146808. */
  146809. height: number;
  146810. /**
  146811. * Maximum allowed acceleration. [Limit: >= 0]
  146812. */
  146813. maxAcceleration: number;
  146814. /**
  146815. * Maximum allowed speed. [Limit: >= 0]
  146816. */
  146817. maxSpeed: number;
  146818. /**
  146819. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  146820. */
  146821. collisionQueryRange: number;
  146822. /**
  146823. * The path visibility optimization range. [Limit: > 0]
  146824. */
  146825. pathOptimizationRange: number;
  146826. /**
  146827. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  146828. */
  146829. separationWeight: number;
  146830. }
  146831. /**
  146832. * Configures the navigation mesh creation
  146833. */
  146834. export interface INavMeshParameters {
  146835. /**
  146836. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  146837. */
  146838. cs: number;
  146839. /**
  146840. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  146841. */
  146842. ch: number;
  146843. /**
  146844. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  146845. */
  146846. walkableSlopeAngle: number;
  146847. /**
  146848. * Minimum floor to 'ceiling' height that will still allow the floor area to
  146849. * be considered walkable. [Limit: >= 3] [Units: vx]
  146850. */
  146851. walkableHeight: number;
  146852. /**
  146853. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  146854. */
  146855. walkableClimb: number;
  146856. /**
  146857. * The distance to erode/shrink the walkable area of the heightfield away from
  146858. * obstructions. [Limit: >=0] [Units: vx]
  146859. */
  146860. walkableRadius: number;
  146861. /**
  146862. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  146863. */
  146864. maxEdgeLen: number;
  146865. /**
  146866. * The maximum distance a simplfied contour's border edges should deviate
  146867. * the original raw contour. [Limit: >=0] [Units: vx]
  146868. */
  146869. maxSimplificationError: number;
  146870. /**
  146871. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  146872. */
  146873. minRegionArea: number;
  146874. /**
  146875. * Any regions with a span count smaller than this value will, if possible,
  146876. * be merged with larger regions. [Limit: >=0] [Units: vx]
  146877. */
  146878. mergeRegionArea: number;
  146879. /**
  146880. * The maximum number of vertices allowed for polygons generated during the
  146881. * contour to polygon conversion process. [Limit: >= 3]
  146882. */
  146883. maxVertsPerPoly: number;
  146884. /**
  146885. * Sets the sampling distance to use when generating the detail mesh.
  146886. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  146887. */
  146888. detailSampleDist: number;
  146889. /**
  146890. * The maximum distance the detail mesh surface should deviate from heightfield
  146891. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  146892. */
  146893. detailSampleMaxError: number;
  146894. }
  146895. }
  146896. declare module BABYLON {
  146897. /**
  146898. * RecastJS navigation plugin
  146899. */
  146900. export class RecastJSPlugin implements INavigationEnginePlugin {
  146901. /**
  146902. * Reference to the Recast library
  146903. */
  146904. bjsRECAST: any;
  146905. /**
  146906. * plugin name
  146907. */
  146908. name: string;
  146909. /**
  146910. * the first navmesh created. We might extend this to support multiple navmeshes
  146911. */
  146912. navMesh: any;
  146913. /**
  146914. * Initializes the recastJS plugin
  146915. * @param recastInjection can be used to inject your own recast reference
  146916. */
  146917. constructor(recastInjection?: any);
  146918. /**
  146919. * Creates a navigation mesh
  146920. * @param meshes array of all the geometry used to compute the navigatio mesh
  146921. * @param parameters bunch of parameters used to filter geometry
  146922. */
  146923. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  146924. /**
  146925. * Create a navigation mesh debug mesh
  146926. * @param scene is where the mesh will be added
  146927. * @returns debug display mesh
  146928. */
  146929. createDebugNavMesh(scene: Scene): Mesh;
  146930. /**
  146931. * Get a navigation mesh constrained position, closest to the parameter position
  146932. * @param position world position
  146933. * @returns the closest point to position constrained by the navigation mesh
  146934. */
  146935. getClosestPoint(position: Vector3): Vector3;
  146936. /**
  146937. * Get a navigation mesh constrained position, closest to the parameter position
  146938. * @param position world position
  146939. * @param result output the closest point to position constrained by the navigation mesh
  146940. */
  146941. getClosestPointToRef(position: Vector3, result: Vector3): void;
  146942. /**
  146943. * Get a navigation mesh constrained position, within a particular radius
  146944. * @param position world position
  146945. * @param maxRadius the maximum distance to the constrained world position
  146946. * @returns the closest point to position constrained by the navigation mesh
  146947. */
  146948. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  146949. /**
  146950. * Get a navigation mesh constrained position, within a particular radius
  146951. * @param position world position
  146952. * @param maxRadius the maximum distance to the constrained world position
  146953. * @param result output the closest point to position constrained by the navigation mesh
  146954. */
  146955. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  146956. /**
  146957. * Compute the final position from a segment made of destination-position
  146958. * @param position world position
  146959. * @param destination world position
  146960. * @returns the resulting point along the navmesh
  146961. */
  146962. moveAlong(position: Vector3, destination: Vector3): Vector3;
  146963. /**
  146964. * Compute the final position from a segment made of destination-position
  146965. * @param position world position
  146966. * @param destination world position
  146967. * @param result output the resulting point along the navmesh
  146968. */
  146969. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  146970. /**
  146971. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  146972. * @param start world position
  146973. * @param end world position
  146974. * @returns array containing world position composing the path
  146975. */
  146976. computePath(start: Vector3, end: Vector3): Vector3[];
  146977. /**
  146978. * Create a new Crowd so you can add agents
  146979. * @param maxAgents the maximum agent count in the crowd
  146980. * @param maxAgentRadius the maximum radius an agent can have
  146981. * @param scene to attach the crowd to
  146982. * @returns the crowd you can add agents to
  146983. */
  146984. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  146985. /**
  146986. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  146987. * The queries will try to find a solution within those bounds
  146988. * default is (1,1,1)
  146989. * @param extent x,y,z value that define the extent around the queries point of reference
  146990. */
  146991. setDefaultQueryExtent(extent: Vector3): void;
  146992. /**
  146993. * Get the Bounding box extent specified by setDefaultQueryExtent
  146994. * @returns the box extent values
  146995. */
  146996. getDefaultQueryExtent(): Vector3;
  146997. /**
  146998. * build the navmesh from a previously saved state using getNavmeshData
  146999. * @param data the Uint8Array returned by getNavmeshData
  147000. */
  147001. buildFromNavmeshData(data: Uint8Array): void;
  147002. /**
  147003. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  147004. * @returns data the Uint8Array that can be saved and reused
  147005. */
  147006. getNavmeshData(): Uint8Array;
  147007. /**
  147008. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147009. * @param result output the box extent values
  147010. */
  147011. getDefaultQueryExtentToRef(result: Vector3): void;
  147012. /**
  147013. * Disposes
  147014. */
  147015. dispose(): void;
  147016. /**
  147017. * If this plugin is supported
  147018. * @returns true if plugin is supported
  147019. */
  147020. isSupported(): boolean;
  147021. }
  147022. /**
  147023. * Recast detour crowd implementation
  147024. */
  147025. export class RecastJSCrowd implements ICrowd {
  147026. /**
  147027. * Recast/detour plugin
  147028. */
  147029. bjsRECASTPlugin: RecastJSPlugin;
  147030. /**
  147031. * Link to the detour crowd
  147032. */
  147033. recastCrowd: any;
  147034. /**
  147035. * One transform per agent
  147036. */
  147037. transforms: TransformNode[];
  147038. /**
  147039. * All agents created
  147040. */
  147041. agents: number[];
  147042. /**
  147043. * Link to the scene is kept to unregister the crowd from the scene
  147044. */
  147045. private _scene;
  147046. /**
  147047. * Observer for crowd updates
  147048. */
  147049. private _onBeforeAnimationsObserver;
  147050. /**
  147051. * Constructor
  147052. * @param plugin recastJS plugin
  147053. * @param maxAgents the maximum agent count in the crowd
  147054. * @param maxAgentRadius the maximum radius an agent can have
  147055. * @param scene to attach the crowd to
  147056. * @returns the crowd you can add agents to
  147057. */
  147058. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  147059. /**
  147060. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  147061. * You can attach anything to that node. The node position is updated in the scene update tick.
  147062. * @param pos world position that will be constrained by the navigation mesh
  147063. * @param parameters agent parameters
  147064. * @param transform hooked to the agent that will be update by the scene
  147065. * @returns agent index
  147066. */
  147067. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  147068. /**
  147069. * Returns the agent position in world space
  147070. * @param index agent index returned by addAgent
  147071. * @returns world space position
  147072. */
  147073. getAgentPosition(index: number): Vector3;
  147074. /**
  147075. * Returns the agent position result in world space
  147076. * @param index agent index returned by addAgent
  147077. * @param result output world space position
  147078. */
  147079. getAgentPositionToRef(index: number, result: Vector3): void;
  147080. /**
  147081. * Returns the agent velocity in world space
  147082. * @param index agent index returned by addAgent
  147083. * @returns world space velocity
  147084. */
  147085. getAgentVelocity(index: number): Vector3;
  147086. /**
  147087. * Returns the agent velocity result in world space
  147088. * @param index agent index returned by addAgent
  147089. * @param result output world space velocity
  147090. */
  147091. getAgentVelocityToRef(index: number, result: Vector3): void;
  147092. /**
  147093. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  147094. * @param index agent index returned by addAgent
  147095. * @param destination targeted world position
  147096. */
  147097. agentGoto(index: number, destination: Vector3): void;
  147098. /**
  147099. * Teleport the agent to a new position
  147100. * @param index agent index returned by addAgent
  147101. * @param destination targeted world position
  147102. */
  147103. agentTeleport(index: number, destination: Vector3): void;
  147104. /**
  147105. * Update agent parameters
  147106. * @param index agent index returned by addAgent
  147107. * @param parameters agent parameters
  147108. */
  147109. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  147110. /**
  147111. * remove a particular agent previously created
  147112. * @param index agent index returned by addAgent
  147113. */
  147114. removeAgent(index: number): void;
  147115. /**
  147116. * get the list of all agents attached to this crowd
  147117. * @returns list of agent indices
  147118. */
  147119. getAgents(): number[];
  147120. /**
  147121. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  147122. * @param deltaTime in seconds
  147123. */
  147124. update(deltaTime: number): void;
  147125. /**
  147126. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147127. * The queries will try to find a solution within those bounds
  147128. * default is (1,1,1)
  147129. * @param extent x,y,z value that define the extent around the queries point of reference
  147130. */
  147131. setDefaultQueryExtent(extent: Vector3): void;
  147132. /**
  147133. * Get the Bounding box extent specified by setDefaultQueryExtent
  147134. * @returns the box extent values
  147135. */
  147136. getDefaultQueryExtent(): Vector3;
  147137. /**
  147138. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147139. * @param result output the box extent values
  147140. */
  147141. getDefaultQueryExtentToRef(result: Vector3): void;
  147142. /**
  147143. * Release all resources
  147144. */
  147145. dispose(): void;
  147146. }
  147147. }
  147148. declare module BABYLON {
  147149. /**
  147150. * Class used to enable access to IndexedDB
  147151. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  147152. */
  147153. export class Database implements IOfflineProvider {
  147154. private _callbackManifestChecked;
  147155. private _currentSceneUrl;
  147156. private _db;
  147157. private _enableSceneOffline;
  147158. private _enableTexturesOffline;
  147159. private _manifestVersionFound;
  147160. private _mustUpdateRessources;
  147161. private _hasReachedQuota;
  147162. private _isSupported;
  147163. private _idbFactory;
  147164. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  147165. private static IsUASupportingBlobStorage;
  147166. /**
  147167. * Gets a boolean indicating if Database storate is enabled (off by default)
  147168. */
  147169. static IDBStorageEnabled: boolean;
  147170. /**
  147171. * Gets a boolean indicating if scene must be saved in the database
  147172. */
  147173. get enableSceneOffline(): boolean;
  147174. /**
  147175. * Gets a boolean indicating if textures must be saved in the database
  147176. */
  147177. get enableTexturesOffline(): boolean;
  147178. /**
  147179. * Creates a new Database
  147180. * @param urlToScene defines the url to load the scene
  147181. * @param callbackManifestChecked defines the callback to use when manifest is checked
  147182. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  147183. */
  147184. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  147185. private static _ParseURL;
  147186. private static _ReturnFullUrlLocation;
  147187. private _checkManifestFile;
  147188. /**
  147189. * Open the database and make it available
  147190. * @param successCallback defines the callback to call on success
  147191. * @param errorCallback defines the callback to call on error
  147192. */
  147193. open(successCallback: () => void, errorCallback: () => void): void;
  147194. /**
  147195. * Loads an image from the database
  147196. * @param url defines the url to load from
  147197. * @param image defines the target DOM image
  147198. */
  147199. loadImage(url: string, image: HTMLImageElement): void;
  147200. private _loadImageFromDBAsync;
  147201. private _saveImageIntoDBAsync;
  147202. private _checkVersionFromDB;
  147203. private _loadVersionFromDBAsync;
  147204. private _saveVersionIntoDBAsync;
  147205. /**
  147206. * Loads a file from database
  147207. * @param url defines the URL to load from
  147208. * @param sceneLoaded defines a callback to call on success
  147209. * @param progressCallBack defines a callback to call when progress changed
  147210. * @param errorCallback defines a callback to call on error
  147211. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  147212. */
  147213. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  147214. private _loadFileAsync;
  147215. private _saveFileAsync;
  147216. /**
  147217. * Validates if xhr data is correct
  147218. * @param xhr defines the request to validate
  147219. * @param dataType defines the expected data type
  147220. * @returns true if data is correct
  147221. */
  147222. private static _ValidateXHRData;
  147223. }
  147224. }
  147225. declare module BABYLON {
  147226. /** @hidden */
  147227. export var gpuUpdateParticlesPixelShader: {
  147228. name: string;
  147229. shader: string;
  147230. };
  147231. }
  147232. declare module BABYLON {
  147233. /** @hidden */
  147234. export var gpuUpdateParticlesVertexShader: {
  147235. name: string;
  147236. shader: string;
  147237. };
  147238. }
  147239. declare module BABYLON {
  147240. /** @hidden */
  147241. export var clipPlaneFragmentDeclaration2: {
  147242. name: string;
  147243. shader: string;
  147244. };
  147245. }
  147246. declare module BABYLON {
  147247. /** @hidden */
  147248. export var gpuRenderParticlesPixelShader: {
  147249. name: string;
  147250. shader: string;
  147251. };
  147252. }
  147253. declare module BABYLON {
  147254. /** @hidden */
  147255. export var clipPlaneVertexDeclaration2: {
  147256. name: string;
  147257. shader: string;
  147258. };
  147259. }
  147260. declare module BABYLON {
  147261. /** @hidden */
  147262. export var gpuRenderParticlesVertexShader: {
  147263. name: string;
  147264. shader: string;
  147265. };
  147266. }
  147267. declare module BABYLON {
  147268. /**
  147269. * This represents a GPU particle system in Babylon
  147270. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  147271. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  147272. */
  147273. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  147274. /**
  147275. * The layer mask we are rendering the particles through.
  147276. */
  147277. layerMask: number;
  147278. private _capacity;
  147279. private _activeCount;
  147280. private _currentActiveCount;
  147281. private _accumulatedCount;
  147282. private _renderEffect;
  147283. private _updateEffect;
  147284. private _buffer0;
  147285. private _buffer1;
  147286. private _spriteBuffer;
  147287. private _updateVAO;
  147288. private _renderVAO;
  147289. private _targetIndex;
  147290. private _sourceBuffer;
  147291. private _targetBuffer;
  147292. private _currentRenderId;
  147293. private _started;
  147294. private _stopped;
  147295. private _timeDelta;
  147296. private _randomTexture;
  147297. private _randomTexture2;
  147298. private _attributesStrideSize;
  147299. private _updateEffectOptions;
  147300. private _randomTextureSize;
  147301. private _actualFrame;
  147302. private _customEffect;
  147303. private readonly _rawTextureWidth;
  147304. /**
  147305. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  147306. */
  147307. static get IsSupported(): boolean;
  147308. /**
  147309. * An event triggered when the system is disposed.
  147310. */
  147311. onDisposeObservable: Observable<IParticleSystem>;
  147312. /**
  147313. * Gets the maximum number of particles active at the same time.
  147314. * @returns The max number of active particles.
  147315. */
  147316. getCapacity(): number;
  147317. /**
  147318. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  147319. * to override the particles.
  147320. */
  147321. forceDepthWrite: boolean;
  147322. /**
  147323. * Gets or set the number of active particles
  147324. */
  147325. get activeParticleCount(): number;
  147326. set activeParticleCount(value: number);
  147327. private _preWarmDone;
  147328. /**
  147329. * Specifies if the particles are updated in emitter local space or world space.
  147330. */
  147331. isLocal: boolean;
  147332. /** Gets or sets a matrix to use to compute projection */
  147333. defaultProjectionMatrix: Matrix;
  147334. /**
  147335. * Is this system ready to be used/rendered
  147336. * @return true if the system is ready
  147337. */
  147338. isReady(): boolean;
  147339. /**
  147340. * Gets if the system has been started. (Note: this will still be true after stop is called)
  147341. * @returns True if it has been started, otherwise false.
  147342. */
  147343. isStarted(): boolean;
  147344. /**
  147345. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  147346. * @returns True if it has been stopped, otherwise false.
  147347. */
  147348. isStopped(): boolean;
  147349. /**
  147350. * Gets a boolean indicating that the system is stopping
  147351. * @returns true if the system is currently stopping
  147352. */
  147353. isStopping(): boolean;
  147354. /**
  147355. * Gets the number of particles active at the same time.
  147356. * @returns The number of active particles.
  147357. */
  147358. getActiveCount(): number;
  147359. /**
  147360. * Starts the particle system and begins to emit
  147361. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  147362. */
  147363. start(delay?: number): void;
  147364. /**
  147365. * Stops the particle system.
  147366. */
  147367. stop(): void;
  147368. /**
  147369. * Remove all active particles
  147370. */
  147371. reset(): void;
  147372. /**
  147373. * Returns the string "GPUParticleSystem"
  147374. * @returns a string containing the class name
  147375. */
  147376. getClassName(): string;
  147377. /**
  147378. * Gets the custom effect used to render the particles
  147379. * @param blendMode Blend mode for which the effect should be retrieved
  147380. * @returns The effect
  147381. */
  147382. getCustomEffect(blendMode?: number): Nullable<Effect>;
  147383. /**
  147384. * Sets the custom effect used to render the particles
  147385. * @param effect The effect to set
  147386. * @param blendMode Blend mode for which the effect should be set
  147387. */
  147388. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  147389. /** @hidden */
  147390. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  147391. /**
  147392. * Observable that will be called just before the particles are drawn
  147393. */
  147394. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  147395. /**
  147396. * Gets the name of the particle vertex shader
  147397. */
  147398. get vertexShaderName(): string;
  147399. private _colorGradientsTexture;
  147400. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  147401. /**
  147402. * Adds a new color gradient
  147403. * @param gradient defines the gradient to use (between 0 and 1)
  147404. * @param color1 defines the color to affect to the specified gradient
  147405. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  147406. * @returns the current particle system
  147407. */
  147408. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  147409. private _refreshColorGradient;
  147410. /** Force the system to rebuild all gradients that need to be resync */
  147411. forceRefreshGradients(): void;
  147412. /**
  147413. * Remove a specific color gradient
  147414. * @param gradient defines the gradient to remove
  147415. * @returns the current particle system
  147416. */
  147417. removeColorGradient(gradient: number): GPUParticleSystem;
  147418. private _angularSpeedGradientsTexture;
  147419. private _sizeGradientsTexture;
  147420. private _velocityGradientsTexture;
  147421. private _limitVelocityGradientsTexture;
  147422. private _dragGradientsTexture;
  147423. private _addFactorGradient;
  147424. /**
  147425. * Adds a new size gradient
  147426. * @param gradient defines the gradient to use (between 0 and 1)
  147427. * @param factor defines the size factor to affect to the specified gradient
  147428. * @returns the current particle system
  147429. */
  147430. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  147431. /**
  147432. * Remove a specific size gradient
  147433. * @param gradient defines the gradient to remove
  147434. * @returns the current particle system
  147435. */
  147436. removeSizeGradient(gradient: number): GPUParticleSystem;
  147437. private _refreshFactorGradient;
  147438. /**
  147439. * Adds a new angular speed gradient
  147440. * @param gradient defines the gradient to use (between 0 and 1)
  147441. * @param factor defines the angular speed to affect to the specified gradient
  147442. * @returns the current particle system
  147443. */
  147444. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  147445. /**
  147446. * Remove a specific angular speed gradient
  147447. * @param gradient defines the gradient to remove
  147448. * @returns the current particle system
  147449. */
  147450. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  147451. /**
  147452. * Adds a new velocity gradient
  147453. * @param gradient defines the gradient to use (between 0 and 1)
  147454. * @param factor defines the velocity to affect to the specified gradient
  147455. * @returns the current particle system
  147456. */
  147457. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  147458. /**
  147459. * Remove a specific velocity gradient
  147460. * @param gradient defines the gradient to remove
  147461. * @returns the current particle system
  147462. */
  147463. removeVelocityGradient(gradient: number): GPUParticleSystem;
  147464. /**
  147465. * Adds a new limit velocity gradient
  147466. * @param gradient defines the gradient to use (between 0 and 1)
  147467. * @param factor defines the limit velocity value to affect to the specified gradient
  147468. * @returns the current particle system
  147469. */
  147470. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  147471. /**
  147472. * Remove a specific limit velocity gradient
  147473. * @param gradient defines the gradient to remove
  147474. * @returns the current particle system
  147475. */
  147476. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  147477. /**
  147478. * Adds a new drag gradient
  147479. * @param gradient defines the gradient to use (between 0 and 1)
  147480. * @param factor defines the drag value to affect to the specified gradient
  147481. * @returns the current particle system
  147482. */
  147483. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  147484. /**
  147485. * Remove a specific drag gradient
  147486. * @param gradient defines the gradient to remove
  147487. * @returns the current particle system
  147488. */
  147489. removeDragGradient(gradient: number): GPUParticleSystem;
  147490. /**
  147491. * Not supported by GPUParticleSystem
  147492. * @param gradient defines the gradient to use (between 0 and 1)
  147493. * @param factor defines the emit rate value to affect to the specified gradient
  147494. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  147495. * @returns the current particle system
  147496. */
  147497. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  147498. /**
  147499. * Not supported by GPUParticleSystem
  147500. * @param gradient defines the gradient to remove
  147501. * @returns the current particle system
  147502. */
  147503. removeEmitRateGradient(gradient: number): IParticleSystem;
  147504. /**
  147505. * Not supported by GPUParticleSystem
  147506. * @param gradient defines the gradient to use (between 0 and 1)
  147507. * @param factor defines the start size value to affect to the specified gradient
  147508. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  147509. * @returns the current particle system
  147510. */
  147511. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  147512. /**
  147513. * Not supported by GPUParticleSystem
  147514. * @param gradient defines the gradient to remove
  147515. * @returns the current particle system
  147516. */
  147517. removeStartSizeGradient(gradient: number): IParticleSystem;
  147518. /**
  147519. * Not supported by GPUParticleSystem
  147520. * @param gradient defines the gradient to use (between 0 and 1)
  147521. * @param min defines the color remap minimal range
  147522. * @param max defines the color remap maximal range
  147523. * @returns the current particle system
  147524. */
  147525. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  147526. /**
  147527. * Not supported by GPUParticleSystem
  147528. * @param gradient defines the gradient to remove
  147529. * @returns the current particle system
  147530. */
  147531. removeColorRemapGradient(): IParticleSystem;
  147532. /**
  147533. * Not supported by GPUParticleSystem
  147534. * @param gradient defines the gradient to use (between 0 and 1)
  147535. * @param min defines the alpha remap minimal range
  147536. * @param max defines the alpha remap maximal range
  147537. * @returns the current particle system
  147538. */
  147539. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  147540. /**
  147541. * Not supported by GPUParticleSystem
  147542. * @param gradient defines the gradient to remove
  147543. * @returns the current particle system
  147544. */
  147545. removeAlphaRemapGradient(): IParticleSystem;
  147546. /**
  147547. * Not supported by GPUParticleSystem
  147548. * @param gradient defines the gradient to use (between 0 and 1)
  147549. * @param color defines the color to affect to the specified gradient
  147550. * @returns the current particle system
  147551. */
  147552. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  147553. /**
  147554. * Not supported by GPUParticleSystem
  147555. * @param gradient defines the gradient to remove
  147556. * @returns the current particle system
  147557. */
  147558. removeRampGradient(): IParticleSystem;
  147559. /**
  147560. * Not supported by GPUParticleSystem
  147561. * @returns the list of ramp gradients
  147562. */
  147563. getRampGradients(): Nullable<Array<Color3Gradient>>;
  147564. /**
  147565. * Not supported by GPUParticleSystem
  147566. * Gets or sets a boolean indicating that ramp gradients must be used
  147567. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  147568. */
  147569. get useRampGradients(): boolean;
  147570. set useRampGradients(value: boolean);
  147571. /**
  147572. * Not supported by GPUParticleSystem
  147573. * @param gradient defines the gradient to use (between 0 and 1)
  147574. * @param factor defines the life time factor to affect to the specified gradient
  147575. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  147576. * @returns the current particle system
  147577. */
  147578. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  147579. /**
  147580. * Not supported by GPUParticleSystem
  147581. * @param gradient defines the gradient to remove
  147582. * @returns the current particle system
  147583. */
  147584. removeLifeTimeGradient(gradient: number): IParticleSystem;
  147585. /**
  147586. * Instantiates a GPU particle system.
  147587. * 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.
  147588. * @param name The name of the particle system
  147589. * @param options The options used to create the system
  147590. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  147591. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  147592. * @param customEffect a custom effect used to change the way particles are rendered by default
  147593. */
  147594. constructor(name: string, options: Partial<{
  147595. capacity: number;
  147596. randomTextureSize: number;
  147597. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  147598. protected _reset(): void;
  147599. private _createUpdateVAO;
  147600. private _createRenderVAO;
  147601. private _initialize;
  147602. /** @hidden */
  147603. _recreateUpdateEffect(): void;
  147604. private _getEffect;
  147605. /**
  147606. * Fill the defines array according to the current settings of the particle system
  147607. * @param defines Array to be updated
  147608. * @param blendMode blend mode to take into account when updating the array
  147609. */
  147610. fillDefines(defines: Array<string>, blendMode?: number): void;
  147611. /**
  147612. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  147613. * @param uniforms Uniforms array to fill
  147614. * @param attributes Attributes array to fill
  147615. * @param samplers Samplers array to fill
  147616. */
  147617. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  147618. /** @hidden */
  147619. _recreateRenderEffect(): Effect;
  147620. /**
  147621. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  147622. * @param preWarm defines if we are in the pre-warmimg phase
  147623. */
  147624. animate(preWarm?: boolean): void;
  147625. private _createFactorGradientTexture;
  147626. private _createSizeGradientTexture;
  147627. private _createAngularSpeedGradientTexture;
  147628. private _createVelocityGradientTexture;
  147629. private _createLimitVelocityGradientTexture;
  147630. private _createDragGradientTexture;
  147631. private _createColorGradientTexture;
  147632. /**
  147633. * Renders the particle system in its current state
  147634. * @param preWarm defines if the system should only update the particles but not render them
  147635. * @returns the current number of particles
  147636. */
  147637. render(preWarm?: boolean): number;
  147638. /**
  147639. * Rebuilds the particle system
  147640. */
  147641. rebuild(): void;
  147642. private _releaseBuffers;
  147643. private _releaseVAOs;
  147644. /**
  147645. * Disposes the particle system and free the associated resources
  147646. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  147647. */
  147648. dispose(disposeTexture?: boolean): void;
  147649. /**
  147650. * Clones the particle system.
  147651. * @param name The name of the cloned object
  147652. * @param newEmitter The new emitter to use
  147653. * @returns the cloned particle system
  147654. */
  147655. clone(name: string, newEmitter: any): GPUParticleSystem;
  147656. /**
  147657. * Serializes the particle system to a JSON object
  147658. * @param serializeTexture defines if the texture must be serialized as well
  147659. * @returns the JSON object
  147660. */
  147661. serialize(serializeTexture?: boolean): any;
  147662. /**
  147663. * Parses a JSON object to create a GPU particle system.
  147664. * @param parsedParticleSystem The JSON object to parse
  147665. * @param sceneOrEngine The scene or the engine to create the particle system in
  147666. * @param rootUrl The root url to use to load external dependencies like texture
  147667. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  147668. * @returns the parsed GPU particle system
  147669. */
  147670. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  147671. }
  147672. }
  147673. declare module BABYLON {
  147674. /**
  147675. * Represents a set of particle systems working together to create a specific effect
  147676. */
  147677. export class ParticleSystemSet implements IDisposable {
  147678. /**
  147679. * Gets or sets base Assets URL
  147680. */
  147681. static BaseAssetsUrl: string;
  147682. private _emitterCreationOptions;
  147683. private _emitterNode;
  147684. /**
  147685. * Gets the particle system list
  147686. */
  147687. systems: IParticleSystem[];
  147688. /**
  147689. * Gets the emitter node used with this set
  147690. */
  147691. get emitterNode(): Nullable<TransformNode>;
  147692. /**
  147693. * Creates a new emitter mesh as a sphere
  147694. * @param options defines the options used to create the sphere
  147695. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  147696. * @param scene defines the hosting scene
  147697. */
  147698. setEmitterAsSphere(options: {
  147699. diameter: number;
  147700. segments: number;
  147701. color: Color3;
  147702. }, renderingGroupId: number, scene: Scene): void;
  147703. /**
  147704. * Starts all particle systems of the set
  147705. * @param emitter defines an optional mesh to use as emitter for the particle systems
  147706. */
  147707. start(emitter?: AbstractMesh): void;
  147708. /**
  147709. * Release all associated resources
  147710. */
  147711. dispose(): void;
  147712. /**
  147713. * Serialize the set into a JSON compatible object
  147714. * @param serializeTexture defines if the texture must be serialized as well
  147715. * @returns a JSON compatible representation of the set
  147716. */
  147717. serialize(serializeTexture?: boolean): any;
  147718. /**
  147719. * Parse a new ParticleSystemSet from a serialized source
  147720. * @param data defines a JSON compatible representation of the set
  147721. * @param scene defines the hosting scene
  147722. * @param gpu defines if we want GPU particles or CPU particles
  147723. * @returns a new ParticleSystemSet
  147724. */
  147725. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  147726. }
  147727. }
  147728. declare module BABYLON {
  147729. /**
  147730. * This class is made for on one-liner static method to help creating particle system set.
  147731. */
  147732. export class ParticleHelper {
  147733. /**
  147734. * Gets or sets base Assets URL
  147735. */
  147736. static BaseAssetsUrl: string;
  147737. /** Define the Url to load snippets */
  147738. static SnippetUrl: string;
  147739. /**
  147740. * Create a default particle system that you can tweak
  147741. * @param emitter defines the emitter to use
  147742. * @param capacity defines the system capacity (default is 500 particles)
  147743. * @param scene defines the hosting scene
  147744. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  147745. * @returns the new Particle system
  147746. */
  147747. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  147748. /**
  147749. * This is the main static method (one-liner) of this helper to create different particle systems
  147750. * @param type This string represents the type to the particle system to create
  147751. * @param scene The scene where the particle system should live
  147752. * @param gpu If the system will use gpu
  147753. * @returns the ParticleSystemSet created
  147754. */
  147755. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  147756. /**
  147757. * Static function used to export a particle system to a ParticleSystemSet variable.
  147758. * Please note that the emitter shape is not exported
  147759. * @param systems defines the particle systems to export
  147760. * @returns the created particle system set
  147761. */
  147762. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  147763. /**
  147764. * Creates a particle system from a snippet saved in a remote file
  147765. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  147766. * @param url defines the url to load from
  147767. * @param scene defines the hosting scene
  147768. * @param gpu If the system will use gpu
  147769. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  147770. * @returns a promise that will resolve to the new particle system
  147771. */
  147772. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  147773. /**
  147774. * Creates a particle system from a snippet saved by the particle system editor
  147775. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  147776. * @param scene defines the hosting scene
  147777. * @param gpu If the system will use gpu
  147778. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  147779. * @returns a promise that will resolve to the new particle system
  147780. */
  147781. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  147782. }
  147783. }
  147784. declare module BABYLON {
  147785. interface Engine {
  147786. /**
  147787. * Create an effect to use with particle systems.
  147788. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  147789. * the particle system for which you want to create a custom effect in the last parameter
  147790. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  147791. * @param uniformsNames defines a list of attribute names
  147792. * @param samplers defines an array of string used to represent textures
  147793. * @param defines defines the string containing the defines to use to compile the shaders
  147794. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  147795. * @param onCompiled defines a function to call when the effect creation is successful
  147796. * @param onError defines a function to call when the effect creation has failed
  147797. * @param particleSystem the particle system you want to create the effect for
  147798. * @returns the new Effect
  147799. */
  147800. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  147801. }
  147802. interface Mesh {
  147803. /**
  147804. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  147805. * @returns an array of IParticleSystem
  147806. */
  147807. getEmittedParticleSystems(): IParticleSystem[];
  147808. /**
  147809. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  147810. * @returns an array of IParticleSystem
  147811. */
  147812. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  147813. }
  147814. }
  147815. declare module BABYLON {
  147816. /** Defines the 4 color options */
  147817. export enum PointColor {
  147818. /** color value */
  147819. Color = 2,
  147820. /** uv value */
  147821. UV = 1,
  147822. /** random value */
  147823. Random = 0,
  147824. /** stated value */
  147825. Stated = 3
  147826. }
  147827. /**
  147828. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  147829. * 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.
  147830. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  147831. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  147832. *
  147833. * Full documentation here : TO BE ENTERED
  147834. */
  147835. export class PointsCloudSystem implements IDisposable {
  147836. /**
  147837. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  147838. * Example : var p = SPS.particles[i];
  147839. */
  147840. particles: CloudPoint[];
  147841. /**
  147842. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  147843. */
  147844. nbParticles: number;
  147845. /**
  147846. * This a counter for your own usage. It's not set by any SPS functions.
  147847. */
  147848. counter: number;
  147849. /**
  147850. * The PCS name. This name is also given to the underlying mesh.
  147851. */
  147852. name: string;
  147853. /**
  147854. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  147855. */
  147856. mesh: Mesh;
  147857. /**
  147858. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  147859. * Please read :
  147860. */
  147861. vars: any;
  147862. /**
  147863. * @hidden
  147864. */
  147865. _size: number;
  147866. private _scene;
  147867. private _promises;
  147868. private _positions;
  147869. private _indices;
  147870. private _normals;
  147871. private _colors;
  147872. private _uvs;
  147873. private _indices32;
  147874. private _positions32;
  147875. private _colors32;
  147876. private _uvs32;
  147877. private _updatable;
  147878. private _isVisibilityBoxLocked;
  147879. private _alwaysVisible;
  147880. private _groups;
  147881. private _groupCounter;
  147882. private _computeParticleColor;
  147883. private _computeParticleTexture;
  147884. private _computeParticleRotation;
  147885. private _computeBoundingBox;
  147886. private _isReady;
  147887. /**
  147888. * Creates a PCS (Points Cloud System) object
  147889. * @param name (String) is the PCS name, this will be the underlying mesh name
  147890. * @param pointSize (number) is the size for each point
  147891. * @param scene (Scene) is the scene in which the PCS is added
  147892. * @param options defines the options of the PCS e.g.
  147893. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  147894. */
  147895. constructor(name: string, pointSize: number, scene: Scene, options?: {
  147896. updatable?: boolean;
  147897. });
  147898. /**
  147899. * Builds the PCS underlying mesh. Returns a standard Mesh.
  147900. * If no points were added to the PCS, the returned mesh is just a single point.
  147901. * @returns a promise for the created mesh
  147902. */
  147903. buildMeshAsync(): Promise<Mesh>;
  147904. /**
  147905. * @hidden
  147906. */
  147907. private _buildMesh;
  147908. private _addParticle;
  147909. private _randomUnitVector;
  147910. private _getColorIndicesForCoord;
  147911. private _setPointsColorOrUV;
  147912. private _colorFromTexture;
  147913. private _calculateDensity;
  147914. /**
  147915. * Adds points to the PCS in random positions within a unit sphere
  147916. * @param nb (positive integer) the number of particles to be created from this model
  147917. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  147918. * @returns the number of groups in the system
  147919. */
  147920. addPoints(nb: number, pointFunction?: any): number;
  147921. /**
  147922. * Adds points to the PCS from the surface of the model shape
  147923. * @param mesh is any Mesh object that will be used as a surface model for the points
  147924. * @param nb (positive integer) the number of particles to be created from this model
  147925. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  147926. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  147927. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  147928. * @returns the number of groups in the system
  147929. */
  147930. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  147931. /**
  147932. * Adds points to the PCS inside the model shape
  147933. * @param mesh is any Mesh object that will be used as a surface model for the points
  147934. * @param nb (positive integer) the number of particles to be created from this model
  147935. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  147936. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  147937. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  147938. * @returns the number of groups in the system
  147939. */
  147940. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  147941. /**
  147942. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  147943. * This method calls `updateParticle()` for each particle of the SPS.
  147944. * For an animated SPS, it is usually called within the render loop.
  147945. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  147946. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  147947. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  147948. * @returns the PCS.
  147949. */
  147950. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  147951. /**
  147952. * Disposes the PCS.
  147953. */
  147954. dispose(): void;
  147955. /**
  147956. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  147957. * doc :
  147958. * @returns the PCS.
  147959. */
  147960. refreshVisibleSize(): PointsCloudSystem;
  147961. /**
  147962. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  147963. * @param size the size (float) of the visibility box
  147964. * note : this doesn't lock the PCS mesh bounding box.
  147965. * doc :
  147966. */
  147967. setVisibilityBox(size: number): void;
  147968. /**
  147969. * Gets whether the PCS is always visible or not
  147970. * doc :
  147971. */
  147972. get isAlwaysVisible(): boolean;
  147973. /**
  147974. * Sets the PCS as always visible or not
  147975. * doc :
  147976. */
  147977. set isAlwaysVisible(val: boolean);
  147978. /**
  147979. * Tells to `setParticles()` to compute the particle rotations or not
  147980. * Default value : false. The PCS is faster when it's set to false
  147981. * Note : particle rotations are only applied to parent particles
  147982. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  147983. */
  147984. set computeParticleRotation(val: boolean);
  147985. /**
  147986. * Tells to `setParticles()` to compute the particle colors or not.
  147987. * Default value : true. The PCS is faster when it's set to false.
  147988. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  147989. */
  147990. set computeParticleColor(val: boolean);
  147991. set computeParticleTexture(val: boolean);
  147992. /**
  147993. * Gets if `setParticles()` computes the particle colors or not.
  147994. * Default value : false. The PCS is faster when it's set to false.
  147995. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  147996. */
  147997. get computeParticleColor(): boolean;
  147998. /**
  147999. * Gets if `setParticles()` computes the particle textures or not.
  148000. * Default value : false. The PCS is faster when it's set to false.
  148001. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  148002. */
  148003. get computeParticleTexture(): boolean;
  148004. /**
  148005. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  148006. */
  148007. set computeBoundingBox(val: boolean);
  148008. /**
  148009. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  148010. */
  148011. get computeBoundingBox(): boolean;
  148012. /**
  148013. * This function does nothing. It may be overwritten to set all the particle first values.
  148014. * The PCS doesn't call this function, you may have to call it by your own.
  148015. * doc :
  148016. */
  148017. initParticles(): void;
  148018. /**
  148019. * This function does nothing. It may be overwritten to recycle a particle
  148020. * The PCS doesn't call this function, you can to call it
  148021. * doc :
  148022. * @param particle The particle to recycle
  148023. * @returns the recycled particle
  148024. */
  148025. recycleParticle(particle: CloudPoint): CloudPoint;
  148026. /**
  148027. * Updates a particle : this function should be overwritten by the user.
  148028. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  148029. * doc :
  148030. * @example : just set a particle position or velocity and recycle conditions
  148031. * @param particle The particle to update
  148032. * @returns the updated particle
  148033. */
  148034. updateParticle(particle: CloudPoint): CloudPoint;
  148035. /**
  148036. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  148037. * This does nothing and may be overwritten by the user.
  148038. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  148039. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  148040. * @param update the boolean update value actually passed to setParticles()
  148041. */
  148042. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  148043. /**
  148044. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  148045. * This will be passed three parameters.
  148046. * This does nothing and may be overwritten by the user.
  148047. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  148048. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  148049. * @param update the boolean update value actually passed to setParticles()
  148050. */
  148051. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  148052. }
  148053. }
  148054. declare module BABYLON {
  148055. /**
  148056. * Represents one particle of a points cloud system.
  148057. */
  148058. export class CloudPoint {
  148059. /**
  148060. * particle global index
  148061. */
  148062. idx: number;
  148063. /**
  148064. * The color of the particle
  148065. */
  148066. color: Nullable<Color4>;
  148067. /**
  148068. * The world space position of the particle.
  148069. */
  148070. position: Vector3;
  148071. /**
  148072. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  148073. */
  148074. rotation: Vector3;
  148075. /**
  148076. * The world space rotation quaternion of the particle.
  148077. */
  148078. rotationQuaternion: Nullable<Quaternion>;
  148079. /**
  148080. * The uv of the particle.
  148081. */
  148082. uv: Nullable<Vector2>;
  148083. /**
  148084. * The current speed of the particle.
  148085. */
  148086. velocity: Vector3;
  148087. /**
  148088. * The pivot point in the particle local space.
  148089. */
  148090. pivot: Vector3;
  148091. /**
  148092. * Must the particle be translated from its pivot point in its local space ?
  148093. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  148094. * Default : false
  148095. */
  148096. translateFromPivot: boolean;
  148097. /**
  148098. * Index of this particle in the global "positions" array (Internal use)
  148099. * @hidden
  148100. */
  148101. _pos: number;
  148102. /**
  148103. * @hidden Index of this particle in the global "indices" array (Internal use)
  148104. */
  148105. _ind: number;
  148106. /**
  148107. * Group this particle belongs to
  148108. */
  148109. _group: PointsGroup;
  148110. /**
  148111. * Group id of this particle
  148112. */
  148113. groupId: number;
  148114. /**
  148115. * Index of the particle in its group id (Internal use)
  148116. */
  148117. idxInGroup: number;
  148118. /**
  148119. * @hidden Particle BoundingInfo object (Internal use)
  148120. */
  148121. _boundingInfo: BoundingInfo;
  148122. /**
  148123. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  148124. */
  148125. _pcs: PointsCloudSystem;
  148126. /**
  148127. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  148128. */
  148129. _stillInvisible: boolean;
  148130. /**
  148131. * @hidden Last computed particle rotation matrix
  148132. */
  148133. _rotationMatrix: number[];
  148134. /**
  148135. * Parent particle Id, if any.
  148136. * Default null.
  148137. */
  148138. parentId: Nullable<number>;
  148139. /**
  148140. * @hidden Internal global position in the PCS.
  148141. */
  148142. _globalPosition: Vector3;
  148143. /**
  148144. * Creates a Point Cloud object.
  148145. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  148146. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  148147. * @param group (PointsGroup) is the group the particle belongs to
  148148. * @param groupId (integer) is the group identifier in the PCS.
  148149. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  148150. * @param pcs defines the PCS it is associated to
  148151. */
  148152. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  148153. /**
  148154. * get point size
  148155. */
  148156. get size(): Vector3;
  148157. /**
  148158. * Set point size
  148159. */
  148160. set size(scale: Vector3);
  148161. /**
  148162. * Legacy support, changed quaternion to rotationQuaternion
  148163. */
  148164. get quaternion(): Nullable<Quaternion>;
  148165. /**
  148166. * Legacy support, changed quaternion to rotationQuaternion
  148167. */
  148168. set quaternion(q: Nullable<Quaternion>);
  148169. /**
  148170. * Returns a boolean. True if the particle intersects a mesh, else false
  148171. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  148172. * @param target is the object (point or mesh) what the intersection is computed against
  148173. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  148174. * @returns true if it intersects
  148175. */
  148176. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  148177. /**
  148178. * get the rotation matrix of the particle
  148179. * @hidden
  148180. */
  148181. getRotationMatrix(m: Matrix): void;
  148182. }
  148183. /**
  148184. * Represents a group of points in a points cloud system
  148185. * * PCS internal tool, don't use it manually.
  148186. */
  148187. export class PointsGroup {
  148188. /**
  148189. * The group id
  148190. * @hidden
  148191. */
  148192. groupID: number;
  148193. /**
  148194. * image data for group (internal use)
  148195. * @hidden
  148196. */
  148197. _groupImageData: Nullable<ArrayBufferView>;
  148198. /**
  148199. * Image Width (internal use)
  148200. * @hidden
  148201. */
  148202. _groupImgWidth: number;
  148203. /**
  148204. * Image Height (internal use)
  148205. * @hidden
  148206. */
  148207. _groupImgHeight: number;
  148208. /**
  148209. * Custom position function (internal use)
  148210. * @hidden
  148211. */
  148212. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  148213. /**
  148214. * density per facet for surface points
  148215. * @hidden
  148216. */
  148217. _groupDensity: number[];
  148218. /**
  148219. * Only when points are colored by texture carries pointer to texture list array
  148220. * @hidden
  148221. */
  148222. _textureNb: number;
  148223. /**
  148224. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  148225. * PCS internal tool, don't use it manually.
  148226. * @hidden
  148227. */
  148228. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  148229. }
  148230. }
  148231. declare module BABYLON {
  148232. interface Scene {
  148233. /** @hidden (Backing field) */
  148234. _physicsEngine: Nullable<IPhysicsEngine>;
  148235. /** @hidden */
  148236. _physicsTimeAccumulator: number;
  148237. /**
  148238. * Gets the current physics engine
  148239. * @returns a IPhysicsEngine or null if none attached
  148240. */
  148241. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  148242. /**
  148243. * Enables physics to the current scene
  148244. * @param gravity defines the scene's gravity for the physics engine
  148245. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  148246. * @return a boolean indicating if the physics engine was initialized
  148247. */
  148248. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  148249. /**
  148250. * Disables and disposes the physics engine associated with the scene
  148251. */
  148252. disablePhysicsEngine(): void;
  148253. /**
  148254. * Gets a boolean indicating if there is an active physics engine
  148255. * @returns a boolean indicating if there is an active physics engine
  148256. */
  148257. isPhysicsEnabled(): boolean;
  148258. /**
  148259. * Deletes a physics compound impostor
  148260. * @param compound defines the compound to delete
  148261. */
  148262. deleteCompoundImpostor(compound: any): void;
  148263. /**
  148264. * An event triggered when physic simulation is about to be run
  148265. */
  148266. onBeforePhysicsObservable: Observable<Scene>;
  148267. /**
  148268. * An event triggered when physic simulation has been done
  148269. */
  148270. onAfterPhysicsObservable: Observable<Scene>;
  148271. }
  148272. interface AbstractMesh {
  148273. /** @hidden */
  148274. _physicsImpostor: Nullable<PhysicsImpostor>;
  148275. /**
  148276. * Gets or sets impostor used for physic simulation
  148277. * @see https://doc.babylonjs.com/features/physics_engine
  148278. */
  148279. physicsImpostor: Nullable<PhysicsImpostor>;
  148280. /**
  148281. * Gets the current physics impostor
  148282. * @see https://doc.babylonjs.com/features/physics_engine
  148283. * @returns a physics impostor or null
  148284. */
  148285. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  148286. /** Apply a physic impulse to the mesh
  148287. * @param force defines the force to apply
  148288. * @param contactPoint defines where to apply the force
  148289. * @returns the current mesh
  148290. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  148291. */
  148292. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  148293. /**
  148294. * Creates a physic joint between two meshes
  148295. * @param otherMesh defines the other mesh to use
  148296. * @param pivot1 defines the pivot to use on this mesh
  148297. * @param pivot2 defines the pivot to use on the other mesh
  148298. * @param options defines additional options (can be plugin dependent)
  148299. * @returns the current mesh
  148300. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  148301. */
  148302. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  148303. /** @hidden */
  148304. _disposePhysicsObserver: Nullable<Observer<Node>>;
  148305. }
  148306. /**
  148307. * Defines the physics engine scene component responsible to manage a physics engine
  148308. */
  148309. export class PhysicsEngineSceneComponent implements ISceneComponent {
  148310. /**
  148311. * The component name helpful to identify the component in the list of scene components.
  148312. */
  148313. readonly name: string;
  148314. /**
  148315. * The scene the component belongs to.
  148316. */
  148317. scene: Scene;
  148318. /**
  148319. * Creates a new instance of the component for the given scene
  148320. * @param scene Defines the scene to register the component in
  148321. */
  148322. constructor(scene: Scene);
  148323. /**
  148324. * Registers the component in a given scene
  148325. */
  148326. register(): void;
  148327. /**
  148328. * Rebuilds the elements related to this component in case of
  148329. * context lost for instance.
  148330. */
  148331. rebuild(): void;
  148332. /**
  148333. * Disposes the component and the associated ressources
  148334. */
  148335. dispose(): void;
  148336. }
  148337. }
  148338. declare module BABYLON {
  148339. /**
  148340. * A helper for physics simulations
  148341. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148342. */
  148343. export class PhysicsHelper {
  148344. private _scene;
  148345. private _physicsEngine;
  148346. /**
  148347. * Initializes the Physics helper
  148348. * @param scene Babylon.js scene
  148349. */
  148350. constructor(scene: Scene);
  148351. /**
  148352. * Applies a radial explosion impulse
  148353. * @param origin the origin of the explosion
  148354. * @param radiusOrEventOptions the radius or the options of radial explosion
  148355. * @param strength the explosion strength
  148356. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148357. * @returns A physics radial explosion event, or null
  148358. */
  148359. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  148360. /**
  148361. * Applies a radial explosion force
  148362. * @param origin the origin of the explosion
  148363. * @param radiusOrEventOptions the radius or the options of radial explosion
  148364. * @param strength the explosion strength
  148365. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148366. * @returns A physics radial explosion event, or null
  148367. */
  148368. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  148369. /**
  148370. * Creates a gravitational field
  148371. * @param origin the origin of the explosion
  148372. * @param radiusOrEventOptions the radius or the options of radial explosion
  148373. * @param strength the explosion strength
  148374. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148375. * @returns A physics gravitational field event, or null
  148376. */
  148377. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  148378. /**
  148379. * Creates a physics updraft event
  148380. * @param origin the origin of the updraft
  148381. * @param radiusOrEventOptions the radius or the options of the updraft
  148382. * @param strength the strength of the updraft
  148383. * @param height the height of the updraft
  148384. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  148385. * @returns A physics updraft event, or null
  148386. */
  148387. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  148388. /**
  148389. * Creates a physics vortex event
  148390. * @param origin the of the vortex
  148391. * @param radiusOrEventOptions the radius or the options of the vortex
  148392. * @param strength the strength of the vortex
  148393. * @param height the height of the vortex
  148394. * @returns a Physics vortex event, or null
  148395. * A physics vortex event or null
  148396. */
  148397. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  148398. }
  148399. /**
  148400. * Represents a physics radial explosion event
  148401. */
  148402. class PhysicsRadialExplosionEvent {
  148403. private _scene;
  148404. private _options;
  148405. private _sphere;
  148406. private _dataFetched;
  148407. /**
  148408. * Initializes a radial explosioin event
  148409. * @param _scene BabylonJS scene
  148410. * @param _options The options for the vortex event
  148411. */
  148412. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  148413. /**
  148414. * Returns the data related to the radial explosion event (sphere).
  148415. * @returns The radial explosion event data
  148416. */
  148417. getData(): PhysicsRadialExplosionEventData;
  148418. /**
  148419. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  148420. * @param impostor A physics imposter
  148421. * @param origin the origin of the explosion
  148422. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  148423. */
  148424. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  148425. /**
  148426. * Triggers affecterd impostors callbacks
  148427. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  148428. */
  148429. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  148430. /**
  148431. * Disposes the sphere.
  148432. * @param force Specifies if the sphere should be disposed by force
  148433. */
  148434. dispose(force?: boolean): void;
  148435. /*** Helpers ***/
  148436. private _prepareSphere;
  148437. private _intersectsWithSphere;
  148438. }
  148439. /**
  148440. * Represents a gravitational field event
  148441. */
  148442. class PhysicsGravitationalFieldEvent {
  148443. private _physicsHelper;
  148444. private _scene;
  148445. private _origin;
  148446. private _options;
  148447. private _tickCallback;
  148448. private _sphere;
  148449. private _dataFetched;
  148450. /**
  148451. * Initializes the physics gravitational field event
  148452. * @param _physicsHelper A physics helper
  148453. * @param _scene BabylonJS scene
  148454. * @param _origin The origin position of the gravitational field event
  148455. * @param _options The options for the vortex event
  148456. */
  148457. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  148458. /**
  148459. * Returns the data related to the gravitational field event (sphere).
  148460. * @returns A gravitational field event
  148461. */
  148462. getData(): PhysicsGravitationalFieldEventData;
  148463. /**
  148464. * Enables the gravitational field.
  148465. */
  148466. enable(): void;
  148467. /**
  148468. * Disables the gravitational field.
  148469. */
  148470. disable(): void;
  148471. /**
  148472. * Disposes the sphere.
  148473. * @param force The force to dispose from the gravitational field event
  148474. */
  148475. dispose(force?: boolean): void;
  148476. private _tick;
  148477. }
  148478. /**
  148479. * Represents a physics updraft event
  148480. */
  148481. class PhysicsUpdraftEvent {
  148482. private _scene;
  148483. private _origin;
  148484. private _options;
  148485. private _physicsEngine;
  148486. private _originTop;
  148487. private _originDirection;
  148488. private _tickCallback;
  148489. private _cylinder;
  148490. private _cylinderPosition;
  148491. private _dataFetched;
  148492. /**
  148493. * Initializes the physics updraft event
  148494. * @param _scene BabylonJS scene
  148495. * @param _origin The origin position of the updraft
  148496. * @param _options The options for the updraft event
  148497. */
  148498. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  148499. /**
  148500. * Returns the data related to the updraft event (cylinder).
  148501. * @returns A physics updraft event
  148502. */
  148503. getData(): PhysicsUpdraftEventData;
  148504. /**
  148505. * Enables the updraft.
  148506. */
  148507. enable(): void;
  148508. /**
  148509. * Disables the updraft.
  148510. */
  148511. disable(): void;
  148512. /**
  148513. * Disposes the cylinder.
  148514. * @param force Specifies if the updraft should be disposed by force
  148515. */
  148516. dispose(force?: boolean): void;
  148517. private getImpostorHitData;
  148518. private _tick;
  148519. /*** Helpers ***/
  148520. private _prepareCylinder;
  148521. private _intersectsWithCylinder;
  148522. }
  148523. /**
  148524. * Represents a physics vortex event
  148525. */
  148526. class PhysicsVortexEvent {
  148527. private _scene;
  148528. private _origin;
  148529. private _options;
  148530. private _physicsEngine;
  148531. private _originTop;
  148532. private _tickCallback;
  148533. private _cylinder;
  148534. private _cylinderPosition;
  148535. private _dataFetched;
  148536. /**
  148537. * Initializes the physics vortex event
  148538. * @param _scene The BabylonJS scene
  148539. * @param _origin The origin position of the vortex
  148540. * @param _options The options for the vortex event
  148541. */
  148542. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  148543. /**
  148544. * Returns the data related to the vortex event (cylinder).
  148545. * @returns The physics vortex event data
  148546. */
  148547. getData(): PhysicsVortexEventData;
  148548. /**
  148549. * Enables the vortex.
  148550. */
  148551. enable(): void;
  148552. /**
  148553. * Disables the cortex.
  148554. */
  148555. disable(): void;
  148556. /**
  148557. * Disposes the sphere.
  148558. * @param force
  148559. */
  148560. dispose(force?: boolean): void;
  148561. private getImpostorHitData;
  148562. private _tick;
  148563. /*** Helpers ***/
  148564. private _prepareCylinder;
  148565. private _intersectsWithCylinder;
  148566. }
  148567. /**
  148568. * Options fot the radial explosion event
  148569. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148570. */
  148571. export class PhysicsRadialExplosionEventOptions {
  148572. /**
  148573. * The radius of the sphere for the radial explosion.
  148574. */
  148575. radius: number;
  148576. /**
  148577. * The strenth of the explosion.
  148578. */
  148579. strength: number;
  148580. /**
  148581. * The strenght of the force in correspondence to the distance of the affected object
  148582. */
  148583. falloff: PhysicsRadialImpulseFalloff;
  148584. /**
  148585. * Sphere options for the radial explosion.
  148586. */
  148587. sphere: {
  148588. segments: number;
  148589. diameter: number;
  148590. };
  148591. /**
  148592. * Sphere options for the radial explosion.
  148593. */
  148594. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  148595. }
  148596. /**
  148597. * Options fot the updraft event
  148598. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148599. */
  148600. export class PhysicsUpdraftEventOptions {
  148601. /**
  148602. * The radius of the cylinder for the vortex
  148603. */
  148604. radius: number;
  148605. /**
  148606. * The strenth of the updraft.
  148607. */
  148608. strength: number;
  148609. /**
  148610. * The height of the cylinder for the updraft.
  148611. */
  148612. height: number;
  148613. /**
  148614. * The mode for the the updraft.
  148615. */
  148616. updraftMode: PhysicsUpdraftMode;
  148617. }
  148618. /**
  148619. * Options fot the vortex event
  148620. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148621. */
  148622. export class PhysicsVortexEventOptions {
  148623. /**
  148624. * The radius of the cylinder for the vortex
  148625. */
  148626. radius: number;
  148627. /**
  148628. * The strenth of the vortex.
  148629. */
  148630. strength: number;
  148631. /**
  148632. * The height of the cylinder for the vortex.
  148633. */
  148634. height: number;
  148635. /**
  148636. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  148637. */
  148638. centripetalForceThreshold: number;
  148639. /**
  148640. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  148641. */
  148642. centripetalForceMultiplier: number;
  148643. /**
  148644. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  148645. */
  148646. centrifugalForceMultiplier: number;
  148647. /**
  148648. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  148649. */
  148650. updraftForceMultiplier: number;
  148651. }
  148652. /**
  148653. * The strenght of the force in correspondence to the distance of the affected object
  148654. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148655. */
  148656. export enum PhysicsRadialImpulseFalloff {
  148657. /** Defines that impulse is constant in strength across it's whole radius */
  148658. Constant = 0,
  148659. /** Defines that impulse gets weaker if it's further from the origin */
  148660. Linear = 1
  148661. }
  148662. /**
  148663. * The strength of the force in correspondence to the distance of the affected object
  148664. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148665. */
  148666. export enum PhysicsUpdraftMode {
  148667. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  148668. Center = 0,
  148669. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  148670. Perpendicular = 1
  148671. }
  148672. /**
  148673. * Interface for a physics hit data
  148674. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148675. */
  148676. export interface PhysicsHitData {
  148677. /**
  148678. * The force applied at the contact point
  148679. */
  148680. force: Vector3;
  148681. /**
  148682. * The contact point
  148683. */
  148684. contactPoint: Vector3;
  148685. /**
  148686. * The distance from the origin to the contact point
  148687. */
  148688. distanceFromOrigin: number;
  148689. }
  148690. /**
  148691. * Interface for radial explosion event data
  148692. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148693. */
  148694. export interface PhysicsRadialExplosionEventData {
  148695. /**
  148696. * A sphere used for the radial explosion event
  148697. */
  148698. sphere: Mesh;
  148699. }
  148700. /**
  148701. * Interface for gravitational field event data
  148702. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148703. */
  148704. export interface PhysicsGravitationalFieldEventData {
  148705. /**
  148706. * A sphere mesh used for the gravitational field event
  148707. */
  148708. sphere: Mesh;
  148709. }
  148710. /**
  148711. * Interface for updraft event data
  148712. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148713. */
  148714. export interface PhysicsUpdraftEventData {
  148715. /**
  148716. * A cylinder used for the updraft event
  148717. */
  148718. cylinder: Mesh;
  148719. }
  148720. /**
  148721. * Interface for vortex event data
  148722. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148723. */
  148724. export interface PhysicsVortexEventData {
  148725. /**
  148726. * A cylinder used for the vortex event
  148727. */
  148728. cylinder: Mesh;
  148729. }
  148730. /**
  148731. * Interface for an affected physics impostor
  148732. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148733. */
  148734. export interface PhysicsAffectedImpostorWithData {
  148735. /**
  148736. * The impostor affected by the effect
  148737. */
  148738. impostor: PhysicsImpostor;
  148739. /**
  148740. * The data about the hit/horce from the explosion
  148741. */
  148742. hitData: PhysicsHitData;
  148743. }
  148744. }
  148745. declare module BABYLON {
  148746. /** @hidden */
  148747. export var blackAndWhitePixelShader: {
  148748. name: string;
  148749. shader: string;
  148750. };
  148751. }
  148752. declare module BABYLON {
  148753. /**
  148754. * Post process used to render in black and white
  148755. */
  148756. export class BlackAndWhitePostProcess extends PostProcess {
  148757. /**
  148758. * Linear about to convert he result to black and white (default: 1)
  148759. */
  148760. degree: number;
  148761. /**
  148762. * Gets a string identifying the name of the class
  148763. * @returns "BlackAndWhitePostProcess" string
  148764. */
  148765. getClassName(): string;
  148766. /**
  148767. * Creates a black and white post process
  148768. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  148769. * @param name The name of the effect.
  148770. * @param options The required width/height ratio to downsize to before computing the render pass.
  148771. * @param camera The camera to apply the render pass to.
  148772. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148773. * @param engine The engine which the post process will be applied. (default: current engine)
  148774. * @param reusable If the post process can be reused on the same frame. (default: false)
  148775. */
  148776. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  148777. /** @hidden */
  148778. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  148779. }
  148780. }
  148781. declare module BABYLON {
  148782. /**
  148783. * This represents a set of one or more post processes in Babylon.
  148784. * A post process can be used to apply a shader to a texture after it is rendered.
  148785. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  148786. */
  148787. export class PostProcessRenderEffect {
  148788. private _postProcesses;
  148789. private _getPostProcesses;
  148790. private _singleInstance;
  148791. private _cameras;
  148792. private _indicesForCamera;
  148793. /**
  148794. * Name of the effect
  148795. * @hidden
  148796. */
  148797. _name: string;
  148798. /**
  148799. * Instantiates a post process render effect.
  148800. * A post process can be used to apply a shader to a texture after it is rendered.
  148801. * @param engine The engine the effect is tied to
  148802. * @param name The name of the effect
  148803. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  148804. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  148805. */
  148806. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  148807. /**
  148808. * Checks if all the post processes in the effect are supported.
  148809. */
  148810. get isSupported(): boolean;
  148811. /**
  148812. * Updates the current state of the effect
  148813. * @hidden
  148814. */
  148815. _update(): void;
  148816. /**
  148817. * Attaches the effect on cameras
  148818. * @param cameras The camera to attach to.
  148819. * @hidden
  148820. */
  148821. _attachCameras(cameras: Camera): void;
  148822. /**
  148823. * Attaches the effect on cameras
  148824. * @param cameras The camera to attach to.
  148825. * @hidden
  148826. */
  148827. _attachCameras(cameras: Camera[]): void;
  148828. /**
  148829. * Detaches the effect on cameras
  148830. * @param cameras The camera to detatch from.
  148831. * @hidden
  148832. */
  148833. _detachCameras(cameras: Camera): void;
  148834. /**
  148835. * Detatches the effect on cameras
  148836. * @param cameras The camera to detatch from.
  148837. * @hidden
  148838. */
  148839. _detachCameras(cameras: Camera[]): void;
  148840. /**
  148841. * Enables the effect on given cameras
  148842. * @param cameras The camera to enable.
  148843. * @hidden
  148844. */
  148845. _enable(cameras: Camera): void;
  148846. /**
  148847. * Enables the effect on given cameras
  148848. * @param cameras The camera to enable.
  148849. * @hidden
  148850. */
  148851. _enable(cameras: Nullable<Camera[]>): void;
  148852. /**
  148853. * Disables the effect on the given cameras
  148854. * @param cameras The camera to disable.
  148855. * @hidden
  148856. */
  148857. _disable(cameras: Camera): void;
  148858. /**
  148859. * Disables the effect on the given cameras
  148860. * @param cameras The camera to disable.
  148861. * @hidden
  148862. */
  148863. _disable(cameras: Nullable<Camera[]>): void;
  148864. /**
  148865. * Gets a list of the post processes contained in the effect.
  148866. * @param camera The camera to get the post processes on.
  148867. * @returns The list of the post processes in the effect.
  148868. */
  148869. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  148870. }
  148871. }
  148872. declare module BABYLON {
  148873. /** @hidden */
  148874. export var extractHighlightsPixelShader: {
  148875. name: string;
  148876. shader: string;
  148877. };
  148878. }
  148879. declare module BABYLON {
  148880. /**
  148881. * 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.
  148882. */
  148883. export class ExtractHighlightsPostProcess extends PostProcess {
  148884. /**
  148885. * The luminance threshold, pixels below this value will be set to black.
  148886. */
  148887. threshold: number;
  148888. /** @hidden */
  148889. _exposure: number;
  148890. /**
  148891. * Post process which has the input texture to be used when performing highlight extraction
  148892. * @hidden
  148893. */
  148894. _inputPostProcess: Nullable<PostProcess>;
  148895. /**
  148896. * Gets a string identifying the name of the class
  148897. * @returns "ExtractHighlightsPostProcess" string
  148898. */
  148899. getClassName(): string;
  148900. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148901. }
  148902. }
  148903. declare module BABYLON {
  148904. /** @hidden */
  148905. export var bloomMergePixelShader: {
  148906. name: string;
  148907. shader: string;
  148908. };
  148909. }
  148910. declare module BABYLON {
  148911. /**
  148912. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  148913. */
  148914. export class BloomMergePostProcess extends PostProcess {
  148915. /** Weight of the bloom to be added to the original input. */
  148916. weight: number;
  148917. /**
  148918. * Gets a string identifying the name of the class
  148919. * @returns "BloomMergePostProcess" string
  148920. */
  148921. getClassName(): string;
  148922. /**
  148923. * Creates a new instance of @see BloomMergePostProcess
  148924. * @param name The name of the effect.
  148925. * @param originalFromInput Post process which's input will be used for the merge.
  148926. * @param blurred Blurred highlights post process which's output will be used.
  148927. * @param weight Weight of the bloom to be added to the original input.
  148928. * @param options The required width/height ratio to downsize to before computing the render pass.
  148929. * @param camera The camera to apply the render pass to.
  148930. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148931. * @param engine The engine which the post process will be applied. (default: current engine)
  148932. * @param reusable If the post process can be reused on the same frame. (default: false)
  148933. * @param textureType Type of textures used when performing the post process. (default: 0)
  148934. * @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)
  148935. */
  148936. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  148937. /** Weight of the bloom to be added to the original input. */
  148938. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148939. }
  148940. }
  148941. declare module BABYLON {
  148942. /**
  148943. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  148944. */
  148945. export class BloomEffect extends PostProcessRenderEffect {
  148946. private bloomScale;
  148947. /**
  148948. * @hidden Internal
  148949. */
  148950. _effects: Array<PostProcess>;
  148951. /**
  148952. * @hidden Internal
  148953. */
  148954. _downscale: ExtractHighlightsPostProcess;
  148955. private _blurX;
  148956. private _blurY;
  148957. private _merge;
  148958. /**
  148959. * The luminance threshold to find bright areas of the image to bloom.
  148960. */
  148961. get threshold(): number;
  148962. set threshold(value: number);
  148963. /**
  148964. * The strength of the bloom.
  148965. */
  148966. get weight(): number;
  148967. set weight(value: number);
  148968. /**
  148969. * Specifies the size of the bloom blur kernel, relative to the final output size
  148970. */
  148971. get kernel(): number;
  148972. set kernel(value: number);
  148973. /**
  148974. * Creates a new instance of @see BloomEffect
  148975. * @param scene The scene the effect belongs to.
  148976. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  148977. * @param bloomKernel The size of the kernel to be used when applying the blur.
  148978. * @param bloomWeight The the strength of bloom.
  148979. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  148980. * @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)
  148981. */
  148982. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  148983. /**
  148984. * Disposes each of the internal effects for a given camera.
  148985. * @param camera The camera to dispose the effect on.
  148986. */
  148987. disposeEffects(camera: Camera): void;
  148988. /**
  148989. * @hidden Internal
  148990. */
  148991. _updateEffects(): void;
  148992. /**
  148993. * Internal
  148994. * @returns if all the contained post processes are ready.
  148995. * @hidden
  148996. */
  148997. _isReady(): boolean;
  148998. }
  148999. }
  149000. declare module BABYLON {
  149001. /** @hidden */
  149002. export var chromaticAberrationPixelShader: {
  149003. name: string;
  149004. shader: string;
  149005. };
  149006. }
  149007. declare module BABYLON {
  149008. /**
  149009. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  149010. */
  149011. export class ChromaticAberrationPostProcess extends PostProcess {
  149012. /**
  149013. * The amount of seperation of rgb channels (default: 30)
  149014. */
  149015. aberrationAmount: number;
  149016. /**
  149017. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  149018. */
  149019. radialIntensity: number;
  149020. /**
  149021. * 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))
  149022. */
  149023. direction: Vector2;
  149024. /**
  149025. * 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))
  149026. */
  149027. centerPosition: Vector2;
  149028. /** The width of the screen to apply the effect on */
  149029. screenWidth: number;
  149030. /** The height of the screen to apply the effect on */
  149031. screenHeight: number;
  149032. /**
  149033. * Gets a string identifying the name of the class
  149034. * @returns "ChromaticAberrationPostProcess" string
  149035. */
  149036. getClassName(): string;
  149037. /**
  149038. * Creates a new instance ChromaticAberrationPostProcess
  149039. * @param name The name of the effect.
  149040. * @param screenWidth The width of the screen to apply the effect on.
  149041. * @param screenHeight The height of the screen to apply the effect on.
  149042. * @param options The required width/height ratio to downsize to before computing the render pass.
  149043. * @param camera The camera to apply the render pass to.
  149044. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149045. * @param engine The engine which the post process will be applied. (default: current engine)
  149046. * @param reusable If the post process can be reused on the same frame. (default: false)
  149047. * @param textureType Type of textures used when performing the post process. (default: 0)
  149048. * @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)
  149049. */
  149050. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149051. /** @hidden */
  149052. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  149053. }
  149054. }
  149055. declare module BABYLON {
  149056. /** @hidden */
  149057. export var circleOfConfusionPixelShader: {
  149058. name: string;
  149059. shader: string;
  149060. };
  149061. }
  149062. declare module BABYLON {
  149063. /**
  149064. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  149065. */
  149066. export class CircleOfConfusionPostProcess extends PostProcess {
  149067. /**
  149068. * 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.
  149069. */
  149070. lensSize: number;
  149071. /**
  149072. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  149073. */
  149074. fStop: number;
  149075. /**
  149076. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  149077. */
  149078. focusDistance: number;
  149079. /**
  149080. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  149081. */
  149082. focalLength: number;
  149083. /**
  149084. * Gets a string identifying the name of the class
  149085. * @returns "CircleOfConfusionPostProcess" string
  149086. */
  149087. getClassName(): string;
  149088. private _depthTexture;
  149089. /**
  149090. * Creates a new instance CircleOfConfusionPostProcess
  149091. * @param name The name of the effect.
  149092. * @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.
  149093. * @param options The required width/height ratio to downsize to before computing the render pass.
  149094. * @param camera The camera to apply the render pass to.
  149095. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149096. * @param engine The engine which the post process will be applied. (default: current engine)
  149097. * @param reusable If the post process can be reused on the same frame. (default: false)
  149098. * @param textureType Type of textures used when performing the post process. (default: 0)
  149099. * @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)
  149100. */
  149101. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149102. /**
  149103. * 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.
  149104. */
  149105. set depthTexture(value: RenderTargetTexture);
  149106. }
  149107. }
  149108. declare module BABYLON {
  149109. /** @hidden */
  149110. export var colorCorrectionPixelShader: {
  149111. name: string;
  149112. shader: string;
  149113. };
  149114. }
  149115. declare module BABYLON {
  149116. /**
  149117. *
  149118. * This post-process allows the modification of rendered colors by using
  149119. * a 'look-up table' (LUT). This effect is also called Color Grading.
  149120. *
  149121. * The object needs to be provided an url to a texture containing the color
  149122. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  149123. * Use an image editing software to tweak the LUT to match your needs.
  149124. *
  149125. * For an example of a color LUT, see here:
  149126. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  149127. * For explanations on color grading, see here:
  149128. * @see http://udn.epicgames.com/Three/ColorGrading.html
  149129. *
  149130. */
  149131. export class ColorCorrectionPostProcess extends PostProcess {
  149132. private _colorTableTexture;
  149133. /**
  149134. * Gets the color table url used to create the LUT texture
  149135. */
  149136. colorTableUrl: string;
  149137. /**
  149138. * Gets a string identifying the name of the class
  149139. * @returns "ColorCorrectionPostProcess" string
  149140. */
  149141. getClassName(): string;
  149142. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149143. /** @hidden */
  149144. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  149145. }
  149146. }
  149147. declare module BABYLON {
  149148. /** @hidden */
  149149. export var convolutionPixelShader: {
  149150. name: string;
  149151. shader: string;
  149152. };
  149153. }
  149154. declare module BABYLON {
  149155. /**
  149156. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  149157. * input texture to perform effects such as edge detection or sharpening
  149158. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  149159. */
  149160. export class ConvolutionPostProcess extends PostProcess {
  149161. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  149162. kernel: number[];
  149163. /**
  149164. * Gets a string identifying the name of the class
  149165. * @returns "ConvolutionPostProcess" string
  149166. */
  149167. getClassName(): string;
  149168. /**
  149169. * Creates a new instance ConvolutionPostProcess
  149170. * @param name The name of the effect.
  149171. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  149172. * @param options The required width/height ratio to downsize to before computing the render pass.
  149173. * @param camera The camera to apply the render pass to.
  149174. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149175. * @param engine The engine which the post process will be applied. (default: current engine)
  149176. * @param reusable If the post process can be reused on the same frame. (default: false)
  149177. * @param textureType Type of textures used when performing the post process. (default: 0)
  149178. */
  149179. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  149180. /** @hidden */
  149181. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  149182. /**
  149183. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149184. */
  149185. static EdgeDetect0Kernel: number[];
  149186. /**
  149187. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149188. */
  149189. static EdgeDetect1Kernel: number[];
  149190. /**
  149191. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149192. */
  149193. static EdgeDetect2Kernel: number[];
  149194. /**
  149195. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149196. */
  149197. static SharpenKernel: number[];
  149198. /**
  149199. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149200. */
  149201. static EmbossKernel: number[];
  149202. /**
  149203. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149204. */
  149205. static GaussianKernel: number[];
  149206. }
  149207. }
  149208. declare module BABYLON {
  149209. /**
  149210. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  149211. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  149212. * based on samples that have a large difference in distance than the center pixel.
  149213. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  149214. */
  149215. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  149216. /**
  149217. * The direction the blur should be applied
  149218. */
  149219. direction: Vector2;
  149220. /**
  149221. * Gets a string identifying the name of the class
  149222. * @returns "DepthOfFieldBlurPostProcess" string
  149223. */
  149224. getClassName(): string;
  149225. /**
  149226. * Creates a new instance CircleOfConfusionPostProcess
  149227. * @param name The name of the effect.
  149228. * @param scene The scene the effect belongs to.
  149229. * @param direction The direction the blur should be applied.
  149230. * @param kernel The size of the kernel used to blur.
  149231. * @param options The required width/height ratio to downsize to before computing the render pass.
  149232. * @param camera The camera to apply the render pass to.
  149233. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  149234. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  149235. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149236. * @param engine The engine which the post process will be applied. (default: current engine)
  149237. * @param reusable If the post process can be reused on the same frame. (default: false)
  149238. * @param textureType Type of textures used when performing the post process. (default: 0)
  149239. * @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)
  149240. */
  149241. 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);
  149242. }
  149243. }
  149244. declare module BABYLON {
  149245. /** @hidden */
  149246. export var depthOfFieldMergePixelShader: {
  149247. name: string;
  149248. shader: string;
  149249. };
  149250. }
  149251. declare module BABYLON {
  149252. /**
  149253. * Options to be set when merging outputs from the default pipeline.
  149254. */
  149255. export class DepthOfFieldMergePostProcessOptions {
  149256. /**
  149257. * The original image to merge on top of
  149258. */
  149259. originalFromInput: PostProcess;
  149260. /**
  149261. * Parameters to perform the merge of the depth of field effect
  149262. */
  149263. depthOfField?: {
  149264. circleOfConfusion: PostProcess;
  149265. blurSteps: Array<PostProcess>;
  149266. };
  149267. /**
  149268. * Parameters to perform the merge of bloom effect
  149269. */
  149270. bloom?: {
  149271. blurred: PostProcess;
  149272. weight: number;
  149273. };
  149274. }
  149275. /**
  149276. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  149277. */
  149278. export class DepthOfFieldMergePostProcess extends PostProcess {
  149279. private blurSteps;
  149280. /**
  149281. * Gets a string identifying the name of the class
  149282. * @returns "DepthOfFieldMergePostProcess" string
  149283. */
  149284. getClassName(): string;
  149285. /**
  149286. * Creates a new instance of DepthOfFieldMergePostProcess
  149287. * @param name The name of the effect.
  149288. * @param originalFromInput Post process which's input will be used for the merge.
  149289. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  149290. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  149291. * @param options The required width/height ratio to downsize to before computing the render pass.
  149292. * @param camera The camera to apply the render pass to.
  149293. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149294. * @param engine The engine which the post process will be applied. (default: current engine)
  149295. * @param reusable If the post process can be reused on the same frame. (default: false)
  149296. * @param textureType Type of textures used when performing the post process. (default: 0)
  149297. * @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)
  149298. */
  149299. 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);
  149300. /**
  149301. * Updates the effect with the current post process compile time values and recompiles the shader.
  149302. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  149303. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  149304. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  149305. * @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
  149306. * @param onCompiled Called when the shader has been compiled.
  149307. * @param onError Called if there is an error when compiling a shader.
  149308. */
  149309. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  149310. }
  149311. }
  149312. declare module BABYLON {
  149313. /**
  149314. * Specifies the level of max blur that should be applied when using the depth of field effect
  149315. */
  149316. export enum DepthOfFieldEffectBlurLevel {
  149317. /**
  149318. * Subtle blur
  149319. */
  149320. Low = 0,
  149321. /**
  149322. * Medium blur
  149323. */
  149324. Medium = 1,
  149325. /**
  149326. * Large blur
  149327. */
  149328. High = 2
  149329. }
  149330. /**
  149331. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  149332. */
  149333. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  149334. private _circleOfConfusion;
  149335. /**
  149336. * @hidden Internal, blurs from high to low
  149337. */
  149338. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  149339. private _depthOfFieldBlurY;
  149340. private _dofMerge;
  149341. /**
  149342. * @hidden Internal post processes in depth of field effect
  149343. */
  149344. _effects: Array<PostProcess>;
  149345. /**
  149346. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  149347. */
  149348. set focalLength(value: number);
  149349. get focalLength(): number;
  149350. /**
  149351. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  149352. */
  149353. set fStop(value: number);
  149354. get fStop(): number;
  149355. /**
  149356. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  149357. */
  149358. set focusDistance(value: number);
  149359. get focusDistance(): number;
  149360. /**
  149361. * 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.
  149362. */
  149363. set lensSize(value: number);
  149364. get lensSize(): number;
  149365. /**
  149366. * Creates a new instance DepthOfFieldEffect
  149367. * @param scene The scene the effect belongs to.
  149368. * @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.
  149369. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  149370. * @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)
  149371. */
  149372. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  149373. /**
  149374. * Get the current class name of the current effet
  149375. * @returns "DepthOfFieldEffect"
  149376. */
  149377. getClassName(): string;
  149378. /**
  149379. * 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.
  149380. */
  149381. set depthTexture(value: RenderTargetTexture);
  149382. /**
  149383. * Disposes each of the internal effects for a given camera.
  149384. * @param camera The camera to dispose the effect on.
  149385. */
  149386. disposeEffects(camera: Camera): void;
  149387. /**
  149388. * @hidden Internal
  149389. */
  149390. _updateEffects(): void;
  149391. /**
  149392. * Internal
  149393. * @returns if all the contained post processes are ready.
  149394. * @hidden
  149395. */
  149396. _isReady(): boolean;
  149397. }
  149398. }
  149399. declare module BABYLON {
  149400. /** @hidden */
  149401. export var displayPassPixelShader: {
  149402. name: string;
  149403. shader: string;
  149404. };
  149405. }
  149406. declare module BABYLON {
  149407. /**
  149408. * DisplayPassPostProcess which produces an output the same as it's input
  149409. */
  149410. export class DisplayPassPostProcess extends PostProcess {
  149411. /**
  149412. * Gets a string identifying the name of the class
  149413. * @returns "DisplayPassPostProcess" string
  149414. */
  149415. getClassName(): string;
  149416. /**
  149417. * Creates the DisplayPassPostProcess
  149418. * @param name The name of the effect.
  149419. * @param options The required width/height ratio to downsize to before computing the render pass.
  149420. * @param camera The camera to apply the render pass to.
  149421. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149422. * @param engine The engine which the post process will be applied. (default: current engine)
  149423. * @param reusable If the post process can be reused on the same frame. (default: false)
  149424. */
  149425. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149426. /** @hidden */
  149427. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  149428. }
  149429. }
  149430. declare module BABYLON {
  149431. /** @hidden */
  149432. export var filterPixelShader: {
  149433. name: string;
  149434. shader: string;
  149435. };
  149436. }
  149437. declare module BABYLON {
  149438. /**
  149439. * Applies a kernel filter to the image
  149440. */
  149441. export class FilterPostProcess extends PostProcess {
  149442. /** The matrix to be applied to the image */
  149443. kernelMatrix: Matrix;
  149444. /**
  149445. * Gets a string identifying the name of the class
  149446. * @returns "FilterPostProcess" string
  149447. */
  149448. getClassName(): string;
  149449. /**
  149450. *
  149451. * @param name The name of the effect.
  149452. * @param kernelMatrix The matrix to be applied to the image
  149453. * @param options The required width/height ratio to downsize to before computing the render pass.
  149454. * @param camera The camera to apply the render pass to.
  149455. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149456. * @param engine The engine which the post process will be applied. (default: current engine)
  149457. * @param reusable If the post process can be reused on the same frame. (default: false)
  149458. */
  149459. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149460. /** @hidden */
  149461. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  149462. }
  149463. }
  149464. declare module BABYLON {
  149465. /** @hidden */
  149466. export var fxaaPixelShader: {
  149467. name: string;
  149468. shader: string;
  149469. };
  149470. }
  149471. declare module BABYLON {
  149472. /** @hidden */
  149473. export var fxaaVertexShader: {
  149474. name: string;
  149475. shader: string;
  149476. };
  149477. }
  149478. declare module BABYLON {
  149479. /**
  149480. * Fxaa post process
  149481. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  149482. */
  149483. export class FxaaPostProcess extends PostProcess {
  149484. /**
  149485. * Gets a string identifying the name of the class
  149486. * @returns "FxaaPostProcess" string
  149487. */
  149488. getClassName(): string;
  149489. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  149490. private _getDefines;
  149491. /** @hidden */
  149492. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  149493. }
  149494. }
  149495. declare module BABYLON {
  149496. /** @hidden */
  149497. export var grainPixelShader: {
  149498. name: string;
  149499. shader: string;
  149500. };
  149501. }
  149502. declare module BABYLON {
  149503. /**
  149504. * The GrainPostProcess adds noise to the image at mid luminance levels
  149505. */
  149506. export class GrainPostProcess extends PostProcess {
  149507. /**
  149508. * The intensity of the grain added (default: 30)
  149509. */
  149510. intensity: number;
  149511. /**
  149512. * If the grain should be randomized on every frame
  149513. */
  149514. animated: boolean;
  149515. /**
  149516. * Gets a string identifying the name of the class
  149517. * @returns "GrainPostProcess" string
  149518. */
  149519. getClassName(): string;
  149520. /**
  149521. * Creates a new instance of @see GrainPostProcess
  149522. * @param name The name of the effect.
  149523. * @param options The required width/height ratio to downsize to before computing the render pass.
  149524. * @param camera The camera to apply the render pass to.
  149525. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149526. * @param engine The engine which the post process will be applied. (default: current engine)
  149527. * @param reusable If the post process can be reused on the same frame. (default: false)
  149528. * @param textureType Type of textures used when performing the post process. (default: 0)
  149529. * @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)
  149530. */
  149531. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149532. /** @hidden */
  149533. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  149534. }
  149535. }
  149536. declare module BABYLON {
  149537. /** @hidden */
  149538. export var highlightsPixelShader: {
  149539. name: string;
  149540. shader: string;
  149541. };
  149542. }
  149543. declare module BABYLON {
  149544. /**
  149545. * Extracts highlights from the image
  149546. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  149547. */
  149548. export class HighlightsPostProcess extends PostProcess {
  149549. /**
  149550. * Gets a string identifying the name of the class
  149551. * @returns "HighlightsPostProcess" string
  149552. */
  149553. getClassName(): string;
  149554. /**
  149555. * Extracts highlights from the image
  149556. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  149557. * @param name The name of the effect.
  149558. * @param options The required width/height ratio to downsize to before computing the render pass.
  149559. * @param camera The camera to apply the render pass to.
  149560. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149561. * @param engine The engine which the post process will be applied. (default: current engine)
  149562. * @param reusable If the post process can be reused on the same frame. (default: false)
  149563. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  149564. */
  149565. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  149566. }
  149567. }
  149568. declare module BABYLON {
  149569. /** @hidden */
  149570. export var mrtFragmentDeclaration: {
  149571. name: string;
  149572. shader: string;
  149573. };
  149574. }
  149575. declare module BABYLON {
  149576. /** @hidden */
  149577. export var geometryPixelShader: {
  149578. name: string;
  149579. shader: string;
  149580. };
  149581. }
  149582. declare module BABYLON {
  149583. /** @hidden */
  149584. export var geometryVertexShader: {
  149585. name: string;
  149586. shader: string;
  149587. };
  149588. }
  149589. declare module BABYLON {
  149590. /** @hidden */
  149591. interface ISavedTransformationMatrix {
  149592. world: Matrix;
  149593. viewProjection: Matrix;
  149594. }
  149595. /**
  149596. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  149597. */
  149598. export class GeometryBufferRenderer {
  149599. /**
  149600. * Constant used to retrieve the position texture index in the G-Buffer textures array
  149601. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  149602. */
  149603. static readonly POSITION_TEXTURE_TYPE: number;
  149604. /**
  149605. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  149606. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  149607. */
  149608. static readonly VELOCITY_TEXTURE_TYPE: number;
  149609. /**
  149610. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  149611. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  149612. */
  149613. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  149614. /**
  149615. * Dictionary used to store the previous transformation matrices of each rendered mesh
  149616. * in order to compute objects velocities when enableVelocity is set to "true"
  149617. * @hidden
  149618. */
  149619. _previousTransformationMatrices: {
  149620. [index: number]: ISavedTransformationMatrix;
  149621. };
  149622. /**
  149623. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  149624. * in order to compute objects velocities when enableVelocity is set to "true"
  149625. * @hidden
  149626. */
  149627. _previousBonesTransformationMatrices: {
  149628. [index: number]: Float32Array;
  149629. };
  149630. /**
  149631. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  149632. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  149633. */
  149634. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  149635. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  149636. renderTransparentMeshes: boolean;
  149637. private _scene;
  149638. private _resizeObserver;
  149639. private _multiRenderTarget;
  149640. private _ratio;
  149641. private _enablePosition;
  149642. private _enableVelocity;
  149643. private _enableReflectivity;
  149644. private _positionIndex;
  149645. private _velocityIndex;
  149646. private _reflectivityIndex;
  149647. protected _effect: Effect;
  149648. protected _cachedDefines: string;
  149649. /**
  149650. * Set the render list (meshes to be rendered) used in the G buffer.
  149651. */
  149652. set renderList(meshes: Mesh[]);
  149653. /**
  149654. * Gets wether or not G buffer are supported by the running hardware.
  149655. * This requires draw buffer supports
  149656. */
  149657. get isSupported(): boolean;
  149658. /**
  149659. * Returns the index of the given texture type in the G-Buffer textures array
  149660. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  149661. * @returns the index of the given texture type in the G-Buffer textures array
  149662. */
  149663. getTextureIndex(textureType: number): number;
  149664. /**
  149665. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  149666. */
  149667. get enablePosition(): boolean;
  149668. /**
  149669. * Sets whether or not objects positions are enabled for the G buffer.
  149670. */
  149671. set enablePosition(enable: boolean);
  149672. /**
  149673. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  149674. */
  149675. get enableVelocity(): boolean;
  149676. /**
  149677. * Sets wether or not objects velocities are enabled for the G buffer.
  149678. */
  149679. set enableVelocity(enable: boolean);
  149680. /**
  149681. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  149682. */
  149683. get enableReflectivity(): boolean;
  149684. /**
  149685. * Sets wether or not objects roughness are enabled for the G buffer.
  149686. */
  149687. set enableReflectivity(enable: boolean);
  149688. /**
  149689. * Gets the scene associated with the buffer.
  149690. */
  149691. get scene(): Scene;
  149692. /**
  149693. * Gets the ratio used by the buffer during its creation.
  149694. * How big is the buffer related to the main canvas.
  149695. */
  149696. get ratio(): number;
  149697. /** @hidden */
  149698. static _SceneComponentInitialization: (scene: Scene) => void;
  149699. /**
  149700. * Creates a new G Buffer for the scene
  149701. * @param scene The scene the buffer belongs to
  149702. * @param ratio How big is the buffer related to the main canvas.
  149703. */
  149704. constructor(scene: Scene, ratio?: number);
  149705. /**
  149706. * Checks wether everything is ready to render a submesh to the G buffer.
  149707. * @param subMesh the submesh to check readiness for
  149708. * @param useInstances is the mesh drawn using instance or not
  149709. * @returns true if ready otherwise false
  149710. */
  149711. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  149712. /**
  149713. * Gets the current underlying G Buffer.
  149714. * @returns the buffer
  149715. */
  149716. getGBuffer(): MultiRenderTarget;
  149717. /**
  149718. * Gets the number of samples used to render the buffer (anti aliasing).
  149719. */
  149720. get samples(): number;
  149721. /**
  149722. * Sets the number of samples used to render the buffer (anti aliasing).
  149723. */
  149724. set samples(value: number);
  149725. /**
  149726. * Disposes the renderer and frees up associated resources.
  149727. */
  149728. dispose(): void;
  149729. protected _createRenderTargets(): void;
  149730. private _copyBonesTransformationMatrices;
  149731. }
  149732. }
  149733. declare module BABYLON {
  149734. interface Scene {
  149735. /** @hidden (Backing field) */
  149736. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  149737. /**
  149738. * Gets or Sets the current geometry buffer associated to the scene.
  149739. */
  149740. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  149741. /**
  149742. * Enables a GeometryBufferRender and associates it with the scene
  149743. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  149744. * @returns the GeometryBufferRenderer
  149745. */
  149746. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  149747. /**
  149748. * Disables the GeometryBufferRender associated with the scene
  149749. */
  149750. disableGeometryBufferRenderer(): void;
  149751. }
  149752. /**
  149753. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  149754. * in several rendering techniques.
  149755. */
  149756. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  149757. /**
  149758. * The component name helpful to identify the component in the list of scene components.
  149759. */
  149760. readonly name: string;
  149761. /**
  149762. * The scene the component belongs to.
  149763. */
  149764. scene: Scene;
  149765. /**
  149766. * Creates a new instance of the component for the given scene
  149767. * @param scene Defines the scene to register the component in
  149768. */
  149769. constructor(scene: Scene);
  149770. /**
  149771. * Registers the component in a given scene
  149772. */
  149773. register(): void;
  149774. /**
  149775. * Rebuilds the elements related to this component in case of
  149776. * context lost for instance.
  149777. */
  149778. rebuild(): void;
  149779. /**
  149780. * Disposes the component and the associated ressources
  149781. */
  149782. dispose(): void;
  149783. private _gatherRenderTargets;
  149784. }
  149785. }
  149786. declare module BABYLON {
  149787. /** @hidden */
  149788. export var motionBlurPixelShader: {
  149789. name: string;
  149790. shader: string;
  149791. };
  149792. }
  149793. declare module BABYLON {
  149794. /**
  149795. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  149796. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  149797. * As an example, all you have to do is to create the post-process:
  149798. * var mb = new BABYLON.MotionBlurPostProcess(
  149799. * 'mb', // The name of the effect.
  149800. * scene, // The scene containing the objects to blur according to their velocity.
  149801. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  149802. * camera // The camera to apply the render pass to.
  149803. * );
  149804. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  149805. */
  149806. export class MotionBlurPostProcess extends PostProcess {
  149807. /**
  149808. * Defines how much the image is blurred by the movement. Default value is equal to 1
  149809. */
  149810. motionStrength: number;
  149811. /**
  149812. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  149813. */
  149814. get motionBlurSamples(): number;
  149815. /**
  149816. * Sets the number of iterations to be used for motion blur quality
  149817. */
  149818. set motionBlurSamples(samples: number);
  149819. private _motionBlurSamples;
  149820. private _geometryBufferRenderer;
  149821. /**
  149822. * Gets a string identifying the name of the class
  149823. * @returns "MotionBlurPostProcess" string
  149824. */
  149825. getClassName(): string;
  149826. /**
  149827. * Creates a new instance MotionBlurPostProcess
  149828. * @param name The name of the effect.
  149829. * @param scene The scene containing the objects to blur according to their velocity.
  149830. * @param options The required width/height ratio to downsize to before computing the render pass.
  149831. * @param camera The camera to apply the render pass to.
  149832. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149833. * @param engine The engine which the post process will be applied. (default: current engine)
  149834. * @param reusable If the post process can be reused on the same frame. (default: false)
  149835. * @param textureType Type of textures used when performing the post process. (default: 0)
  149836. * @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)
  149837. */
  149838. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149839. /**
  149840. * Excludes the given skinned mesh from computing bones velocities.
  149841. * 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.
  149842. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  149843. */
  149844. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  149845. /**
  149846. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  149847. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  149848. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  149849. */
  149850. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  149851. /**
  149852. * Disposes the post process.
  149853. * @param camera The camera to dispose the post process on.
  149854. */
  149855. dispose(camera?: Camera): void;
  149856. /** @hidden */
  149857. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  149858. }
  149859. }
  149860. declare module BABYLON {
  149861. /** @hidden */
  149862. export var refractionPixelShader: {
  149863. name: string;
  149864. shader: string;
  149865. };
  149866. }
  149867. declare module BABYLON {
  149868. /**
  149869. * Post process which applies a refractin texture
  149870. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  149871. */
  149872. export class RefractionPostProcess extends PostProcess {
  149873. private _refTexture;
  149874. private _ownRefractionTexture;
  149875. /** the base color of the refraction (used to taint the rendering) */
  149876. color: Color3;
  149877. /** simulated refraction depth */
  149878. depth: number;
  149879. /** the coefficient of the base color (0 to remove base color tainting) */
  149880. colorLevel: number;
  149881. /** Gets the url used to load the refraction texture */
  149882. refractionTextureUrl: string;
  149883. /**
  149884. * Gets or sets the refraction texture
  149885. * Please note that you are responsible for disposing the texture if you set it manually
  149886. */
  149887. get refractionTexture(): Texture;
  149888. set refractionTexture(value: Texture);
  149889. /**
  149890. * Gets a string identifying the name of the class
  149891. * @returns "RefractionPostProcess" string
  149892. */
  149893. getClassName(): string;
  149894. /**
  149895. * Initializes the RefractionPostProcess
  149896. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  149897. * @param name The name of the effect.
  149898. * @param refractionTextureUrl Url of the refraction texture to use
  149899. * @param color the base color of the refraction (used to taint the rendering)
  149900. * @param depth simulated refraction depth
  149901. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  149902. * @param camera The camera to apply the render pass to.
  149903. * @param options The required width/height ratio to downsize to before computing the render pass.
  149904. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149905. * @param engine The engine which the post process will be applied. (default: current engine)
  149906. * @param reusable If the post process can be reused on the same frame. (default: false)
  149907. */
  149908. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149909. /**
  149910. * Disposes of the post process
  149911. * @param camera Camera to dispose post process on
  149912. */
  149913. dispose(camera: Camera): void;
  149914. /** @hidden */
  149915. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  149916. }
  149917. }
  149918. declare module BABYLON {
  149919. /** @hidden */
  149920. export var sharpenPixelShader: {
  149921. name: string;
  149922. shader: string;
  149923. };
  149924. }
  149925. declare module BABYLON {
  149926. /**
  149927. * The SharpenPostProcess applies a sharpen kernel to every pixel
  149928. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  149929. */
  149930. export class SharpenPostProcess extends PostProcess {
  149931. /**
  149932. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  149933. */
  149934. colorAmount: number;
  149935. /**
  149936. * How much sharpness should be applied (default: 0.3)
  149937. */
  149938. edgeAmount: number;
  149939. /**
  149940. * Gets a string identifying the name of the class
  149941. * @returns "SharpenPostProcess" string
  149942. */
  149943. getClassName(): string;
  149944. /**
  149945. * Creates a new instance ConvolutionPostProcess
  149946. * @param name The name of the effect.
  149947. * @param options The required width/height ratio to downsize to before computing the render pass.
  149948. * @param camera The camera to apply the render pass to.
  149949. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149950. * @param engine The engine which the post process will be applied. (default: current engine)
  149951. * @param reusable If the post process can be reused on the same frame. (default: false)
  149952. * @param textureType Type of textures used when performing the post process. (default: 0)
  149953. * @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)
  149954. */
  149955. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149956. /** @hidden */
  149957. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  149958. }
  149959. }
  149960. declare module BABYLON {
  149961. /**
  149962. * PostProcessRenderPipeline
  149963. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  149964. */
  149965. export class PostProcessRenderPipeline {
  149966. private engine;
  149967. private _renderEffects;
  149968. private _renderEffectsForIsolatedPass;
  149969. /**
  149970. * List of inspectable custom properties (used by the Inspector)
  149971. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  149972. */
  149973. inspectableCustomProperties: IInspectable[];
  149974. /**
  149975. * @hidden
  149976. */
  149977. protected _cameras: Camera[];
  149978. /** @hidden */
  149979. _name: string;
  149980. /**
  149981. * Gets pipeline name
  149982. */
  149983. get name(): string;
  149984. /** Gets the list of attached cameras */
  149985. get cameras(): Camera[];
  149986. /**
  149987. * Initializes a PostProcessRenderPipeline
  149988. * @param engine engine to add the pipeline to
  149989. * @param name name of the pipeline
  149990. */
  149991. constructor(engine: Engine, name: string);
  149992. /**
  149993. * Gets the class name
  149994. * @returns "PostProcessRenderPipeline"
  149995. */
  149996. getClassName(): string;
  149997. /**
  149998. * If all the render effects in the pipeline are supported
  149999. */
  150000. get isSupported(): boolean;
  150001. /**
  150002. * Adds an effect to the pipeline
  150003. * @param renderEffect the effect to add
  150004. */
  150005. addEffect(renderEffect: PostProcessRenderEffect): void;
  150006. /** @hidden */
  150007. _rebuild(): void;
  150008. /** @hidden */
  150009. _enableEffect(renderEffectName: string, cameras: Camera): void;
  150010. /** @hidden */
  150011. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  150012. /** @hidden */
  150013. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  150014. /** @hidden */
  150015. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  150016. /** @hidden */
  150017. _attachCameras(cameras: Camera, unique: boolean): void;
  150018. /** @hidden */
  150019. _attachCameras(cameras: Camera[], unique: boolean): void;
  150020. /** @hidden */
  150021. _detachCameras(cameras: Camera): void;
  150022. /** @hidden */
  150023. _detachCameras(cameras: Nullable<Camera[]>): void;
  150024. /** @hidden */
  150025. _update(): void;
  150026. /** @hidden */
  150027. _reset(): void;
  150028. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  150029. /**
  150030. * Sets the required values to the prepass renderer.
  150031. * @param prePassRenderer defines the prepass renderer to setup.
  150032. * @returns true if the pre pass is needed.
  150033. */
  150034. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  150035. /**
  150036. * Disposes of the pipeline
  150037. */
  150038. dispose(): void;
  150039. }
  150040. }
  150041. declare module BABYLON {
  150042. /**
  150043. * PostProcessRenderPipelineManager class
  150044. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150045. */
  150046. export class PostProcessRenderPipelineManager {
  150047. private _renderPipelines;
  150048. /**
  150049. * Initializes a PostProcessRenderPipelineManager
  150050. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150051. */
  150052. constructor();
  150053. /**
  150054. * Gets the list of supported render pipelines
  150055. */
  150056. get supportedPipelines(): PostProcessRenderPipeline[];
  150057. /**
  150058. * Adds a pipeline to the manager
  150059. * @param renderPipeline The pipeline to add
  150060. */
  150061. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  150062. /**
  150063. * Attaches a camera to the pipeline
  150064. * @param renderPipelineName The name of the pipeline to attach to
  150065. * @param cameras the camera to attach
  150066. * @param unique if the camera can be attached multiple times to the pipeline
  150067. */
  150068. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  150069. /**
  150070. * Detaches a camera from the pipeline
  150071. * @param renderPipelineName The name of the pipeline to detach from
  150072. * @param cameras the camera to detach
  150073. */
  150074. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  150075. /**
  150076. * Enables an effect by name on a pipeline
  150077. * @param renderPipelineName the name of the pipeline to enable the effect in
  150078. * @param renderEffectName the name of the effect to enable
  150079. * @param cameras the cameras that the effect should be enabled on
  150080. */
  150081. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  150082. /**
  150083. * Disables an effect by name on a pipeline
  150084. * @param renderPipelineName the name of the pipeline to disable the effect in
  150085. * @param renderEffectName the name of the effect to disable
  150086. * @param cameras the cameras that the effect should be disabled on
  150087. */
  150088. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  150089. /**
  150090. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  150091. */
  150092. update(): void;
  150093. /** @hidden */
  150094. _rebuild(): void;
  150095. /**
  150096. * Disposes of the manager and pipelines
  150097. */
  150098. dispose(): void;
  150099. }
  150100. }
  150101. declare module BABYLON {
  150102. interface Scene {
  150103. /** @hidden (Backing field) */
  150104. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  150105. /**
  150106. * Gets the postprocess render pipeline manager
  150107. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150108. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  150109. */
  150110. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  150111. }
  150112. /**
  150113. * Defines the Render Pipeline scene component responsible to rendering pipelines
  150114. */
  150115. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  150116. /**
  150117. * The component name helpfull to identify the component in the list of scene components.
  150118. */
  150119. readonly name: string;
  150120. /**
  150121. * The scene the component belongs to.
  150122. */
  150123. scene: Scene;
  150124. /**
  150125. * Creates a new instance of the component for the given scene
  150126. * @param scene Defines the scene to register the component in
  150127. */
  150128. constructor(scene: Scene);
  150129. /**
  150130. * Registers the component in a given scene
  150131. */
  150132. register(): void;
  150133. /**
  150134. * Rebuilds the elements related to this component in case of
  150135. * context lost for instance.
  150136. */
  150137. rebuild(): void;
  150138. /**
  150139. * Disposes the component and the associated ressources
  150140. */
  150141. dispose(): void;
  150142. private _gatherRenderTargets;
  150143. }
  150144. }
  150145. declare module BABYLON {
  150146. /**
  150147. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  150148. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  150149. */
  150150. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  150151. private _scene;
  150152. private _camerasToBeAttached;
  150153. /**
  150154. * ID of the sharpen post process,
  150155. */
  150156. private readonly SharpenPostProcessId;
  150157. /**
  150158. * @ignore
  150159. * ID of the image processing post process;
  150160. */
  150161. readonly ImageProcessingPostProcessId: string;
  150162. /**
  150163. * @ignore
  150164. * ID of the Fast Approximate Anti-Aliasing post process;
  150165. */
  150166. readonly FxaaPostProcessId: string;
  150167. /**
  150168. * ID of the chromatic aberration post process,
  150169. */
  150170. private readonly ChromaticAberrationPostProcessId;
  150171. /**
  150172. * ID of the grain post process
  150173. */
  150174. private readonly GrainPostProcessId;
  150175. /**
  150176. * Sharpen post process which will apply a sharpen convolution to enhance edges
  150177. */
  150178. sharpen: SharpenPostProcess;
  150179. private _sharpenEffect;
  150180. private bloom;
  150181. /**
  150182. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  150183. */
  150184. depthOfField: DepthOfFieldEffect;
  150185. /**
  150186. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  150187. */
  150188. fxaa: FxaaPostProcess;
  150189. /**
  150190. * Image post processing pass used to perform operations such as tone mapping or color grading.
  150191. */
  150192. imageProcessing: ImageProcessingPostProcess;
  150193. /**
  150194. * Chromatic aberration post process which will shift rgb colors in the image
  150195. */
  150196. chromaticAberration: ChromaticAberrationPostProcess;
  150197. private _chromaticAberrationEffect;
  150198. /**
  150199. * Grain post process which add noise to the image
  150200. */
  150201. grain: GrainPostProcess;
  150202. private _grainEffect;
  150203. /**
  150204. * Glow post process which adds a glow to emissive areas of the image
  150205. */
  150206. private _glowLayer;
  150207. /**
  150208. * Animations which can be used to tweak settings over a period of time
  150209. */
  150210. animations: Animation[];
  150211. private _imageProcessingConfigurationObserver;
  150212. private _sharpenEnabled;
  150213. private _bloomEnabled;
  150214. private _depthOfFieldEnabled;
  150215. private _depthOfFieldBlurLevel;
  150216. private _fxaaEnabled;
  150217. private _imageProcessingEnabled;
  150218. private _defaultPipelineTextureType;
  150219. private _bloomScale;
  150220. private _chromaticAberrationEnabled;
  150221. private _grainEnabled;
  150222. private _buildAllowed;
  150223. /**
  150224. * Gets active scene
  150225. */
  150226. get scene(): Scene;
  150227. /**
  150228. * Enable or disable the sharpen process from the pipeline
  150229. */
  150230. set sharpenEnabled(enabled: boolean);
  150231. get sharpenEnabled(): boolean;
  150232. private _resizeObserver;
  150233. private _hardwareScaleLevel;
  150234. private _bloomKernel;
  150235. /**
  150236. * Specifies the size of the bloom blur kernel, relative to the final output size
  150237. */
  150238. get bloomKernel(): number;
  150239. set bloomKernel(value: number);
  150240. /**
  150241. * Specifies the weight of the bloom in the final rendering
  150242. */
  150243. private _bloomWeight;
  150244. /**
  150245. * Specifies the luma threshold for the area that will be blurred by the bloom
  150246. */
  150247. private _bloomThreshold;
  150248. private _hdr;
  150249. /**
  150250. * The strength of the bloom.
  150251. */
  150252. set bloomWeight(value: number);
  150253. get bloomWeight(): number;
  150254. /**
  150255. * The strength of the bloom.
  150256. */
  150257. set bloomThreshold(value: number);
  150258. get bloomThreshold(): number;
  150259. /**
  150260. * The scale of the bloom, lower value will provide better performance.
  150261. */
  150262. set bloomScale(value: number);
  150263. get bloomScale(): number;
  150264. /**
  150265. * Enable or disable the bloom from the pipeline
  150266. */
  150267. set bloomEnabled(enabled: boolean);
  150268. get bloomEnabled(): boolean;
  150269. private _rebuildBloom;
  150270. /**
  150271. * If the depth of field is enabled.
  150272. */
  150273. get depthOfFieldEnabled(): boolean;
  150274. set depthOfFieldEnabled(enabled: boolean);
  150275. /**
  150276. * Blur level of the depth of field effect. (Higher blur will effect performance)
  150277. */
  150278. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  150279. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  150280. /**
  150281. * If the anti aliasing is enabled.
  150282. */
  150283. set fxaaEnabled(enabled: boolean);
  150284. get fxaaEnabled(): boolean;
  150285. private _samples;
  150286. /**
  150287. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  150288. */
  150289. set samples(sampleCount: number);
  150290. get samples(): number;
  150291. /**
  150292. * If image processing is enabled.
  150293. */
  150294. set imageProcessingEnabled(enabled: boolean);
  150295. get imageProcessingEnabled(): boolean;
  150296. /**
  150297. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  150298. */
  150299. set glowLayerEnabled(enabled: boolean);
  150300. get glowLayerEnabled(): boolean;
  150301. /**
  150302. * Gets the glow layer (or null if not defined)
  150303. */
  150304. get glowLayer(): Nullable<GlowLayer>;
  150305. /**
  150306. * Enable or disable the chromaticAberration process from the pipeline
  150307. */
  150308. set chromaticAberrationEnabled(enabled: boolean);
  150309. get chromaticAberrationEnabled(): boolean;
  150310. /**
  150311. * Enable or disable the grain process from the pipeline
  150312. */
  150313. set grainEnabled(enabled: boolean);
  150314. get grainEnabled(): boolean;
  150315. /**
  150316. * @constructor
  150317. * @param name - The rendering pipeline name (default: "")
  150318. * @param hdr - If high dynamic range textures should be used (default: true)
  150319. * @param scene - The scene linked to this pipeline (default: the last created scene)
  150320. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  150321. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  150322. */
  150323. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  150324. /**
  150325. * Get the class name
  150326. * @returns "DefaultRenderingPipeline"
  150327. */
  150328. getClassName(): string;
  150329. /**
  150330. * Force the compilation of the entire pipeline.
  150331. */
  150332. prepare(): void;
  150333. private _hasCleared;
  150334. private _prevPostProcess;
  150335. private _prevPrevPostProcess;
  150336. private _setAutoClearAndTextureSharing;
  150337. private _depthOfFieldSceneObserver;
  150338. private _buildPipeline;
  150339. private _disposePostProcesses;
  150340. /**
  150341. * Adds a camera to the pipeline
  150342. * @param camera the camera to be added
  150343. */
  150344. addCamera(camera: Camera): void;
  150345. /**
  150346. * Removes a camera from the pipeline
  150347. * @param camera the camera to remove
  150348. */
  150349. removeCamera(camera: Camera): void;
  150350. /**
  150351. * Dispose of the pipeline and stop all post processes
  150352. */
  150353. dispose(): void;
  150354. /**
  150355. * Serialize the rendering pipeline (Used when exporting)
  150356. * @returns the serialized object
  150357. */
  150358. serialize(): any;
  150359. /**
  150360. * Parse the serialized pipeline
  150361. * @param source Source pipeline.
  150362. * @param scene The scene to load the pipeline to.
  150363. * @param rootUrl The URL of the serialized pipeline.
  150364. * @returns An instantiated pipeline from the serialized object.
  150365. */
  150366. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  150367. }
  150368. }
  150369. declare module BABYLON {
  150370. /** @hidden */
  150371. export var lensHighlightsPixelShader: {
  150372. name: string;
  150373. shader: string;
  150374. };
  150375. }
  150376. declare module BABYLON {
  150377. /** @hidden */
  150378. export var depthOfFieldPixelShader: {
  150379. name: string;
  150380. shader: string;
  150381. };
  150382. }
  150383. declare module BABYLON {
  150384. /**
  150385. * BABYLON.JS Chromatic Aberration GLSL Shader
  150386. * Author: Olivier Guyot
  150387. * Separates very slightly R, G and B colors on the edges of the screen
  150388. * Inspired by Francois Tarlier & Martins Upitis
  150389. */
  150390. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  150391. /**
  150392. * @ignore
  150393. * The chromatic aberration PostProcess id in the pipeline
  150394. */
  150395. LensChromaticAberrationEffect: string;
  150396. /**
  150397. * @ignore
  150398. * The highlights enhancing PostProcess id in the pipeline
  150399. */
  150400. HighlightsEnhancingEffect: string;
  150401. /**
  150402. * @ignore
  150403. * The depth-of-field PostProcess id in the pipeline
  150404. */
  150405. LensDepthOfFieldEffect: string;
  150406. private _scene;
  150407. private _depthTexture;
  150408. private _grainTexture;
  150409. private _chromaticAberrationPostProcess;
  150410. private _highlightsPostProcess;
  150411. private _depthOfFieldPostProcess;
  150412. private _edgeBlur;
  150413. private _grainAmount;
  150414. private _chromaticAberration;
  150415. private _distortion;
  150416. private _highlightsGain;
  150417. private _highlightsThreshold;
  150418. private _dofDistance;
  150419. private _dofAperture;
  150420. private _dofDarken;
  150421. private _dofPentagon;
  150422. private _blurNoise;
  150423. /**
  150424. * @constructor
  150425. *
  150426. * Effect parameters are as follow:
  150427. * {
  150428. * chromatic_aberration: number; // from 0 to x (1 for realism)
  150429. * edge_blur: number; // from 0 to x (1 for realism)
  150430. * distortion: number; // from 0 to x (1 for realism)
  150431. * grain_amount: number; // from 0 to 1
  150432. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  150433. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  150434. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  150435. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  150436. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  150437. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  150438. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  150439. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  150440. * }
  150441. * Note: if an effect parameter is unset, effect is disabled
  150442. *
  150443. * @param name The rendering pipeline name
  150444. * @param parameters - An object containing all parameters (see above)
  150445. * @param scene The scene linked to this pipeline
  150446. * @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)
  150447. * @param cameras The array of cameras that the rendering pipeline will be attached to
  150448. */
  150449. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  150450. /**
  150451. * Get the class name
  150452. * @returns "LensRenderingPipeline"
  150453. */
  150454. getClassName(): string;
  150455. /**
  150456. * Gets associated scene
  150457. */
  150458. get scene(): Scene;
  150459. /**
  150460. * Gets or sets the edge blur
  150461. */
  150462. get edgeBlur(): number;
  150463. set edgeBlur(value: number);
  150464. /**
  150465. * Gets or sets the grain amount
  150466. */
  150467. get grainAmount(): number;
  150468. set grainAmount(value: number);
  150469. /**
  150470. * Gets or sets the chromatic aberration amount
  150471. */
  150472. get chromaticAberration(): number;
  150473. set chromaticAberration(value: number);
  150474. /**
  150475. * Gets or sets the depth of field aperture
  150476. */
  150477. get dofAperture(): number;
  150478. set dofAperture(value: number);
  150479. /**
  150480. * Gets or sets the edge distortion
  150481. */
  150482. get edgeDistortion(): number;
  150483. set edgeDistortion(value: number);
  150484. /**
  150485. * Gets or sets the depth of field distortion
  150486. */
  150487. get dofDistortion(): number;
  150488. set dofDistortion(value: number);
  150489. /**
  150490. * Gets or sets the darken out of focus amount
  150491. */
  150492. get darkenOutOfFocus(): number;
  150493. set darkenOutOfFocus(value: number);
  150494. /**
  150495. * Gets or sets a boolean indicating if blur noise is enabled
  150496. */
  150497. get blurNoise(): boolean;
  150498. set blurNoise(value: boolean);
  150499. /**
  150500. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  150501. */
  150502. get pentagonBokeh(): boolean;
  150503. set pentagonBokeh(value: boolean);
  150504. /**
  150505. * Gets or sets the highlight grain amount
  150506. */
  150507. get highlightsGain(): number;
  150508. set highlightsGain(value: number);
  150509. /**
  150510. * Gets or sets the highlight threshold
  150511. */
  150512. get highlightsThreshold(): number;
  150513. set highlightsThreshold(value: number);
  150514. /**
  150515. * Sets the amount of blur at the edges
  150516. * @param amount blur amount
  150517. */
  150518. setEdgeBlur(amount: number): void;
  150519. /**
  150520. * Sets edge blur to 0
  150521. */
  150522. disableEdgeBlur(): void;
  150523. /**
  150524. * Sets the amout of grain
  150525. * @param amount Amount of grain
  150526. */
  150527. setGrainAmount(amount: number): void;
  150528. /**
  150529. * Set grain amount to 0
  150530. */
  150531. disableGrain(): void;
  150532. /**
  150533. * Sets the chromatic aberration amount
  150534. * @param amount amount of chromatic aberration
  150535. */
  150536. setChromaticAberration(amount: number): void;
  150537. /**
  150538. * Sets chromatic aberration amount to 0
  150539. */
  150540. disableChromaticAberration(): void;
  150541. /**
  150542. * Sets the EdgeDistortion amount
  150543. * @param amount amount of EdgeDistortion
  150544. */
  150545. setEdgeDistortion(amount: number): void;
  150546. /**
  150547. * Sets edge distortion to 0
  150548. */
  150549. disableEdgeDistortion(): void;
  150550. /**
  150551. * Sets the FocusDistance amount
  150552. * @param amount amount of FocusDistance
  150553. */
  150554. setFocusDistance(amount: number): void;
  150555. /**
  150556. * Disables depth of field
  150557. */
  150558. disableDepthOfField(): void;
  150559. /**
  150560. * Sets the Aperture amount
  150561. * @param amount amount of Aperture
  150562. */
  150563. setAperture(amount: number): void;
  150564. /**
  150565. * Sets the DarkenOutOfFocus amount
  150566. * @param amount amount of DarkenOutOfFocus
  150567. */
  150568. setDarkenOutOfFocus(amount: number): void;
  150569. private _pentagonBokehIsEnabled;
  150570. /**
  150571. * Creates a pentagon bokeh effect
  150572. */
  150573. enablePentagonBokeh(): void;
  150574. /**
  150575. * Disables the pentagon bokeh effect
  150576. */
  150577. disablePentagonBokeh(): void;
  150578. /**
  150579. * Enables noise blur
  150580. */
  150581. enableNoiseBlur(): void;
  150582. /**
  150583. * Disables noise blur
  150584. */
  150585. disableNoiseBlur(): void;
  150586. /**
  150587. * Sets the HighlightsGain amount
  150588. * @param amount amount of HighlightsGain
  150589. */
  150590. setHighlightsGain(amount: number): void;
  150591. /**
  150592. * Sets the HighlightsThreshold amount
  150593. * @param amount amount of HighlightsThreshold
  150594. */
  150595. setHighlightsThreshold(amount: number): void;
  150596. /**
  150597. * Disables highlights
  150598. */
  150599. disableHighlights(): void;
  150600. /**
  150601. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  150602. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  150603. */
  150604. dispose(disableDepthRender?: boolean): void;
  150605. private _createChromaticAberrationPostProcess;
  150606. private _createHighlightsPostProcess;
  150607. private _createDepthOfFieldPostProcess;
  150608. private _createGrainTexture;
  150609. }
  150610. }
  150611. declare module BABYLON {
  150612. /** @hidden */
  150613. export var ssao2PixelShader: {
  150614. name: string;
  150615. shader: string;
  150616. };
  150617. }
  150618. declare module BABYLON {
  150619. /** @hidden */
  150620. export var ssaoCombinePixelShader: {
  150621. name: string;
  150622. shader: string;
  150623. };
  150624. }
  150625. declare module BABYLON {
  150626. /**
  150627. * Render pipeline to produce ssao effect
  150628. */
  150629. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  150630. /**
  150631. * @ignore
  150632. * The PassPostProcess id in the pipeline that contains the original scene color
  150633. */
  150634. SSAOOriginalSceneColorEffect: string;
  150635. /**
  150636. * @ignore
  150637. * The SSAO PostProcess id in the pipeline
  150638. */
  150639. SSAORenderEffect: string;
  150640. /**
  150641. * @ignore
  150642. * The horizontal blur PostProcess id in the pipeline
  150643. */
  150644. SSAOBlurHRenderEffect: string;
  150645. /**
  150646. * @ignore
  150647. * The vertical blur PostProcess id in the pipeline
  150648. */
  150649. SSAOBlurVRenderEffect: string;
  150650. /**
  150651. * @ignore
  150652. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  150653. */
  150654. SSAOCombineRenderEffect: string;
  150655. /**
  150656. * The output strength of the SSAO post-process. Default value is 1.0.
  150657. */
  150658. totalStrength: number;
  150659. /**
  150660. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  150661. */
  150662. maxZ: number;
  150663. /**
  150664. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  150665. */
  150666. minZAspect: number;
  150667. private _samples;
  150668. /**
  150669. * Number of samples used for the SSAO calculations. Default value is 8
  150670. */
  150671. set samples(n: number);
  150672. get samples(): number;
  150673. private _textureSamples;
  150674. /**
  150675. * Number of samples to use for antialiasing
  150676. */
  150677. set textureSamples(n: number);
  150678. get textureSamples(): number;
  150679. /**
  150680. * Force rendering the geometry through geometry buffer
  150681. */
  150682. private _forceGeometryBuffer;
  150683. /**
  150684. * Ratio object used for SSAO ratio and blur ratio
  150685. */
  150686. private _ratio;
  150687. /**
  150688. * Dynamically generated sphere sampler.
  150689. */
  150690. private _sampleSphere;
  150691. /**
  150692. * Blur filter offsets
  150693. */
  150694. private _samplerOffsets;
  150695. private _expensiveBlur;
  150696. /**
  150697. * If bilateral blur should be used
  150698. */
  150699. set expensiveBlur(b: boolean);
  150700. get expensiveBlur(): boolean;
  150701. /**
  150702. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  150703. */
  150704. radius: number;
  150705. /**
  150706. * The base color of the SSAO post-process
  150707. * The final result is "base + ssao" between [0, 1]
  150708. */
  150709. base: number;
  150710. /**
  150711. * Support test.
  150712. */
  150713. static get IsSupported(): boolean;
  150714. private _scene;
  150715. private _randomTexture;
  150716. private _originalColorPostProcess;
  150717. private _ssaoPostProcess;
  150718. private _blurHPostProcess;
  150719. private _blurVPostProcess;
  150720. private _ssaoCombinePostProcess;
  150721. private _prePassRenderer;
  150722. /**
  150723. * Gets active scene
  150724. */
  150725. get scene(): Scene;
  150726. /**
  150727. * @constructor
  150728. * @param name The rendering pipeline name
  150729. * @param scene The scene linked to this pipeline
  150730. * @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 }
  150731. * @param cameras The array of cameras that the rendering pipeline will be attached to
  150732. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  150733. */
  150734. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  150735. /**
  150736. * Get the class name
  150737. * @returns "SSAO2RenderingPipeline"
  150738. */
  150739. getClassName(): string;
  150740. /**
  150741. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  150742. */
  150743. dispose(disableGeometryBufferRenderer?: boolean): void;
  150744. private _createBlurPostProcess;
  150745. /** @hidden */
  150746. _rebuild(): void;
  150747. private _bits;
  150748. private _radicalInverse_VdC;
  150749. private _hammersley;
  150750. private _hemisphereSample_uniform;
  150751. private _generateHemisphere;
  150752. private _getDefinesForSSAO;
  150753. private _createSSAOPostProcess;
  150754. private _createSSAOCombinePostProcess;
  150755. private _createRandomTexture;
  150756. /**
  150757. * Serialize the rendering pipeline (Used when exporting)
  150758. * @returns the serialized object
  150759. */
  150760. serialize(): any;
  150761. /**
  150762. * Parse the serialized pipeline
  150763. * @param source Source pipeline.
  150764. * @param scene The scene to load the pipeline to.
  150765. * @param rootUrl The URL of the serialized pipeline.
  150766. * @returns An instantiated pipeline from the serialized object.
  150767. */
  150768. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  150769. /**
  150770. * Sets the required values to the prepass renderer.
  150771. * @param prePassRenderer defines the prepass renderer to setup
  150772. * @returns true if the pre pass is needed.
  150773. */
  150774. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  150775. }
  150776. }
  150777. declare module BABYLON {
  150778. /** @hidden */
  150779. export var ssaoPixelShader: {
  150780. name: string;
  150781. shader: string;
  150782. };
  150783. }
  150784. declare module BABYLON {
  150785. /**
  150786. * Render pipeline to produce ssao effect
  150787. */
  150788. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  150789. /**
  150790. * @ignore
  150791. * The PassPostProcess id in the pipeline that contains the original scene color
  150792. */
  150793. SSAOOriginalSceneColorEffect: string;
  150794. /**
  150795. * @ignore
  150796. * The SSAO PostProcess id in the pipeline
  150797. */
  150798. SSAORenderEffect: string;
  150799. /**
  150800. * @ignore
  150801. * The horizontal blur PostProcess id in the pipeline
  150802. */
  150803. SSAOBlurHRenderEffect: string;
  150804. /**
  150805. * @ignore
  150806. * The vertical blur PostProcess id in the pipeline
  150807. */
  150808. SSAOBlurVRenderEffect: string;
  150809. /**
  150810. * @ignore
  150811. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  150812. */
  150813. SSAOCombineRenderEffect: string;
  150814. /**
  150815. * The output strength of the SSAO post-process. Default value is 1.0.
  150816. */
  150817. totalStrength: number;
  150818. /**
  150819. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  150820. */
  150821. radius: number;
  150822. /**
  150823. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  150824. * Must not be equal to fallOff and superior to fallOff.
  150825. * Default value is 0.0075
  150826. */
  150827. area: number;
  150828. /**
  150829. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  150830. * Must not be equal to area and inferior to area.
  150831. * Default value is 0.000001
  150832. */
  150833. fallOff: number;
  150834. /**
  150835. * The base color of the SSAO post-process
  150836. * The final result is "base + ssao" between [0, 1]
  150837. */
  150838. base: number;
  150839. private _scene;
  150840. private _depthTexture;
  150841. private _randomTexture;
  150842. private _originalColorPostProcess;
  150843. private _ssaoPostProcess;
  150844. private _blurHPostProcess;
  150845. private _blurVPostProcess;
  150846. private _ssaoCombinePostProcess;
  150847. private _firstUpdate;
  150848. /**
  150849. * Gets active scene
  150850. */
  150851. get scene(): Scene;
  150852. /**
  150853. * @constructor
  150854. * @param name - The rendering pipeline name
  150855. * @param scene - The scene linked to this pipeline
  150856. * @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 }
  150857. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  150858. */
  150859. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  150860. /**
  150861. * Get the class name
  150862. * @returns "SSAORenderingPipeline"
  150863. */
  150864. getClassName(): string;
  150865. /**
  150866. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  150867. */
  150868. dispose(disableDepthRender?: boolean): void;
  150869. private _createBlurPostProcess;
  150870. /** @hidden */
  150871. _rebuild(): void;
  150872. private _createSSAOPostProcess;
  150873. private _createSSAOCombinePostProcess;
  150874. private _createRandomTexture;
  150875. }
  150876. }
  150877. declare module BABYLON {
  150878. /** @hidden */
  150879. export var screenSpaceReflectionPixelShader: {
  150880. name: string;
  150881. shader: string;
  150882. };
  150883. }
  150884. declare module BABYLON {
  150885. /**
  150886. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  150887. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  150888. */
  150889. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  150890. /**
  150891. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  150892. */
  150893. threshold: number;
  150894. /**
  150895. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  150896. */
  150897. strength: number;
  150898. /**
  150899. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  150900. */
  150901. reflectionSpecularFalloffExponent: number;
  150902. /**
  150903. * 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]
  150904. */
  150905. step: number;
  150906. /**
  150907. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  150908. */
  150909. roughnessFactor: number;
  150910. private _geometryBufferRenderer;
  150911. private _enableSmoothReflections;
  150912. private _reflectionSamples;
  150913. private _smoothSteps;
  150914. /**
  150915. * Gets a string identifying the name of the class
  150916. * @returns "ScreenSpaceReflectionPostProcess" string
  150917. */
  150918. getClassName(): string;
  150919. /**
  150920. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  150921. * @param name The name of the effect.
  150922. * @param scene The scene containing the objects to calculate reflections.
  150923. * @param options The required width/height ratio to downsize to before computing the render pass.
  150924. * @param camera The camera to apply the render pass to.
  150925. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150926. * @param engine The engine which the post process will be applied. (default: current engine)
  150927. * @param reusable If the post process can be reused on the same frame. (default: false)
  150928. * @param textureType Type of textures used when performing the post process. (default: 0)
  150929. * @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)
  150930. */
  150931. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150932. /**
  150933. * Gets wether or not smoothing reflections is enabled.
  150934. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  150935. */
  150936. get enableSmoothReflections(): boolean;
  150937. /**
  150938. * Sets wether or not smoothing reflections is enabled.
  150939. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  150940. */
  150941. set enableSmoothReflections(enabled: boolean);
  150942. /**
  150943. * Gets the number of samples taken while computing reflections. More samples count is high,
  150944. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  150945. */
  150946. get reflectionSamples(): number;
  150947. /**
  150948. * Sets the number of samples taken while computing reflections. More samples count is high,
  150949. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  150950. */
  150951. set reflectionSamples(samples: number);
  150952. /**
  150953. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  150954. * more the post-process will require GPU power and can generate a drop in FPS.
  150955. * Default value (5.0) work pretty well in all cases but can be adjusted.
  150956. */
  150957. get smoothSteps(): number;
  150958. set smoothSteps(steps: number);
  150959. private _updateEffectDefines;
  150960. /** @hidden */
  150961. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  150962. }
  150963. }
  150964. declare module BABYLON {
  150965. /** @hidden */
  150966. export var standardPixelShader: {
  150967. name: string;
  150968. shader: string;
  150969. };
  150970. }
  150971. declare module BABYLON {
  150972. /**
  150973. * Standard rendering pipeline
  150974. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  150975. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  150976. */
  150977. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  150978. /**
  150979. * Public members
  150980. */
  150981. /**
  150982. * Post-process which contains the original scene color before the pipeline applies all the effects
  150983. */
  150984. originalPostProcess: Nullable<PostProcess>;
  150985. /**
  150986. * Post-process used to down scale an image x4
  150987. */
  150988. downSampleX4PostProcess: Nullable<PostProcess>;
  150989. /**
  150990. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  150991. */
  150992. brightPassPostProcess: Nullable<PostProcess>;
  150993. /**
  150994. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  150995. */
  150996. blurHPostProcesses: PostProcess[];
  150997. /**
  150998. * Post-process array storing all the vertical blur post-processes used by the pipeline
  150999. */
  151000. blurVPostProcesses: PostProcess[];
  151001. /**
  151002. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  151003. */
  151004. textureAdderPostProcess: Nullable<PostProcess>;
  151005. /**
  151006. * Post-process used to create volumetric lighting effect
  151007. */
  151008. volumetricLightPostProcess: Nullable<PostProcess>;
  151009. /**
  151010. * Post-process used to smooth the previous volumetric light post-process on the X axis
  151011. */
  151012. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  151013. /**
  151014. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  151015. */
  151016. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  151017. /**
  151018. * Post-process used to merge the volumetric light effect and the real scene color
  151019. */
  151020. volumetricLightMergePostProces: Nullable<PostProcess>;
  151021. /**
  151022. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  151023. */
  151024. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  151025. /**
  151026. * Base post-process used to calculate the average luminance of the final image for HDR
  151027. */
  151028. luminancePostProcess: Nullable<PostProcess>;
  151029. /**
  151030. * Post-processes used to create down sample post-processes in order to get
  151031. * the average luminance of the final image for HDR
  151032. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  151033. */
  151034. luminanceDownSamplePostProcesses: PostProcess[];
  151035. /**
  151036. * Post-process used to create a HDR effect (light adaptation)
  151037. */
  151038. hdrPostProcess: Nullable<PostProcess>;
  151039. /**
  151040. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  151041. */
  151042. textureAdderFinalPostProcess: Nullable<PostProcess>;
  151043. /**
  151044. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  151045. */
  151046. lensFlareFinalPostProcess: Nullable<PostProcess>;
  151047. /**
  151048. * Post-process used to merge the final HDR post-process and the real scene color
  151049. */
  151050. hdrFinalPostProcess: Nullable<PostProcess>;
  151051. /**
  151052. * Post-process used to create a lens flare effect
  151053. */
  151054. lensFlarePostProcess: Nullable<PostProcess>;
  151055. /**
  151056. * Post-process that merges the result of the lens flare post-process and the real scene color
  151057. */
  151058. lensFlareComposePostProcess: Nullable<PostProcess>;
  151059. /**
  151060. * Post-process used to create a motion blur effect
  151061. */
  151062. motionBlurPostProcess: Nullable<PostProcess>;
  151063. /**
  151064. * Post-process used to create a depth of field effect
  151065. */
  151066. depthOfFieldPostProcess: Nullable<PostProcess>;
  151067. /**
  151068. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  151069. */
  151070. fxaaPostProcess: Nullable<FxaaPostProcess>;
  151071. /**
  151072. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  151073. */
  151074. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  151075. /**
  151076. * Represents the brightness threshold in order to configure the illuminated surfaces
  151077. */
  151078. brightThreshold: number;
  151079. /**
  151080. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  151081. */
  151082. blurWidth: number;
  151083. /**
  151084. * Sets if the blur for highlighted surfaces must be only horizontal
  151085. */
  151086. horizontalBlur: boolean;
  151087. /**
  151088. * Gets the overall exposure used by the pipeline
  151089. */
  151090. get exposure(): number;
  151091. /**
  151092. * Sets the overall exposure used by the pipeline
  151093. */
  151094. set exposure(value: number);
  151095. /**
  151096. * Texture used typically to simulate "dirty" on camera lens
  151097. */
  151098. lensTexture: Nullable<Texture>;
  151099. /**
  151100. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  151101. */
  151102. volumetricLightCoefficient: number;
  151103. /**
  151104. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  151105. */
  151106. volumetricLightPower: number;
  151107. /**
  151108. * Used the set the blur intensity to smooth the volumetric lights
  151109. */
  151110. volumetricLightBlurScale: number;
  151111. /**
  151112. * Light (spot or directional) used to generate the volumetric lights rays
  151113. * The source light must have a shadow generate so the pipeline can get its
  151114. * depth map
  151115. */
  151116. sourceLight: Nullable<SpotLight | DirectionalLight>;
  151117. /**
  151118. * For eye adaptation, represents the minimum luminance the eye can see
  151119. */
  151120. hdrMinimumLuminance: number;
  151121. /**
  151122. * For eye adaptation, represents the decrease luminance speed
  151123. */
  151124. hdrDecreaseRate: number;
  151125. /**
  151126. * For eye adaptation, represents the increase luminance speed
  151127. */
  151128. hdrIncreaseRate: number;
  151129. /**
  151130. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  151131. */
  151132. get hdrAutoExposure(): boolean;
  151133. /**
  151134. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  151135. */
  151136. set hdrAutoExposure(value: boolean);
  151137. /**
  151138. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  151139. */
  151140. lensColorTexture: Nullable<Texture>;
  151141. /**
  151142. * The overall strengh for the lens flare effect
  151143. */
  151144. lensFlareStrength: number;
  151145. /**
  151146. * Dispersion coefficient for lens flare ghosts
  151147. */
  151148. lensFlareGhostDispersal: number;
  151149. /**
  151150. * Main lens flare halo width
  151151. */
  151152. lensFlareHaloWidth: number;
  151153. /**
  151154. * Based on the lens distortion effect, defines how much the lens flare result
  151155. * is distorted
  151156. */
  151157. lensFlareDistortionStrength: number;
  151158. /**
  151159. * Configures the blur intensity used for for lens flare (halo)
  151160. */
  151161. lensFlareBlurWidth: number;
  151162. /**
  151163. * Lens star texture must be used to simulate rays on the flares and is available
  151164. * in the documentation
  151165. */
  151166. lensStarTexture: Nullable<Texture>;
  151167. /**
  151168. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  151169. * flare effect by taking account of the dirt texture
  151170. */
  151171. lensFlareDirtTexture: Nullable<Texture>;
  151172. /**
  151173. * Represents the focal length for the depth of field effect
  151174. */
  151175. depthOfFieldDistance: number;
  151176. /**
  151177. * Represents the blur intensity for the blurred part of the depth of field effect
  151178. */
  151179. depthOfFieldBlurWidth: number;
  151180. /**
  151181. * Gets how much the image is blurred by the movement while using the motion blur post-process
  151182. */
  151183. get motionStrength(): number;
  151184. /**
  151185. * Sets how much the image is blurred by the movement while using the motion blur post-process
  151186. */
  151187. set motionStrength(strength: number);
  151188. /**
  151189. * Gets wether or not the motion blur post-process is object based or screen based.
  151190. */
  151191. get objectBasedMotionBlur(): boolean;
  151192. /**
  151193. * Sets wether or not the motion blur post-process should be object based or screen based
  151194. */
  151195. set objectBasedMotionBlur(value: boolean);
  151196. /**
  151197. * List of animations for the pipeline (IAnimatable implementation)
  151198. */
  151199. animations: Animation[];
  151200. /**
  151201. * Private members
  151202. */
  151203. private _scene;
  151204. private _currentDepthOfFieldSource;
  151205. private _basePostProcess;
  151206. private _fixedExposure;
  151207. private _currentExposure;
  151208. private _hdrAutoExposure;
  151209. private _hdrCurrentLuminance;
  151210. private _motionStrength;
  151211. private _isObjectBasedMotionBlur;
  151212. private _floatTextureType;
  151213. private _camerasToBeAttached;
  151214. private _ratio;
  151215. private _bloomEnabled;
  151216. private _depthOfFieldEnabled;
  151217. private _vlsEnabled;
  151218. private _lensFlareEnabled;
  151219. private _hdrEnabled;
  151220. private _motionBlurEnabled;
  151221. private _fxaaEnabled;
  151222. private _screenSpaceReflectionsEnabled;
  151223. private _motionBlurSamples;
  151224. private _volumetricLightStepsCount;
  151225. private _samples;
  151226. /**
  151227. * @ignore
  151228. * Specifies if the bloom pipeline is enabled
  151229. */
  151230. get BloomEnabled(): boolean;
  151231. set BloomEnabled(enabled: boolean);
  151232. /**
  151233. * @ignore
  151234. * Specifies if the depth of field pipeline is enabed
  151235. */
  151236. get DepthOfFieldEnabled(): boolean;
  151237. set DepthOfFieldEnabled(enabled: boolean);
  151238. /**
  151239. * @ignore
  151240. * Specifies if the lens flare pipeline is enabed
  151241. */
  151242. get LensFlareEnabled(): boolean;
  151243. set LensFlareEnabled(enabled: boolean);
  151244. /**
  151245. * @ignore
  151246. * Specifies if the HDR pipeline is enabled
  151247. */
  151248. get HDREnabled(): boolean;
  151249. set HDREnabled(enabled: boolean);
  151250. /**
  151251. * @ignore
  151252. * Specifies if the volumetric lights scattering effect is enabled
  151253. */
  151254. get VLSEnabled(): boolean;
  151255. set VLSEnabled(enabled: boolean);
  151256. /**
  151257. * @ignore
  151258. * Specifies if the motion blur effect is enabled
  151259. */
  151260. get MotionBlurEnabled(): boolean;
  151261. set MotionBlurEnabled(enabled: boolean);
  151262. /**
  151263. * Specifies if anti-aliasing is enabled
  151264. */
  151265. get fxaaEnabled(): boolean;
  151266. set fxaaEnabled(enabled: boolean);
  151267. /**
  151268. * Specifies if screen space reflections are enabled.
  151269. */
  151270. get screenSpaceReflectionsEnabled(): boolean;
  151271. set screenSpaceReflectionsEnabled(enabled: boolean);
  151272. /**
  151273. * Specifies the number of steps used to calculate the volumetric lights
  151274. * Typically in interval [50, 200]
  151275. */
  151276. get volumetricLightStepsCount(): number;
  151277. set volumetricLightStepsCount(count: number);
  151278. /**
  151279. * Specifies the number of samples used for the motion blur effect
  151280. * Typically in interval [16, 64]
  151281. */
  151282. get motionBlurSamples(): number;
  151283. set motionBlurSamples(samples: number);
  151284. /**
  151285. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  151286. */
  151287. get samples(): number;
  151288. set samples(sampleCount: number);
  151289. /**
  151290. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  151291. * @constructor
  151292. * @param name The rendering pipeline name
  151293. * @param scene The scene linked to this pipeline
  151294. * @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)
  151295. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  151296. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151297. */
  151298. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  151299. private _buildPipeline;
  151300. private _createDownSampleX4PostProcess;
  151301. private _createBrightPassPostProcess;
  151302. private _createBlurPostProcesses;
  151303. private _createTextureAdderPostProcess;
  151304. private _createVolumetricLightPostProcess;
  151305. private _createLuminancePostProcesses;
  151306. private _createHdrPostProcess;
  151307. private _createLensFlarePostProcess;
  151308. private _createDepthOfFieldPostProcess;
  151309. private _createMotionBlurPostProcess;
  151310. private _getDepthTexture;
  151311. private _disposePostProcesses;
  151312. /**
  151313. * Dispose of the pipeline and stop all post processes
  151314. */
  151315. dispose(): void;
  151316. /**
  151317. * Serialize the rendering pipeline (Used when exporting)
  151318. * @returns the serialized object
  151319. */
  151320. serialize(): any;
  151321. /**
  151322. * Parse the serialized pipeline
  151323. * @param source Source pipeline.
  151324. * @param scene The scene to load the pipeline to.
  151325. * @param rootUrl The URL of the serialized pipeline.
  151326. * @returns An instantiated pipeline from the serialized object.
  151327. */
  151328. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  151329. /**
  151330. * Luminance steps
  151331. */
  151332. static LuminanceSteps: number;
  151333. }
  151334. }
  151335. declare module BABYLON {
  151336. /** @hidden */
  151337. export var stereoscopicInterlacePixelShader: {
  151338. name: string;
  151339. shader: string;
  151340. };
  151341. }
  151342. declare module BABYLON {
  151343. /**
  151344. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  151345. */
  151346. export class StereoscopicInterlacePostProcessI extends PostProcess {
  151347. private _stepSize;
  151348. private _passedProcess;
  151349. /**
  151350. * Gets a string identifying the name of the class
  151351. * @returns "StereoscopicInterlacePostProcessI" string
  151352. */
  151353. getClassName(): string;
  151354. /**
  151355. * Initializes a StereoscopicInterlacePostProcessI
  151356. * @param name The name of the effect.
  151357. * @param rigCameras The rig cameras to be appled to the post process
  151358. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  151359. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  151360. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151361. * @param engine The engine which the post process will be applied. (default: current engine)
  151362. * @param reusable If the post process can be reused on the same frame. (default: false)
  151363. */
  151364. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151365. }
  151366. /**
  151367. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  151368. */
  151369. export class StereoscopicInterlacePostProcess extends PostProcess {
  151370. private _stepSize;
  151371. private _passedProcess;
  151372. /**
  151373. * Gets a string identifying the name of the class
  151374. * @returns "StereoscopicInterlacePostProcess" string
  151375. */
  151376. getClassName(): string;
  151377. /**
  151378. * Initializes a StereoscopicInterlacePostProcess
  151379. * @param name The name of the effect.
  151380. * @param rigCameras The rig cameras to be appled to the post process
  151381. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  151382. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151383. * @param engine The engine which the post process will be applied. (default: current engine)
  151384. * @param reusable If the post process can be reused on the same frame. (default: false)
  151385. */
  151386. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151387. }
  151388. }
  151389. declare module BABYLON {
  151390. /** @hidden */
  151391. export var tonemapPixelShader: {
  151392. name: string;
  151393. shader: string;
  151394. };
  151395. }
  151396. declare module BABYLON {
  151397. /** Defines operator used for tonemapping */
  151398. export enum TonemappingOperator {
  151399. /** Hable */
  151400. Hable = 0,
  151401. /** Reinhard */
  151402. Reinhard = 1,
  151403. /** HejiDawson */
  151404. HejiDawson = 2,
  151405. /** Photographic */
  151406. Photographic = 3
  151407. }
  151408. /**
  151409. * Defines a post process to apply tone mapping
  151410. */
  151411. export class TonemapPostProcess extends PostProcess {
  151412. private _operator;
  151413. /** Defines the required exposure adjustement */
  151414. exposureAdjustment: number;
  151415. /**
  151416. * Gets a string identifying the name of the class
  151417. * @returns "TonemapPostProcess" string
  151418. */
  151419. getClassName(): string;
  151420. /**
  151421. * Creates a new TonemapPostProcess
  151422. * @param name defines the name of the postprocess
  151423. * @param _operator defines the operator to use
  151424. * @param exposureAdjustment defines the required exposure adjustement
  151425. * @param camera defines the camera to use (can be null)
  151426. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  151427. * @param engine defines the hosting engine (can be ignore if camera is set)
  151428. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  151429. */
  151430. constructor(name: string, _operator: TonemappingOperator,
  151431. /** Defines the required exposure adjustement */
  151432. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  151433. }
  151434. }
  151435. declare module BABYLON {
  151436. /** @hidden */
  151437. export var volumetricLightScatteringPixelShader: {
  151438. name: string;
  151439. shader: string;
  151440. };
  151441. }
  151442. declare module BABYLON {
  151443. /** @hidden */
  151444. export var volumetricLightScatteringPassVertexShader: {
  151445. name: string;
  151446. shader: string;
  151447. };
  151448. }
  151449. declare module BABYLON {
  151450. /** @hidden */
  151451. export var volumetricLightScatteringPassPixelShader: {
  151452. name: string;
  151453. shader: string;
  151454. };
  151455. }
  151456. declare module BABYLON {
  151457. /**
  151458. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  151459. */
  151460. export class VolumetricLightScatteringPostProcess extends PostProcess {
  151461. private _volumetricLightScatteringPass;
  151462. private _volumetricLightScatteringRTT;
  151463. private _viewPort;
  151464. private _screenCoordinates;
  151465. private _cachedDefines;
  151466. /**
  151467. * If not undefined, the mesh position is computed from the attached node position
  151468. */
  151469. attachedNode: {
  151470. position: Vector3;
  151471. };
  151472. /**
  151473. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  151474. */
  151475. customMeshPosition: Vector3;
  151476. /**
  151477. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  151478. */
  151479. useCustomMeshPosition: boolean;
  151480. /**
  151481. * If the post-process should inverse the light scattering direction
  151482. */
  151483. invert: boolean;
  151484. /**
  151485. * The internal mesh used by the post-process
  151486. */
  151487. mesh: Mesh;
  151488. /**
  151489. * @hidden
  151490. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  151491. */
  151492. get useDiffuseColor(): boolean;
  151493. set useDiffuseColor(useDiffuseColor: boolean);
  151494. /**
  151495. * Array containing the excluded meshes not rendered in the internal pass
  151496. */
  151497. excludedMeshes: AbstractMesh[];
  151498. /**
  151499. * Controls the overall intensity of the post-process
  151500. */
  151501. exposure: number;
  151502. /**
  151503. * Dissipates each sample's contribution in range [0, 1]
  151504. */
  151505. decay: number;
  151506. /**
  151507. * Controls the overall intensity of each sample
  151508. */
  151509. weight: number;
  151510. /**
  151511. * Controls the density of each sample
  151512. */
  151513. density: number;
  151514. /**
  151515. * @constructor
  151516. * @param name The post-process name
  151517. * @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)
  151518. * @param camera The camera that the post-process will be attached to
  151519. * @param mesh The mesh used to create the light scattering
  151520. * @param samples The post-process quality, default 100
  151521. * @param samplingModeThe post-process filtering mode
  151522. * @param engine The babylon engine
  151523. * @param reusable If the post-process is reusable
  151524. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  151525. */
  151526. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  151527. /**
  151528. * Returns the string "VolumetricLightScatteringPostProcess"
  151529. * @returns "VolumetricLightScatteringPostProcess"
  151530. */
  151531. getClassName(): string;
  151532. private _isReady;
  151533. /**
  151534. * Sets the new light position for light scattering effect
  151535. * @param position The new custom light position
  151536. */
  151537. setCustomMeshPosition(position: Vector3): void;
  151538. /**
  151539. * Returns the light position for light scattering effect
  151540. * @return Vector3 The custom light position
  151541. */
  151542. getCustomMeshPosition(): Vector3;
  151543. /**
  151544. * Disposes the internal assets and detaches the post-process from the camera
  151545. */
  151546. dispose(camera: Camera): void;
  151547. /**
  151548. * Returns the render target texture used by the post-process
  151549. * @return the render target texture used by the post-process
  151550. */
  151551. getPass(): RenderTargetTexture;
  151552. private _meshExcluded;
  151553. private _createPass;
  151554. private _updateMeshScreenCoordinates;
  151555. /**
  151556. * Creates a default mesh for the Volumeric Light Scattering post-process
  151557. * @param name The mesh name
  151558. * @param scene The scene where to create the mesh
  151559. * @return the default mesh
  151560. */
  151561. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  151562. }
  151563. }
  151564. declare module BABYLON {
  151565. /** @hidden */
  151566. export var screenSpaceCurvaturePixelShader: {
  151567. name: string;
  151568. shader: string;
  151569. };
  151570. }
  151571. declare module BABYLON {
  151572. /**
  151573. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  151574. */
  151575. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  151576. /**
  151577. * Defines how much ridge the curvature effect displays.
  151578. */
  151579. ridge: number;
  151580. /**
  151581. * Defines how much valley the curvature effect displays.
  151582. */
  151583. valley: number;
  151584. private _geometryBufferRenderer;
  151585. /**
  151586. * Gets a string identifying the name of the class
  151587. * @returns "ScreenSpaceCurvaturePostProcess" string
  151588. */
  151589. getClassName(): string;
  151590. /**
  151591. * Creates a new instance ScreenSpaceCurvaturePostProcess
  151592. * @param name The name of the effect.
  151593. * @param scene The scene containing the objects to blur according to their velocity.
  151594. * @param options The required width/height ratio to downsize to before computing the render pass.
  151595. * @param camera The camera to apply the render pass to.
  151596. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151597. * @param engine The engine which the post process will be applied. (default: current engine)
  151598. * @param reusable If the post process can be reused on the same frame. (default: false)
  151599. * @param textureType Type of textures used when performing the post process. (default: 0)
  151600. * @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)
  151601. */
  151602. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151603. /**
  151604. * Support test.
  151605. */
  151606. static get IsSupported(): boolean;
  151607. /** @hidden */
  151608. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  151609. }
  151610. }
  151611. declare module BABYLON {
  151612. interface Scene {
  151613. /** @hidden (Backing field) */
  151614. _boundingBoxRenderer: BoundingBoxRenderer;
  151615. /** @hidden (Backing field) */
  151616. _forceShowBoundingBoxes: boolean;
  151617. /**
  151618. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  151619. */
  151620. forceShowBoundingBoxes: boolean;
  151621. /**
  151622. * Gets the bounding box renderer associated with the scene
  151623. * @returns a BoundingBoxRenderer
  151624. */
  151625. getBoundingBoxRenderer(): BoundingBoxRenderer;
  151626. }
  151627. interface AbstractMesh {
  151628. /** @hidden (Backing field) */
  151629. _showBoundingBox: boolean;
  151630. /**
  151631. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  151632. */
  151633. showBoundingBox: boolean;
  151634. }
  151635. /**
  151636. * Component responsible of rendering the bounding box of the meshes in a scene.
  151637. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  151638. */
  151639. export class BoundingBoxRenderer implements ISceneComponent {
  151640. /**
  151641. * The component name helpfull to identify the component in the list of scene components.
  151642. */
  151643. readonly name: string;
  151644. /**
  151645. * The scene the component belongs to.
  151646. */
  151647. scene: Scene;
  151648. /**
  151649. * Color of the bounding box lines placed in front of an object
  151650. */
  151651. frontColor: Color3;
  151652. /**
  151653. * Color of the bounding box lines placed behind an object
  151654. */
  151655. backColor: Color3;
  151656. /**
  151657. * Defines if the renderer should show the back lines or not
  151658. */
  151659. showBackLines: boolean;
  151660. /**
  151661. * Observable raised before rendering a bounding box
  151662. */
  151663. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  151664. /**
  151665. * Observable raised after rendering a bounding box
  151666. */
  151667. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  151668. /**
  151669. * @hidden
  151670. */
  151671. renderList: SmartArray<BoundingBox>;
  151672. private _colorShader;
  151673. private _vertexBuffers;
  151674. private _indexBuffer;
  151675. private _fillIndexBuffer;
  151676. private _fillIndexData;
  151677. /**
  151678. * Instantiates a new bounding box renderer in a scene.
  151679. * @param scene the scene the renderer renders in
  151680. */
  151681. constructor(scene: Scene);
  151682. /**
  151683. * Registers the component in a given scene
  151684. */
  151685. register(): void;
  151686. private _evaluateSubMesh;
  151687. private _activeMesh;
  151688. private _prepareRessources;
  151689. private _createIndexBuffer;
  151690. /**
  151691. * Rebuilds the elements related to this component in case of
  151692. * context lost for instance.
  151693. */
  151694. rebuild(): void;
  151695. /**
  151696. * @hidden
  151697. */
  151698. reset(): void;
  151699. /**
  151700. * Render the bounding boxes of a specific rendering group
  151701. * @param renderingGroupId defines the rendering group to render
  151702. */
  151703. render(renderingGroupId: number): void;
  151704. /**
  151705. * In case of occlusion queries, we can render the occlusion bounding box through this method
  151706. * @param mesh Define the mesh to render the occlusion bounding box for
  151707. */
  151708. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  151709. /**
  151710. * Dispose and release the resources attached to this renderer.
  151711. */
  151712. dispose(): void;
  151713. }
  151714. }
  151715. declare module BABYLON {
  151716. interface Scene {
  151717. /** @hidden (Backing field) */
  151718. _depthRenderer: {
  151719. [id: string]: DepthRenderer;
  151720. };
  151721. /**
  151722. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  151723. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  151724. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  151725. * @returns the created depth renderer
  151726. */
  151727. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  151728. /**
  151729. * Disables a depth renderer for a given camera
  151730. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  151731. */
  151732. disableDepthRenderer(camera?: Nullable<Camera>): void;
  151733. }
  151734. /**
  151735. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  151736. * in several rendering techniques.
  151737. */
  151738. export class DepthRendererSceneComponent implements ISceneComponent {
  151739. /**
  151740. * The component name helpfull to identify the component in the list of scene components.
  151741. */
  151742. readonly name: string;
  151743. /**
  151744. * The scene the component belongs to.
  151745. */
  151746. scene: Scene;
  151747. /**
  151748. * Creates a new instance of the component for the given scene
  151749. * @param scene Defines the scene to register the component in
  151750. */
  151751. constructor(scene: Scene);
  151752. /**
  151753. * Registers the component in a given scene
  151754. */
  151755. register(): void;
  151756. /**
  151757. * Rebuilds the elements related to this component in case of
  151758. * context lost for instance.
  151759. */
  151760. rebuild(): void;
  151761. /**
  151762. * Disposes the component and the associated ressources
  151763. */
  151764. dispose(): void;
  151765. private _gatherRenderTargets;
  151766. private _gatherActiveCameraRenderTargets;
  151767. }
  151768. }
  151769. declare module BABYLON {
  151770. interface AbstractScene {
  151771. /** @hidden (Backing field) */
  151772. _prePassRenderer: Nullable<PrePassRenderer>;
  151773. /**
  151774. * Gets or Sets the current prepass renderer associated to the scene.
  151775. */
  151776. prePassRenderer: Nullable<PrePassRenderer>;
  151777. /**
  151778. * Enables the prepass and associates it with the scene
  151779. * @returns the PrePassRenderer
  151780. */
  151781. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  151782. /**
  151783. * Disables the prepass associated with the scene
  151784. */
  151785. disablePrePassRenderer(): void;
  151786. }
  151787. /**
  151788. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  151789. * in several rendering techniques.
  151790. */
  151791. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  151792. /**
  151793. * The component name helpful to identify the component in the list of scene components.
  151794. */
  151795. readonly name: string;
  151796. /**
  151797. * The scene the component belongs to.
  151798. */
  151799. scene: Scene;
  151800. /**
  151801. * Creates a new instance of the component for the given scene
  151802. * @param scene Defines the scene to register the component in
  151803. */
  151804. constructor(scene: Scene);
  151805. /**
  151806. * Registers the component in a given scene
  151807. */
  151808. register(): void;
  151809. private _beforeCameraDraw;
  151810. private _afterCameraDraw;
  151811. private _beforeClearStage;
  151812. /**
  151813. * Serializes the component data to the specified json object
  151814. * @param serializationObject The object to serialize to
  151815. */
  151816. serialize(serializationObject: any): void;
  151817. /**
  151818. * Adds all the elements from the container to the scene
  151819. * @param container the container holding the elements
  151820. */
  151821. addFromContainer(container: AbstractScene): void;
  151822. /**
  151823. * Removes all the elements in the container from the scene
  151824. * @param container contains the elements to remove
  151825. * @param dispose if the removed element should be disposed (default: false)
  151826. */
  151827. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  151828. /**
  151829. * Rebuilds the elements related to this component in case of
  151830. * context lost for instance.
  151831. */
  151832. rebuild(): void;
  151833. /**
  151834. * Disposes the component and the associated ressources
  151835. */
  151836. dispose(): void;
  151837. }
  151838. }
  151839. declare module BABYLON {
  151840. /** @hidden */
  151841. export var outlinePixelShader: {
  151842. name: string;
  151843. shader: string;
  151844. };
  151845. }
  151846. declare module BABYLON {
  151847. /** @hidden */
  151848. export var outlineVertexShader: {
  151849. name: string;
  151850. shader: string;
  151851. };
  151852. }
  151853. declare module BABYLON {
  151854. interface Scene {
  151855. /** @hidden */
  151856. _outlineRenderer: OutlineRenderer;
  151857. /**
  151858. * Gets the outline renderer associated with the scene
  151859. * @returns a OutlineRenderer
  151860. */
  151861. getOutlineRenderer(): OutlineRenderer;
  151862. }
  151863. interface AbstractMesh {
  151864. /** @hidden (Backing field) */
  151865. _renderOutline: boolean;
  151866. /**
  151867. * Gets or sets a boolean indicating if the outline must be rendered as well
  151868. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  151869. */
  151870. renderOutline: boolean;
  151871. /** @hidden (Backing field) */
  151872. _renderOverlay: boolean;
  151873. /**
  151874. * Gets or sets a boolean indicating if the overlay must be rendered as well
  151875. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  151876. */
  151877. renderOverlay: boolean;
  151878. }
  151879. /**
  151880. * This class is responsible to draw bothe outline/overlay of meshes.
  151881. * It should not be used directly but through the available method on mesh.
  151882. */
  151883. export class OutlineRenderer implements ISceneComponent {
  151884. /**
  151885. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  151886. */
  151887. private static _StencilReference;
  151888. /**
  151889. * The name of the component. Each component must have a unique name.
  151890. */
  151891. name: string;
  151892. /**
  151893. * The scene the component belongs to.
  151894. */
  151895. scene: Scene;
  151896. /**
  151897. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  151898. */
  151899. zOffset: number;
  151900. private _engine;
  151901. private _effect;
  151902. private _cachedDefines;
  151903. private _savedDepthWrite;
  151904. /**
  151905. * Instantiates a new outline renderer. (There could be only one per scene).
  151906. * @param scene Defines the scene it belongs to
  151907. */
  151908. constructor(scene: Scene);
  151909. /**
  151910. * Register the component to one instance of a scene.
  151911. */
  151912. register(): void;
  151913. /**
  151914. * Rebuilds the elements related to this component in case of
  151915. * context lost for instance.
  151916. */
  151917. rebuild(): void;
  151918. /**
  151919. * Disposes the component and the associated ressources.
  151920. */
  151921. dispose(): void;
  151922. /**
  151923. * Renders the outline in the canvas.
  151924. * @param subMesh Defines the sumesh to render
  151925. * @param batch Defines the batch of meshes in case of instances
  151926. * @param useOverlay Defines if the rendering is for the overlay or the outline
  151927. */
  151928. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  151929. /**
  151930. * Returns whether or not the outline renderer is ready for a given submesh.
  151931. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  151932. * @param subMesh Defines the submesh to check readyness for
  151933. * @param useInstances Defines wheter wee are trying to render instances or not
  151934. * @returns true if ready otherwise false
  151935. */
  151936. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  151937. private _beforeRenderingMesh;
  151938. private _afterRenderingMesh;
  151939. }
  151940. }
  151941. declare module BABYLON {
  151942. /**
  151943. * Defines the basic options interface of a Sprite Frame Source Size.
  151944. */
  151945. export interface ISpriteJSONSpriteSourceSize {
  151946. /**
  151947. * number of the original width of the Frame
  151948. */
  151949. w: number;
  151950. /**
  151951. * number of the original height of the Frame
  151952. */
  151953. h: number;
  151954. }
  151955. /**
  151956. * Defines the basic options interface of a Sprite Frame Data.
  151957. */
  151958. export interface ISpriteJSONSpriteFrameData {
  151959. /**
  151960. * number of the x offset of the Frame
  151961. */
  151962. x: number;
  151963. /**
  151964. * number of the y offset of the Frame
  151965. */
  151966. y: number;
  151967. /**
  151968. * number of the width of the Frame
  151969. */
  151970. w: number;
  151971. /**
  151972. * number of the height of the Frame
  151973. */
  151974. h: number;
  151975. }
  151976. /**
  151977. * Defines the basic options interface of a JSON Sprite.
  151978. */
  151979. export interface ISpriteJSONSprite {
  151980. /**
  151981. * string name of the Frame
  151982. */
  151983. filename: string;
  151984. /**
  151985. * ISpriteJSONSpriteFrame basic object of the frame data
  151986. */
  151987. frame: ISpriteJSONSpriteFrameData;
  151988. /**
  151989. * boolean to flag is the frame was rotated.
  151990. */
  151991. rotated: boolean;
  151992. /**
  151993. * boolean to flag is the frame was trimmed.
  151994. */
  151995. trimmed: boolean;
  151996. /**
  151997. * ISpriteJSONSpriteFrame basic object of the source data
  151998. */
  151999. spriteSourceSize: ISpriteJSONSpriteFrameData;
  152000. /**
  152001. * ISpriteJSONSpriteFrame basic object of the source data
  152002. */
  152003. sourceSize: ISpriteJSONSpriteSourceSize;
  152004. }
  152005. /**
  152006. * Defines the basic options interface of a JSON atlas.
  152007. */
  152008. export interface ISpriteJSONAtlas {
  152009. /**
  152010. * Array of objects that contain the frame data.
  152011. */
  152012. frames: Array<ISpriteJSONSprite>;
  152013. /**
  152014. * object basic object containing the sprite meta data.
  152015. */
  152016. meta?: object;
  152017. }
  152018. }
  152019. declare module BABYLON {
  152020. /** @hidden */
  152021. export var spriteMapPixelShader: {
  152022. name: string;
  152023. shader: string;
  152024. };
  152025. }
  152026. declare module BABYLON {
  152027. /** @hidden */
  152028. export var spriteMapVertexShader: {
  152029. name: string;
  152030. shader: string;
  152031. };
  152032. }
  152033. declare module BABYLON {
  152034. /**
  152035. * Defines the basic options interface of a SpriteMap
  152036. */
  152037. export interface ISpriteMapOptions {
  152038. /**
  152039. * Vector2 of the number of cells in the grid.
  152040. */
  152041. stageSize?: Vector2;
  152042. /**
  152043. * Vector2 of the size of the output plane in World Units.
  152044. */
  152045. outputSize?: Vector2;
  152046. /**
  152047. * Vector3 of the position of the output plane in World Units.
  152048. */
  152049. outputPosition?: Vector3;
  152050. /**
  152051. * Vector3 of the rotation of the output plane.
  152052. */
  152053. outputRotation?: Vector3;
  152054. /**
  152055. * number of layers that the system will reserve in resources.
  152056. */
  152057. layerCount?: number;
  152058. /**
  152059. * number of max animation frames a single cell will reserve in resources.
  152060. */
  152061. maxAnimationFrames?: number;
  152062. /**
  152063. * number cell index of the base tile when the system compiles.
  152064. */
  152065. baseTile?: number;
  152066. /**
  152067. * boolean flip the sprite after its been repositioned by the framing data.
  152068. */
  152069. flipU?: boolean;
  152070. /**
  152071. * Vector3 scalar of the global RGB values of the SpriteMap.
  152072. */
  152073. colorMultiply?: Vector3;
  152074. }
  152075. /**
  152076. * Defines the IDisposable interface in order to be cleanable from resources.
  152077. */
  152078. export interface ISpriteMap extends IDisposable {
  152079. /**
  152080. * String name of the SpriteMap.
  152081. */
  152082. name: string;
  152083. /**
  152084. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  152085. */
  152086. atlasJSON: ISpriteJSONAtlas;
  152087. /**
  152088. * Texture of the SpriteMap.
  152089. */
  152090. spriteSheet: Texture;
  152091. /**
  152092. * The parameters to initialize the SpriteMap with.
  152093. */
  152094. options: ISpriteMapOptions;
  152095. }
  152096. /**
  152097. * Class used to manage a grid restricted sprite deployment on an Output plane.
  152098. */
  152099. export class SpriteMap implements ISpriteMap {
  152100. /** The Name of the spriteMap */
  152101. name: string;
  152102. /** The JSON file with the frame and meta data */
  152103. atlasJSON: ISpriteJSONAtlas;
  152104. /** The systems Sprite Sheet Texture */
  152105. spriteSheet: Texture;
  152106. /** Arguments passed with the Constructor */
  152107. options: ISpriteMapOptions;
  152108. /** Public Sprite Storage array, parsed from atlasJSON */
  152109. sprites: Array<ISpriteJSONSprite>;
  152110. /** Returns the Number of Sprites in the System */
  152111. get spriteCount(): number;
  152112. /** Returns the Position of Output Plane*/
  152113. get position(): Vector3;
  152114. /** Returns the Position of Output Plane*/
  152115. set position(v: Vector3);
  152116. /** Returns the Rotation of Output Plane*/
  152117. get rotation(): Vector3;
  152118. /** Returns the Rotation of Output Plane*/
  152119. set rotation(v: Vector3);
  152120. /** Sets the AnimationMap*/
  152121. get animationMap(): RawTexture;
  152122. /** Sets the AnimationMap*/
  152123. set animationMap(v: RawTexture);
  152124. /** Scene that the SpriteMap was created in */
  152125. private _scene;
  152126. /** Texture Buffer of Float32 that holds tile frame data*/
  152127. private _frameMap;
  152128. /** Texture Buffers of Float32 that holds tileMap data*/
  152129. private _tileMaps;
  152130. /** Texture Buffer of Float32 that holds Animation Data*/
  152131. private _animationMap;
  152132. /** Custom ShaderMaterial Central to the System*/
  152133. private _material;
  152134. /** Custom ShaderMaterial Central to the System*/
  152135. private _output;
  152136. /** Systems Time Ticker*/
  152137. private _time;
  152138. /**
  152139. * Creates a new SpriteMap
  152140. * @param name defines the SpriteMaps Name
  152141. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  152142. * @param spriteSheet is the Texture that the Sprites are on.
  152143. * @param options a basic deployment configuration
  152144. * @param scene The Scene that the map is deployed on
  152145. */
  152146. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  152147. /**
  152148. * Returns tileID location
  152149. * @returns Vector2 the cell position ID
  152150. */
  152151. getTileID(): Vector2;
  152152. /**
  152153. * Gets the UV location of the mouse over the SpriteMap.
  152154. * @returns Vector2 the UV position of the mouse interaction
  152155. */
  152156. getMousePosition(): Vector2;
  152157. /**
  152158. * Creates the "frame" texture Buffer
  152159. * -------------------------------------
  152160. * Structure of frames
  152161. * "filename": "Falling-Water-2.png",
  152162. * "frame": {"x":69,"y":103,"w":24,"h":32},
  152163. * "rotated": true,
  152164. * "trimmed": true,
  152165. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  152166. * "sourceSize": {"w":32,"h":32}
  152167. * @returns RawTexture of the frameMap
  152168. */
  152169. private _createFrameBuffer;
  152170. /**
  152171. * Creates the tileMap texture Buffer
  152172. * @param buffer normally and array of numbers, or a false to generate from scratch
  152173. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  152174. * @returns RawTexture of the tileMap
  152175. */
  152176. private _createTileBuffer;
  152177. /**
  152178. * Modifies the data of the tileMaps
  152179. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  152180. * @param pos is the iVector2 Coordinates of the Tile
  152181. * @param tile The SpriteIndex of the new Tile
  152182. */
  152183. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  152184. /**
  152185. * Creates the animationMap texture Buffer
  152186. * @param buffer normally and array of numbers, or a false to generate from scratch
  152187. * @returns RawTexture of the animationMap
  152188. */
  152189. private _createTileAnimationBuffer;
  152190. /**
  152191. * Modifies the data of the animationMap
  152192. * @param cellID is the Index of the Sprite
  152193. * @param _frame is the target Animation frame
  152194. * @param toCell is the Target Index of the next frame of the animation
  152195. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  152196. * @param speed is a global scalar of the time variable on the map.
  152197. */
  152198. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  152199. /**
  152200. * Exports the .tilemaps file
  152201. */
  152202. saveTileMaps(): void;
  152203. /**
  152204. * Imports the .tilemaps file
  152205. * @param url of the .tilemaps file
  152206. */
  152207. loadTileMaps(url: string): void;
  152208. /**
  152209. * Release associated resources
  152210. */
  152211. dispose(): void;
  152212. }
  152213. }
  152214. declare module BABYLON {
  152215. /**
  152216. * Class used to manage multiple sprites of different sizes on the same spritesheet
  152217. * @see https://doc.babylonjs.com/babylon101/sprites
  152218. */
  152219. export class SpritePackedManager extends SpriteManager {
  152220. /** defines the packed manager's name */
  152221. name: string;
  152222. /**
  152223. * Creates a new sprite manager from a packed sprite sheet
  152224. * @param name defines the manager's name
  152225. * @param imgUrl defines the sprite sheet url
  152226. * @param capacity defines the maximum allowed number of sprites
  152227. * @param scene defines the hosting scene
  152228. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  152229. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  152230. * @param samplingMode defines the smapling mode to use with spritesheet
  152231. * @param fromPacked set to true; do not alter
  152232. */
  152233. constructor(
  152234. /** defines the packed manager's name */
  152235. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  152236. }
  152237. }
  152238. declare module BABYLON {
  152239. /**
  152240. * Defines the list of states available for a task inside a AssetsManager
  152241. */
  152242. export enum AssetTaskState {
  152243. /**
  152244. * Initialization
  152245. */
  152246. INIT = 0,
  152247. /**
  152248. * Running
  152249. */
  152250. RUNNING = 1,
  152251. /**
  152252. * Done
  152253. */
  152254. DONE = 2,
  152255. /**
  152256. * Error
  152257. */
  152258. ERROR = 3
  152259. }
  152260. /**
  152261. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  152262. */
  152263. export abstract class AbstractAssetTask {
  152264. /**
  152265. * Task name
  152266. */ name: string;
  152267. /**
  152268. * Callback called when the task is successful
  152269. */
  152270. onSuccess: (task: any) => void;
  152271. /**
  152272. * Callback called when the task is not successful
  152273. */
  152274. onError: (task: any, message?: string, exception?: any) => void;
  152275. /**
  152276. * Creates a new AssetsManager
  152277. * @param name defines the name of the task
  152278. */
  152279. constructor(
  152280. /**
  152281. * Task name
  152282. */ name: string);
  152283. private _isCompleted;
  152284. private _taskState;
  152285. private _errorObject;
  152286. /**
  152287. * Get if the task is completed
  152288. */
  152289. get isCompleted(): boolean;
  152290. /**
  152291. * Gets the current state of the task
  152292. */
  152293. get taskState(): AssetTaskState;
  152294. /**
  152295. * Gets the current error object (if task is in error)
  152296. */
  152297. get errorObject(): {
  152298. message?: string;
  152299. exception?: any;
  152300. };
  152301. /**
  152302. * Internal only
  152303. * @hidden
  152304. */
  152305. _setErrorObject(message?: string, exception?: any): void;
  152306. /**
  152307. * Execute the current task
  152308. * @param scene defines the scene where you want your assets to be loaded
  152309. * @param onSuccess is a callback called when the task is successfully executed
  152310. * @param onError is a callback called if an error occurs
  152311. */
  152312. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152313. /**
  152314. * Execute the current task
  152315. * @param scene defines the scene where you want your assets to be loaded
  152316. * @param onSuccess is a callback called when the task is successfully executed
  152317. * @param onError is a callback called if an error occurs
  152318. */
  152319. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152320. /**
  152321. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  152322. * This can be used with failed tasks that have the reason for failure fixed.
  152323. */
  152324. reset(): void;
  152325. private onErrorCallback;
  152326. private onDoneCallback;
  152327. }
  152328. /**
  152329. * Define the interface used by progress events raised during assets loading
  152330. */
  152331. export interface IAssetsProgressEvent {
  152332. /**
  152333. * Defines the number of remaining tasks to process
  152334. */
  152335. remainingCount: number;
  152336. /**
  152337. * Defines the total number of tasks
  152338. */
  152339. totalCount: number;
  152340. /**
  152341. * Defines the task that was just processed
  152342. */
  152343. task: AbstractAssetTask;
  152344. }
  152345. /**
  152346. * Class used to share progress information about assets loading
  152347. */
  152348. export class AssetsProgressEvent implements IAssetsProgressEvent {
  152349. /**
  152350. * Defines the number of remaining tasks to process
  152351. */
  152352. remainingCount: number;
  152353. /**
  152354. * Defines the total number of tasks
  152355. */
  152356. totalCount: number;
  152357. /**
  152358. * Defines the task that was just processed
  152359. */
  152360. task: AbstractAssetTask;
  152361. /**
  152362. * Creates a AssetsProgressEvent
  152363. * @param remainingCount defines the number of remaining tasks to process
  152364. * @param totalCount defines the total number of tasks
  152365. * @param task defines the task that was just processed
  152366. */
  152367. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  152368. }
  152369. /**
  152370. * Define a task used by AssetsManager to load assets into a container
  152371. */
  152372. export class ContainerAssetTask extends AbstractAssetTask {
  152373. /**
  152374. * Defines the name of the task
  152375. */
  152376. name: string;
  152377. /**
  152378. * Defines the list of mesh's names you want to load
  152379. */
  152380. meshesNames: any;
  152381. /**
  152382. * Defines the root url to use as a base to load your meshes and associated resources
  152383. */
  152384. rootUrl: string;
  152385. /**
  152386. * Defines the filename or File of the scene to load from
  152387. */
  152388. sceneFilename: string | File;
  152389. /**
  152390. * Get the loaded asset container
  152391. */
  152392. loadedContainer: AssetContainer;
  152393. /**
  152394. * Gets the list of loaded meshes
  152395. */
  152396. loadedMeshes: Array<AbstractMesh>;
  152397. /**
  152398. * Gets the list of loaded particle systems
  152399. */
  152400. loadedParticleSystems: Array<IParticleSystem>;
  152401. /**
  152402. * Gets the list of loaded skeletons
  152403. */
  152404. loadedSkeletons: Array<Skeleton>;
  152405. /**
  152406. * Gets the list of loaded animation groups
  152407. */
  152408. loadedAnimationGroups: Array<AnimationGroup>;
  152409. /**
  152410. * Callback called when the task is successful
  152411. */
  152412. onSuccess: (task: ContainerAssetTask) => void;
  152413. /**
  152414. * Callback called when the task is successful
  152415. */
  152416. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  152417. /**
  152418. * Creates a new ContainerAssetTask
  152419. * @param name defines the name of the task
  152420. * @param meshesNames defines the list of mesh's names you want to load
  152421. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  152422. * @param sceneFilename defines the filename or File of the scene to load from
  152423. */
  152424. constructor(
  152425. /**
  152426. * Defines the name of the task
  152427. */
  152428. name: string,
  152429. /**
  152430. * Defines the list of mesh's names you want to load
  152431. */
  152432. meshesNames: any,
  152433. /**
  152434. * Defines the root url to use as a base to load your meshes and associated resources
  152435. */
  152436. rootUrl: string,
  152437. /**
  152438. * Defines the filename or File of the scene to load from
  152439. */
  152440. sceneFilename: string | File);
  152441. /**
  152442. * Execute the current task
  152443. * @param scene defines the scene where you want your assets to be loaded
  152444. * @param onSuccess is a callback called when the task is successfully executed
  152445. * @param onError is a callback called if an error occurs
  152446. */
  152447. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152448. }
  152449. /**
  152450. * Define a task used by AssetsManager to load meshes
  152451. */
  152452. export class MeshAssetTask extends AbstractAssetTask {
  152453. /**
  152454. * Defines the name of the task
  152455. */
  152456. name: string;
  152457. /**
  152458. * Defines the list of mesh's names you want to load
  152459. */
  152460. meshesNames: any;
  152461. /**
  152462. * Defines the root url to use as a base to load your meshes and associated resources
  152463. */
  152464. rootUrl: string;
  152465. /**
  152466. * Defines the filename or File of the scene to load from
  152467. */
  152468. sceneFilename: string | File;
  152469. /**
  152470. * Gets the list of loaded meshes
  152471. */
  152472. loadedMeshes: Array<AbstractMesh>;
  152473. /**
  152474. * Gets the list of loaded particle systems
  152475. */
  152476. loadedParticleSystems: Array<IParticleSystem>;
  152477. /**
  152478. * Gets the list of loaded skeletons
  152479. */
  152480. loadedSkeletons: Array<Skeleton>;
  152481. /**
  152482. * Gets the list of loaded animation groups
  152483. */
  152484. loadedAnimationGroups: Array<AnimationGroup>;
  152485. /**
  152486. * Callback called when the task is successful
  152487. */
  152488. onSuccess: (task: MeshAssetTask) => void;
  152489. /**
  152490. * Callback called when the task is successful
  152491. */
  152492. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  152493. /**
  152494. * Creates a new MeshAssetTask
  152495. * @param name defines the name of the task
  152496. * @param meshesNames defines the list of mesh's names you want to load
  152497. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  152498. * @param sceneFilename defines the filename or File of the scene to load from
  152499. */
  152500. constructor(
  152501. /**
  152502. * Defines the name of the task
  152503. */
  152504. name: string,
  152505. /**
  152506. * Defines the list of mesh's names you want to load
  152507. */
  152508. meshesNames: any,
  152509. /**
  152510. * Defines the root url to use as a base to load your meshes and associated resources
  152511. */
  152512. rootUrl: string,
  152513. /**
  152514. * Defines the filename or File of the scene to load from
  152515. */
  152516. sceneFilename: string | File);
  152517. /**
  152518. * Execute the current task
  152519. * @param scene defines the scene where you want your assets to be loaded
  152520. * @param onSuccess is a callback called when the task is successfully executed
  152521. * @param onError is a callback called if an error occurs
  152522. */
  152523. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152524. }
  152525. /**
  152526. * Define a task used by AssetsManager to load text content
  152527. */
  152528. export class TextFileAssetTask extends AbstractAssetTask {
  152529. /**
  152530. * Defines the name of the task
  152531. */
  152532. name: string;
  152533. /**
  152534. * Defines the location of the file to load
  152535. */
  152536. url: string;
  152537. /**
  152538. * Gets the loaded text string
  152539. */
  152540. text: string;
  152541. /**
  152542. * Callback called when the task is successful
  152543. */
  152544. onSuccess: (task: TextFileAssetTask) => void;
  152545. /**
  152546. * Callback called when the task is successful
  152547. */
  152548. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  152549. /**
  152550. * Creates a new TextFileAssetTask object
  152551. * @param name defines the name of the task
  152552. * @param url defines the location of the file to load
  152553. */
  152554. constructor(
  152555. /**
  152556. * Defines the name of the task
  152557. */
  152558. name: string,
  152559. /**
  152560. * Defines the location of the file to load
  152561. */
  152562. url: string);
  152563. /**
  152564. * Execute the current task
  152565. * @param scene defines the scene where you want your assets to be loaded
  152566. * @param onSuccess is a callback called when the task is successfully executed
  152567. * @param onError is a callback called if an error occurs
  152568. */
  152569. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152570. }
  152571. /**
  152572. * Define a task used by AssetsManager to load binary data
  152573. */
  152574. export class BinaryFileAssetTask extends AbstractAssetTask {
  152575. /**
  152576. * Defines the name of the task
  152577. */
  152578. name: string;
  152579. /**
  152580. * Defines the location of the file to load
  152581. */
  152582. url: string;
  152583. /**
  152584. * Gets the lodaded data (as an array buffer)
  152585. */
  152586. data: ArrayBuffer;
  152587. /**
  152588. * Callback called when the task is successful
  152589. */
  152590. onSuccess: (task: BinaryFileAssetTask) => void;
  152591. /**
  152592. * Callback called when the task is successful
  152593. */
  152594. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  152595. /**
  152596. * Creates a new BinaryFileAssetTask object
  152597. * @param name defines the name of the new task
  152598. * @param url defines the location of the file to load
  152599. */
  152600. constructor(
  152601. /**
  152602. * Defines the name of the task
  152603. */
  152604. name: string,
  152605. /**
  152606. * Defines the location of the file to load
  152607. */
  152608. url: string);
  152609. /**
  152610. * Execute the current task
  152611. * @param scene defines the scene where you want your assets to be loaded
  152612. * @param onSuccess is a callback called when the task is successfully executed
  152613. * @param onError is a callback called if an error occurs
  152614. */
  152615. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152616. }
  152617. /**
  152618. * Define a task used by AssetsManager to load images
  152619. */
  152620. export class ImageAssetTask extends AbstractAssetTask {
  152621. /**
  152622. * Defines the name of the task
  152623. */
  152624. name: string;
  152625. /**
  152626. * Defines the location of the image to load
  152627. */
  152628. url: string;
  152629. /**
  152630. * Gets the loaded images
  152631. */
  152632. image: HTMLImageElement;
  152633. /**
  152634. * Callback called when the task is successful
  152635. */
  152636. onSuccess: (task: ImageAssetTask) => void;
  152637. /**
  152638. * Callback called when the task is successful
  152639. */
  152640. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  152641. /**
  152642. * Creates a new ImageAssetTask
  152643. * @param name defines the name of the task
  152644. * @param url defines the location of the image to load
  152645. */
  152646. constructor(
  152647. /**
  152648. * Defines the name of the task
  152649. */
  152650. name: string,
  152651. /**
  152652. * Defines the location of the image to load
  152653. */
  152654. url: string);
  152655. /**
  152656. * Execute the current task
  152657. * @param scene defines the scene where you want your assets to be loaded
  152658. * @param onSuccess is a callback called when the task is successfully executed
  152659. * @param onError is a callback called if an error occurs
  152660. */
  152661. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152662. }
  152663. /**
  152664. * Defines the interface used by texture loading tasks
  152665. */
  152666. export interface ITextureAssetTask<TEX extends BaseTexture> {
  152667. /**
  152668. * Gets the loaded texture
  152669. */
  152670. texture: TEX;
  152671. }
  152672. /**
  152673. * Define a task used by AssetsManager to load 2D textures
  152674. */
  152675. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  152676. /**
  152677. * Defines the name of the task
  152678. */
  152679. name: string;
  152680. /**
  152681. * Defines the location of the file to load
  152682. */
  152683. url: string;
  152684. /**
  152685. * Defines if mipmap should not be generated (default is false)
  152686. */
  152687. noMipmap?: boolean | undefined;
  152688. /**
  152689. * Defines if texture must be inverted on Y axis (default is true)
  152690. */
  152691. invertY: boolean;
  152692. /**
  152693. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  152694. */
  152695. samplingMode: number;
  152696. /**
  152697. * Gets the loaded texture
  152698. */
  152699. texture: Texture;
  152700. /**
  152701. * Callback called when the task is successful
  152702. */
  152703. onSuccess: (task: TextureAssetTask) => void;
  152704. /**
  152705. * Callback called when the task is successful
  152706. */
  152707. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  152708. /**
  152709. * Creates a new TextureAssetTask object
  152710. * @param name defines the name of the task
  152711. * @param url defines the location of the file to load
  152712. * @param noMipmap defines if mipmap should not be generated (default is false)
  152713. * @param invertY defines if texture must be inverted on Y axis (default is true)
  152714. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  152715. */
  152716. constructor(
  152717. /**
  152718. * Defines the name of the task
  152719. */
  152720. name: string,
  152721. /**
  152722. * Defines the location of the file to load
  152723. */
  152724. url: string,
  152725. /**
  152726. * Defines if mipmap should not be generated (default is false)
  152727. */
  152728. noMipmap?: boolean | undefined,
  152729. /**
  152730. * Defines if texture must be inverted on Y axis (default is true)
  152731. */
  152732. invertY?: boolean,
  152733. /**
  152734. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  152735. */
  152736. samplingMode?: number);
  152737. /**
  152738. * Execute the current task
  152739. * @param scene defines the scene where you want your assets to be loaded
  152740. * @param onSuccess is a callback called when the task is successfully executed
  152741. * @param onError is a callback called if an error occurs
  152742. */
  152743. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152744. }
  152745. /**
  152746. * Define a task used by AssetsManager to load cube textures
  152747. */
  152748. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  152749. /**
  152750. * Defines the name of the task
  152751. */
  152752. name: string;
  152753. /**
  152754. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  152755. */
  152756. url: string;
  152757. /**
  152758. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  152759. */
  152760. extensions?: string[] | undefined;
  152761. /**
  152762. * Defines if mipmaps should not be generated (default is false)
  152763. */
  152764. noMipmap?: boolean | undefined;
  152765. /**
  152766. * Defines the explicit list of files (undefined by default)
  152767. */
  152768. files?: string[] | undefined;
  152769. /**
  152770. * Gets the loaded texture
  152771. */
  152772. texture: CubeTexture;
  152773. /**
  152774. * Callback called when the task is successful
  152775. */
  152776. onSuccess: (task: CubeTextureAssetTask) => void;
  152777. /**
  152778. * Callback called when the task is successful
  152779. */
  152780. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  152781. /**
  152782. * Creates a new CubeTextureAssetTask
  152783. * @param name defines the name of the task
  152784. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  152785. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  152786. * @param noMipmap defines if mipmaps should not be generated (default is false)
  152787. * @param files defines the explicit list of files (undefined by default)
  152788. */
  152789. constructor(
  152790. /**
  152791. * Defines the name of the task
  152792. */
  152793. name: string,
  152794. /**
  152795. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  152796. */
  152797. url: string,
  152798. /**
  152799. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  152800. */
  152801. extensions?: string[] | undefined,
  152802. /**
  152803. * Defines if mipmaps should not be generated (default is false)
  152804. */
  152805. noMipmap?: boolean | undefined,
  152806. /**
  152807. * Defines the explicit list of files (undefined by default)
  152808. */
  152809. files?: string[] | undefined);
  152810. /**
  152811. * Execute the current task
  152812. * @param scene defines the scene where you want your assets to be loaded
  152813. * @param onSuccess is a callback called when the task is successfully executed
  152814. * @param onError is a callback called if an error occurs
  152815. */
  152816. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152817. }
  152818. /**
  152819. * Define a task used by AssetsManager to load HDR cube textures
  152820. */
  152821. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  152822. /**
  152823. * Defines the name of the task
  152824. */
  152825. name: string;
  152826. /**
  152827. * Defines the location of the file to load
  152828. */
  152829. url: string;
  152830. /**
  152831. * Defines the desired size (the more it increases the longer the generation will be)
  152832. */
  152833. size: number;
  152834. /**
  152835. * Defines if mipmaps should not be generated (default is false)
  152836. */
  152837. noMipmap: boolean;
  152838. /**
  152839. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  152840. */
  152841. generateHarmonics: boolean;
  152842. /**
  152843. * 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)
  152844. */
  152845. gammaSpace: boolean;
  152846. /**
  152847. * Internal Use Only
  152848. */
  152849. reserved: boolean;
  152850. /**
  152851. * Gets the loaded texture
  152852. */
  152853. texture: HDRCubeTexture;
  152854. /**
  152855. * Callback called when the task is successful
  152856. */
  152857. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  152858. /**
  152859. * Callback called when the task is successful
  152860. */
  152861. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  152862. /**
  152863. * Creates a new HDRCubeTextureAssetTask object
  152864. * @param name defines the name of the task
  152865. * @param url defines the location of the file to load
  152866. * @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.
  152867. * @param noMipmap defines if mipmaps should not be generated (default is false)
  152868. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  152869. * @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)
  152870. * @param reserved Internal use only
  152871. */
  152872. constructor(
  152873. /**
  152874. * Defines the name of the task
  152875. */
  152876. name: string,
  152877. /**
  152878. * Defines the location of the file to load
  152879. */
  152880. url: string,
  152881. /**
  152882. * Defines the desired size (the more it increases the longer the generation will be)
  152883. */
  152884. size: number,
  152885. /**
  152886. * Defines if mipmaps should not be generated (default is false)
  152887. */
  152888. noMipmap?: boolean,
  152889. /**
  152890. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  152891. */
  152892. generateHarmonics?: boolean,
  152893. /**
  152894. * 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)
  152895. */
  152896. gammaSpace?: boolean,
  152897. /**
  152898. * Internal Use Only
  152899. */
  152900. reserved?: boolean);
  152901. /**
  152902. * Execute the current task
  152903. * @param scene defines the scene where you want your assets to be loaded
  152904. * @param onSuccess is a callback called when the task is successfully executed
  152905. * @param onError is a callback called if an error occurs
  152906. */
  152907. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152908. }
  152909. /**
  152910. * Define a task used by AssetsManager to load Equirectangular cube textures
  152911. */
  152912. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  152913. /**
  152914. * Defines the name of the task
  152915. */
  152916. name: string;
  152917. /**
  152918. * Defines the location of the file to load
  152919. */
  152920. url: string;
  152921. /**
  152922. * Defines the desired size (the more it increases the longer the generation will be)
  152923. */
  152924. size: number;
  152925. /**
  152926. * Defines if mipmaps should not be generated (default is false)
  152927. */
  152928. noMipmap: boolean;
  152929. /**
  152930. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  152931. * but the standard material would require them in Gamma space) (default is true)
  152932. */
  152933. gammaSpace: boolean;
  152934. /**
  152935. * Gets the loaded texture
  152936. */
  152937. texture: EquiRectangularCubeTexture;
  152938. /**
  152939. * Callback called when the task is successful
  152940. */
  152941. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  152942. /**
  152943. * Callback called when the task is successful
  152944. */
  152945. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  152946. /**
  152947. * Creates a new EquiRectangularCubeTextureAssetTask object
  152948. * @param name defines the name of the task
  152949. * @param url defines the location of the file to load
  152950. * @param size defines the desired size (the more it increases the longer the generation will be)
  152951. * If the size is omitted this implies you are using a preprocessed cubemap.
  152952. * @param noMipmap defines if mipmaps should not be generated (default is false)
  152953. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  152954. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  152955. * (default is true)
  152956. */
  152957. constructor(
  152958. /**
  152959. * Defines the name of the task
  152960. */
  152961. name: string,
  152962. /**
  152963. * Defines the location of the file to load
  152964. */
  152965. url: string,
  152966. /**
  152967. * Defines the desired size (the more it increases the longer the generation will be)
  152968. */
  152969. size: number,
  152970. /**
  152971. * Defines if mipmaps should not be generated (default is false)
  152972. */
  152973. noMipmap?: boolean,
  152974. /**
  152975. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  152976. * but the standard material would require them in Gamma space) (default is true)
  152977. */
  152978. gammaSpace?: boolean);
  152979. /**
  152980. * Execute the current task
  152981. * @param scene defines the scene where you want your assets to be loaded
  152982. * @param onSuccess is a callback called when the task is successfully executed
  152983. * @param onError is a callback called if an error occurs
  152984. */
  152985. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  152986. }
  152987. /**
  152988. * This class can be used to easily import assets into a scene
  152989. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  152990. */
  152991. export class AssetsManager {
  152992. private _scene;
  152993. private _isLoading;
  152994. protected _tasks: AbstractAssetTask[];
  152995. protected _waitingTasksCount: number;
  152996. protected _totalTasksCount: number;
  152997. /**
  152998. * Callback called when all tasks are processed
  152999. */
  153000. onFinish: (tasks: AbstractAssetTask[]) => void;
  153001. /**
  153002. * Callback called when a task is successful
  153003. */
  153004. onTaskSuccess: (task: AbstractAssetTask) => void;
  153005. /**
  153006. * Callback called when a task had an error
  153007. */
  153008. onTaskError: (task: AbstractAssetTask) => void;
  153009. /**
  153010. * Callback called when a task is done (whatever the result is)
  153011. */
  153012. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  153013. /**
  153014. * Observable called when all tasks are processed
  153015. */
  153016. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  153017. /**
  153018. * Observable called when a task had an error
  153019. */
  153020. onTaskErrorObservable: Observable<AbstractAssetTask>;
  153021. /**
  153022. * Observable called when all tasks were executed
  153023. */
  153024. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  153025. /**
  153026. * Observable called when a task is done (whatever the result is)
  153027. */
  153028. onProgressObservable: Observable<IAssetsProgressEvent>;
  153029. /**
  153030. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  153031. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  153032. */
  153033. useDefaultLoadingScreen: boolean;
  153034. /**
  153035. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  153036. * when all assets have been downloaded.
  153037. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  153038. */
  153039. autoHideLoadingUI: boolean;
  153040. /**
  153041. * Creates a new AssetsManager
  153042. * @param scene defines the scene to work on
  153043. */
  153044. constructor(scene: Scene);
  153045. /**
  153046. * Add a ContainerAssetTask to the list of active tasks
  153047. * @param taskName defines the name of the new task
  153048. * @param meshesNames defines the name of meshes to load
  153049. * @param rootUrl defines the root url to use to locate files
  153050. * @param sceneFilename defines the filename of the scene file
  153051. * @returns a new ContainerAssetTask object
  153052. */
  153053. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  153054. /**
  153055. * Add a MeshAssetTask to the list of active tasks
  153056. * @param taskName defines the name of the new task
  153057. * @param meshesNames defines the name of meshes to load
  153058. * @param rootUrl defines the root url to use to locate files
  153059. * @param sceneFilename defines the filename of the scene file
  153060. * @returns a new MeshAssetTask object
  153061. */
  153062. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  153063. /**
  153064. * Add a TextFileAssetTask to the list of active tasks
  153065. * @param taskName defines the name of the new task
  153066. * @param url defines the url of the file to load
  153067. * @returns a new TextFileAssetTask object
  153068. */
  153069. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  153070. /**
  153071. * Add a BinaryFileAssetTask to the list of active tasks
  153072. * @param taskName defines the name of the new task
  153073. * @param url defines the url of the file to load
  153074. * @returns a new BinaryFileAssetTask object
  153075. */
  153076. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  153077. /**
  153078. * Add a ImageAssetTask to the list of active tasks
  153079. * @param taskName defines the name of the new task
  153080. * @param url defines the url of the file to load
  153081. * @returns a new ImageAssetTask object
  153082. */
  153083. addImageTask(taskName: string, url: string): ImageAssetTask;
  153084. /**
  153085. * Add a TextureAssetTask to the list of active tasks
  153086. * @param taskName defines the name of the new task
  153087. * @param url defines the url of the file to load
  153088. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153089. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  153090. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  153091. * @returns a new TextureAssetTask object
  153092. */
  153093. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  153094. /**
  153095. * Add a CubeTextureAssetTask to the list of active tasks
  153096. * @param taskName defines the name of the new task
  153097. * @param url defines the url of the file to load
  153098. * @param extensions defines the extension to use to load the cube map (can be null)
  153099. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153100. * @param files defines the list of files to load (can be null)
  153101. * @returns a new CubeTextureAssetTask object
  153102. */
  153103. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  153104. /**
  153105. *
  153106. * Add a HDRCubeTextureAssetTask to the list of active tasks
  153107. * @param taskName defines the name of the new task
  153108. * @param url defines the url of the file to load
  153109. * @param size defines the size you want for the cubemap (can be null)
  153110. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153111. * @param generateHarmonics defines if you want to automatically generate (true by default)
  153112. * @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)
  153113. * @param reserved Internal use only
  153114. * @returns a new HDRCubeTextureAssetTask object
  153115. */
  153116. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  153117. /**
  153118. *
  153119. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  153120. * @param taskName defines the name of the new task
  153121. * @param url defines the url of the file to load
  153122. * @param size defines the size you want for the cubemap (can be null)
  153123. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153124. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  153125. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  153126. * @returns a new EquiRectangularCubeTextureAssetTask object
  153127. */
  153128. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  153129. /**
  153130. * Remove a task from the assets manager.
  153131. * @param task the task to remove
  153132. */
  153133. removeTask(task: AbstractAssetTask): void;
  153134. private _decreaseWaitingTasksCount;
  153135. private _runTask;
  153136. /**
  153137. * Reset the AssetsManager and remove all tasks
  153138. * @return the current instance of the AssetsManager
  153139. */
  153140. reset(): AssetsManager;
  153141. /**
  153142. * Start the loading process
  153143. * @return the current instance of the AssetsManager
  153144. */
  153145. load(): AssetsManager;
  153146. /**
  153147. * Start the loading process as an async operation
  153148. * @return a promise returning the list of failed tasks
  153149. */
  153150. loadAsync(): Promise<void>;
  153151. }
  153152. }
  153153. declare module BABYLON {
  153154. /**
  153155. * Wrapper class for promise with external resolve and reject.
  153156. */
  153157. export class Deferred<T> {
  153158. /**
  153159. * The promise associated with this deferred object.
  153160. */
  153161. readonly promise: Promise<T>;
  153162. private _resolve;
  153163. private _reject;
  153164. /**
  153165. * The resolve method of the promise associated with this deferred object.
  153166. */
  153167. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  153168. /**
  153169. * The reject method of the promise associated with this deferred object.
  153170. */
  153171. get reject(): (reason?: any) => void;
  153172. /**
  153173. * Constructor for this deferred object.
  153174. */
  153175. constructor();
  153176. }
  153177. }
  153178. declare module BABYLON {
  153179. /**
  153180. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  153181. */
  153182. export class MeshExploder {
  153183. private _centerMesh;
  153184. private _meshes;
  153185. private _meshesOrigins;
  153186. private _toCenterVectors;
  153187. private _scaledDirection;
  153188. private _newPosition;
  153189. private _centerPosition;
  153190. /**
  153191. * Explodes meshes from a center mesh.
  153192. * @param meshes The meshes to explode.
  153193. * @param centerMesh The mesh to be center of explosion.
  153194. */
  153195. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  153196. private _setCenterMesh;
  153197. /**
  153198. * Get class name
  153199. * @returns "MeshExploder"
  153200. */
  153201. getClassName(): string;
  153202. /**
  153203. * "Exploded meshes"
  153204. * @returns Array of meshes with the centerMesh at index 0.
  153205. */
  153206. getMeshes(): Array<Mesh>;
  153207. /**
  153208. * Explodes meshes giving a specific direction
  153209. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  153210. */
  153211. explode(direction?: number): void;
  153212. }
  153213. }
  153214. declare module BABYLON {
  153215. /**
  153216. * Class used to help managing file picking and drag'n'drop
  153217. */
  153218. export class FilesInput {
  153219. /**
  153220. * List of files ready to be loaded
  153221. */
  153222. static get FilesToLoad(): {
  153223. [key: string]: File;
  153224. };
  153225. /**
  153226. * Callback called when a file is processed
  153227. */
  153228. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  153229. private _engine;
  153230. private _currentScene;
  153231. private _sceneLoadedCallback;
  153232. private _progressCallback;
  153233. private _additionalRenderLoopLogicCallback;
  153234. private _textureLoadingCallback;
  153235. private _startingProcessingFilesCallback;
  153236. private _onReloadCallback;
  153237. private _errorCallback;
  153238. private _elementToMonitor;
  153239. private _sceneFileToLoad;
  153240. private _filesToLoad;
  153241. /**
  153242. * Creates a new FilesInput
  153243. * @param engine defines the rendering engine
  153244. * @param scene defines the hosting scene
  153245. * @param sceneLoadedCallback callback called when scene is loaded
  153246. * @param progressCallback callback called to track progress
  153247. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  153248. * @param textureLoadingCallback callback called when a texture is loading
  153249. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  153250. * @param onReloadCallback callback called when a reload is requested
  153251. * @param errorCallback callback call if an error occurs
  153252. */
  153253. 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>);
  153254. private _dragEnterHandler;
  153255. private _dragOverHandler;
  153256. private _dropHandler;
  153257. /**
  153258. * Calls this function to listen to drag'n'drop events on a specific DOM element
  153259. * @param elementToMonitor defines the DOM element to track
  153260. */
  153261. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  153262. /** Gets the current list of files to load */
  153263. get filesToLoad(): File[];
  153264. /**
  153265. * Release all associated resources
  153266. */
  153267. dispose(): void;
  153268. private renderFunction;
  153269. private drag;
  153270. private drop;
  153271. private _traverseFolder;
  153272. private _processFiles;
  153273. /**
  153274. * Load files from a drop event
  153275. * @param event defines the drop event to use as source
  153276. */
  153277. loadFiles(event: any): void;
  153278. private _processReload;
  153279. /**
  153280. * Reload the current scene from the loaded files
  153281. */
  153282. reload(): void;
  153283. }
  153284. }
  153285. declare module BABYLON {
  153286. /**
  153287. * Defines the root class used to create scene optimization to use with SceneOptimizer
  153288. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153289. */
  153290. export class SceneOptimization {
  153291. /**
  153292. * Defines the priority of this optimization (0 by default which means first in the list)
  153293. */
  153294. priority: number;
  153295. /**
  153296. * Gets a string describing the action executed by the current optimization
  153297. * @returns description string
  153298. */
  153299. getDescription(): string;
  153300. /**
  153301. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153302. * @param scene defines the current scene where to apply this optimization
  153303. * @param optimizer defines the current optimizer
  153304. * @returns true if everything that can be done was applied
  153305. */
  153306. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153307. /**
  153308. * Creates the SceneOptimization object
  153309. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  153310. * @param desc defines the description associated with the optimization
  153311. */
  153312. constructor(
  153313. /**
  153314. * Defines the priority of this optimization (0 by default which means first in the list)
  153315. */
  153316. priority?: number);
  153317. }
  153318. /**
  153319. * Defines an optimization used to reduce the size of render target textures
  153320. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153321. */
  153322. export class TextureOptimization extends SceneOptimization {
  153323. /**
  153324. * Defines the priority of this optimization (0 by default which means first in the list)
  153325. */
  153326. priority: number;
  153327. /**
  153328. * 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
  153329. */
  153330. maximumSize: number;
  153331. /**
  153332. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  153333. */
  153334. step: number;
  153335. /**
  153336. * Gets a string describing the action executed by the current optimization
  153337. * @returns description string
  153338. */
  153339. getDescription(): string;
  153340. /**
  153341. * Creates the TextureOptimization object
  153342. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  153343. * @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
  153344. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  153345. */
  153346. constructor(
  153347. /**
  153348. * Defines the priority of this optimization (0 by default which means first in the list)
  153349. */
  153350. priority?: number,
  153351. /**
  153352. * 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
  153353. */
  153354. maximumSize?: number,
  153355. /**
  153356. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  153357. */
  153358. step?: number);
  153359. /**
  153360. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153361. * @param scene defines the current scene where to apply this optimization
  153362. * @param optimizer defines the current optimizer
  153363. * @returns true if everything that can be done was applied
  153364. */
  153365. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153366. }
  153367. /**
  153368. * Defines an optimization used to increase or decrease the rendering resolution
  153369. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153370. */
  153371. export class HardwareScalingOptimization extends SceneOptimization {
  153372. /**
  153373. * Defines the priority of this optimization (0 by default which means first in the list)
  153374. */
  153375. priority: number;
  153376. /**
  153377. * Defines the maximum scale to use (2 by default)
  153378. */
  153379. maximumScale: number;
  153380. /**
  153381. * Defines the step to use between two passes (0.5 by default)
  153382. */
  153383. step: number;
  153384. private _currentScale;
  153385. private _directionOffset;
  153386. /**
  153387. * Gets a string describing the action executed by the current optimization
  153388. * @return description string
  153389. */
  153390. getDescription(): string;
  153391. /**
  153392. * Creates the HardwareScalingOptimization object
  153393. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  153394. * @param maximumScale defines the maximum scale to use (2 by default)
  153395. * @param step defines the step to use between two passes (0.5 by default)
  153396. */
  153397. constructor(
  153398. /**
  153399. * Defines the priority of this optimization (0 by default which means first in the list)
  153400. */
  153401. priority?: number,
  153402. /**
  153403. * Defines the maximum scale to use (2 by default)
  153404. */
  153405. maximumScale?: number,
  153406. /**
  153407. * Defines the step to use between two passes (0.5 by default)
  153408. */
  153409. step?: number);
  153410. /**
  153411. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153412. * @param scene defines the current scene where to apply this optimization
  153413. * @param optimizer defines the current optimizer
  153414. * @returns true if everything that can be done was applied
  153415. */
  153416. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153417. }
  153418. /**
  153419. * Defines an optimization used to remove shadows
  153420. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153421. */
  153422. export class ShadowsOptimization extends SceneOptimization {
  153423. /**
  153424. * Gets a string describing the action executed by the current optimization
  153425. * @return description string
  153426. */
  153427. getDescription(): string;
  153428. /**
  153429. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153430. * @param scene defines the current scene where to apply this optimization
  153431. * @param optimizer defines the current optimizer
  153432. * @returns true if everything that can be done was applied
  153433. */
  153434. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153435. }
  153436. /**
  153437. * Defines an optimization used to turn post-processes off
  153438. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153439. */
  153440. export class PostProcessesOptimization extends SceneOptimization {
  153441. /**
  153442. * Gets a string describing the action executed by the current optimization
  153443. * @return description string
  153444. */
  153445. getDescription(): string;
  153446. /**
  153447. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153448. * @param scene defines the current scene where to apply this optimization
  153449. * @param optimizer defines the current optimizer
  153450. * @returns true if everything that can be done was applied
  153451. */
  153452. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153453. }
  153454. /**
  153455. * Defines an optimization used to turn lens flares off
  153456. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153457. */
  153458. export class LensFlaresOptimization extends SceneOptimization {
  153459. /**
  153460. * Gets a string describing the action executed by the current optimization
  153461. * @return description string
  153462. */
  153463. getDescription(): string;
  153464. /**
  153465. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153466. * @param scene defines the current scene where to apply this optimization
  153467. * @param optimizer defines the current optimizer
  153468. * @returns true if everything that can be done was applied
  153469. */
  153470. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153471. }
  153472. /**
  153473. * Defines an optimization based on user defined callback.
  153474. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153475. */
  153476. export class CustomOptimization extends SceneOptimization {
  153477. /**
  153478. * Callback called to apply the custom optimization.
  153479. */
  153480. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  153481. /**
  153482. * Callback called to get custom description
  153483. */
  153484. onGetDescription: () => string;
  153485. /**
  153486. * Gets a string describing the action executed by the current optimization
  153487. * @returns description string
  153488. */
  153489. getDescription(): string;
  153490. /**
  153491. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153492. * @param scene defines the current scene where to apply this optimization
  153493. * @param optimizer defines the current optimizer
  153494. * @returns true if everything that can be done was applied
  153495. */
  153496. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153497. }
  153498. /**
  153499. * Defines an optimization used to turn particles off
  153500. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153501. */
  153502. export class ParticlesOptimization extends SceneOptimization {
  153503. /**
  153504. * Gets a string describing the action executed by the current optimization
  153505. * @return description string
  153506. */
  153507. getDescription(): string;
  153508. /**
  153509. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153510. * @param scene defines the current scene where to apply this optimization
  153511. * @param optimizer defines the current optimizer
  153512. * @returns true if everything that can be done was applied
  153513. */
  153514. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153515. }
  153516. /**
  153517. * Defines an optimization used to turn render targets off
  153518. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153519. */
  153520. export class RenderTargetsOptimization extends SceneOptimization {
  153521. /**
  153522. * Gets a string describing the action executed by the current optimization
  153523. * @return description string
  153524. */
  153525. getDescription(): string;
  153526. /**
  153527. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153528. * @param scene defines the current scene where to apply this optimization
  153529. * @param optimizer defines the current optimizer
  153530. * @returns true if everything that can be done was applied
  153531. */
  153532. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  153533. }
  153534. /**
  153535. * Defines an optimization used to merge meshes with compatible materials
  153536. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153537. */
  153538. export class MergeMeshesOptimization extends SceneOptimization {
  153539. private static _UpdateSelectionTree;
  153540. /**
  153541. * Gets or sets a boolean which defines if optimization octree has to be updated
  153542. */
  153543. static get UpdateSelectionTree(): boolean;
  153544. /**
  153545. * Gets or sets a boolean which defines if optimization octree has to be updated
  153546. */
  153547. static set UpdateSelectionTree(value: boolean);
  153548. /**
  153549. * Gets a string describing the action executed by the current optimization
  153550. * @return description string
  153551. */
  153552. getDescription(): string;
  153553. private _canBeMerged;
  153554. /**
  153555. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  153556. * @param scene defines the current scene where to apply this optimization
  153557. * @param optimizer defines the current optimizer
  153558. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  153559. * @returns true if everything that can be done was applied
  153560. */
  153561. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  153562. }
  153563. /**
  153564. * Defines a list of options used by SceneOptimizer
  153565. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153566. */
  153567. export class SceneOptimizerOptions {
  153568. /**
  153569. * Defines the target frame rate to reach (60 by default)
  153570. */
  153571. targetFrameRate: number;
  153572. /**
  153573. * Defines the interval between two checkes (2000ms by default)
  153574. */
  153575. trackerDuration: number;
  153576. /**
  153577. * Gets the list of optimizations to apply
  153578. */
  153579. optimizations: SceneOptimization[];
  153580. /**
  153581. * Creates a new list of options used by SceneOptimizer
  153582. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  153583. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  153584. */
  153585. constructor(
  153586. /**
  153587. * Defines the target frame rate to reach (60 by default)
  153588. */
  153589. targetFrameRate?: number,
  153590. /**
  153591. * Defines the interval between two checkes (2000ms by default)
  153592. */
  153593. trackerDuration?: number);
  153594. /**
  153595. * Add a new optimization
  153596. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  153597. * @returns the current SceneOptimizerOptions
  153598. */
  153599. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  153600. /**
  153601. * Add a new custom optimization
  153602. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  153603. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  153604. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  153605. * @returns the current SceneOptimizerOptions
  153606. */
  153607. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  153608. /**
  153609. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  153610. * @param targetFrameRate defines the target frame rate (60 by default)
  153611. * @returns a SceneOptimizerOptions object
  153612. */
  153613. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  153614. /**
  153615. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  153616. * @param targetFrameRate defines the target frame rate (60 by default)
  153617. * @returns a SceneOptimizerOptions object
  153618. */
  153619. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  153620. /**
  153621. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  153622. * @param targetFrameRate defines the target frame rate (60 by default)
  153623. * @returns a SceneOptimizerOptions object
  153624. */
  153625. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  153626. }
  153627. /**
  153628. * Class used to run optimizations in order to reach a target frame rate
  153629. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  153630. */
  153631. export class SceneOptimizer implements IDisposable {
  153632. private _isRunning;
  153633. private _options;
  153634. private _scene;
  153635. private _currentPriorityLevel;
  153636. private _targetFrameRate;
  153637. private _trackerDuration;
  153638. private _currentFrameRate;
  153639. private _sceneDisposeObserver;
  153640. private _improvementMode;
  153641. /**
  153642. * Defines an observable called when the optimizer reaches the target frame rate
  153643. */
  153644. onSuccessObservable: Observable<SceneOptimizer>;
  153645. /**
  153646. * Defines an observable called when the optimizer enables an optimization
  153647. */
  153648. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  153649. /**
  153650. * Defines an observable called when the optimizer is not able to reach the target frame rate
  153651. */
  153652. onFailureObservable: Observable<SceneOptimizer>;
  153653. /**
  153654. * Gets a boolean indicating if the optimizer is in improvement mode
  153655. */
  153656. get isInImprovementMode(): boolean;
  153657. /**
  153658. * Gets the current priority level (0 at start)
  153659. */
  153660. get currentPriorityLevel(): number;
  153661. /**
  153662. * Gets the current frame rate checked by the SceneOptimizer
  153663. */
  153664. get currentFrameRate(): number;
  153665. /**
  153666. * Gets or sets the current target frame rate (60 by default)
  153667. */
  153668. get targetFrameRate(): number;
  153669. /**
  153670. * Gets or sets the current target frame rate (60 by default)
  153671. */
  153672. set targetFrameRate(value: number);
  153673. /**
  153674. * Gets or sets the current interval between two checks (every 2000ms by default)
  153675. */
  153676. get trackerDuration(): number;
  153677. /**
  153678. * Gets or sets the current interval between two checks (every 2000ms by default)
  153679. */
  153680. set trackerDuration(value: number);
  153681. /**
  153682. * Gets the list of active optimizations
  153683. */
  153684. get optimizations(): SceneOptimization[];
  153685. /**
  153686. * Creates a new SceneOptimizer
  153687. * @param scene defines the scene to work on
  153688. * @param options defines the options to use with the SceneOptimizer
  153689. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  153690. * @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)
  153691. */
  153692. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  153693. /**
  153694. * Stops the current optimizer
  153695. */
  153696. stop(): void;
  153697. /**
  153698. * Reset the optimizer to initial step (current priority level = 0)
  153699. */
  153700. reset(): void;
  153701. /**
  153702. * Start the optimizer. By default it will try to reach a specific framerate
  153703. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  153704. */
  153705. start(): void;
  153706. private _checkCurrentState;
  153707. /**
  153708. * Release all resources
  153709. */
  153710. dispose(): void;
  153711. /**
  153712. * Helper function to create a SceneOptimizer with one single line of code
  153713. * @param scene defines the scene to work on
  153714. * @param options defines the options to use with the SceneOptimizer
  153715. * @param onSuccess defines a callback to call on success
  153716. * @param onFailure defines a callback to call on failure
  153717. * @returns the new SceneOptimizer object
  153718. */
  153719. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  153720. }
  153721. }
  153722. declare module BABYLON {
  153723. /**
  153724. * Class used to serialize a scene into a string
  153725. */
  153726. export class SceneSerializer {
  153727. /**
  153728. * Clear cache used by a previous serialization
  153729. */
  153730. static ClearCache(): void;
  153731. /**
  153732. * Serialize a scene into a JSON compatible object
  153733. * @param scene defines the scene to serialize
  153734. * @returns a JSON compatible object
  153735. */
  153736. static Serialize(scene: Scene): any;
  153737. /**
  153738. * Serialize a mesh into a JSON compatible object
  153739. * @param toSerialize defines the mesh to serialize
  153740. * @param withParents defines if parents must be serialized as well
  153741. * @param withChildren defines if children must be serialized as well
  153742. * @returns a JSON compatible object
  153743. */
  153744. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  153745. }
  153746. }
  153747. declare module BABYLON {
  153748. /**
  153749. * Class used to host texture specific utilities
  153750. */
  153751. export class TextureTools {
  153752. /**
  153753. * Uses the GPU to create a copy texture rescaled at a given size
  153754. * @param texture Texture to copy from
  153755. * @param width defines the desired width
  153756. * @param height defines the desired height
  153757. * @param useBilinearMode defines if bilinear mode has to be used
  153758. * @return the generated texture
  153759. */
  153760. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  153761. }
  153762. }
  153763. declare module BABYLON {
  153764. /**
  153765. * This represents the different options available for the video capture.
  153766. */
  153767. export interface VideoRecorderOptions {
  153768. /** Defines the mime type of the video. */
  153769. mimeType: string;
  153770. /** Defines the FPS the video should be recorded at. */
  153771. fps: number;
  153772. /** Defines the chunk size for the recording data. */
  153773. recordChunckSize: number;
  153774. /** The audio tracks to attach to the recording. */
  153775. audioTracks?: MediaStreamTrack[];
  153776. }
  153777. /**
  153778. * This can help with recording videos from BabylonJS.
  153779. * This is based on the available WebRTC functionalities of the browser.
  153780. *
  153781. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  153782. */
  153783. export class VideoRecorder {
  153784. private static readonly _defaultOptions;
  153785. /**
  153786. * Returns whether or not the VideoRecorder is available in your browser.
  153787. * @param engine Defines the Babylon Engine.
  153788. * @returns true if supported otherwise false.
  153789. */
  153790. static IsSupported(engine: Engine): boolean;
  153791. private readonly _options;
  153792. private _canvas;
  153793. private _mediaRecorder;
  153794. private _recordedChunks;
  153795. private _fileName;
  153796. private _resolve;
  153797. private _reject;
  153798. /**
  153799. * True when a recording is already in progress.
  153800. */
  153801. get isRecording(): boolean;
  153802. /**
  153803. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  153804. * @param engine Defines the BabylonJS Engine you wish to record.
  153805. * @param options Defines options that can be used to customize the capture.
  153806. */
  153807. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  153808. /**
  153809. * Stops the current recording before the default capture timeout passed in the startRecording function.
  153810. */
  153811. stopRecording(): void;
  153812. /**
  153813. * Starts recording the canvas for a max duration specified in parameters.
  153814. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  153815. * If null no automatic download will start and you can rely on the promise to get the data back.
  153816. * @param maxDuration Defines the maximum recording time in seconds.
  153817. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  153818. * @return A promise callback at the end of the recording with the video data in Blob.
  153819. */
  153820. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  153821. /**
  153822. * Releases internal resources used during the recording.
  153823. */
  153824. dispose(): void;
  153825. private _handleDataAvailable;
  153826. private _handleError;
  153827. private _handleStop;
  153828. }
  153829. }
  153830. declare module BABYLON {
  153831. /**
  153832. * Class containing a set of static utilities functions for screenshots
  153833. */
  153834. export class ScreenshotTools {
  153835. /**
  153836. * Captures a screenshot of the current rendering
  153837. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  153838. * @param engine defines the rendering engine
  153839. * @param camera defines the source camera
  153840. * @param size This parameter can be set to a single number or to an object with the
  153841. * following (optional) properties: precision, width, height. If a single number is passed,
  153842. * it will be used for both width and height. If an object is passed, the screenshot size
  153843. * will be derived from the parameters. The precision property is a multiplier allowing
  153844. * rendering at a higher or lower resolution
  153845. * @param successCallback defines the callback receives a single parameter which contains the
  153846. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  153847. * src parameter of an <img> to display it
  153848. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  153849. * Check your browser for supported MIME types
  153850. */
  153851. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  153852. /**
  153853. * Captures a screenshot of the current rendering
  153854. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  153855. * @param engine defines the rendering engine
  153856. * @param camera defines the source camera
  153857. * @param size This parameter can be set to a single number or to an object with the
  153858. * following (optional) properties: precision, width, height. If a single number is passed,
  153859. * it will be used for both width and height. If an object is passed, the screenshot size
  153860. * will be derived from the parameters. The precision property is a multiplier allowing
  153861. * rendering at a higher or lower resolution
  153862. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  153863. * Check your browser for supported MIME types
  153864. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  153865. * to the src parameter of an <img> to display it
  153866. */
  153867. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  153868. /**
  153869. * Generates an image screenshot from the specified camera.
  153870. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  153871. * @param engine The engine to use for rendering
  153872. * @param camera The camera to use for rendering
  153873. * @param size This parameter can be set to a single number or to an object with the
  153874. * following (optional) properties: precision, width, height. If a single number is passed,
  153875. * it will be used for both width and height. If an object is passed, the screenshot size
  153876. * will be derived from the parameters. The precision property is a multiplier allowing
  153877. * rendering at a higher or lower resolution
  153878. * @param successCallback The callback receives a single parameter which contains the
  153879. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  153880. * src parameter of an <img> to display it
  153881. * @param mimeType The MIME type of the screenshot image (default: image/png).
  153882. * Check your browser for supported MIME types
  153883. * @param samples Texture samples (default: 1)
  153884. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  153885. * @param fileName A name for for the downloaded file.
  153886. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  153887. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  153888. */
  153889. 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;
  153890. /**
  153891. * Generates an image screenshot from the specified camera.
  153892. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  153893. * @param engine The engine to use for rendering
  153894. * @param camera The camera to use for rendering
  153895. * @param size This parameter can be set to a single number or to an object with the
  153896. * following (optional) properties: precision, width, height. If a single number is passed,
  153897. * it will be used for both width and height. If an object is passed, the screenshot size
  153898. * will be derived from the parameters. The precision property is a multiplier allowing
  153899. * rendering at a higher or lower resolution
  153900. * @param mimeType The MIME type of the screenshot image (default: image/png).
  153901. * Check your browser for supported MIME types
  153902. * @param samples Texture samples (default: 1)
  153903. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  153904. * @param fileName A name for for the downloaded file.
  153905. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  153906. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  153907. * to the src parameter of an <img> to display it
  153908. */
  153909. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  153910. /**
  153911. * Gets height and width for screenshot size
  153912. * @private
  153913. */
  153914. private static _getScreenshotSize;
  153915. }
  153916. }
  153917. declare module BABYLON {
  153918. /**
  153919. * Interface for a data buffer
  153920. */
  153921. export interface IDataBuffer {
  153922. /**
  153923. * Reads bytes from the data buffer.
  153924. * @param byteOffset The byte offset to read
  153925. * @param byteLength The byte length to read
  153926. * @returns A promise that resolves when the bytes are read
  153927. */
  153928. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  153929. /**
  153930. * The byte length of the buffer.
  153931. */
  153932. readonly byteLength: number;
  153933. }
  153934. /**
  153935. * Utility class for reading from a data buffer
  153936. */
  153937. export class DataReader {
  153938. /**
  153939. * The data buffer associated with this data reader.
  153940. */
  153941. readonly buffer: IDataBuffer;
  153942. /**
  153943. * The current byte offset from the beginning of the data buffer.
  153944. */
  153945. byteOffset: number;
  153946. private _dataView;
  153947. private _dataByteOffset;
  153948. /**
  153949. * Constructor
  153950. * @param buffer The buffer to read
  153951. */
  153952. constructor(buffer: IDataBuffer);
  153953. /**
  153954. * Loads the given byte length.
  153955. * @param byteLength The byte length to load
  153956. * @returns A promise that resolves when the load is complete
  153957. */
  153958. loadAsync(byteLength: number): Promise<void>;
  153959. /**
  153960. * Read a unsigned 32-bit integer from the currently loaded data range.
  153961. * @returns The 32-bit integer read
  153962. */
  153963. readUint32(): number;
  153964. /**
  153965. * Read a byte array from the currently loaded data range.
  153966. * @param byteLength The byte length to read
  153967. * @returns The byte array read
  153968. */
  153969. readUint8Array(byteLength: number): Uint8Array;
  153970. /**
  153971. * Read a string from the currently loaded data range.
  153972. * @param byteLength The byte length to read
  153973. * @returns The string read
  153974. */
  153975. readString(byteLength: number): string;
  153976. /**
  153977. * Skips the given byte length the currently loaded data range.
  153978. * @param byteLength The byte length to skip
  153979. */
  153980. skipBytes(byteLength: number): void;
  153981. }
  153982. }
  153983. declare module BABYLON {
  153984. /**
  153985. * Class for storing data to local storage if available or in-memory storage otherwise
  153986. */
  153987. export class DataStorage {
  153988. private static _Storage;
  153989. private static _GetStorage;
  153990. /**
  153991. * Reads a string from the data storage
  153992. * @param key The key to read
  153993. * @param defaultValue The value if the key doesn't exist
  153994. * @returns The string value
  153995. */
  153996. static ReadString(key: string, defaultValue: string): string;
  153997. /**
  153998. * Writes a string to the data storage
  153999. * @param key The key to write
  154000. * @param value The value to write
  154001. */
  154002. static WriteString(key: string, value: string): void;
  154003. /**
  154004. * Reads a boolean from the data storage
  154005. * @param key The key to read
  154006. * @param defaultValue The value if the key doesn't exist
  154007. * @returns The boolean value
  154008. */
  154009. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  154010. /**
  154011. * Writes a boolean to the data storage
  154012. * @param key The key to write
  154013. * @param value The value to write
  154014. */
  154015. static WriteBoolean(key: string, value: boolean): void;
  154016. /**
  154017. * Reads a number from the data storage
  154018. * @param key The key to read
  154019. * @param defaultValue The value if the key doesn't exist
  154020. * @returns The number value
  154021. */
  154022. static ReadNumber(key: string, defaultValue: number): number;
  154023. /**
  154024. * Writes a number to the data storage
  154025. * @param key The key to write
  154026. * @param value The value to write
  154027. */
  154028. static WriteNumber(key: string, value: number): void;
  154029. }
  154030. }
  154031. declare module BABYLON {
  154032. /**
  154033. * Class used to record delta files between 2 scene states
  154034. */
  154035. export class SceneRecorder {
  154036. private _trackedScene;
  154037. private _savedJSON;
  154038. /**
  154039. * Track a given scene. This means the current scene state will be considered the original state
  154040. * @param scene defines the scene to track
  154041. */
  154042. track(scene: Scene): void;
  154043. /**
  154044. * Get the delta between current state and original state
  154045. * @returns a string containing the delta
  154046. */
  154047. getDelta(): any;
  154048. private _compareArray;
  154049. private _compareObjects;
  154050. private _compareCollections;
  154051. private static GetShadowGeneratorById;
  154052. /**
  154053. * Apply a given delta to a given scene
  154054. * @param deltaJSON defines the JSON containing the delta
  154055. * @param scene defines the scene to apply the delta to
  154056. */
  154057. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  154058. private static _ApplyPropertiesToEntity;
  154059. private static _ApplyDeltaForEntity;
  154060. }
  154061. }
  154062. declare module BABYLON {
  154063. /**
  154064. * An interface for all Hit test features
  154065. */
  154066. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  154067. /**
  154068. * Triggered when new babylon (transformed) hit test results are available
  154069. */
  154070. onHitTestResultObservable: Observable<T[]>;
  154071. }
  154072. /**
  154073. * Options used for hit testing
  154074. */
  154075. export interface IWebXRLegacyHitTestOptions {
  154076. /**
  154077. * Only test when user interacted with the scene. Default - hit test every frame
  154078. */
  154079. testOnPointerDownOnly?: boolean;
  154080. /**
  154081. * The node to use to transform the local results to world coordinates
  154082. */
  154083. worldParentNode?: TransformNode;
  154084. }
  154085. /**
  154086. * Interface defining the babylon result of raycasting/hit-test
  154087. */
  154088. export interface IWebXRLegacyHitResult {
  154089. /**
  154090. * Transformation matrix that can be applied to a node that will put it in the hit point location
  154091. */
  154092. transformationMatrix: Matrix;
  154093. /**
  154094. * The native hit test result
  154095. */
  154096. xrHitResult: XRHitResult | XRHitTestResult;
  154097. }
  154098. /**
  154099. * The currently-working hit-test module.
  154100. * Hit test (or Ray-casting) is used to interact with the real world.
  154101. * For further information read here - https://github.com/immersive-web/hit-test
  154102. */
  154103. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  154104. /**
  154105. * options to use when constructing this feature
  154106. */
  154107. readonly options: IWebXRLegacyHitTestOptions;
  154108. private _direction;
  154109. private _mat;
  154110. private _onSelectEnabled;
  154111. private _origin;
  154112. /**
  154113. * The module's name
  154114. */
  154115. static readonly Name: string;
  154116. /**
  154117. * The (Babylon) version of this module.
  154118. * This is an integer representing the implementation version.
  154119. * This number does not correspond to the WebXR specs version
  154120. */
  154121. static readonly Version: number;
  154122. /**
  154123. * Populated with the last native XR Hit Results
  154124. */
  154125. lastNativeXRHitResults: XRHitResult[];
  154126. /**
  154127. * Triggered when new babylon (transformed) hit test results are available
  154128. */
  154129. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  154130. /**
  154131. * Creates a new instance of the (legacy version) hit test feature
  154132. * @param _xrSessionManager an instance of WebXRSessionManager
  154133. * @param options options to use when constructing this feature
  154134. */
  154135. constructor(_xrSessionManager: WebXRSessionManager,
  154136. /**
  154137. * options to use when constructing this feature
  154138. */
  154139. options?: IWebXRLegacyHitTestOptions);
  154140. /**
  154141. * execute a hit test with an XR Ray
  154142. *
  154143. * @param xrSession a native xrSession that will execute this hit test
  154144. * @param xrRay the ray (position and direction) to use for ray-casting
  154145. * @param referenceSpace native XR reference space to use for the hit-test
  154146. * @param filter filter function that will filter the results
  154147. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  154148. */
  154149. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  154150. /**
  154151. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  154152. * @param event the (select) event to use to select with
  154153. * @param referenceSpace the reference space to use for this hit test
  154154. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  154155. */
  154156. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  154157. /**
  154158. * attach this feature
  154159. * Will usually be called by the features manager
  154160. *
  154161. * @returns true if successful.
  154162. */
  154163. attach(): boolean;
  154164. /**
  154165. * detach this feature.
  154166. * Will usually be called by the features manager
  154167. *
  154168. * @returns true if successful.
  154169. */
  154170. detach(): boolean;
  154171. /**
  154172. * Dispose this feature and all of the resources attached
  154173. */
  154174. dispose(): void;
  154175. protected _onXRFrame(frame: XRFrame): void;
  154176. private _onHitTestResults;
  154177. private _onSelect;
  154178. }
  154179. }
  154180. declare module BABYLON {
  154181. /**
  154182. * Options used for hit testing (version 2)
  154183. */
  154184. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  154185. /**
  154186. * Do not create a permanent hit test. Will usually be used when only
  154187. * transient inputs are needed.
  154188. */
  154189. disablePermanentHitTest?: boolean;
  154190. /**
  154191. * Enable transient (for example touch-based) hit test inspections
  154192. */
  154193. enableTransientHitTest?: boolean;
  154194. /**
  154195. * Offset ray for the permanent hit test
  154196. */
  154197. offsetRay?: Vector3;
  154198. /**
  154199. * Offset ray for the transient hit test
  154200. */
  154201. transientOffsetRay?: Vector3;
  154202. /**
  154203. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  154204. */
  154205. useReferenceSpace?: boolean;
  154206. /**
  154207. * Override the default entity type(s) of the hit-test result
  154208. */
  154209. entityTypes?: XRHitTestTrackableType[];
  154210. }
  154211. /**
  154212. * Interface defining the babylon result of hit-test
  154213. */
  154214. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  154215. /**
  154216. * The input source that generated this hit test (if transient)
  154217. */
  154218. inputSource?: XRInputSource;
  154219. /**
  154220. * Is this a transient hit test
  154221. */
  154222. isTransient?: boolean;
  154223. /**
  154224. * Position of the hit test result
  154225. */
  154226. position: Vector3;
  154227. /**
  154228. * Rotation of the hit test result
  154229. */
  154230. rotationQuaternion: Quaternion;
  154231. /**
  154232. * The native hit test result
  154233. */
  154234. xrHitResult: XRHitTestResult;
  154235. }
  154236. /**
  154237. * The currently-working hit-test module.
  154238. * Hit test (or Ray-casting) is used to interact with the real world.
  154239. * For further information read here - https://github.com/immersive-web/hit-test
  154240. *
  154241. * Tested on chrome (mobile) 80.
  154242. */
  154243. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  154244. /**
  154245. * options to use when constructing this feature
  154246. */
  154247. readonly options: IWebXRHitTestOptions;
  154248. private _tmpMat;
  154249. private _tmpPos;
  154250. private _tmpQuat;
  154251. private _transientXrHitTestSource;
  154252. private _xrHitTestSource;
  154253. private initHitTestSource;
  154254. /**
  154255. * The module's name
  154256. */
  154257. static readonly Name: string;
  154258. /**
  154259. * The (Babylon) version of this module.
  154260. * This is an integer representing the implementation version.
  154261. * This number does not correspond to the WebXR specs version
  154262. */
  154263. static readonly Version: number;
  154264. /**
  154265. * When set to true, each hit test will have its own position/rotation objects
  154266. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  154267. * the developers will clone them or copy them as they see fit.
  154268. */
  154269. autoCloneTransformation: boolean;
  154270. /**
  154271. * Triggered when new babylon (transformed) hit test results are available
  154272. * Note - this will be called when results come back from the device. It can be an empty array!!
  154273. */
  154274. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  154275. /**
  154276. * Use this to temporarily pause hit test checks.
  154277. */
  154278. paused: boolean;
  154279. /**
  154280. * Creates a new instance of the hit test feature
  154281. * @param _xrSessionManager an instance of WebXRSessionManager
  154282. * @param options options to use when constructing this feature
  154283. */
  154284. constructor(_xrSessionManager: WebXRSessionManager,
  154285. /**
  154286. * options to use when constructing this feature
  154287. */
  154288. options?: IWebXRHitTestOptions);
  154289. /**
  154290. * attach this feature
  154291. * Will usually be called by the features manager
  154292. *
  154293. * @returns true if successful.
  154294. */
  154295. attach(): boolean;
  154296. /**
  154297. * detach this feature.
  154298. * Will usually be called by the features manager
  154299. *
  154300. * @returns true if successful.
  154301. */
  154302. detach(): boolean;
  154303. /**
  154304. * Dispose this feature and all of the resources attached
  154305. */
  154306. dispose(): void;
  154307. protected _onXRFrame(frame: XRFrame): void;
  154308. private _processWebXRHitTestResult;
  154309. }
  154310. }
  154311. declare module BABYLON {
  154312. /**
  154313. * Configuration options of the anchor system
  154314. */
  154315. export interface IWebXRAnchorSystemOptions {
  154316. /**
  154317. * a node that will be used to convert local to world coordinates
  154318. */
  154319. worldParentNode?: TransformNode;
  154320. /**
  154321. * If set to true a reference of the created anchors will be kept until the next session starts
  154322. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  154323. */
  154324. doNotRemoveAnchorsOnSessionEnded?: boolean;
  154325. }
  154326. /**
  154327. * A babylon container for an XR Anchor
  154328. */
  154329. export interface IWebXRAnchor {
  154330. /**
  154331. * A babylon-assigned ID for this anchor
  154332. */
  154333. id: number;
  154334. /**
  154335. * Transformation matrix to apply to an object attached to this anchor
  154336. */
  154337. transformationMatrix: Matrix;
  154338. /**
  154339. * The native anchor object
  154340. */
  154341. xrAnchor: XRAnchor;
  154342. /**
  154343. * if defined, this object will be constantly updated by the anchor's position and rotation
  154344. */
  154345. attachedNode?: TransformNode;
  154346. }
  154347. /**
  154348. * An implementation of the anchor system for WebXR.
  154349. * For further information see https://github.com/immersive-web/anchors/
  154350. */
  154351. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  154352. private _options;
  154353. private _lastFrameDetected;
  154354. private _trackedAnchors;
  154355. private _referenceSpaceForFrameAnchors;
  154356. private _futureAnchors;
  154357. /**
  154358. * The module's name
  154359. */
  154360. static readonly Name: string;
  154361. /**
  154362. * The (Babylon) version of this module.
  154363. * This is an integer representing the implementation version.
  154364. * This number does not correspond to the WebXR specs version
  154365. */
  154366. static readonly Version: number;
  154367. /**
  154368. * Observers registered here will be executed when a new anchor was added to the session
  154369. */
  154370. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  154371. /**
  154372. * Observers registered here will be executed when an anchor was removed from the session
  154373. */
  154374. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  154375. /**
  154376. * Observers registered here will be executed when an existing anchor updates
  154377. * This can execute N times every frame
  154378. */
  154379. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  154380. /**
  154381. * Set the reference space to use for anchor creation, when not using a hit test.
  154382. * Will default to the session's reference space if not defined
  154383. */
  154384. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  154385. /**
  154386. * constructs a new anchor system
  154387. * @param _xrSessionManager an instance of WebXRSessionManager
  154388. * @param _options configuration object for this feature
  154389. */
  154390. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  154391. private _tmpVector;
  154392. private _tmpQuaternion;
  154393. private _populateTmpTransformation;
  154394. /**
  154395. * Create a new anchor point using a hit test result at a specific point in the scene
  154396. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  154397. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  154398. *
  154399. * @param hitTestResult The hit test result to use for this anchor creation
  154400. * @param position an optional position offset for this anchor
  154401. * @param rotationQuaternion an optional rotation offset for this anchor
  154402. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  154403. */
  154404. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  154405. /**
  154406. * Add a new anchor at a specific position and rotation
  154407. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  154408. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  154409. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  154410. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  154411. *
  154412. * @param position the position in which to add an anchor
  154413. * @param rotationQuaternion an optional rotation for the anchor transformation
  154414. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  154415. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  154416. */
  154417. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  154418. /**
  154419. * detach this feature.
  154420. * Will usually be called by the features manager
  154421. *
  154422. * @returns true if successful.
  154423. */
  154424. detach(): boolean;
  154425. /**
  154426. * Dispose this feature and all of the resources attached
  154427. */
  154428. dispose(): void;
  154429. protected _onXRFrame(frame: XRFrame): void;
  154430. /**
  154431. * avoiding using Array.find for global support.
  154432. * @param xrAnchor the plane to find in the array
  154433. */
  154434. private _findIndexInAnchorArray;
  154435. private _updateAnchorWithXRFrame;
  154436. private _createAnchorAtTransformation;
  154437. }
  154438. }
  154439. declare module BABYLON {
  154440. /**
  154441. * Options used in the plane detector module
  154442. */
  154443. export interface IWebXRPlaneDetectorOptions {
  154444. /**
  154445. * The node to use to transform the local results to world coordinates
  154446. */
  154447. worldParentNode?: TransformNode;
  154448. /**
  154449. * If set to true a reference of the created planes will be kept until the next session starts
  154450. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  154451. */
  154452. doNotRemovePlanesOnSessionEnded?: boolean;
  154453. }
  154454. /**
  154455. * A babylon interface for a WebXR plane.
  154456. * A Plane is actually a polygon, built from N points in space
  154457. *
  154458. * Supported in chrome 79, not supported in canary 81 ATM
  154459. */
  154460. export interface IWebXRPlane {
  154461. /**
  154462. * a babylon-assigned ID for this polygon
  154463. */
  154464. id: number;
  154465. /**
  154466. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  154467. */
  154468. polygonDefinition: Array<Vector3>;
  154469. /**
  154470. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  154471. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  154472. */
  154473. transformationMatrix: Matrix;
  154474. /**
  154475. * the native xr-plane object
  154476. */
  154477. xrPlane: XRPlane;
  154478. }
  154479. /**
  154480. * The plane detector is used to detect planes in the real world when in AR
  154481. * For more information see https://github.com/immersive-web/real-world-geometry/
  154482. */
  154483. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  154484. private _options;
  154485. private _detectedPlanes;
  154486. private _enabled;
  154487. private _lastFrameDetected;
  154488. /**
  154489. * The module's name
  154490. */
  154491. static readonly Name: string;
  154492. /**
  154493. * The (Babylon) version of this module.
  154494. * This is an integer representing the implementation version.
  154495. * This number does not correspond to the WebXR specs version
  154496. */
  154497. static readonly Version: number;
  154498. /**
  154499. * Observers registered here will be executed when a new plane was added to the session
  154500. */
  154501. onPlaneAddedObservable: Observable<IWebXRPlane>;
  154502. /**
  154503. * Observers registered here will be executed when a plane is no longer detected in the session
  154504. */
  154505. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  154506. /**
  154507. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  154508. * This can execute N times every frame
  154509. */
  154510. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  154511. /**
  154512. * construct a new Plane Detector
  154513. * @param _xrSessionManager an instance of xr Session manager
  154514. * @param _options configuration to use when constructing this feature
  154515. */
  154516. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  154517. /**
  154518. * detach this feature.
  154519. * Will usually be called by the features manager
  154520. *
  154521. * @returns true if successful.
  154522. */
  154523. detach(): boolean;
  154524. /**
  154525. * Dispose this feature and all of the resources attached
  154526. */
  154527. dispose(): void;
  154528. protected _onXRFrame(frame: XRFrame): void;
  154529. private _init;
  154530. private _updatePlaneWithXRPlane;
  154531. /**
  154532. * avoiding using Array.find for global support.
  154533. * @param xrPlane the plane to find in the array
  154534. */
  154535. private findIndexInPlaneArray;
  154536. }
  154537. }
  154538. declare module BABYLON {
  154539. /**
  154540. * Options interface for the background remover plugin
  154541. */
  154542. export interface IWebXRBackgroundRemoverOptions {
  154543. /**
  154544. * Further background meshes to disable when entering AR
  154545. */
  154546. backgroundMeshes?: AbstractMesh[];
  154547. /**
  154548. * flags to configure the removal of the environment helper.
  154549. * If not set, the entire background will be removed. If set, flags should be set as well.
  154550. */
  154551. environmentHelperRemovalFlags?: {
  154552. /**
  154553. * Should the skybox be removed (default false)
  154554. */
  154555. skyBox?: boolean;
  154556. /**
  154557. * Should the ground be removed (default false)
  154558. */
  154559. ground?: boolean;
  154560. };
  154561. /**
  154562. * don't disable the environment helper
  154563. */
  154564. ignoreEnvironmentHelper?: boolean;
  154565. }
  154566. /**
  154567. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  154568. */
  154569. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  154570. /**
  154571. * read-only options to be used in this module
  154572. */
  154573. readonly options: IWebXRBackgroundRemoverOptions;
  154574. /**
  154575. * The module's name
  154576. */
  154577. static readonly Name: string;
  154578. /**
  154579. * The (Babylon) version of this module.
  154580. * This is an integer representing the implementation version.
  154581. * This number does not correspond to the WebXR specs version
  154582. */
  154583. static readonly Version: number;
  154584. /**
  154585. * registered observers will be triggered when the background state changes
  154586. */
  154587. onBackgroundStateChangedObservable: Observable<boolean>;
  154588. /**
  154589. * constructs a new background remover module
  154590. * @param _xrSessionManager the session manager for this module
  154591. * @param options read-only options to be used in this module
  154592. */
  154593. constructor(_xrSessionManager: WebXRSessionManager,
  154594. /**
  154595. * read-only options to be used in this module
  154596. */
  154597. options?: IWebXRBackgroundRemoverOptions);
  154598. /**
  154599. * attach this feature
  154600. * Will usually be called by the features manager
  154601. *
  154602. * @returns true if successful.
  154603. */
  154604. attach(): boolean;
  154605. /**
  154606. * detach this feature.
  154607. * Will usually be called by the features manager
  154608. *
  154609. * @returns true if successful.
  154610. */
  154611. detach(): boolean;
  154612. /**
  154613. * Dispose this feature and all of the resources attached
  154614. */
  154615. dispose(): void;
  154616. protected _onXRFrame(_xrFrame: XRFrame): void;
  154617. private _setBackgroundState;
  154618. }
  154619. }
  154620. declare module BABYLON {
  154621. /**
  154622. * Options for the controller physics feature
  154623. */
  154624. export class IWebXRControllerPhysicsOptions {
  154625. /**
  154626. * Should the headset get its own impostor
  154627. */
  154628. enableHeadsetImpostor?: boolean;
  154629. /**
  154630. * Optional parameters for the headset impostor
  154631. */
  154632. headsetImpostorParams?: {
  154633. /**
  154634. * The type of impostor to create. Default is sphere
  154635. */
  154636. impostorType: number;
  154637. /**
  154638. * the size of the impostor. Defaults to 10cm
  154639. */
  154640. impostorSize?: number | {
  154641. width: number;
  154642. height: number;
  154643. depth: number;
  154644. };
  154645. /**
  154646. * Friction definitions
  154647. */
  154648. friction?: number;
  154649. /**
  154650. * Restitution
  154651. */
  154652. restitution?: number;
  154653. };
  154654. /**
  154655. * The physics properties of the future impostors
  154656. */
  154657. physicsProperties?: {
  154658. /**
  154659. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  154660. * Note that this requires a physics engine that supports mesh impostors!
  154661. */
  154662. useControllerMesh?: boolean;
  154663. /**
  154664. * The type of impostor to create. Default is sphere
  154665. */
  154666. impostorType?: number;
  154667. /**
  154668. * the size of the impostor. Defaults to 10cm
  154669. */
  154670. impostorSize?: number | {
  154671. width: number;
  154672. height: number;
  154673. depth: number;
  154674. };
  154675. /**
  154676. * Friction definitions
  154677. */
  154678. friction?: number;
  154679. /**
  154680. * Restitution
  154681. */
  154682. restitution?: number;
  154683. };
  154684. /**
  154685. * the xr input to use with this pointer selection
  154686. */
  154687. xrInput: WebXRInput;
  154688. }
  154689. /**
  154690. * Add physics impostor to your webxr controllers,
  154691. * including naive calculation of their linear and angular velocity
  154692. */
  154693. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  154694. private readonly _options;
  154695. private _attachController;
  154696. private _controllers;
  154697. private _debugMode;
  154698. private _delta;
  154699. private _headsetImpostor?;
  154700. private _headsetMesh?;
  154701. private _lastTimestamp;
  154702. private _tmpQuaternion;
  154703. private _tmpVector;
  154704. /**
  154705. * The module's name
  154706. */
  154707. static readonly Name: string;
  154708. /**
  154709. * The (Babylon) version of this module.
  154710. * This is an integer representing the implementation version.
  154711. * This number does not correspond to the webxr specs version
  154712. */
  154713. static readonly Version: number;
  154714. /**
  154715. * Construct a new Controller Physics Feature
  154716. * @param _xrSessionManager the corresponding xr session manager
  154717. * @param _options options to create this feature with
  154718. */
  154719. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  154720. /**
  154721. * @hidden
  154722. * enable debugging - will show console outputs and the impostor mesh
  154723. */
  154724. _enablePhysicsDebug(): void;
  154725. /**
  154726. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  154727. * @param xrController the controller to add
  154728. */
  154729. addController(xrController: WebXRInputSource): void;
  154730. /**
  154731. * attach this feature
  154732. * Will usually be called by the features manager
  154733. *
  154734. * @returns true if successful.
  154735. */
  154736. attach(): boolean;
  154737. /**
  154738. * detach this feature.
  154739. * Will usually be called by the features manager
  154740. *
  154741. * @returns true if successful.
  154742. */
  154743. detach(): boolean;
  154744. /**
  154745. * Get the headset impostor, if enabled
  154746. * @returns the impostor
  154747. */
  154748. getHeadsetImpostor(): PhysicsImpostor | undefined;
  154749. /**
  154750. * Get the physics impostor of a specific controller.
  154751. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  154752. * @param controller the controller or the controller id of which to get the impostor
  154753. * @returns the impostor or null
  154754. */
  154755. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  154756. /**
  154757. * Update the physics properties provided in the constructor
  154758. * @param newProperties the new properties object
  154759. */
  154760. setPhysicsProperties(newProperties: {
  154761. impostorType?: number;
  154762. impostorSize?: number | {
  154763. width: number;
  154764. height: number;
  154765. depth: number;
  154766. };
  154767. friction?: number;
  154768. restitution?: number;
  154769. }): void;
  154770. protected _onXRFrame(_xrFrame: any): void;
  154771. private _detachController;
  154772. }
  154773. }
  154774. declare module BABYLON {
  154775. /**
  154776. * A babylon interface for a "WebXR" feature point.
  154777. * Represents the position and confidence value of a given feature point.
  154778. */
  154779. export interface IWebXRFeaturePoint {
  154780. /**
  154781. * Represents the position of the feature point in world space.
  154782. */
  154783. position: Vector3;
  154784. /**
  154785. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  154786. */
  154787. confidenceValue: number;
  154788. }
  154789. /**
  154790. * The feature point system is used to detect feature points from real world geometry.
  154791. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  154792. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  154793. */
  154794. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  154795. private _enabled;
  154796. private _featurePointCloud;
  154797. /**
  154798. * The module's name
  154799. */
  154800. static readonly Name: string;
  154801. /**
  154802. * The (Babylon) version of this module.
  154803. * This is an integer representing the implementation version.
  154804. * This number does not correspond to the WebXR specs version
  154805. */
  154806. static readonly Version: number;
  154807. /**
  154808. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  154809. * Will notify the observers about which feature points have been added.
  154810. */
  154811. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  154812. /**
  154813. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  154814. * Will notify the observers about which feature points have been updated.
  154815. */
  154816. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  154817. /**
  154818. * The current feature point cloud maintained across frames.
  154819. */
  154820. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  154821. /**
  154822. * construct the feature point system
  154823. * @param _xrSessionManager an instance of xr Session manager
  154824. */
  154825. constructor(_xrSessionManager: WebXRSessionManager);
  154826. /**
  154827. * Detach this feature.
  154828. * Will usually be called by the features manager
  154829. *
  154830. * @returns true if successful.
  154831. */
  154832. detach(): boolean;
  154833. /**
  154834. * Dispose this feature and all of the resources attached
  154835. */
  154836. dispose(): void;
  154837. /**
  154838. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  154839. */
  154840. protected _onXRFrame(frame: XRFrame): void;
  154841. /**
  154842. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  154843. */
  154844. private _init;
  154845. }
  154846. }
  154847. declare module BABYLON {
  154848. /**
  154849. * Configuration interface for the hand tracking feature
  154850. */
  154851. export interface IWebXRHandTrackingOptions {
  154852. /**
  154853. * The xrInput that will be used as source for new hands
  154854. */
  154855. xrInput: WebXRInput;
  154856. /**
  154857. * Configuration object for the joint meshes
  154858. */
  154859. jointMeshes?: {
  154860. /**
  154861. * Should the meshes created be invisible (defaults to false)
  154862. */
  154863. invisible?: boolean;
  154864. /**
  154865. * A source mesh to be used to create instances. Defaults to a sphere.
  154866. * This mesh will be the source for all other (25) meshes.
  154867. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  154868. */
  154869. sourceMesh?: Mesh;
  154870. /**
  154871. * Should the source mesh stay visible. Defaults to false
  154872. */
  154873. keepOriginalVisible?: boolean;
  154874. /**
  154875. * Scale factor for all instances (defaults to 2)
  154876. */
  154877. scaleFactor?: number;
  154878. /**
  154879. * Should each instance have its own physics impostor
  154880. */
  154881. enablePhysics?: boolean;
  154882. /**
  154883. * If enabled, override default physics properties
  154884. */
  154885. physicsProps?: {
  154886. friction?: number;
  154887. restitution?: number;
  154888. impostorType?: number;
  154889. };
  154890. /**
  154891. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  154892. */
  154893. handMesh?: AbstractMesh;
  154894. };
  154895. }
  154896. /**
  154897. * Parts of the hands divided to writs and finger names
  154898. */
  154899. export const enum HandPart {
  154900. /**
  154901. * HandPart - Wrist
  154902. */
  154903. WRIST = "wrist",
  154904. /**
  154905. * HandPart - The THumb
  154906. */
  154907. THUMB = "thumb",
  154908. /**
  154909. * HandPart - Index finger
  154910. */
  154911. INDEX = "index",
  154912. /**
  154913. * HandPart - Middle finger
  154914. */
  154915. MIDDLE = "middle",
  154916. /**
  154917. * HandPart - Ring finger
  154918. */
  154919. RING = "ring",
  154920. /**
  154921. * HandPart - Little finger
  154922. */
  154923. LITTLE = "little"
  154924. }
  154925. /**
  154926. * Representing a single hand (with its corresponding native XRHand object)
  154927. */
  154928. export class WebXRHand implements IDisposable {
  154929. /** the controller to which the hand correlates */
  154930. readonly xrController: WebXRInputSource;
  154931. /** the meshes to be used to track the hand joints */
  154932. readonly trackedMeshes: AbstractMesh[];
  154933. /**
  154934. * Hand-parts definition (key is HandPart)
  154935. */
  154936. handPartsDefinition: {
  154937. [key: string]: number[];
  154938. };
  154939. /**
  154940. * Populate the HandPartsDefinition object.
  154941. * This is called as a side effect since certain browsers don't have XRHand defined.
  154942. */
  154943. private generateHandPartsDefinition;
  154944. /**
  154945. * Construct a new hand object
  154946. * @param xrController the controller to which the hand correlates
  154947. * @param trackedMeshes the meshes to be used to track the hand joints
  154948. */
  154949. constructor(
  154950. /** the controller to which the hand correlates */
  154951. xrController: WebXRInputSource,
  154952. /** the meshes to be used to track the hand joints */
  154953. trackedMeshes: AbstractMesh[]);
  154954. /**
  154955. * Update this hand from the latest xr frame
  154956. * @param xrFrame xrFrame to update from
  154957. * @param referenceSpace The current viewer reference space
  154958. * @param scaleFactor optional scale factor for the meshes
  154959. */
  154960. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  154961. /**
  154962. * Get meshes of part of the hand
  154963. * @param part the part of hand to get
  154964. * @returns An array of meshes that correlate to the hand part requested
  154965. */
  154966. getHandPartMeshes(part: HandPart): AbstractMesh[];
  154967. /**
  154968. * Dispose this Hand object
  154969. */
  154970. dispose(): void;
  154971. }
  154972. /**
  154973. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  154974. */
  154975. export class WebXRHandTracking extends WebXRAbstractFeature {
  154976. /**
  154977. * options to use when constructing this feature
  154978. */
  154979. readonly options: IWebXRHandTrackingOptions;
  154980. private static _idCounter;
  154981. /**
  154982. * The module's name
  154983. */
  154984. static readonly Name: string;
  154985. /**
  154986. * The (Babylon) version of this module.
  154987. * This is an integer representing the implementation version.
  154988. * This number does not correspond to the WebXR specs version
  154989. */
  154990. static readonly Version: number;
  154991. /**
  154992. * This observable will notify registered observers when a new hand object was added and initialized
  154993. */
  154994. onHandAddedObservable: Observable<WebXRHand>;
  154995. /**
  154996. * This observable will notify its observers right before the hand object is disposed
  154997. */
  154998. onHandRemovedObservable: Observable<WebXRHand>;
  154999. private _hands;
  155000. /**
  155001. * Creates a new instance of the hit test feature
  155002. * @param _xrSessionManager an instance of WebXRSessionManager
  155003. * @param options options to use when constructing this feature
  155004. */
  155005. constructor(_xrSessionManager: WebXRSessionManager,
  155006. /**
  155007. * options to use when constructing this feature
  155008. */
  155009. options: IWebXRHandTrackingOptions);
  155010. /**
  155011. * Check if the needed objects are defined.
  155012. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  155013. */
  155014. isCompatible(): boolean;
  155015. /**
  155016. * attach this feature
  155017. * Will usually be called by the features manager
  155018. *
  155019. * @returns true if successful.
  155020. */
  155021. attach(): boolean;
  155022. /**
  155023. * detach this feature.
  155024. * Will usually be called by the features manager
  155025. *
  155026. * @returns true if successful.
  155027. */
  155028. detach(): boolean;
  155029. /**
  155030. * Dispose this feature and all of the resources attached
  155031. */
  155032. dispose(): void;
  155033. /**
  155034. * Get the hand object according to the controller id
  155035. * @param controllerId the controller id to which we want to get the hand
  155036. * @returns null if not found or the WebXRHand object if found
  155037. */
  155038. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  155039. /**
  155040. * Get a hand object according to the requested handedness
  155041. * @param handedness the handedness to request
  155042. * @returns null if not found or the WebXRHand object if found
  155043. */
  155044. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  155045. protected _onXRFrame(_xrFrame: XRFrame): void;
  155046. private _attachHand;
  155047. private _detachHand;
  155048. }
  155049. }
  155050. declare module BABYLON {
  155051. /**
  155052. * The motion controller class for all microsoft mixed reality controllers
  155053. */
  155054. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  155055. protected readonly _mapping: {
  155056. defaultButton: {
  155057. valueNodeName: string;
  155058. unpressedNodeName: string;
  155059. pressedNodeName: string;
  155060. };
  155061. defaultAxis: {
  155062. valueNodeName: string;
  155063. minNodeName: string;
  155064. maxNodeName: string;
  155065. };
  155066. buttons: {
  155067. "xr-standard-trigger": {
  155068. rootNodeName: string;
  155069. componentProperty: string;
  155070. states: string[];
  155071. };
  155072. "xr-standard-squeeze": {
  155073. rootNodeName: string;
  155074. componentProperty: string;
  155075. states: string[];
  155076. };
  155077. "xr-standard-touchpad": {
  155078. rootNodeName: string;
  155079. labelAnchorNodeName: string;
  155080. touchPointNodeName: string;
  155081. };
  155082. "xr-standard-thumbstick": {
  155083. rootNodeName: string;
  155084. componentProperty: string;
  155085. states: string[];
  155086. };
  155087. };
  155088. axes: {
  155089. "xr-standard-touchpad": {
  155090. "x-axis": {
  155091. rootNodeName: string;
  155092. };
  155093. "y-axis": {
  155094. rootNodeName: string;
  155095. };
  155096. };
  155097. "xr-standard-thumbstick": {
  155098. "x-axis": {
  155099. rootNodeName: string;
  155100. };
  155101. "y-axis": {
  155102. rootNodeName: string;
  155103. };
  155104. };
  155105. };
  155106. };
  155107. /**
  155108. * The base url used to load the left and right controller models
  155109. */
  155110. static MODEL_BASE_URL: string;
  155111. /**
  155112. * The name of the left controller model file
  155113. */
  155114. static MODEL_LEFT_FILENAME: string;
  155115. /**
  155116. * The name of the right controller model file
  155117. */
  155118. static MODEL_RIGHT_FILENAME: string;
  155119. profileId: string;
  155120. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  155121. protected _getFilenameAndPath(): {
  155122. filename: string;
  155123. path: string;
  155124. };
  155125. protected _getModelLoadingConstraints(): boolean;
  155126. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  155127. protected _setRootMesh(meshes: AbstractMesh[]): void;
  155128. protected _updateModel(): void;
  155129. }
  155130. }
  155131. declare module BABYLON {
  155132. /**
  155133. * The motion controller class for oculus touch (quest, rift).
  155134. * This class supports legacy mapping as well the standard xr mapping
  155135. */
  155136. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  155137. private _forceLegacyControllers;
  155138. private _modelRootNode;
  155139. /**
  155140. * The base url used to load the left and right controller models
  155141. */
  155142. static MODEL_BASE_URL: string;
  155143. /**
  155144. * The name of the left controller model file
  155145. */
  155146. static MODEL_LEFT_FILENAME: string;
  155147. /**
  155148. * The name of the right controller model file
  155149. */
  155150. static MODEL_RIGHT_FILENAME: string;
  155151. /**
  155152. * Base Url for the Quest controller model.
  155153. */
  155154. static QUEST_MODEL_BASE_URL: string;
  155155. profileId: string;
  155156. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  155157. protected _getFilenameAndPath(): {
  155158. filename: string;
  155159. path: string;
  155160. };
  155161. protected _getModelLoadingConstraints(): boolean;
  155162. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  155163. protected _setRootMesh(meshes: AbstractMesh[]): void;
  155164. protected _updateModel(): void;
  155165. /**
  155166. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  155167. * between the touch and touch 2.
  155168. */
  155169. private _isQuest;
  155170. }
  155171. }
  155172. declare module BABYLON {
  155173. /**
  155174. * The motion controller class for the standard HTC-Vive controllers
  155175. */
  155176. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  155177. private _modelRootNode;
  155178. /**
  155179. * The base url used to load the left and right controller models
  155180. */
  155181. static MODEL_BASE_URL: string;
  155182. /**
  155183. * File name for the controller model.
  155184. */
  155185. static MODEL_FILENAME: string;
  155186. profileId: string;
  155187. /**
  155188. * Create a new Vive motion controller object
  155189. * @param scene the scene to use to create this controller
  155190. * @param gamepadObject the corresponding gamepad object
  155191. * @param handedness the handedness of the controller
  155192. */
  155193. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  155194. protected _getFilenameAndPath(): {
  155195. filename: string;
  155196. path: string;
  155197. };
  155198. protected _getModelLoadingConstraints(): boolean;
  155199. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  155200. protected _setRootMesh(meshes: AbstractMesh[]): void;
  155201. protected _updateModel(): void;
  155202. }
  155203. }
  155204. declare module BABYLON {
  155205. /**
  155206. * A cursor which tracks a point on a path
  155207. */
  155208. export class PathCursor {
  155209. private path;
  155210. /**
  155211. * Stores path cursor callbacks for when an onchange event is triggered
  155212. */
  155213. private _onchange;
  155214. /**
  155215. * The value of the path cursor
  155216. */
  155217. value: number;
  155218. /**
  155219. * The animation array of the path cursor
  155220. */
  155221. animations: Animation[];
  155222. /**
  155223. * Initializes the path cursor
  155224. * @param path The path to track
  155225. */
  155226. constructor(path: Path2);
  155227. /**
  155228. * Gets the cursor point on the path
  155229. * @returns A point on the path cursor at the cursor location
  155230. */
  155231. getPoint(): Vector3;
  155232. /**
  155233. * Moves the cursor ahead by the step amount
  155234. * @param step The amount to move the cursor forward
  155235. * @returns This path cursor
  155236. */
  155237. moveAhead(step?: number): PathCursor;
  155238. /**
  155239. * Moves the cursor behind by the step amount
  155240. * @param step The amount to move the cursor back
  155241. * @returns This path cursor
  155242. */
  155243. moveBack(step?: number): PathCursor;
  155244. /**
  155245. * Moves the cursor by the step amount
  155246. * If the step amount is greater than one, an exception is thrown
  155247. * @param step The amount to move the cursor
  155248. * @returns This path cursor
  155249. */
  155250. move(step: number): PathCursor;
  155251. /**
  155252. * Ensures that the value is limited between zero and one
  155253. * @returns This path cursor
  155254. */
  155255. private ensureLimits;
  155256. /**
  155257. * Runs onchange callbacks on change (used by the animation engine)
  155258. * @returns This path cursor
  155259. */
  155260. private raiseOnChange;
  155261. /**
  155262. * Executes a function on change
  155263. * @param f A path cursor onchange callback
  155264. * @returns This path cursor
  155265. */
  155266. onchange(f: (cursor: PathCursor) => void): PathCursor;
  155267. }
  155268. }
  155269. declare module BABYLON {
  155270. /** @hidden */
  155271. export var blurPixelShader: {
  155272. name: string;
  155273. shader: string;
  155274. };
  155275. }
  155276. declare module BABYLON {
  155277. /** @hidden */
  155278. export var pointCloudVertexDeclaration: {
  155279. name: string;
  155280. shader: string;
  155281. };
  155282. }
  155283. // Mixins
  155284. interface Window {
  155285. mozIndexedDB: IDBFactory;
  155286. webkitIndexedDB: IDBFactory;
  155287. msIndexedDB: IDBFactory;
  155288. webkitURL: typeof URL;
  155289. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  155290. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  155291. WebGLRenderingContext: WebGLRenderingContext;
  155292. MSGesture: MSGesture;
  155293. CANNON: any;
  155294. AudioContext: AudioContext;
  155295. webkitAudioContext: AudioContext;
  155296. PointerEvent: any;
  155297. Math: Math;
  155298. Uint8Array: Uint8ArrayConstructor;
  155299. Float32Array: Float32ArrayConstructor;
  155300. mozURL: typeof URL;
  155301. msURL: typeof URL;
  155302. VRFrameData: any; // WebVR, from specs 1.1
  155303. DracoDecoderModule: any;
  155304. setImmediate(handler: (...args: any[]) => void): number;
  155305. }
  155306. interface HTMLCanvasElement {
  155307. requestPointerLock(): void;
  155308. msRequestPointerLock?(): void;
  155309. mozRequestPointerLock?(): void;
  155310. webkitRequestPointerLock?(): void;
  155311. /** Track wether a record is in progress */
  155312. isRecording: boolean;
  155313. /** Capture Stream method defined by some browsers */
  155314. captureStream(fps?: number): MediaStream;
  155315. }
  155316. interface CanvasRenderingContext2D {
  155317. msImageSmoothingEnabled: boolean;
  155318. }
  155319. interface MouseEvent {
  155320. mozMovementX: number;
  155321. mozMovementY: number;
  155322. webkitMovementX: number;
  155323. webkitMovementY: number;
  155324. msMovementX: number;
  155325. msMovementY: number;
  155326. }
  155327. interface Navigator {
  155328. mozGetVRDevices: (any: any) => any;
  155329. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  155330. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  155331. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  155332. webkitGetGamepads(): Gamepad[];
  155333. msGetGamepads(): Gamepad[];
  155334. webkitGamepads(): Gamepad[];
  155335. }
  155336. interface HTMLVideoElement {
  155337. mozSrcObject: any;
  155338. }
  155339. interface Math {
  155340. fround(x: number): number;
  155341. imul(a: number, b: number): number;
  155342. }
  155343. interface WebGLRenderingContext {
  155344. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  155345. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  155346. vertexAttribDivisor(index: number, divisor: number): void;
  155347. createVertexArray(): any;
  155348. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  155349. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  155350. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  155351. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  155352. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  155353. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  155354. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  155355. // Queries
  155356. createQuery(): WebGLQuery;
  155357. deleteQuery(query: WebGLQuery): void;
  155358. beginQuery(target: number, query: WebGLQuery): void;
  155359. endQuery(target: number): void;
  155360. getQueryParameter(query: WebGLQuery, pname: number): any;
  155361. getQuery(target: number, pname: number): any;
  155362. MAX_SAMPLES: number;
  155363. RGBA8: number;
  155364. READ_FRAMEBUFFER: number;
  155365. DRAW_FRAMEBUFFER: number;
  155366. UNIFORM_BUFFER: number;
  155367. HALF_FLOAT_OES: number;
  155368. RGBA16F: number;
  155369. RGBA32F: number;
  155370. R32F: number;
  155371. RG32F: number;
  155372. RGB32F: number;
  155373. R16F: number;
  155374. RG16F: number;
  155375. RGB16F: number;
  155376. RED: number;
  155377. RG: number;
  155378. R8: number;
  155379. RG8: number;
  155380. UNSIGNED_INT_24_8: number;
  155381. DEPTH24_STENCIL8: number;
  155382. MIN: number;
  155383. MAX: number;
  155384. /* Multiple Render Targets */
  155385. drawBuffers(buffers: number[]): void;
  155386. readBuffer(src: number): void;
  155387. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  155388. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  155389. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  155390. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  155391. // Occlusion Query
  155392. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  155393. ANY_SAMPLES_PASSED: number;
  155394. QUERY_RESULT_AVAILABLE: number;
  155395. QUERY_RESULT: number;
  155396. }
  155397. interface WebGLProgram {
  155398. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  155399. }
  155400. interface EXT_disjoint_timer_query {
  155401. QUERY_COUNTER_BITS_EXT: number;
  155402. TIME_ELAPSED_EXT: number;
  155403. TIMESTAMP_EXT: number;
  155404. GPU_DISJOINT_EXT: number;
  155405. QUERY_RESULT_EXT: number;
  155406. QUERY_RESULT_AVAILABLE_EXT: number;
  155407. queryCounterEXT(query: WebGLQuery, target: number): void;
  155408. createQueryEXT(): WebGLQuery;
  155409. beginQueryEXT(target: number, query: WebGLQuery): void;
  155410. endQueryEXT(target: number): void;
  155411. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  155412. deleteQueryEXT(query: WebGLQuery): void;
  155413. }
  155414. interface WebGLUniformLocation {
  155415. _currentState: any;
  155416. }
  155417. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  155418. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  155419. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  155420. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  155421. interface WebGLRenderingContext {
  155422. readonly RASTERIZER_DISCARD: number;
  155423. readonly DEPTH_COMPONENT24: number;
  155424. readonly TEXTURE_3D: number;
  155425. readonly TEXTURE_2D_ARRAY: number;
  155426. readonly TEXTURE_COMPARE_FUNC: number;
  155427. readonly TEXTURE_COMPARE_MODE: number;
  155428. readonly COMPARE_REF_TO_TEXTURE: number;
  155429. readonly TEXTURE_WRAP_R: number;
  155430. readonly HALF_FLOAT: number;
  155431. readonly RGB8: number;
  155432. readonly RED_INTEGER: number;
  155433. readonly RG_INTEGER: number;
  155434. readonly RGB_INTEGER: number;
  155435. readonly RGBA_INTEGER: number;
  155436. readonly R8_SNORM: number;
  155437. readonly RG8_SNORM: number;
  155438. readonly RGB8_SNORM: number;
  155439. readonly RGBA8_SNORM: number;
  155440. readonly R8I: number;
  155441. readonly RG8I: number;
  155442. readonly RGB8I: number;
  155443. readonly RGBA8I: number;
  155444. readonly R8UI: number;
  155445. readonly RG8UI: number;
  155446. readonly RGB8UI: number;
  155447. readonly RGBA8UI: number;
  155448. readonly R16I: number;
  155449. readonly RG16I: number;
  155450. readonly RGB16I: number;
  155451. readonly RGBA16I: number;
  155452. readonly R16UI: number;
  155453. readonly RG16UI: number;
  155454. readonly RGB16UI: number;
  155455. readonly RGBA16UI: number;
  155456. readonly R32I: number;
  155457. readonly RG32I: number;
  155458. readonly RGB32I: number;
  155459. readonly RGBA32I: number;
  155460. readonly R32UI: number;
  155461. readonly RG32UI: number;
  155462. readonly RGB32UI: number;
  155463. readonly RGBA32UI: number;
  155464. readonly RGB10_A2UI: number;
  155465. readonly R11F_G11F_B10F: number;
  155466. readonly RGB9_E5: number;
  155467. readonly RGB10_A2: number;
  155468. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  155469. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  155470. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  155471. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  155472. readonly DEPTH_COMPONENT32F: number;
  155473. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  155474. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  155475. 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;
  155476. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  155477. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  155478. readonly TRANSFORM_FEEDBACK: number;
  155479. readonly INTERLEAVED_ATTRIBS: number;
  155480. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  155481. createTransformFeedback(): WebGLTransformFeedback;
  155482. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  155483. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  155484. beginTransformFeedback(primitiveMode: number): void;
  155485. endTransformFeedback(): void;
  155486. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  155487. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  155488. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  155489. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  155490. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  155491. }
  155492. interface ImageBitmap {
  155493. readonly width: number;
  155494. readonly height: number;
  155495. close(): void;
  155496. }
  155497. interface WebGLQuery extends WebGLObject {
  155498. }
  155499. declare var WebGLQuery: {
  155500. prototype: WebGLQuery;
  155501. new(): WebGLQuery;
  155502. };
  155503. interface WebGLSampler extends WebGLObject {
  155504. }
  155505. declare var WebGLSampler: {
  155506. prototype: WebGLSampler;
  155507. new(): WebGLSampler;
  155508. };
  155509. interface WebGLSync extends WebGLObject {
  155510. }
  155511. declare var WebGLSync: {
  155512. prototype: WebGLSync;
  155513. new(): WebGLSync;
  155514. };
  155515. interface WebGLTransformFeedback extends WebGLObject {
  155516. }
  155517. declare var WebGLTransformFeedback: {
  155518. prototype: WebGLTransformFeedback;
  155519. new(): WebGLTransformFeedback;
  155520. };
  155521. interface WebGLVertexArrayObject extends WebGLObject {
  155522. }
  155523. declare var WebGLVertexArrayObject: {
  155524. prototype: WebGLVertexArrayObject;
  155525. new(): WebGLVertexArrayObject;
  155526. };
  155527. // Type definitions for WebVR API
  155528. // Project: https://w3c.github.io/webvr/
  155529. // Definitions by: six a <https://github.com/lostfictions>
  155530. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  155531. interface VRDisplay extends EventTarget {
  155532. /**
  155533. * Dictionary of capabilities describing the VRDisplay.
  155534. */
  155535. readonly capabilities: VRDisplayCapabilities;
  155536. /**
  155537. * z-depth defining the far plane of the eye view frustum
  155538. * enables mapping of values in the render target depth
  155539. * attachment to scene coordinates. Initially set to 10000.0.
  155540. */
  155541. depthFar: number;
  155542. /**
  155543. * z-depth defining the near plane of the eye view frustum
  155544. * enables mapping of values in the render target depth
  155545. * attachment to scene coordinates. Initially set to 0.01.
  155546. */
  155547. depthNear: number;
  155548. /**
  155549. * An identifier for this distinct VRDisplay. Used as an
  155550. * association point in the Gamepad API.
  155551. */
  155552. readonly displayId: number;
  155553. /**
  155554. * A display name, a user-readable name identifying it.
  155555. */
  155556. readonly displayName: string;
  155557. readonly isConnected: boolean;
  155558. readonly isPresenting: boolean;
  155559. /**
  155560. * If this VRDisplay supports room-scale experiences, the optional
  155561. * stage attribute contains details on the room-scale parameters.
  155562. */
  155563. readonly stageParameters: VRStageParameters | null;
  155564. /**
  155565. * Passing the value returned by `requestAnimationFrame` to
  155566. * `cancelAnimationFrame` will unregister the callback.
  155567. * @param handle Define the hanle of the request to cancel
  155568. */
  155569. cancelAnimationFrame(handle: number): void;
  155570. /**
  155571. * Stops presenting to the VRDisplay.
  155572. * @returns a promise to know when it stopped
  155573. */
  155574. exitPresent(): Promise<void>;
  155575. /**
  155576. * Return the current VREyeParameters for the given eye.
  155577. * @param whichEye Define the eye we want the parameter for
  155578. * @returns the eye parameters
  155579. */
  155580. getEyeParameters(whichEye: string): VREyeParameters;
  155581. /**
  155582. * Populates the passed VRFrameData with the information required to render
  155583. * the current frame.
  155584. * @param frameData Define the data structure to populate
  155585. * @returns true if ok otherwise false
  155586. */
  155587. getFrameData(frameData: VRFrameData): boolean;
  155588. /**
  155589. * Get the layers currently being presented.
  155590. * @returns the list of VR layers
  155591. */
  155592. getLayers(): VRLayer[];
  155593. /**
  155594. * Return a VRPose containing the future predicted pose of the VRDisplay
  155595. * when the current frame will be presented. The value returned will not
  155596. * change until JavaScript has returned control to the browser.
  155597. *
  155598. * The VRPose will contain the position, orientation, velocity,
  155599. * and acceleration of each of these properties.
  155600. * @returns the pose object
  155601. */
  155602. getPose(): VRPose;
  155603. /**
  155604. * Return the current instantaneous pose of the VRDisplay, with no
  155605. * prediction applied.
  155606. * @returns the current instantaneous pose
  155607. */
  155608. getImmediatePose(): VRPose;
  155609. /**
  155610. * The callback passed to `requestAnimationFrame` will be called
  155611. * any time a new frame should be rendered. When the VRDisplay is
  155612. * presenting the callback will be called at the native refresh
  155613. * rate of the HMD. When not presenting this function acts
  155614. * identically to how window.requestAnimationFrame acts. Content should
  155615. * make no assumptions of frame rate or vsync behavior as the HMD runs
  155616. * asynchronously from other displays and at differing refresh rates.
  155617. * @param callback Define the eaction to run next frame
  155618. * @returns the request handle it
  155619. */
  155620. requestAnimationFrame(callback: FrameRequestCallback): number;
  155621. /**
  155622. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  155623. * Repeat calls while already presenting will update the VRLayers being displayed.
  155624. * @param layers Define the list of layer to present
  155625. * @returns a promise to know when the request has been fulfilled
  155626. */
  155627. requestPresent(layers: VRLayer[]): Promise<void>;
  155628. /**
  155629. * Reset the pose for this display, treating its current position and
  155630. * orientation as the "origin/zero" values. VRPose.position,
  155631. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  155632. * updated when calling resetPose(). This should be called in only
  155633. * sitting-space experiences.
  155634. */
  155635. resetPose(): void;
  155636. /**
  155637. * The VRLayer provided to the VRDisplay will be captured and presented
  155638. * in the HMD. Calling this function has the same effect on the source
  155639. * canvas as any other operation that uses its source image, and canvases
  155640. * created without preserveDrawingBuffer set to true will be cleared.
  155641. * @param pose Define the pose to submit
  155642. */
  155643. submitFrame(pose?: VRPose): void;
  155644. }
  155645. declare var VRDisplay: {
  155646. prototype: VRDisplay;
  155647. new(): VRDisplay;
  155648. };
  155649. interface VRLayer {
  155650. leftBounds?: number[] | Float32Array | null;
  155651. rightBounds?: number[] | Float32Array | null;
  155652. source?: HTMLCanvasElement | null;
  155653. }
  155654. interface VRDisplayCapabilities {
  155655. readonly canPresent: boolean;
  155656. readonly hasExternalDisplay: boolean;
  155657. readonly hasOrientation: boolean;
  155658. readonly hasPosition: boolean;
  155659. readonly maxLayers: number;
  155660. }
  155661. interface VREyeParameters {
  155662. /** @deprecated */
  155663. readonly fieldOfView: VRFieldOfView;
  155664. readonly offset: Float32Array;
  155665. readonly renderHeight: number;
  155666. readonly renderWidth: number;
  155667. }
  155668. interface VRFieldOfView {
  155669. readonly downDegrees: number;
  155670. readonly leftDegrees: number;
  155671. readonly rightDegrees: number;
  155672. readonly upDegrees: number;
  155673. }
  155674. interface VRFrameData {
  155675. readonly leftProjectionMatrix: Float32Array;
  155676. readonly leftViewMatrix: Float32Array;
  155677. readonly pose: VRPose;
  155678. readonly rightProjectionMatrix: Float32Array;
  155679. readonly rightViewMatrix: Float32Array;
  155680. readonly timestamp: number;
  155681. }
  155682. interface VRPose {
  155683. readonly angularAcceleration: Float32Array | null;
  155684. readonly angularVelocity: Float32Array | null;
  155685. readonly linearAcceleration: Float32Array | null;
  155686. readonly linearVelocity: Float32Array | null;
  155687. readonly orientation: Float32Array | null;
  155688. readonly position: Float32Array | null;
  155689. readonly timestamp: number;
  155690. }
  155691. interface VRStageParameters {
  155692. sittingToStandingTransform?: Float32Array;
  155693. sizeX?: number;
  155694. sizeY?: number;
  155695. }
  155696. interface Navigator {
  155697. getVRDisplays(): Promise<VRDisplay[]>;
  155698. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  155699. }
  155700. interface Window {
  155701. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  155702. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  155703. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  155704. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  155705. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  155706. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  155707. }
  155708. interface Gamepad {
  155709. readonly displayId: number;
  155710. }
  155711. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  155712. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  155713. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  155714. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  155715. type XRHandedness = "none" | "left" | "right";
  155716. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  155717. type XREye = "none" | "left" | "right";
  155718. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  155719. interface XRSpace extends EventTarget {}
  155720. interface XRRenderState {
  155721. depthNear?: number;
  155722. depthFar?: number;
  155723. inlineVerticalFieldOfView?: number;
  155724. baseLayer?: XRWebGLLayer;
  155725. }
  155726. interface XRInputSource {
  155727. handedness: XRHandedness;
  155728. targetRayMode: XRTargetRayMode;
  155729. targetRaySpace: XRSpace;
  155730. gripSpace: XRSpace | undefined;
  155731. gamepad: Gamepad | undefined;
  155732. profiles: Array<string>;
  155733. hand: XRHand | undefined;
  155734. }
  155735. interface XRSessionInit {
  155736. optionalFeatures?: string[];
  155737. requiredFeatures?: string[];
  155738. }
  155739. interface XRSession {
  155740. addEventListener: Function;
  155741. removeEventListener: Function;
  155742. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  155743. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  155744. requestAnimationFrame: Function;
  155745. end(): Promise<void>;
  155746. renderState: XRRenderState;
  155747. inputSources: Array<XRInputSource>;
  155748. // hit test
  155749. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  155750. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  155751. // legacy AR hit test
  155752. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  155753. // legacy plane detection
  155754. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  155755. }
  155756. interface XRReferenceSpace extends XRSpace {
  155757. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  155758. onreset: any;
  155759. }
  155760. type XRPlaneSet = Set<XRPlane>;
  155761. type XRAnchorSet = Set<XRAnchor>;
  155762. interface XRFrame {
  155763. session: XRSession;
  155764. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  155765. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  155766. // AR
  155767. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  155768. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  155769. // Anchors
  155770. trackedAnchors?: XRAnchorSet;
  155771. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  155772. // Planes
  155773. worldInformation: {
  155774. detectedPlanes?: XRPlaneSet;
  155775. };
  155776. // Hand tracking
  155777. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  155778. }
  155779. interface XRViewerPose extends XRPose {
  155780. views: Array<XRView>;
  155781. }
  155782. interface XRPose {
  155783. transform: XRRigidTransform;
  155784. emulatedPosition: boolean;
  155785. }
  155786. interface XRWebGLLayerOptions {
  155787. antialias?: boolean;
  155788. depth?: boolean;
  155789. stencil?: boolean;
  155790. alpha?: boolean;
  155791. multiview?: boolean;
  155792. framebufferScaleFactor?: number;
  155793. }
  155794. declare var XRWebGLLayer: {
  155795. prototype: XRWebGLLayer;
  155796. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  155797. };
  155798. interface XRWebGLLayer {
  155799. framebuffer: WebGLFramebuffer;
  155800. framebufferWidth: number;
  155801. framebufferHeight: number;
  155802. getViewport: Function;
  155803. }
  155804. declare class XRRigidTransform {
  155805. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  155806. position: DOMPointReadOnly;
  155807. orientation: DOMPointReadOnly;
  155808. matrix: Float32Array;
  155809. inverse: XRRigidTransform;
  155810. }
  155811. interface XRView {
  155812. eye: XREye;
  155813. projectionMatrix: Float32Array;
  155814. transform: XRRigidTransform;
  155815. }
  155816. interface XRInputSourceChangeEvent {
  155817. session: XRSession;
  155818. removed: Array<XRInputSource>;
  155819. added: Array<XRInputSource>;
  155820. }
  155821. interface XRInputSourceEvent extends Event {
  155822. readonly frame: XRFrame;
  155823. readonly inputSource: XRInputSource;
  155824. }
  155825. // Experimental(er) features
  155826. declare class XRRay {
  155827. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  155828. origin: DOMPointReadOnly;
  155829. direction: DOMPointReadOnly;
  155830. matrix: Float32Array;
  155831. }
  155832. declare enum XRHitTestTrackableType {
  155833. "point",
  155834. "plane",
  155835. "mesh",
  155836. }
  155837. interface XRHitResult {
  155838. hitMatrix: Float32Array;
  155839. }
  155840. interface XRTransientInputHitTestResult {
  155841. readonly inputSource: XRInputSource;
  155842. readonly results: Array<XRHitTestResult>;
  155843. }
  155844. interface XRHitTestResult {
  155845. getPose(baseSpace: XRSpace): XRPose | undefined;
  155846. // When anchor system is enabled
  155847. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  155848. }
  155849. interface XRHitTestSource {
  155850. cancel(): void;
  155851. }
  155852. interface XRTransientInputHitTestSource {
  155853. cancel(): void;
  155854. }
  155855. interface XRHitTestOptionsInit {
  155856. space: XRSpace;
  155857. entityTypes?: Array<XRHitTestTrackableType>;
  155858. offsetRay?: XRRay;
  155859. }
  155860. interface XRTransientInputHitTestOptionsInit {
  155861. profile: string;
  155862. entityTypes?: Array<XRHitTestTrackableType>;
  155863. offsetRay?: XRRay;
  155864. }
  155865. interface XRAnchor {
  155866. anchorSpace: XRSpace;
  155867. delete(): void;
  155868. }
  155869. interface XRPlane {
  155870. orientation: "Horizontal" | "Vertical";
  155871. planeSpace: XRSpace;
  155872. polygon: Array<DOMPointReadOnly>;
  155873. lastChangedTime: number;
  155874. }
  155875. interface XRJointSpace extends XRSpace {}
  155876. interface XRJointPose extends XRPose {
  155877. radius: number | undefined;
  155878. }
  155879. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  155880. readonly length: number;
  155881. [index: number]: XRJointSpace;
  155882. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  155883. readonly WRIST: number;
  155884. readonly THUMB_METACARPAL: number;
  155885. readonly THUMB_PHALANX_PROXIMAL: number;
  155886. readonly THUMB_PHALANX_DISTAL: number;
  155887. readonly THUMB_PHALANX_TIP: number;
  155888. readonly INDEX_METACARPAL: number;
  155889. readonly INDEX_PHALANX_PROXIMAL: number;
  155890. readonly INDEX_PHALANX_INTERMEDIATE: number;
  155891. readonly INDEX_PHALANX_DISTAL: number;
  155892. readonly INDEX_PHALANX_TIP: number;
  155893. readonly MIDDLE_METACARPAL: number;
  155894. readonly MIDDLE_PHALANX_PROXIMAL: number;
  155895. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  155896. readonly MIDDLE_PHALANX_DISTAL: number;
  155897. readonly MIDDLE_PHALANX_TIP: number;
  155898. readonly RING_METACARPAL: number;
  155899. readonly RING_PHALANX_PROXIMAL: number;
  155900. readonly RING_PHALANX_INTERMEDIATE: number;
  155901. readonly RING_PHALANX_DISTAL: number;
  155902. readonly RING_PHALANX_TIP: number;
  155903. readonly LITTLE_METACARPAL: number;
  155904. readonly LITTLE_PHALANX_PROXIMAL: number;
  155905. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  155906. readonly LITTLE_PHALANX_DISTAL: number;
  155907. readonly LITTLE_PHALANX_TIP: number;
  155908. }
  155909. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  155910. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  155911. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  155912. interface XRSession {
  155913. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  155914. }
  155915. interface XRFrame {
  155916. featurePointCloud? : Array<number>;
  155917. }